I use the following to create a user generated playback stream sound…

unsigned int recsamplelen = 16000/50; // number of samples for 20ms = 16000 / (1000/20)
memset(&createsoundexinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
createsoundexinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
createsoundexinfo.decodebuffersize = recsamplelen;
createsoundexinfo.numchannels = 1;
createsoundexinfo.defaultfrequency = 16000;
createsoundexinfo.format = FMOD_SOUND_FORMAT_PCM16;
createsoundexinfo.pcmreadcallback = pcmreadcallback;
createsoundexinfo.pcmsetposcallback = pcmsetposcallback;
createsoundexinfo.length = recsamplelen * sizeof(signed short) * 4; /* SEEMS TO BE IGNORED Length of PCM data in bytes of playback buffer (4 x 20ms) */

system->createSound(0, FMOD_2D | FMOD_OPENUSER | FMOD_LOOP_NORMAL | FMOD_CREATESTREAM , &createsoundexinfo, &playsound);

system->playSound(FMOD_CHANNEL_FREE, playsound, 0, &channel);


pcmreadcallback just copies data from a buffer into the supplied data pointer.

However no matter what I change createsoundexinfo.length to it makes no difference to the total stream size.
Right now it seems the stream maybe about 2 decodebuffersize worth which would be about 40ms of latency, I know about 80ms of latency is in the mixer, and I am seeing around 120 – 150ms of total latency.
I am trying to understand how big all the buffers are in the playback chain, and how much of it I can control.

Is there a way to change how much gets loaded into the stream or is it double buffered at decodebuffersize all the time?
(For non user created streams I could use setStreamBufferSize())

The docs say the stream size for user created sounds is created in createSound, but that does not seem to happen. So long as createsoundexinfo.length is not set to zero it seems to ignore whatever I set that to.


  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.