Playing bundled music files


I am wondering if there is a built-in method within the FMOD API to play game background music files from a bundled file such as a .zip file or a custom file. Specifically, I have combined multiple mp3 files into a single file by copying all of their bytes, and I am wondering if FMOD has a function for playing bundled files like this.

If this feature is not available in the FMOD API, I would greatly appreciate any guidance or hints you could provide to help me achieve this task using the FMOD_CREATESTREAM mode instead of FMOD_CREATESAMPLE or FMOD_CREATECOMPRESSEDSAMPLE, as this would allow me to conserve memory.

Thank you for your time and assistance.


FMOD doesn’t have any “easy” way of doing this i.e. no one function that will just scan your bundled files and figure out the length, format, etc. of each, but there are still ways to go about it - the easiest way would probably be to use FMOD_SOUND_CREATEEXINFO to specify a fileoffset and length for a given audio file in the bundle. Streaming should be as simple as adding FMOD_CREATESTREAM as a mode for the sound. Fundamentally though, you do need to know the location/length of all the sub-files in your bundled file.

However, FMOD comes with a soundbank format called FMOD Sound Bank (FSBank/FSB), which would allow you to encode and compress your BGM, and to load/stream specific subsounds from the FSBank. If this sounds like it’d be useful, I’d recommend taking a look at the fsbank_api example included with the FMOD Engine download, as well as the FSBank API Documentation.

1 Like

Thank you for reminding me about the trick using FMOD_CREATESOUNDEXINFO.
I actually tried that a while ago but completely forgot about it until today, haha.

I completely agree that the FSB format is fantastic, and I will definitely make proactive use of it in my future projects.
However, at the moment, I have to deal with a bunch of bundle and .zip files.

I was wondering if you could provide me with some tips or advice on playing files in a .zip file.
Initially, I thought it might be possible with the funopen() trick, but I just realized that FMOD_System_CreateSound() doesn’t accept a file pointer as an argument.

So, the only solution I can think of is directly loading a .mp3 file from the .zip file into memory and creating a sound with the FMOD_OPENMEMORY mode.
While this approach will work, it will consume more memory due to the source bytes.

Do you have any other ideas or suggestions?

Unfortunately, I don’t have any specific suggestions for streaming from a .zip file. Streaming from a a bundle of .mp3 files that have simply been concatenated is feasible, but FMOD doesn’t support handling .zip files - you would need an external library to decompress the file instead. That said, FMOD does allow you to piggyback on its own file system routines with your own callbacks using System::attachFileSystem, which you could use alongside a third party library to handle your .zip file(s).

1 Like

Thank you so much for your valuable input!
I may be mistaken, but at first glance, System::attachFileSystem seems to be a kind of version of funopen() in the context of FMOD.
I’m really excited to give it a try.
Once again, I truly appreciate your advice and guidance.

1 Like