Skip to content
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 USB Host support #611

Merged
merged 19 commits into from
Mar 7, 2024
Merged

MIDI USB Host support #611

merged 19 commits into from
Mar 7, 2024

Conversation

GregBurns
Copy link
Contributor

Adds support for USB MIDI host. The addition of a Register method for registering the USB class is a breaking change but seems necessary to allow support for MSC and MIDI in the same application.

I have tested this with three different USB Midi device: Arturia Keystep, a very old M-Audio 02 Midi keyboard, a WERSI USB to MIDI (DIN) adapter and an Arturia Beatstep PRO. The first three devices all work correctly. The Beatstep enumerates and connects but MIDI events are not received, this needs further debugging but does not appear at this point to be related to the MIDI USB class implementation.

@stephenhensley
Copy link
Collaborator

Awesome!! This is so exciting. Thanks for the contribution!

We'll take a look and start reviewing this early next week!

DMA is currently very unreliable, it doesn't work at
all with the Arturia Beatstep Pro. Turning it off for
now to allow further testing.

Signed-off-by: Greg Burns <[email protected]>
@GregBurns
Copy link
Contributor Author

After disabling DMA in usbh_conf.c the Arturia Beastep PRO and all my other MIDI USB devices now work reliably. Hot swapping ocasionally fails to detect the disconnect so there is more work needed there. As there are no other USB host examples to compare with I don't know if there is a problem with the DMA configuration or it's something else.

@beserge
Copy link
Contributor

beserge commented Feb 28, 2024

Works great! Tested on the Qu-Bit Aurora with the example you wrote. Used a keyboard based controller (Akai MPK-25) to great success.

Also tried the Roland SPD-SX, which is a drumpad based controller. This one had issues. The serial monitor just prints "device connected" over and over. The SPD displays "MIDI OFFLINE" on the screen. That device also supports USB Audio, which maybe is the issue? I tried messing with lots of different settings to no avail.

@GregBurns
Copy link
Contributor Author

GregBurns commented Feb 28, 2024 via email

@beserge
Copy link
Contributor

beserge commented Mar 1, 2024

I used the latest commit. I think the issue with the SPD-SX is that it also offers USB-Audio. It probably presents as a composite device, which confuses the Midi Host code. Maybe not something we have to worry about at this time. Either that or we can just detect devices that present as composite and ignore them for now.

I want to give you some more time to look into the DMA issue if you choose before we consider merging this.

@GregBurns
Copy link
Contributor Author

GregBurns commented Mar 2, 2024 via email

Seems that the class startup was happening at the wrong
point. It needs to happen when the lower stack calls the
ClassRequest callback. This fix also eliminates the
spurious Device Error callback.

Signed-off-by: Greg Burns <[email protected]>
@GregBurns
Copy link
Contributor Author

I have DMA working now with all four of my devices. Hot plug seems to be stable too. Can you try testing with the SPD-SX again?

@beserge
Copy link
Contributor

beserge commented Mar 6, 2024

Retested with the keyboard and the SPD-SX. The keyboard works well, the SPD still does not. I'm not worried about it, I believe the device is requesting to be a composite device, which is a bit of an edge case. I'm happy to merge it as is unless you feel strongly about continuing work.

@GregBurns
Copy link
Contributor Author

GregBurns commented Mar 6, 2024 via email

@beserge beserge merged commit f7727ed into electro-smith:master Mar 7, 2024
4 checks passed
@dromer
Copy link

dromer commented Mar 7, 2024

a bit of an edge case

What is less common is devices that show up as multiple midi ports. Like the Novation Launchpad series.

How would the USB Host driver deal with these?

@GregBurns
Copy link
Contributor Author

GregBurns commented Mar 7, 2024 via email

@dromer
Copy link

dromer commented Mar 7, 2024

Do you mean multiple interfaces?

Yeah one device with multiple interfaces. My Novation Launchpad X actually also shows up as a storage device.
Then two midi devices first one called DAW (used for integration with Ableton and Ardour) and the other called MIDI, which is the one you want to use.

Just wondering if these devices will work. Will probably give it a try at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants