mvandoornik
Posts: 4
Joined: Mon Nov 28, 2016 5:05 pm

USB MIDI, missing MIDI events

Fri Dec 09, 2016 7:22 pm

For a DIY synthesizer project, I'm running Minibian on a Raspberry Pi 3. RT-PREEMPT kernel, C-Media CM-108 USB soundcard, jackd running at a latency of around 8 ms. The synth is inside a Pure Data (Pd) patch. Audio is running glitch-free, CPU load is comfortably low and response is percieved as immediate, no discernable latency. The whole thing is run headless and is controlled by an Atmega328 as the UI over the GPIO serial interface.

Everything works just fine, but for some reason MIDI events from a USB keyboard controller ( Arturia Minilab) are missed occasionally, say once every few minutes. This can be a note on message, but also a note off, resulting in "sticky" keys and hanging notes. I'm using dwc_otg.speed=1, without this the thing was absolutely unplayable. The preempting kernel improved things a bit more, but I can't seem to get rid of these issues completely. Larger buffers have no effect, so it doesn't seem to be a CPU load issue.

I've also monitored the MIDI data coming directly from the controller by using the amidi dump facility and verified the events against the events seen by Pure Data, but they are identical. Some events just go AWOL without any apparent cause or error. Could anyone shed some light onto this issue? I really want this thing to work properly and it seems so close now. Any help will be appreciated.

TIA, Marc

liamtmlacey
Posts: 3
Joined: Thu Nov 23, 2017 2:58 pm

Re: USB MIDI, missing MIDI events

Thu Nov 23, 2017 3:28 pm

I've also discovered this issue on both a Raspberry Pi 3 and a Compute Module 3 running Raspbian Jessie, where I was using an external USB Hub with the CM3.

I've tested five different USB-MIDI controllers with both commercial and custom MIDI software - Arturia Keystep, AKAI LPK25 Wireless, Samson Graphite 49, Modal 008, and Modal CRAFTsynth. Out of these five controllers both the Keystep and LPK25 would produce hung notes.

To prove it was the controllers rather than the MIDI driver (ge-alsa) or MIDI software, I ran 'amidi -d’ to monitor MIDI coming from the controllers, and I could see a few note-on messages with missing note-off messages.

I would also like to know if this is a known issue and if there is a fix for it.

mvandoornik
Posts: 4
Joined: Mon Nov 28, 2016 5:05 pm

Re: USB MIDI, missing MIDI events

Thu Nov 23, 2017 7:27 pm

Well, apparently it has something to do with the RPi having a USB-OTG port rather than a true USB host. Unfortunately there seems to be nothing we can do about this apart from using a different kind of interface, for example a MIDI circuit wired to the UART GPIO pins or just accepting lost events with some controllers. I am currently investigating using an entirely different SBC for this application, due in large degree to precisely this issue. It is a pity, really, as to the best of my knowledge nothing really offers the same power at this price point. I have also noticed this issue all but disappearing when using my Graphite 49 keyboard, but I just cannot getbit to work 100% reliably. If anyone has a different solution, then please do chime in!

liamtmlacey
Posts: 3
Joined: Thu Nov 23, 2017 2:58 pm

Re: USB MIDI, missing MIDI events

Fri Dec 15, 2017 12:16 pm

Thanks for the info mvandoornik.
Where/how did you find out that is is related to the USB-OTG port?
Do you know if this is specific to the Broadcom processor or on all OTG devices?

mvandoornik
Posts: 4
Joined: Mon Nov 28, 2016 5:05 pm

Re: USB MIDI, missing MIDI events

Fri Dec 15, 2017 1:00 pm

Unfortunately I don't have much more info. From what I've distilled from a lot of web searches on this matter it appears to pertain to the RPi only, although other Broadcom-based devices could very well suffer from the same issue. So far I haven't been able to solve this with the Pi, so another SBC it is, I'm afraid.

liamtmlacey
Posts: 3
Joined: Thu Nov 23, 2017 2:58 pm

Re: USB MIDI, missing MIDI events

Thu Jan 11, 2018 3:37 pm

After implementing the last workaround described at viewtopic.php?t=53832 (put dwc_otg.speed=1 into /boot/cmdline.txt) I found that this resolved the issue I was getting with certain MIDI controllers. Had you tried this or had any luck with it? I haven't yet tested how this changes the performance of my other USB devices though.

mvandoornik
Posts: 4
Joined: Mon Nov 28, 2016 5:05 pm

Re: USB MIDI, missing MIDI events

Fri Jan 12, 2018 7:08 am

In fact I have tried this. It does resolve most of the issue, i.e. the frequency of lost packets drops significantly from multiple times per second to once every few minutes or so, but it doesn't solve the problem entirely. Communication has to be absolutely perfect if it has to be used as a performance instrument, so even sporadic dropped packets are entirely unacceptable. A side effect is that loading files from the connected USB drive drops to a glacial pace, so loading a 100MB-ish sample set is out of the question. I have seriously considered just using MIDI over the serial port, but this rules out loads of cheap and cheerful USB controllers...

pvdmeer
Posts: 29
Joined: Mon Feb 22, 2016 10:29 am

Re: USB MIDI, missing MIDI events

Fri Mar 09, 2018 1:46 pm

First things first, I'm also using Arturias (beatstep and keystep). They seem to really hate the Pi's ALSA rawmidi system. There are hanging notes all over the place. Happens especially with high bandwidth controls such as aftertouch. No problems when I use these Arturias with my Mac. Although I have to say they really have a lot of firmware bugs besides this. I'll have a look at the cmdline.txt solution. Thanks!

pvdmeer
Posts: 29
Joined: Mon Feb 22, 2016 10:29 am

Re: USB MIDI, missing MIDI events

Fri Mar 09, 2018 1:48 pm

well, that worked! cheers!

drbourbon
Posts: 1
Joined: Sat Jun 02, 2018 5:55 am

Re: USB MIDI, missing MIDI events

Sat Jun 02, 2018 6:02 am

wifi is also causing frequent midi events drops on my rpi 3 b (totally unusable for usb midi routing even with usb mode set to 1 as suggested here). no more drops so far after disabling it (sudo ifconfig eth1 down). thanks for these hints!

Yosh
Posts: 1
Joined: Wed Apr 01, 2020 1:07 pm

Re: USB MIDI, missing MIDI events

Wed Apr 01, 2020 1:13 pm

Sorry for necroposting...

Does anyone tested this on rpi4 ? new usb hub and so on.

I too have arturia and can confirm that full speed helps a lot - but not totally on rpi2. I wonder if upgrade do rpi4 would help.

Return to “Troubleshooting”