The documentation for FMOD_MODE states:

"With FMOD_OPENMEMORY_POINT and FMOD_OPENRAW or PCM, if using them together, note that you must pad the data on each side by 16 bytes. This is so fmod can modify the ends of the data for looping/interpolation/mixing purposes. If a wav file, you will need to insert silence, and then reset loop points to stop the playback from playing that silence."

Is this padding always needed with raw in-memory data, or only when the sound is looping?

To be clear, it sounds like our memory is supposed to look like the following:
[16 bytes of zeroes][raw PCM data][16 bytes of zeroes]

So I assume:
1. The pointer we pass to System::createSound should be the start of the padding.
2. The FMOD_CREATESOUNDEXINFO length field should include the size of the padding.

If the above is correct, does FMOD know to ignore the first and last 16 bytes, or will it play silence? I could set the start and end loop points on the sound, but what if the sound isn’t looping? Will FMOD respect the loop points even if the sound mode doesn’t contain FMOD_LOOP_NORMAL, or do I have to make it a looping sound and manually stop playback after it plays once?

Sorry for the confusion.

  • You must to post comments

From my experiments here is what I’ve determined:

  1. The padding is only needed if the sound is looping.
  2. FMOD seems to write into the 16 bytes following your loop end point, so your buffer needs to accommodate for this. If your sound is infinitely looping, FMOD won’t play anything past the loop end point, so you don’t have to worry about it.

Can the above information be safely relied on, or should it be considered an implementation detail?

If the sound is finitely looping, I would expect FMOD to continue beyond the loop end point after looping the correct number of times. Wouldn’t writing past the loop end point corrupt the buffer data then? Does FMOD not support playing anything past the loop end point?

Why does there need to be padding on the back AND the front? If padding is really needed on the front, how do I make sure FMOD starts playing the sound at the start of my sound data? Do I pass in the address of my data to System::createSound, and FMOD assumes it can write to the preceding 16 bytes? Or do I pass in the address of the padding, and specify a file offset of 16 in my FMOD_CREATESOUNDEXINFO struct?

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.