Simple sound play in FMOD

sebap123 picture sebap123 · Jan 24, 2012 · Viewed 12.3k times · Source

I am starting using FMOD API and I have got problem with sound playing. I've used tutorial from this site: http://glasnost.itcarlow.ie/~powerk/audio/AddFMODtoaproject.html and only think I have got is sound cracking.

This is the code which I am using in my OpenGL init function:

FMOD::System_Create(&system);// create an instance of the game engine
system->init(32, FMOD_INIT_NORMAL, 0);

system->createSound("sound.wav", FMOD_HARDWARE, 0, &sound1);
sound1->setMode(FMOD_LOOP_OFF);

system->playSound(FMOD_CHANNEL_FREE, sound1, false, 0);

Does anyone have any idea what is wrong? Or mayby there is another way for that.

Answer

Mathew Block picture Mathew Block · Jan 25, 2012

Firstly make sure you check the return code of all functions, ensure it is FMOD_OK.

Second, you need to call System::update regularly, once per frame for FMOD house keeping.

Regarding your issue though, what platform are you on? Crackling generally means the hardware cannot keep up, to fix it you can increase the amount of buffering FMOD does. This is controlled via System::setDSPBufferSize, try increasing the numBuffers count. You can determine the current values with System::getDSPBufferSize, also make sure you call System::setDSPBufferSize before System::init for the new values to take effect.