-
-
Save poetaster/e8a8cff24ca70ce4052bf301ca36787f to your computer and use it in GitHub Desktop.
CircuitPython USB MIDI to serial MIDI converter for Raspberry Pi Pico (RP2040)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CircuitPython USB MIDI to serial MIDI converter for Raspberry Pi Pico (RP2040). | |
# IMPORTANT! Should *only be used for MIDI in*, i.e. from USB devices to hardware | |
# MIDI synths, and *not* in the opposite direction. Doing so could risk damage to | |
# the microcontroller, your computer, or both. | |
# Wire a 10Ω resistor from the Tx pin on the Raspberry Pi Pico or other | |
# RP2040 board to the 3.5mm stereo jack tip, a 33Ω resistor from the 3v3 pin on | |
# the Raspberry Pi Pico to the 3.5mm stereo jack ring, and the ground pin on the | |
# Raspberry Pi Pico to the 3.5mm stereo jack sleeve. | |
# The code below assumes you're using USB MIDI channel 1. Change the number in | |
# square brackets on the midi_in line if you want to use a different channel. | |
import usb_midi | |
import board | |
import busio | |
midi_in = usb_midi.ports[0] | |
midi_out = busio.UART(tx=board.GP0, baudrate=31250) | |
while True: | |
msg = midi_in.read(3) | |
if len(msg): | |
midi_out.write(msg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment