Fix occasional crash when recording MIDI.