diff --git a/midi.ts b/midi.ts index eb844e5..15bc52e 100644 --- a/midi.ts +++ b/midi.ts @@ -358,7 +358,7 @@ namespace midi { } else { left = mid; } - mid = (left + right) >> 1; + mid = ((left + right) >> 1) >> 0; } // imprecise match return frequency - notes[left] < notes[right] - frequency diff --git a/tests.ts b/tests.ts index bd840ca..1b1280a 100644 --- a/tests.ts +++ b/tests.ts @@ -8,3 +8,5 @@ i.setInstrument(MidiInstrument.Banjo); let piano = midi.channel(0); let trumpet = midi.channel(1); piano.setInstrument(MidiInstrument.Trumpet); + +serial.writeLine('B ' + Note.B + ' -> ' + midi.frequencyToKey(Note.B))