Is there a reliable way to check to see if a PCM sound is currently playing?
This is what I have so far in my main run loop in order to figure out the looping byte for each PCM sound:
Code: Select all
#define LO8(x) ((uint8_t)((x) & 0xFF))
#define HI8(x) ((uint8_t)(((x) >> 8) & 0xFF))
UZEMH = HI8((uint16_t)mixer.channels.type.pcm.position);
UZEMH = LO8((uint16_t)mixer.channels.type.pcm.position);
UZEMC = '\n';
Then when I want to play a sound without interrupting another sound, I can first check to see if the PCM sound position is on one of my known looping bytes before starting a new sound:
Code: Select all
void TriggerNoteNoInterrupt(unsigned char channel,unsigned char patch,unsigned char note,unsigned char volume)
{
if ((uint16_t)mixer.channels.type.pcm.position == 0x3737 ||
(uint16_t)mixer.channels.type.pcm.position == 0x3c51 ||
(uint16_t)mixer.channels.type.pcm.position == 0x3a50)
TriggerNote(channel, patch, note, volume);
}
Is there a more reliable way of detecting when a PCM sound has finished playing?