MOD Music Position Sync

Started by Irrational86,

Irrational86

Is there a way to sync a HMUSIC channel to a position in time. For example, I want a sync to trigger 2 seconds before the HMUSIC channel is done playing, how do i manage that??

Ian @ un4seen

You could try something like this...
// load music using BASS_MUSIC_CALCLEN flag, and then...
length=BASS_ChannelBytes2Seconds(hmusic,BASS_MusicGetLength(hmusic,TRUE));
BASS_ChannelSetPosition(hmusic,MAKELONG(length-2,0xFFFF));
syncpos=BASS_ChannelGetPosition(hmusic);
hsync=BASS_ChannelSetSync(hmusic,BASS_SYNC_POS,syncpos,...);
BASS_ChannelSetPosition(hmusic,0); // rewind ready for playback
This is unlikely to sync exactly 2 seconds from the end, but it should generally be within a second of that :)

The other option is to use a decoding channel + custom stream, to effectively turn the MOD into a stream.