Need help encoding pcm floats to mp3

Hi, what we are trying to achieve is this:

Based on the Windows’s low level plugin example, we could see that fmod’s output_mp3 example uses lame encoder.
We thought it would be easy to port this to Unity but it wasn’t so.

We want to use this encoder in Windows, Mac, Android, and iOS.

Is there any way to use it in Unity?

Thank you

Please clarify why this doesn’t work in Unity.

The low level example project only shows how to do this in Windows platform.
Even if I were to successfully port lame to c#, there’s no guarantee that it would also work in other platforms.

You don’t need to port Lame to C#.

The steps would be as follows:

  1. Compile Lame or some other MP3 encoding library for each of your target platforms. Official Lame doesn’t seem to have iOS or Android targets googling indicates there are 3rd party ones.

  2. Modify the output_mp3 example so instead of LoadLibrary/GetProcAddress which are Windows specific calls it uses the appropriate calls for each platform. iOS will have to be statically linked because the platform doesn’t support dynamic linking.

  3. Compile the output_mp3 example into a library for each platform.

  4. Place the output plugin library and dependent encoder library into your Unity project and set the Unity asset properties.

  5. Use the FMOD C# wrapper for the function System.loadPlugin() and System.setOutputByPlugin()

Thank you sir, right now, I’ve made it until step 4 but unfortunately I don’t quite understand how to load the plugin.

I’ve compiled the output_mp3 example and put the compiled DLLs in the corresponding plugins directory(…/x86, …/x86_64).
I copied the lame_enc DLLs too, btw.

Now, when I tried to call loadPlugin(), it always threw ERR_FILE_NOTFOUND result.
I double checked for any typos but there wasn’t…

I also discovered that I could set the plugins in Resources/FMODStudioSettings
When I tried to add my plugin there, I get a “SystemNotInitializedException”.

Sorry to keep asking but could you tell me in detail on how to load my plugin to FMOD?

Thank you

If you call loadPlugin you need to pass the full path. File Not Found could also mean the dependency was not found. Sometimes copying DLL’s into the top level project folder or next to the exe when doing a build can fix the issue.

If you are startup code and get SystemNotInitializedException it means an error was returned somewhere during startup. The message attached to the exception should tell you which function returned an error.