 	for (byte i = 0; i < OPL2_NUM_CHANNELS; i ++) {
 		if (channelMap[i].midiChannel == channel && channelMap[i].midiNote == note) {
 			opl2.setKeyOn(i, false);
+			channelMap[i].midiChannel = 0xFF;
+			channelMap[i].midiNote = 0x00;
+
+			// Move channel to the back of recently used channels list to prevent it from
+			// being reused immediately and the release portion of the note being clubbored.
+			byte oldestIndex = 0;
+			for (byte j = 0; j < OPL2_NUM_CHANNELS; j ++) {
+				if (oldestChannel[j] == i) {
+					oldestIndex = j;
+					break;
+				}
+			}
+			for (byte j = oldestIndex; j < OPL2_NUM_CHANNELS - 1; j ++) {
+				oldestChannel[j] = oldestChannel[j + 1];
+			}
+			oldestChannel[OPL2_NUM_CHANNELS - 1] = i;
+
 			break;
 		}
 	}


#include <SPI.h>
#include <OPL2.h>

// For better results with midi files created for Window exchange midi_instruments.h for midi_instruments_win31.h
// #include <midi_instruments_win31.h>
#include <midi_instruments.h>
#include <midi_drums.h>


		opl2Octave = 1 + (note - 24) / 12;
		opl2Note   = note % 12;
	}
	opl2.playNote(opl2Channel, opl2Octave, opl2Note);
}


