protected void ActiveNote(int channel, int note, bool active)
{
if (note >= 128 || channel >= 16)
return;
if (active)
ActiveNotes[note] |= (ushort)(1 << channel);
else
ActiveNotes[note] &= (ushort)~(1 << channel);
// See if there are hanging notes that we can cancel
foreach (var hangingNote in HangingNotes.Reverse())
{
if (hangingNote.Channel == channel && hangingNote.Note != 0 && hangingNote.TimeLeft != 0)
{
hangingNote.TimeLeft = 0;
--HangingNotesCount;
break;
}
}
}