How to achieve lagless sound in fmod android?

(Jitendra Singh) #1

I am working on an app in which i am playing an mp3 audio file. i am giving path from sd card of that file in createSound(".mp3", FMOD_DEFAULT, 0, &sound). everything is working fine. but problem is that, it takes 2 or 3 seconds to play sound… what should I do? Please help me out…

result = system->setDSPBufferSize(1024, 4);

result = system->init(1000, FMOD_INIT_NORMAL, extradriverdata);

result = system->getMasterChannelGroup(&mastergroup);

result = system->createSound(Common_EffFilePath(), FMOD_DEFAULT, 0, &sound);

result = system->playSound(sound, 0, false, &channel);

(Brett Paterson) #2

Is the file really big? Its possible you’re trying to create the sound and decompress it into memory as part of your playing of the sound. The time to play a sound should be measured around the ‘playSound’, not the createSound which loads the sound.

If you want the createSound to be faster, try playing it compressed (ie FMOD_CREATECOMRPESSEDSAPMLE) or streaming (createStream).

(Jitendra Singh) #3

thanx for answering sir, its working… but i have one more issue, how can i convert mp3 audio data to stream(pcm) without playing it… I want to save stream in pcm file and byte array…
please help me out sir…

(Brett Paterson) #4

If you use FMOD_OPENONLY you can read data from an mp3 into your own buffer with Sound::readData