Description
Hi,
First off, thank you for your work on this repository! I've been using it extensively and have found it very helpful.
Background
I have successfully used this library with several digital pianos (Yamaha and Casio) for my project. My main use case involves reading MIDI Note On and Off messages and controlling WS2812 LEDs based on those messages. However, I’m encountering issues when using the Akai MPK Mini Play Mk3 MIDI controller.
I’m using the up-to-date usb_midi_host
with the EZ_USB_MIDI_HOST
wrapper on a Raspberry Pi Pico 2, writing in C++ with VSCode on SDK 2.1.0 on Windows 11. A quick note: I’m not a highly experienced programmer, so a lot of the USB driver code is beyond my understanding.
Problem Description
When sending simultaneous Note On or Off messages (e.g., pressing 5–6 note chords), some messages are not received. During troubleshooting, I observed that the likelihood of missed messages increases if there are delays in the code, such as logic processing or sleep_ms commands. If I simplify the program to only output serial messages without additional processing, the issue seems to not be as bad, and no or minimal messages are missed.
I understand that when dealing with a large volume of MIDI data, it’s possible to overflow the buffer if the callback functions don’t process the data in time. However, this issue feels different—it seems like the messages never even sit in the buffer. Below is an example serial output when pressing four notes simultaneously with a sleep_ms(5) in the Note On and Note Off callbacks:
C1: Note on#48 v=95
C1: Note on#50 v=101
C1: Note off#50 v=0
C1: Note off#52 v=0
C1: Note off#48 v=0
C1: Note off#53 v=0
As you can see, two of the Note On messages were not detected. Additionally, I don’t see any FIFO overflow messages.
What Confuses Me
When using a different digital piano, everything works as expected. Messages stay in the buffer, and the program eventually processes them, even with delays in the code. With the Akai, however, the behavior is inconsistent.
I’ve been troubleshooting this issue using the EZ_USB_MIDI_HOST_example.cpp as a starting point. When I connect the Akai, I see the expected message:
MIDI device at address 1 has 1 IN cables and 1 OUT cables
When pressing single notes (even rather rapidly), all Note On and Off messages are received correctly. The MIDI sequence also plays through the Akai’s speakers as expected.
I’ve tried adjusting the buffer size (e.g., changing buffer[48] to smaller and larger sizes), but this did not resolve the issue. I’ve also confirmed that the Akai sends all messages correctly when tested with Ableton and MIDI diagnostic tools on Windows (MIDI-OX and MIDIView), so the issue doesn’t seem to be hardware-related.
Request for Help
I’m unsure where to go from here. Could this be a quirk with this specific MIDI controller's timing over USB, or is there something in the code that can be adjusted to fix this behavior? If additional details or tests would help diagnose the problem, I’d be happy to provide them.
Thank you in advance for any insights or suggestions, and apologies if I’ve missed any important information.