File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
QT_Py_RP2040_USB_to_Serial_MIDI_Friends Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ # SPDX-FileCopyrightText: 2022 Liz Clark for Adafruit Industries
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ import board
5
+ import busio
6
+ import usb_midi
7
+ import adafruit_midi
8
+ # pylint: disable=unused-import
9
+ from adafruit_midi .control_change import ControlChange
10
+ from adafruit_midi .pitch_bend import PitchBend
11
+ from adafruit_midi .note_off import NoteOff
12
+ from adafruit_midi .note_on import NoteOn
13
+ from adafruit_midi .program_change import ProgramChange
14
+
15
+ # uart setup
16
+ uart = busio .UART (board .TX , board .RX , baudrate = 31250 )
17
+ # midi channel setup
18
+ midi_in_channel = 1
19
+ midi_out_channel = 1
20
+ # midi setup
21
+ # UART is setup as the input
22
+ # USB is setup as the output
23
+ midi = adafruit_midi .MIDI (
24
+ midi_in = usb_midi .ports [0 ],
25
+ midi_out = uart ,
26
+ in_channel = (midi_in_channel - 1 ),
27
+ out_channel = (midi_out_channel - 1 ),
28
+ debug = False ,
29
+ )
30
+
31
+ while True :
32
+ # receive MIDI message over USB
33
+ msg = midi .receive ()
34
+ # if a message is received...
35
+ if msg is not None :
36
+ # send that message over UART
37
+ midi .send (msg )
38
+ # print message to REPL for debugging
39
+ print (msg )
You can’t perform that action at this time.
0 commit comments