Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

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

  1. #1
    Junior Member
    Join Date
    Feb 2019
    Posts
    10

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

    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".

  2. #2
    Member
    Join Date
    Jun 2015
    Location
    Palm Springs, CA
    Posts
    27
    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.

  3. #3
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,068
    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

  4. #4
    Junior Member
    Join Date
    Feb 2019
    Posts
    10
    Quote Originally Posted by el_supremo View Post
    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •