Avoid threading bug during recording MIDI