Fixed null pointer bug

This commit is contained in:
Harry Zhou 2022-07-03 22:50:01 -05:00
parent 79bea6b07b
commit 72d91a5ef7

View file

@ -125,10 +125,12 @@ public class MidiConverter {
public static Note getMidiInstrumentNote(int midiInstrument, int midiPitch, long microTime) {
Instrument instrument = null;
Instrument[] instrumentList = instrumentMap.get(midiInstrument);
for (Instrument candidateInstrument : instrumentList) {
if (midiPitch >= candidateInstrument.offset && midiPitch <= candidateInstrument.offset+24) {
instrument = candidateInstrument;
break;
if (instrumentList != null) {
for (Instrument candidateInstrument : instrumentList) {
if (midiPitch >= candidateInstrument.offset && midiPitch <= candidateInstrument.offset+24) {
instrument = candidateInstrument;
break;
}
}
}