I’m new to fmod and looking for some help or at least a point in the right direction. I am currently creating a game with some friends and my task is currently to determine how to load/play video files from disk. Now, I realize that fmod is not a video library–I am using ffmpeg for this part, and I am loading video data just fine currently.
However, we are already using fmod for other sounds in the game so I would like to modify our existing sound manager to play the audio data of the files via fmod. However, the only thing we know how to do currently is load sounds directly from a file–this obviously doesn’t work for video data.
Currently I have an update loop that is decoding packets via ffmpeg and I am using a simple if statement to determine whether the packets contain either video data or audio data.
Every time I decode an audio packet, basically what I have is a buffer of raw audio data which I want to somehow play via fmod, so my question is what is the best way to go about doing this?
I see that there is a flag called FMOD_OPENRAW which I assume is what I have to use but I am unsure how to actually do so.
Thanks for any help
- mdc5237 asked 11 years ago
Yes you would use FMOD_OPENRAW flag.
When you use that flag though, it then means you have to describe the file with FMOD_CREATESOUNDEXINFO
You have to describe the format, defaultfrequency, and numchannels.
This is documented next to the flag.
/* Will ignore file format and treat as raw pcm. Use FMOD_CREATESOUNDEXINFO to specify format. Requires at least defaultfrequency, numchannels and format to be specified before it will open. Must be little endian data. */
Pass the struct to createSound or createStream, and make sure you memset the struct to 0 first then set the ‘cbsize’ member to that of the size of the structure.
awesome that worked!
I knew about the struct but I didn’t realize I had to memset it to 0 first and so I was getting memory access violations and such.
I’m playing each packet as it’s own sound currently, so the result is very choppy due to constantly having to load new sounds.
If you have any brilliant ideas to easily fix this, please let me know, but at least I have a starting point now, so thanks very much for that :-).
- mdc5237 answered 11 years ago
Please login first to submit.