Simple sound play in FMOD

13.3k Views Asked by At

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.

2

There are 2 best solutions below

1
On BEST ANSWER

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.

1
On

I don't know If you are calling FMOD::System::Update() .. you need to call this at least once per frame