buttons sending MIDI ON 127 and MIDI OFF 127

I’ve built a pedalboard to trigger drum one shot samples to play beats with my feet.

I’m having problems with the buttons triggering when I don’t want them to.

When I’m playing beats, my foot rests on the button until I’m ready to click the next beat. Sometimes the button will trigger when my foot is rested on it.

When I view the midi information with MIDI MONITOR … I’m noticing that a press down gives NOTE ON 127. When I release it, it’s NOTE OFF 127.

All my other midi machines, when giving a NOTE OFF message, the NOTE OFF is 0. Not 127.

Can someone take a look at my code and help me figure out how to change the NOTE OFF message from NOTE OFF 127 to NOTE OFF 0?

ANY help is appreciated.

#include <MIDI_Controller.h> // Include the library
#include <PitchToNote.h>

const uint8_t channel  = 1; // MIDI channel 1
const uint8_t velocity = 0b1111111; // Maximum velocity (0b1111111 = 0x7F = 127)

// Create an array of four new instances of the class 'Digital', called 'buttons'
Digital buttons[] = {
    {2, pitchC2,  channel, velocity}, // Create a new instance of class 'Digital' with a button connected to pin 2, 
                                      // that sends note C2 events on MIDI channel 1, with maximum velocity.
    {3, pitchD2b, channel, velocity},
    {4, pitchD2,  channel, velocity},
    {5, pitchE2,  channel, velocity},
    {6, pitchG2,  channel, velocity},
    {7, pitchF2,  channel, velocity},
};

void setup() {}  // Nothing to set up

void loop() {
  // Refresh the buttons (check whether a button's state has changed since last time, if so, send it over MIDI)
  MIDI_Controller.refresh();
}

None of your code is doing that, the library is. But it shouldn't make any difference. I assume the Note Off also contains a note number and the 127 is the velocity. Velocity is always ignored on Note Off messages.

It really sounds like you need to try a few different physical footswitches to find one that isn't so sensitive to things "resting" on it.

Steve

NOTE_ON 0 is equivalent to NOTE_OFF. It doesn't matter which one you use*.
NOTE_OFF 0 is undefined. Most of the programs and hardware I've tried just ignore the note off event if the velocity is zero. Edit: I was wrong, see below.

(*) The interpretation is the same in most cases, and the amount of data transmitted over USB is the same as well. If you are using running status on a serial link, using NOTE_ON 0 instead of NOTE_OFF might save some bytes.

As slipstick mentioned, the problem is in the hardware, not the software. The software (any program, not just this library) can never know whether you intentionally pressed the button, or by accident.

If you find that a button registers multiple times over a short period of time, when you only pressed it once, you can increase the debounce time.

Pieter, author of the MIDI Controller library

PieterP:
NOTE_OFF 0 is undefined. Most of the programs and hardware I've tried just ignore the note off event if the velocity is zero.

That's interesting. Do you have any details of what programs and hardware reacts that way? I've tried quite a few DAWs and MIDI synths/sound modules and they all simply ignore velocity on Note Off events. Most MIDI keyboards will actually send Note Off with velocity 0 and I think I'd have noticed if they were being ignored.

Steve

slipstick:
That's interesting. Do you have any details of what programs and hardware reacts that way? I've tried quite a few DAWs and MIDI synths/sound modules and they all simply ignore velocity on Note Off events. Most MIDI keyboards will actually send Note Off with velocity 0 and I think I'd have noticed if they were being ignored.

Steve

I'll have to check then.
I remember noticing it when I had a bug where the NOTE_OFF velocity was always zero, and all notes kept playing. Maybe there was another bug as well, and I was incorrect in blaming the velocity?

Edit: you're right, they correctly register as note off events, even when the velocity is zero. Something else must have been wrong at the same time and I drew the wrong conclusion.

I wasn't receiving alerts to this topic. Apologies for late replies.

I was suspecting that hardware might be the issue.

I'm using standard SPST foot switches and quite possibly they just aren't meant to function as I'm using them.

I have ordered some different foot switches to see if it helps. But, I may have to ditch this idea for a better plan.

PieterP:
NOTE_ON 0 is equivalent to NOTE_OFF. It doesn't matter which one you use*.
NOTE_OFF 0 is undefined. Most of the programs and hardware I've tried just ignore the note off event if the velocity is zero. Edit: I was wrong, see below.

(*) The interpretation is the same in most cases, and the amount of data transmitted over USB is the same as well. If you are using running status on a serial link, using NOTE_ON 0 instead of NOTE_OFF might save some bytes.

As slipstick mentioned, the problem is in the hardware, not the software. The software (any program, not just this library) can never know whether you intentionally pressed the button, or by accident.

If you find that a button registers multiple times over a short period of time, when you only pressed it once, you can increase the debounce time.

Pieter, author of the MIDI Controller library

So I did try the DeBounce changes.

I found that from the moment I raised my foot OFF the button to when I needed to re-trigger it to press it down was very short and the debounce time was seemingly starting when I released the button...not just when I pressed it down.

So, let's say I pressed it down and held it there (as one would do when playing a kick drum), the debounce time would expire..which is fine.
When I pickup up my foot to press it down again to trigger another beat/sample/kick drum, sometimes during a fast song, the debounce time started over as soon as I lifted my foot and the next trigger wouldn't happen because the debounce time hadn't expired yet.

At any rate ... I think the issue is the hardware.

The contacts must be at the bottom of the shaft of the button and when its pressed down and held, it's liable to re-trigger with the smallest amount of movement.