MIDI All Notes off code takes 2 sec to run can this be fixed?

Status
Not open for further replies.

ValStorm

Member
Code:
for(uint8_t j = 0; j < 16; j++)
  {
    for(uint8_t i = 0; i < 128; i++)
    {
      MIDI.sendNoteOff(i, 0, j);
    }
  }

Takes 2 full seconds to complete. However the same code with usbMidi doing the same thing does not. My guess is something about delays or multiple ports, but I don't know where to find and set these variables.

It was compiled for MIDIx16, though that is unnecessary, I recompiled with just Serial + MIDI and it still takes "forever".
 
That's because MIDI is from the 1980's and it takes about a millisecond to send a note message. Your code sends 2,048 MIDI messages.
 
The MIDI spec >here< has a Control Change message which turns off All Sounds and one which turns off All Notes. The All Notes off message appears to act on individual channels so you'd have to send one for each channel - but that's just 16 messages instead of the 2048 that you're sending now. The All Sound off message might apply to all channels, in which case you can shut up everything with one message.
I've never used either. You'll have to play with them to see if your devices respond to these messages.

Pete
 
The MIDI spec >here< has a Control Change message which turns off All Sounds and one which turns off All Notes. The All Notes off message appears to act on individual channels so you'd have to send one for each channel - but that's just 16 messages instead of the 2048 that you're sending now. The All Sound off message might apply to all channels, in which case you can shut up everything with one message.
I've never used either. You'll have to play with them to see if your devices respond to these messages.

Pete

Totally didn't think about checking MIDI spec for a more appropriate solution. This helps a lot, thanks!
 
Status
Not open for further replies.
Back
Top