0
0

Hello all!

I’m working on a app where I need the sound to start playing after a few moments. I’ve read in the docs about setdelay. However, I can’t get it to work. My sound always start playing right away. Searched this forum without finding any snippets how it should be used.
I read though in the introduction that setdelay should be called between init and start of the sound:
[code:11oswya7]
result = FMOD_System_Create(&system);
result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, NULL);
result = FMOD_System_CreateSound(system, "C:\test.wav", FMOD_SOFTWARE, 0, &sound);
result = FMOD_System_GetDSPClock(system, &hiclock, &loclock);
result = FMOD_Channel_SetDelay(channel,FMOD_DELAYTYPE_DSPCLOCK_START,hiclock+200000,0);
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound, 0, &channel);

//then loop until the sound has stopped playing
[/code:11oswya7]

  • You must to post comments
0
0

You’re setting properties on your channel before you’ve started the sound. Your channel handle isn’t valid until you’ve played a sound on it. Try something like the following:

[code:31zena8k]result = FMOD_System_Create(&system);
result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, NULL);
result = FMOD_System_CreateSound(system, "C:\test.wav", FMOD_SOFTWARE, 0, &sound);
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound, 1, &channel);
result = FMOD_System_GetDSPClock(system, &hiclock, &loclock);
result = FMOD_Channel_SetDelay(channel,FMOD_DELAYTYPE_DSPCLOCK_START,hiclock+200000,0);
result = FMOD_Channel_setPaused(0);
[/code:31zena8k]

Note two things:
1.) I’ve switched the order of the PlaySound() and SetDelay() calls.
2.) I added a "true" parameter to the "start paused" in PlaySound(), then unpause the sound after setting the properties.

Hope that helps!

  • You must to post comments
0
0

Thanks

Now the code looks like this

[code:3j4htpk6] result = FMOD_System_Create(&system);
result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, NULL);
result = FMOD_System_CreateSound(system, "C:\test.wav", FMOD_SOFTWARE, 0, &sound);
result = FMOD_System_GetDSPClock(system, &hiclock, &loclock);
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound, 1, &channel);
result = FMOD_Channel_SetDelay(channel,FMOD_DELAYTYPE_DSPCLOCK_START,hiclock+100,0);
result = FMOD_Channel_SetPaused(channel,0);
// a loop until play is over[/code:3j4htpk6]

Problem is though the sound is never played. I can hear like a short stutter or whatever but then dead silence and my while playing loop just keep going.
This happens only if SetDelay is present and the hi is set to > 0.

Any ideas? Help!

  • You must to post comments
0
0

Remember that the delay is a 64-bit value. By setting the high value, you’re saying "Don’t play my sound until the DSP clock reaches my value." Your value is a very large number. If the DSP clock operates at 48,000Hz, then it’ll be over 24 hours before the the hi 32 bits of the number even get set, and a lot longer than that before the sound starts to play.

Use the FMOD_64BIT_ADD() macro to add your number. Something like:
[code:29gcp8bi]FMOD_System_GetDSPClock(system, &hiclock, &loclock);
FMOD_64BIT_ADD(hiclock, loclock, 0, 48000);
FMOD_Channel_SetDelay(channel,FMOD_DELAYTYPE_DSPCLOCK_START,hiclock,loclock);
[/code:29gcp8bi]

That should delay your sound by one second.

  • You must to post comments
0
0

Thank you very much its working great!

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.