adafruit / Adafruit_TinyUSB_Arduino

Arduino library for TinyUSB
MIT License
450 stars 120 forks source link

USB MIDI commands received in wrong order #313

Closed amowry closed 1 year ago

amowry commented 1 year ago

Operating System

Windows 11

Arduino IDE version

2.1.0

Board

ItsyBitsy NRF52840 Express

ArduinoCore version

1.3.0

TinyUSB Library version

release

Sketch as ATTACHED TXT

This is just a modified version of the MIDI test sketch, which prints received CC commands to the serial monitor

MIDI command order bug test.txt

Compiled Log as ATTACHED TXT

No log

What happened ?

I'm using an ItsyBitsy52840 as a MIDI device, with the MIDI.h library. Occasionally, when the MIDI host sends two MIDI messages (one immediately after the other), the ItsyBitsy receives them in the wrong order. I use a Web MIDI page to send CC commands to my device, and the order in which the commands are received is important.

I was previously using an ItsyBitsy 32u4 with the Arduino USB stack and the MIDIUSB library, and never had this issue, so I'm confident that the host is sending them in the correct order. Also, if I'm connected to the host by BLE instead, the commands are always received in the right order, which leads me to believe that this has something to do with TinyUSB. However, I have no idea how to start tracking this down :). Thanks for your help!

How to reproduce ?

Upload the provided sketch.

Send 2 CC messages from a MIDI host in immediate succession. The received messages will be printed to the Serial Monitor.

To do this, you can go to this web page: https://warbl.xyz/privateSettings.html You may have to click the button that says "Connect to WARBL" first. Upon connection, there will be a number of CC messages sent. Clear these from the Serial Monitor, and then click any one of the toggle switches on the page. Each toggle switch will send a CC 104 message and then a CC 105 message.

Frequently, the ItsyBitsy will receive the messages in the wrong order (with the above page, the CC105 will be received first).

Debug Log

No response

Screenshots

No response

amowry commented 1 year ago

I believe that this possibly may have been a result of bug #314, which I just posted.

amowry commented 1 year ago

I verified that this wasn't caused by the MIDI thru feature that I mentioned in #314, so I'm reopening this. I don't know for sure if this is a TinyUSB or MIDI.h issue, but it seems like TinyUSB is more likely.

amowry commented 1 year ago

I believe my JavaScript was occasionally sending the commands in the wrong order.