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


#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>


	}

	// Get an available OPL2 channel and setup instrument parameters.
	byte opl2Channel = getFreeChannel(channel);
	if (channel != MIDI_DRUM_CHANNEL) {
		opl2.setInstrument(opl2Channel, midiInstruments[programMap[channel]]);
	} else {
		if (note >= DRUM_NOTE_BASE && note < DRUM_NOTE_BASE + NUM_MIDI_DRUMS) {
			opl2.setInstrument(opl2Channel, midiDrums[note - DRUM_NOTE_BASE]);
		} else {
			return;
		}
	}

	// Register channel mapping.
	channelMap[opl2Channel].midiChannel  = channel;
	channelMap[opl2Channel].midiNote     = note;
	channelMap[opl2Channel].midiVelocity = min((float)velocity / 64.0, 1.0);
	channelMap[opl2Channel].op1Level     = (float)(63 - opl2.getVolume(opl2Channel, OPERATOR1)) / 63.0;
	channelMap[opl2Channel].op2Level     = (float)(63 - opl2.getVolume(opl2Channel, OPERATOR2)) / 63.0;

	// Set operator output levels based on note velocity.
	setOpl2ChannelVolume(opl2Channel, channel);

	// Calculate octave and note number and play note!
	byte opl2Octave = 4;
