0
0

I have the following to try and find when a channel has finished playing:

[code:3ubk4rb2]FMOD_Channel_SetCallback(bassChannel, channelEnded);
FMOD_Channel_SetCallback(track1Channel, channelEnded);
FMOD_Channel_SetCallback(track2aChannel, channelEnded);
FMOD_Channel_SetCallback(track2bChannel, channelEnded);[/code:3ubk4rb2]

and the my static channelEnded method like so:

[code:3ubk4rb2]
FMOD_RESULT F_CALLBACK channelEnded(FMOD_CHANNEL *channel, FMOD_CHANNEL_CALLBACKTYPE type, void *commanddata1, void *commanddata2) {
printf(" channel ended called ");
if(type == FMOD_CHANNEL_CALLBACKTYPE_END) {
// stuff
}

return FMOD_OK;

}
[/code:3ubk4rb2]

The sounds play fine, and any info about the channels returns fine, but the callbacks aren’t triggered. I could just poll the channels to see if they’re playing, but I’d rather use the callbacks, unless that’s not recommended. I’ve checked that I’m calling FMOD_System_Update() in my update loop so it seems like it should be alright. Any help is appreciated. Thanks!

  • You must to post comments
0
0

It’s hard to tell what might be going wrong there. Make sure you set the callback after calling playSound and check the FMOD_RESULT being returned from all the FMOD function calls.

  • You must to post comments
0
0

Thanks for the response and apologies for vagueness. Does this clarify anything?

[code:1mqydc2q]
FMOD_Sound_SetLoopCount(track1Snd, track1Repeats);
FMOD_Sound_SetLoopCount(track2aSnd, track2aRepeats);
FMOD_Sound_SetLoopCount(track2bSnd, track2bRepeats);

FMOD_System_PlaySound(esp.getSys(), FMOD_CHANNEL_FREE, bassSnd, FALSE, &bassChannel);
FMOD_System_PlaySound(esp.getSys(), FMOD_CHANNEL_FREE, track1Snd, FALSE, &track1Channel);
FMOD_System_PlaySound(esp.getSys(), FMOD_CHANNEL_FREE, track2aSnd, FALSE, &track2aChannel);
FMOD_System_PlaySound(esp.getSys(), FMOD_CHANNEL_FREE, track2bSnd, FALSE, &track2bChannel);

FMOD_Channel_SetCallback(bassChannel, channelEnded);
FMOD_Channel_SetCallback(track1Channel, channelEnded);
FMOD_Channel_SetCallback(track2aChannel, channelEnded);
FMOD_Channel_SetCallback(track2bChannel, channelEnded);

float intFreq, ratio;
ratio = 2.0 - pitch;

FMOD_Channel_GetFrequency(bassChannel, &intFreq);
FMOD_Channel_SetFrequency(bassChannel, intFreq * ratio);

FMOD_Channel_GetFrequency(track1Channel, &intFreq);
FMOD_Channel_SetFrequency(track1Channel, intFreq * ratio);

FMOD_Channel_GetFrequency(track2aChannel, &intFreq);
FMOD_Channel_SetFrequency(track2aChannel, intFreq * ratio);

FMOD_Channel_GetFrequency(track2bChannel, &intFreq);
FMOD_Channel_SetFrequency(track2bChannel, intFreq * ratio);

FMOD_System_AddDSP(esp.getSys(), dspstretch, NULL);

[/code:1mqydc2q]

  • You must to post comments
0
0

Your code looks good, that should be working. Just to be clear, you will only get a channel end callback when the at the end of the [i:oyk3oxpv]final [/i:oyk3oxpv]loop. If you want one callback for each loop you can do this using syncpoints:

[code:oyk3oxpv] unsigned int end = 0;
FMOD_Sound_GetLength(track1Snd, &end, FMOD_TIMEUNIT_PCM);
FMOD_Sound_AddSyncPoint(track1Snd, end, FMOD_TIMEUNIT_PCM, NULL, NULL); [/code:oyk3oxpv]

and change the callback type to FMOD_CHANNEL_CALLBACKTYPE_SYNCPOINT.

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.