One of the greatest things about FMOD is that you can load virtually any audio file format with a single method call. To load an audio file into memory, use the createSound()
method:
FMOD::Sound* sound; system->createSound("sfx.wav", FMOD_DEFAULT, 0, &sound);
To stream an audio file from disk without having to store it in memory, use the createStream()
method:
FMOD::Sound* stream; system->createStream("song.ogg", FMOD_DEFAULT, 0, &stream);
Both methods take the path of the audio file as the first parameter, and return a pointer to an FMOD::Sound
object through the fourth parameter, which you can use to play the sound. The paths in the previous examples are relative to the application path. If you are running these examples in Visual Studio, make sure that you copy the audio files into the output folder (for example, using a post-build event such as xcopy /y "$(ProjectDir)*.ogg" "$(OutDir)"
).
The choice between loading and streaming is mostly a tradeoff...