-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MIDI UART support #7
Comments
im cool with it if you can figure out how :) |
Thanks. "I'll take a shot at it," he said nervously. |
Status: With just a few changes I was able to create a working UART-only version, but I'm not sure how to combine the two and maintain the original UI -- just yet. I'm looking at other libraries for similar examples and plan to talk to some of the folks on the CPy team for advice. This might take me a while... but I'm having fun. |
@CedarGroveStudios Can you post your changes somewhere? The goal of the USB midi stuff was to act exactly like a UART so this lib would work with both. Maybe something needs to change with it. |
@tannewt That was my objective, too. I have fork of the repo with a MIDI_UART class (and the original but renamed MIDI_USB class) and updated examples. Should I just create a PR from the updated fork? (I'm so new at using GitHub for this.) |
The fork is here: https://github.com/CedarGroveStudios/Adafruit_CircuitPython_MIDI |
@CedarGroveStudios Could you rename the uart version back to the original filename so that the diff is shown? It looks to me like the only change is taking in midi_in and midi_out as pins instead of serial objects. Did you try giving a UART as both midi_in and midi_out? I'd expect that to just work. |
@tannewt The USB version doesn't handle midi_in if I'm understanding it correctly, so I just duplicated the same output-only functionality by adding the UART pins and unique baud/timeout settings as you noted. I created a second class to facilitate instantiation. Is there a more elegant way of doing it that still allows the creation of a UART instance? from adafruit_midi import midi_uart
# defaults to transmit out the board.TX pin
midi = midi_uart.MIDI(out_channel=0) The USB midi_out uses an abbreviated subset of the MIDI protocol stack (CC, Note_On, etc.). Parsing the USB and UART midi_in messages using a similar subset of the MIDI protocol stack would be something for the next version, I'd guess. For this I was just trying to duplicate the existing functionality of the USB code. |
I was thinking: import board
import busio
import adafruit_midi
uart = busio.UART(board.TX, rx=None, baudrate=31250, timeout=0.001)
midi = adafruit_midi.MIDI(midi_out=uart, out_channel=0) Check with @kevinjwalters about MIDI in. I think they've done some work on it already. |
^ That's an excellent approach that could lead to using any MIDI input/output stream including USB, UART, BLE, and file. In your example, how would USB or BLE in/out be instantiated? |
We don't have BLE support yet. USB is already instantiated because the USB descriptor is fixed. It is available as It's a bit weird that those are the default values. |
FYI, I'm hoping to have the MIDI stuff done by Sunday and will look at allowing messages to be sent whilst preserving the existing interface. I'm trying to keep it reasonably tight on memory which is my current area of exploration. |
BTW, I successfully tested USB inputs and outputs along with simultaneous UART output using the existing library. My DAW calls the GrandCentral's USB port an Adafruit CircuitPython keyboard. Nice. |
WRT to comment on default values for |
Just discussing using UART with @jedgarpark and I think the current library will work for |
Where is the |
BTW, I just threw together a quick/dirty UART MIDI sniffer for @jedgarpark using the library. The timeout was set to 1ms rather than the default 1sec: |
Having a |
@kevinjwalters Instead of hacking the library let's just fix midi_out. |
Can you elaborate a bit on that? |
The recent discussion was about adding a flag to distinguish a midi_out from a UART because "midi_out needs to support write(buf, len) but I see busio.UART has write(buf) with a return value" The two should have identical interfaces so that they can be used interchangeably. Any differences are unintentional and should be fixed. |
It would be certainly be nice if Another question is whether support for optionals |
Also, |
Would it be possible to expand this to also support "classic" MIDI communications via a UART port?
The text was updated successfully, but these errors were encountered: