MIDI_Pipes-Filter
Filtering and modifying MIDI messages that travel through a MIDI_Pipe.
This example demonstrates how to create custom MIDI pipes that can filter out and modify the messages that travel through it. It uses a debug MIDI interface for demonstration purposes, and loops back only MIDI note and real-time messages, messages of any other type are dropped. Additionally, all MIDI note messages are transposed down an octave, and their channel is set to 5.
To try it out, open the Serial monitor (at 115200 baud) and type 98 3C 7F
(Note On, channel 9, C4, full velocity). When you press enter, you'll get back the following message (note how the channel and pitch changed):
Note On
Channel: 5 Data 1: 0x30 Data 2: 0x7F
A type-safe class for MIDI channels.
If you try to send a Pitch Bend message (for example, E0 12 34
), you'll get no response, because the code filtered it out.
- Boards: 🛈
- AVR, AVR USB, Nano Every, Due, Nano 33 IoT, Nano 33 BLE, UNO R4, Pi Pico, ESP32, Teensy 3.x
break;
default: break;
}
}
}
};
MyMIDIFilter filter;
void setup() {
midi >> filter >> midi;
}
void loop() {
midi.update();
}
constexpr Channel Channel_5
The main header file that includes all Control-Surface header files.
@ NoteOn
Note On Channel Voice message (3B).
@ NoteOff
Note Off Channel Voice message (3B).
Class that routes MIDI messages from a MIDI_Source to a MIDI_Sink.
void sourceMIDItoSink(Message msg)
Send the given MIDI message to the sink of this pipe.
virtual void mapForwardMIDI(ChannelMessage msg)
Function that maps, edits or filters MIDI messages, and then forwards them to the sink of the pipe.
void begin() override
Start the Serial interface at the predefined baud rate.
A class for debug MIDI interfaces sending and receiving human-readable MIDI messages over the USB CDC...
void setChannel(Channel channel)
Set the MIDI channel of the message.
MIDIMessageType getMessageType() const
Get the MIDI message type.
uint8_t data1
First MIDI data byte.