FMOD Studio API for HTML5 doesn't work with Node based projects

Hello, I’ve been attempting to include the fmod api into a react/node based project. This is because I want to have a dynamic user interface using react when the user uploads their audio banks. I thought that I could just create a custom node module and import it into my code base.

However, when I start the FMODModule, I run into a strange issue.
BindingError {name: “BindingError”, message: “Cannot register public name ‘’ twice”, stack: “BindingError: Cannot register public name ‘’ twice…://localhost:3006/static/js/main.chunk.js:177:15)”}

When I dig into the code, I’m finding that there is a TON of memory manipulation going on, and I’m not able to follow on from there… But I did see a weird issue, the .mem file that is read is in significantly shorter in length in the node version than a direct implementation. It’s as if node is only reading in a portion of the data.

Could anyone point to where I’m going wrong, or perhaps help me understand what I need to do to get this working in node?

1 Like

more digging has shown that for some reason the .mem file is not being loaded in properly. Still investigating.

Ah, I see now. The request for the .mem file is actually not pathing correctly. Something to do with node… I guess I still have some setup to do, and I may have to edit the fmodstudio.js file and how it loads files. Fun!

note that the .mem file lives with the ASM.JS version which is the older / less performant version, the WASM js version of fmod comes with a .wasm file instead of a .mem file, you might want to try that as well.

Hello Joshua,

See the post I just created to see how to include it a node-based project.

The only way I got it to work was including it in the assets folders (since it can’t be packed by webpack etc) and load it how it’s shown in the index.html

If FMOD would conform to npm package best-practices would be best imo…

1 Like

Hi everyone,

I personnally faced the same problem but I only have a front-end interface using React.js. I loaded the fmodstudio.js file in the index.html which is in the public folder and used the constructor “FMODModule(FMOD)” in the src folder in one of my component, for example App.js, and it works. I think that’s what you’ve done @floodgames.

The problem I face now, is that my bank files are not supported when I use loadBankFile function, and it says “Error!!! ‘Unsupported file or audio format.’”

CHECK_RESULT(
gSystem.loadBankFile(
“/Master.bank”,
FMOD.STUDIO_LOAD_BANK_NORMAL,
bankhandle
)
);

Do you think I made something wrong?

Please let us know if you find a better solution…

Thanks.

Perhaps it has something to do with my stack, but I had to throw fmodstudio.js into a custom node module. I had to change how the .mem/.wasm file was loaded. (I’m using .mem for right now, but plan on swapping to .wasm later)

Basically, where it loads in the .mem/.wasm file, comment out the locateFile() function, and remap the “fmodstudio.js.mem” variable to path to the file on your public. Place the file in your public, and it should load in. This isn’t the most elegant solution, but it works.

I was able to load my audio banks and play them.
As for this being compatible with node, it kind of is already. Just have to change out the required files are loaded. I haven’t tried .wasm yet, so maybe I’ll have different issues, but for now I’ve been able to resolve things.

Maybe this helps:
https://wasmbyexample.dev/examples/importing-javascript-functions-into-webassembly/importing-javascript-functions-into-webassembly.assemblyscript.en-us.html
?