X64 version for Fmod api?

I downloaded the fmod api but the fmod.dll and the fmodstudio.dll seem to be x86 versions because I get this error “.FMOD System_Create(System.IntPtr&): System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Ox8007000B)” when trying to use them which I think may point to them being the wrong format for my 64 bit windows.

I selected the first option in the download page (https://www.fmod.com/download#fmodengine)

Any help to find 64 bit compatible versions of these .dll files or explanations on how to use the ones I downloaded will be greatly appreciated.

The calls are made in C# by wrapping the methods like this:
[DllImport(FMOD_STUDIO_DLL)]
private static extern int FMOD_Studio_System_Create(out IntPtr system);

(private const string FMOD_STUDIO_DLL = “fmodstudio.dll”; )

Hi,

What version of FMOD are you downloading? Can you confirm the directory of the .dll you are pointing your program at, e.g. "C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\studio\lib\x64\fmodstudio.dll". If the files are in that directory, could I grab some more information about your implementation of FMOD?

Hi glad to hear from you.

I downloaded this version: fmodstudioapi20100win-installer.exe

The reason is that I tried to use music/sounds developed with a Fmod editor using that version some years ago.

I took the .dll files from the directories you get through the shortcuts that were installed in the windows start menu.

C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\core\examples\bin

C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\studio\examples\bin

A little about the background to all this. I am a pensioner trying to help my son with a game he developed as part of his examination work when he got an exam in games, specialization music.
And he suggested we should take it up and make the game better but we should this time use godot instead of Unity and he want to use Fmod (he has created the music and effects using Fmod)
I looked at it and since the .dlls can be wrapped so they can be called from C# code I said it looked as if we would be able to use Fmod.

I have started sketching a class to be used - where I am running into these problems. Here it is:

(Note FMODUseError is an exception I have created).

using System;
using System.Runtime.InteropServices;
using Godot;

namespace SBS_Utilities
{
    public static class FMODGodot
    {
        private const string FMOD_STUDIO_DLL = "fmodstudio.dll";
        private const string FMOD_CORE_DLL = "fmod.dll";  

        private static IntPtr coreSystem;
        private static IntPtr studioSystem;

        public static void InitializeFMOD()
        {
            try
            {
                // Step 1: Create Core System
                GD.Print("Creating FMOD Core system...");
                int result = FMOD_System_Create(out coreSystem);
                if (result != 0)
                {
                    throw new FMODUseError(nameof(InitializeFMOD), result, "FMOD Core system creation failed");
                }

                // Step 2: Initialize Core System
                GD.Print("Initializing FMOD Core system...");
                result = FMOD_System_Init(coreSystem, 512, FMOD_INIT.NORMAL, IntPtr.Zero);
                if (result != 0)
                {
                    throw new FMODUseError(nameof(InitializeFMOD), result, "FMOD Core system initialization failed");
                }

                GD.Print("FMOD Core system initialized successfully.");

                // Step 3: Create Studio System (linked to Core System)
                GD.Print("Creating FMOD Studio system...");
                result = FMOD_Studio_System_Create(out studioSystem);
                if (result != 0)
                {
                    throw new FMODUseError(nameof(InitializeFMOD), result, "FMOD Studio system creation failed");
                }

                // Step 4: Initialize Studio System
                GD.Print("Initializing FMOD Studio system...");
                result = FMOD_Studio_System_Initialize(studioSystem, 512, FMOD_STUDIO_INIT.NORMAL, FMOD_INIT.NORMAL, IntPtr.Zero);
                if (result != 0)
                {
                    throw new FMODUseError(nameof(InitializeFMOD), result, "FMOD Studio system initialization failed");
                }

                GD.Print("FMOD Studio system initialized successfully.");

                // Step 5: Load banks
                GD.Print("Loading banks.");
                LoadBank(@"F:\FmodBanks\Master.bank");
                LoadBank(@"F:\FmodBanks\Master.strings.bank");
            }
            catch (Exception ex)
            {
                GD.PrintErr($"Error during FMOD initialization: {ex.Message}");
                throw;
            }
        }

        private static void LoadBank(string bankPath)
        {
            try
            {
                if (studioSystem == IntPtr.Zero)
                {
                    throw new FMODUseError(nameof(LoadBank), -1, "FMOD Studio system is not initialized. Cannot load bank.");
                }

                string absolutePath = ProjectSettings.GlobalizePath(bankPath);

                if (!System.IO.File.Exists(absolutePath))
                {
                    throw new FMODUseError(nameof(LoadBank), -1, $"Bank file not found: {absolutePath}");
                }

                GD.Print($"Loading bank: {absolutePath}");
                IntPtr bank;
                int result = FMOD_Studio_System_LoadBankFile(studioSystem, absolutePath, out bank);
                if (result != 0)
                {
                    throw new FMODUseError(nameof(LoadBank), result, $"Failed to load bank {absolutePath}");
                }

                GD.Print($"Loaded bank {absolutePath} successfully.");
            }
            catch (Exception ex)
            {
                GD.PrintErr($"Error during loading bank {bankPath}: {ex.Message}");
                throw;
            }
        }

        public static void ReleaseFMOD()
        {
            try
            {
                if (studioSystem != IntPtr.Zero)
                {
                    GD.Print("Releasing FMOD Studio system...");
                    int result = FMOD_Studio_System_Release(studioSystem);
                    if (result != 0)
                    {
                        throw new FMODUseError(nameof(ReleaseFMOD), result, "FMOD Studio system release failed");
                    }
                    studioSystem = IntPtr.Zero;
                    GD.Print("FMOD Studio system released successfully.");
                }

                if (coreSystem != IntPtr.Zero)
                {
                    GD.Print("Releasing FMOD Core system...");
                    int result = FMOD_System_Release(coreSystem);
                    if (result != 0)
                    {
                        throw new FMODUseError(nameof(ReleaseFMOD), result, "FMOD Core system release failed");
                    }
                    coreSystem = IntPtr.Zero;
                    GD.Print("FMOD Core system released successfully.");
                }
            }
            catch (Exception ex)
            {
                GD.PrintErr($"Error during FMOD release: {ex.Message}");
                throw;
            }
        }

        public static void PlayEvent(string eventPath)
        {
            try
            {
                GD.Print($"Playing event: {eventPath}");

                IntPtr eventInstance;
                int result = FMOD_Studio_System_GetEvent(studioSystem, eventPath, out eventInstance);
                if (result != 0)
                {
                    throw new FMODUseError(nameof(PlayEvent), result, $"Failed to get event {eventPath}");
                }

                result = FMOD_Studio_EventInstance_Start(eventInstance);
                if (result != 0)
                {
                    throw new FMODUseError(nameof(PlayEvent), result, $"Failed to start event {eventPath}");
                }

                GD.Print($"Started event {eventPath} successfully.");
            }
            catch (Exception ex)
            {
                GD.PrintErr($"Error during playing event {eventPath}: {ex.Message}");
                throw;
            }
        }


        // FMOD imports

        [DllImport(FMOD_CORE_DLL)]
        private static extern int FMOD_System_Create(out IntPtr system);  // Example for Core API usage

        [DllImport(FMOD_CORE_DLL)]
        private static extern int FMOD_System_Init(IntPtr system, int maxchannels, FMOD_INIT flags, IntPtr extradriverdata);

        [DllImport(FMOD_CORE_DLL)]
        private static extern int FMOD_System_Release(IntPtr system);


        [DllImport(FMOD_STUDIO_DLL)]
        private static extern int FMOD_Studio_System_Create(out IntPtr system);

        [DllImport(FMOD_STUDIO_DLL)]
        private static extern int FMOD_Studio_System_Initialize(IntPtr system, int maxchannels, FMOD_STUDIO_INIT studioFlags, FMOD_INIT flags, IntPtr extradriverdata);

        [DllImport(FMOD_STUDIO_DLL)]
        private static extern int FMOD_Studio_System_LoadBankFile(IntPtr system, string path, out IntPtr bank);

        [DllImport(FMOD_STUDIO_DLL)]
        private static extern int FMOD_Studio_System_Release(IntPtr system);

        [DllImport(FMOD_STUDIO_DLL)]
        private static extern int FMOD_Studio_System_GetEvent(IntPtr system, string path, out IntPtr eventInstance);

        [DllImport(FMOD_STUDIO_DLL)]
        private static extern int FMOD_Studio_EventInstance_Start(IntPtr eventInstance);

    }

    [Flags]
    public enum FMOD_STUDIO_INIT : uint
    {
        NORMAL = 0x00000000,
        LIVEUPDATE = 0x00000001,
        ALLOW_MISSING_PLUGINS = 0x00000002,
        SYNCHRONOUS_UPDATE = 0x00000004,
        DEFERRED_CALLBACKS = 0x00000008,
        LOAD_FROM_UPDATE = 0x00000010,
        MEMORY_TRACKING = 0x00000020
    }

    [Flags]
    public enum FMOD_INIT : uint
    {
        NORMAL = 0x00000000,
        STREAM_FROM_UPDATE = 0x00000001,
        MIX_FROM_UPDATE = 0x00000002,
        RIGHTHANDED_3D = 0x00000004,
        CHANNEL_LOWPASS = 0x00000100,
        CHANNEL_DISTANCEFILTER = 0x00000200,
        PROFILE_ENABLE = 0x00010000,
        VOL0_BECOMES_VIRTUAL = 0x00020000,
        GEOMETRY_USECLOSEST = 0x00040000,
        PREFER_DOLBY_DOWNMIX = 0x00080000,
        THREAD_UNSAFE = 0x00100000,
        PROFILE_METER_ALL = 0x00200000,
        DISABLE_SRS_HIGH_PASS_FILTER = 0x00400000
    }
}

Thank you for the information.

Unfortunately, we no longer support 2.01. Would it be possible to update to 2.02 or 2.03 (2.03 is current in early access)?

Could you try copying the .dlls from C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\core\lib\x64 and C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\studio\lib\x64? This way we can be sure they are in the correct format.

There is also an unofficial Godot integration here: GitHub - utopia-rise/fmod-gdextension: FMOD Studio GDExtension bindings for the Godot game engine, however, this is in GDscript.

Hope this helps!

Thanks a lot for the feedback.

UPDATING
We are just in the early stages testing to see if we can move from unity to godot. The idea is to move to the latest versions when we have figured things out. So, if the latest version of the fmod editor can read in the old fmod project (created in the FMOD Studio 2.01.00) there should be no problems in updating to a later version. (I guess we will try the latest studio 2.03.02 and engine 2.03.02)

I will try to do that later today.

  • Which .dll files should be copied?
    I just copied fmod.dll and fmodstudio.dll. These are available in both folders so I can only take them from one folder. So it is quite possible I did not copy some .dll files that they depend on. (And of course this was the old api so it would correspond with the banks created by the old fmod editor).

  • Where should the .dll files be put?
    I just put them in the folder where the godot executable is. That is, in my case, in this folder: C:\Godot\Godot_v4.3-stable_mono_win64\Godot_v4.3-stable_mono_win64
    Perhaps there is a better way, for instance adding them to the path in Visual Studio?

Thanks again for your response. It is deeply appreciated.

I have now downloaded new fmod(2.03.02) and the corresponding api for the .dll files, but I still get the same error “Error during FPIOD initialization: An attempt was made to load a program with an incorrect format. (@x8007030B)”

What I find strange is that the examples where we fetch the .dll files seem to be in the x86 section (C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\core\examples\bin
and
C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\studio\examples\bin)
It would have been more natural to find them in a place where you expect 64 bit .dlls. For example, C:\Program Files\FMOD SoundSystem\FMOD Studio API Windows\api\core\lib\x64 or a similar path.
But if what we got is not 64 bit dlls then the error about incorrect format makes a lot of sense.
If that suspiction is correct we get to the question: Where do we find the 64 bit dlls?

An update.

I have tried to tackle this problem of getting access to Fmod in another way - by adding the available wrapper classes you get when you download the api engine and building some code around that. That way I have gotten a little further.

Please check it out:

Perhaps the solution can be found there - at least for us that are willing to use C# to get access to Fmod.

I understand I am not alone wanting to get access to Fmod in Godot. This could be a solution.

I believe you were looking for the fmod.dll and the fmodstudio.dll files.

C:\Godot\Godot_v4.3-stable_mono_win64\Godot_v4.3-stable_mono_win64, I believe that is the correct location.

It is possible to add a post-build action to the Visual Studio project that will copy files for you: https://learn.microsoft.com/en-us/visualstudio/ide/how-to-specify-build-events-csharp?view=vs-2022. They would also have to be added to the project’s additional libraries:
image

There should be .dlls in the location you have here: C:\Program Files\FMOD SoundSystem\FMOD Studio API Windows\api\core\lib\x64:


Let me know if they are not there for you.

Appologies, I should have suggested this earlier. I will have a look into your new thread now.

We currently have an internal tracker for interest in an official Godot integration, I have noted you as well.

Thank you for all the information and your work looking into this issue.

Thanks for the feedback.

The link C:\Program Files\FMOD SoundSystem\FMOD Studio API Windows\api\core\lib\x64 does not work on my computer.

However when installing the api you get two folder paths in the start menue:

StartMenueExamples

The folders contains the following:

and

I thought that the files should be there but since there was no x64 mentioned I decided to go up in the hierarchy and search for x64 which gave this result:

And in one of them I think I found the files:

Anyway these are the files I am using now. But these files since I could not use your filepath may be the wrong ones and may explain the strange behaviour of being able in the other thread [Getting empty events with studioSystem.loadBankFile] to initialize the fmod system and reading in a bank without any errors but not being able to get to its content so I can actually play the music.

You mentioned that you would take a look at that thread and I am looking forward to your feedback about it.

1 Like