FortySevenEffects/arduino_midi_library

Incoming message filtering

SandroGrassia opened this issue · 4 comments

Hi, I'd like to avoid unwanted MIDI messages to be read by my application, I'd like to get rid of them immediately after received; is it possilble?
Thank you!

I'm not sure what you mean, but if you use callbacks, you can "subscribe" only to the message types you're interested in, and not worry about the others.

Hi franky47; I got that using callbacks I can filter "types" of messages that i don't need; in my case, I need to go a bit deeper, I would receive only these Control Change controllers
1 (Modulation), 7 (Main Volume), 10 (PAN), range 102-120

and filter all the other Control Change messages.

In your handleControlChange callback, you can test the control number and act on it:

void handleControlChange(midi::Channel channel, byte control, byte value)
{
    if (control == midi::ModulationWheel)
    {
        // ...
    } 
    else if (control == midi::ChannelVolume)
    {
        // ...
    }
    else if (control >= 102 && control <= 120)
    {
        // ...
    }
    // Otherwise ignore it.
}

ok, it works perfectly :)
Thank you!