We’re using FMOD to output two different “sounds” to two different output devices. These sounds are user audio streams we fill with data using the pcmreadcallback.
The sound is created as followed:
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.numchannels = inchannels;
exinfo.defaultfrequency = insamplerate;
exinfo.decodebuffersize = decodebuffersize;
exinfo.length = exinfo.defaultfrequency * exinfo.numchannels * sizeof(float);
exinfo.format = FMOD_SOUND_FORMAT_PCMFLOAT;
exinfo.pcmreadcallback = pcmreadcallback;
exinfo.pcmsetposcallback = pcmsetposcallback;
exinfo.userdata = (void*)this;
FMOD_MODE mode = FMOD_OPENUSER | FMOD_LOOP_NORMAL | FMOD_CREATESTREAM;
result = system->createSound(0, mode, &exinfo, sound);
The problem is that the rate the callback consumes data on average is 48KHZ samples per second but at some point drops below this value. Sometimes it does recover after a couple of seconds but sometimes it stays on the lower rate for minutes. This can be 47.7KHZ but I’ve seen moments of 46KHZ
This is a problem because our audio data source comes in at a steady 48KHZ and if it’s not consumed at the same rate the data is kept in a buffer until finally requested/read by fmod. Effectively causing a delay between our audio source data and sound being outputted by fmod.
Is there something we can do to improve the data consumption of the callback/fmod or setup the streaming audio in a way we can rely on a steady data consumption? Or is there a different solution to this problem?