FMOD::Studio::System::loadBankMemory randomly fails with FMOD_ERR_INVALID_PARAM, despite seemingly being passed the same parameters

Issue was due to me misunderstanding and 32-byte aligning buffer size rather than the actual memory address. Issue resolved.

When using FMOD_STUDIO_LOAD_MEMORY_POINT, the buffer needs to be 32-bit aligned. Which would explain why you don’t get this error every time.

Make sure to keep the buffer around, you can only free it after receiving a FMOD_STUDIO_SYSTEM_CALLBACK_BANK_UNLOAD callback, otherwise use FMOD_STUDIO_LOAD_MEMORY to create a copy.

1 Like

If you look at my original code sample, you’ll see that it actually is aligned correctly (it’s 32 bytes btw, not bits, but it uses a define anyway)

And yes, I am keeping it in memory

Can you try with the logging libs, they should provide more information on the cause.

Looks like FMOD seem to think that the data isn’t 32 byte aligned

[ERR] AsyncCommandTableShadow::system_loadBankMemory : Error! FMOD_STUDIO_LOAD_MEMORY_POINT buffer is not 32-byte aligned!

However, I’m pretty sure that 800 bytes are aligned to 32 bytes?

I logged my variables just to be sure:

This only happens for this bank as well. The other banks are much larger and always loads correctly:

BANK SIZE: 12480, WAS 12474, PADDED WITH 6
BANK SIZE: 5663456, WAS 5663456, PADDED WITH 0

Or wait, should the actual memory address be aligned to 32 even bytes? Not just the actual size… ?

Yup, that seemed to have been the case. My bad! And thank you for the support Cameron, very appreciated!