-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from todbot/main
Add timeout parameter, add Feather RP2040 with USB Type A Host example
- Loading branch information
Showing
7 changed files
with
130 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2023 Scott Shawcroft for Adafruit Industries | ||
# | ||
# SPDX-License-Identifier: Unlicense | ||
# pylint: disable=unused-import | ||
|
||
import board | ||
import busio | ||
import usb.core | ||
import adafruit_midi | ||
from adafruit_midi.note_on import NoteOn | ||
from adafruit_midi.note_off import NoteOff | ||
from adafruit_midi.control_change import ControlChange | ||
from adafruit_midi.pitch_bend import PitchBend | ||
import adafruit_usb_host_midi | ||
|
||
print("Looking for midi device") | ||
raw_midi = None | ||
while raw_midi is None: | ||
for device in usb.core.find(find_all=True): | ||
try: | ||
raw_midi = adafruit_usb_host_midi.MIDI(device) | ||
print("Found", hex(device.idVendor), hex(device.idProduct)) | ||
except ValueError: | ||
continue | ||
|
||
# This setup is to use TX pin on Feather RP2040 with USB Type A Host as MIDI out | ||
# You must wire up the needed resistors and jack yourself | ||
# This will forward all MIDI messages from the device to hardware uart MIDI | ||
uart = busio.UART(rx=board.RX, tx=board.TX, baudrate=31250, timeout=0.001) | ||
|
||
midi_device = adafruit_midi.MIDI(midi_in=raw_midi, in_channel=0) | ||
midi_uart = adafruit_midi.MIDI(midi_out=uart, midi_in=uart) | ||
|
||
|
||
while True: | ||
msg = midi_device.receive() | ||
if msg: | ||
print("midi msg:", msg) | ||
midi_uart.send(msg) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ | |
# SPDX-License-Identifier: MIT | ||
|
||
Adafruit-Blinka | ||
adafruit-circuitpython-usb-host-descriptors | ||
pyusb |