I'm using the well-known USBMIDI library on a Leonardo-based board.
My code is pretty simple and very similar to the examples. It works fine on a test environment, but when I use it with common music applications like Cubase or Kontact leads to weird behaviors.
I've already opened an issue on github but it hasn't received any answer yet.
I try to ask an advice also here. Perhaps someone has already faced the same problem.
Here the relevant code of my firmware:
Are you sure you know which part of your code is relevant for the problem?
Given the posted code contains the relevant parts, you flood the consuming program with changes which mostly aren't changes. Save the sent value and resend it only if it actually changed.
Are you sure you know which part of your code is relevant for the problem?
The handling of the display or the manipulations of the ADC value should not matter. I tried to report all the code about the MIDI stuff.
you flood the consuming program with changes which mostly aren't changes. Save the sent value and resend it only if it actually changed.
I already do this, at least if I understand correctly what you're saying. This line:
if (sliders[idx].shadow != sliders[idx].value)
compare the current value with the previous one (shadow). It sends the message only if they differ.
Anyway, I have an update after spending the whole day to try it.
The issue is not related to those softwares only, but happens in any case. I tried different monitors to show the actual MIDI packets and after some time (seconds or minutes) no messages are received anymore.
From the Arduino side I noticed the channel is no more writable, i.e. USB_Available(MIDI_TX); returns 0. And this may happen in few seconds or in several minutes, regardless how many packets I sent. The USB device is still there, it's like the "communication channel" will be closed but I cannot understand why and by who.
Furthermore, the issue does not happen in either Linux or Mac, it seems only a Windows problem (tried on 3 different machines).