Hi, guys!
my sound is .wav file and 44.1kHz, my "FMOD_DELAYTYPE" is "FMOD_DELAYTYPE_DSPCLOCK_START", if i want to delay 3ms to play:
1. Is it right i use "FMOD_64BIT_ADD" to set the lag value? And because default soundcard’s output samplerate of fmod system is 48khz, i confused that how much is the value of delay.
2. if i use "system->getDSPClock" in the main.cpp, may i use the "FMOD_64BIT_ADD" in the subprogram?
[code:yj4v7c3f]unsigned int sysHi, sysLo
//** main ****
system->getDSPClock(&sysHi, &sysLo);
//** subprogram **//
FMOD_64BIT_ADD(sysHi, sysLo, 0, 44100*3/1000); // set delay time of 3ms.
system->createSound( 0, mode, &createsoundexinfo, &sound);
system->playSound( FMOD_CHANNEL_FREE, sound, 0, &channel)
channel->setDelay(FMOD_DELAYTYPE_DSPCLOCK_START, sysHi, sysLo)

  • You must to post comments

That should be fine. Be aware that the mixer works in blocks and you cannot schedule a sound less that two blocks ahead. With a DSP buffersize of 1024 running at 48000 Hz that is roughly 21.3ms per mix block. So you cannot schedule a sound at 3ms into the future because FMOD will already be past that point when it starts the next mix.

Here is an example of the worst case scenario where the mixer starts a new mixblock between the calls to ‘getDelay’ and ‘setDelay’:

[code:1brzonms]mixer thread: |— mix —|— mix —|— mix —|— mix —|
main thread: ^ ^ ^
getDSPClock setDelay first opertunity to shedule sound[/code:1brzonms]

To handle this case the minimum delay is two mix blocks which is roughly 42.7ms with a buffersize of 1024 @ 48KHz.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.