Unity CreateSound Error : ERR_VERSION The version of this file format is not supported

Hello,

I am a game developer, and I am quite familiar with integrating FMOD in Unity. However, recently, I have encountered a strange issue when trying to load encrypted FSB files in Unity.

When using the fmodSystem.createSound function to load audio, sometimes it succeeds in reading the audio, but other times it fails with an ERR_VERSION error, which is quite puzzling.

I am using Unity version 2021.3.21f1, FMOD Studio version 2.02, and FMOD Engine version 2.02, and all the tool versions are perfectly matched!

Here is my code:


CREATESOUNDEXINFO exinfo = new CREATESOUNDEXINFO();
byte[] encryptionKeyBytes = System.Text.Encoding.UTF8.GetBytes(encryptionKey);
exinfo.encryptionkey = Marshal.AllocHGlobal(encryptionKeyBytes.Length);                         
Marshal.Copy(encryptionKeyBytes, 0, exinfo.encryptionkey, encryptionKeyBytes.Length);
exinfo.cbsize = Marshal.SizeOf(exinfo);
res = fmodSystem.createSound(path, FMOD.MODE.CREATESTREAM, ref exinfo, out curFSBSound);
Marshal.FreeHGlobal(exinfo.encryptionkey); 

Any help or insight into resolving this issue would be greatly appreciated!

Hi,

Could I get some more info:

  • How are you building the FSB’s, are you using FSBuild_Build or FMOD Soundbank generator?
  • Could I get the minor version of FMOD you are using 2.02.XX
  • Have you installed the FMOD Unity Integration or are you just using the FMOD Engine?

Hi,

The issue is you have to account for the null terminator in the encryption key. If you check Marshal.PtrToStringAnsi(exinfo.encryptionkey) you will see that sometimes your key will have extra letters or symbols following it as the code is not aware where to cut off the string.

A solution is having a look at our implementation of byteFromString() function in fmod.cs which outlines how to get the bytes and implement a null terminator. I simply copied the function into my own class and called it to correctly convert my key.

Hope this helps!

Thank you for your help. The problem has been resolved

1 Like