We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c3e450d commit 8531101Copy full SHA for 8531101
examples/tmidi_simple_receiver.py
@@ -0,0 +1,17 @@
1
+# SPDX-FileCopyrightText: Copyright (c) 2024 Tod Kurt
2
+#
3
+# SPDX-License-Identifier: MIT
4
+
5
+# This example shows how to receive MIDI NoteOn and NoteOff messages
6
7
+import usb_midi
8
+import tmidi
9
10
+midi_usb = tmidi.MIDI(midi_in=usb_midi.ports[0], midi_out=usb_midi.ports[1])
11
12
+while True:
13
+ if msg := midi_usb.receive():
14
+ if msg.type == tmidi.NOTE_ON and msg.velocity > 0:
15
+ print("note on: ", msg.note, msg.velocity)
16
+ elif msg.type == tmidi.NOTE_OFF or msg.velocity == 0:
17
+ print("note off:", msg.note, msg.velocity)
0 commit comments