This can happen from the first press to something over a thousand presses. I have tried the error callback function of rtmidi and it simply quits without printing anything from the call back. I also tried without the try ... except without any results.
Code: Select all
# #!/usr/bin/env python3 # MIDI crash minimum example import rtmidi midiIn = rtmidi.MidiIn() def main(): # program will quit occasionally without an error message initMIDI() rx = 0 while 1: try: m = midiIn.get_message() except: m = None if m != None : command, note, vel = m rx +=1 print(rx," - ",hex(command), hex(note), hex(vel)) def initMIDI(): # open first MIDI port seen available_ports = midiIn.get_ports() print("MIDI ports available:-") for i in range(0,len(available_ports)): print(i,available_ports[i]) if available_ports: midiIn.open_port(1) else: midiIn.open_virtual_port("My virtual output") # Main program logic: if __name__ == '__main__': main()
When I run the code again after a quit then sometimes there seems to be two MIDI messages in the buffer that pop out immediately, that is without pressing a key.
Is it me doing something wrong or is rtmidi a bit flakey? It was installed today so it should be up to date.