Issue with USB MIDI failing over time when using usbMIDI.sendRealTime

Are you doing all the USB transmit (both MIDI and Serial) from the same interrupt? That's what the code in msg #1 does. It's what I've been using to test.

If you're doing a mix of transmitting from interrupts and main program, there's very likely other issues you're triggering. The USB code has never really been very safe to use from both interrupts and main program, or from interrupts at different priority levels.

I know you're in the middle of a huge project, where making small test programs it extra work. But if you can craft another small program like the code of msg #1 which reproduces the problem, I will try to dig into the issue. I can't promise any specific time frame, and at this moment I'm focusing on merging fixes in prep for a 1.43 release. I do track issues with reproducible code, so they're not forgotten... even if it takes me a while to investigate & fix.
 
Hi Paul, sorry we've been distracted with a hardware production issue but I wanted to let you know we are still thinking about this.

We've primarily been testing with the test code from msg #1 since we removed all of the serial writes from our codebase so can't replicate the issue reliably with it.

Regarding transmitting on common interrupts, most serial prints were happening for debug purposes, which could be anywhere in the code. We decided to remove the feature that used serial prints which was transmitting from the same interrupt as the MIDI code. We'll revisit that later. It was a stream of values used to graph waveforms. Not essential.
 
Please give 1.43-beta3 a try, when you can do more testing.

A bug was reported involving USB buffers with serial, which turned out to be related to compiler optimization. Still unknown why it only happens with -O2, but I put a workaround into the USB code to always use -O3 on that file to avoid the bug.

Unknown if that will make any difference on this problem, but it's worth trying since it definitely does fix a different USB issue.
 
Apologies for bumping a thread from 2018, but I suspect i am experiencing a similar problem. Was a solution ever found? Right now I have fixed a crash that was happening very quickly during runtime. I sispected it was MIDI and found this to fix the issue:

Code:
  //usbMIDI.read();                                                       // CRASH!!!! 
  while (usbMIDI.read()) {};                                              // fix: https://forum.pjrc.com/threads/28282-How-big-is-the-MIDI-receive-buffer

this only became apparent yesterday after tidying all my memory declarations into .h files. (i code by the seat of my pants, now im tidying!)

My issue is a slowdown and stuttering when sending lots of midi messages (16 channel sequencer) - it usually involves CC messages, but could be triggered when engaging new channels, or even new notes in a drum sequence... once those notes have been sent though it seems to settle back down. This thread so far is the closest I have found to descibing my issue.

I appreciate using the while() loop for usbMIDI.read() is clearing the buffer, is there a similar method available to be sure the send buffer is clear too?
 
Back
Top