0
0

edit: I guess this is a stupid question. It occurs to me that I should use a looping sound, but to have my callback supply silence for any data that’s requested when none is at hand.

I have gotten some functionality for playing back streaming sound in FMOD, but I don’t quite understand the many parameters and would like a sanity check.

My working code is as follows

[code:2bloe4qg]

FMOD_MODE mode = 
    FMOD_LOOP_OFF  // no looping
            | FMOD_3D
    | FMOD_CREATESTREAM // I have no idea
    | FMOD_OPENUSER // indicates we'll use a callback to supply samples
    ;


FMOD_CREATESOUNDEXINFO info;
memset(&info, 0, sizeof(info)); // zero it out
info.cbsize = sizeof(info); // set this thing to right value

info.pcmreadcallback = myFMODPCMReadCallback; 

info.numchannels = 1;

info.format = FMOD_SOUND_FORMAT_PCM16;
info.defaultfrequency = 16000;

// hand it 1/10th second audio each callback
info.decodebuffersize  = 16000 * 0.1;  

// Is this allocating 10 seconds flat storage?
info.length = 16000 * info.numchannels * sizeof(signed short) * 10; 

sFMODSystem->createStream(
NULL, // no data to start out
mode,
&info,
&mStreamingFMODSound)
);

[/code:2bloe4qg]

The issue I have with the above is that I seem to have to allocate a certain number of seconds of flat audio space for my sound, when indeed I have no idea how long the sound is actually going to last (the nature of VOIP, yes?).

Am I supposed to use looping? Obviously, I never ever want the VOIP sound to loop in case of underruns. What is the proper fix?

I’d like to have this sound have a single second circular input buffer, but to have it play silence should an underrun ever occur. How do I accomplish that?

thanks in advance!

tone

  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.