Control Surface master
MIDI Control Surface library for Arduino
Send-All-MIDI-Messages.ino

Send-All-MIDI-Messages

Example showing how to send any MIDI message.

Boards:
AVR, AVR USB, Nano Every, Due, Nano 33 IoT, Nano 33 BLE, Teensy 3.x, ESP32

See the MIDI_Sender documentation for a full overview of all MIDI sending functions and their arguments.

Expected output

Note Off Channel: 6 Data 1: 0x3c Data 2: 0x7f
Note On Channel: 6 Data 1: 0x3c Data 2: 0x7f
Key Pressure Channel: 6 Data 1: 0x3c Data 2: 0x40
Control Change Channel: 2 Data 1: 0x07 Data 2: 0x78
Program Change Channel: 9 Data 1: 0x06
Channel Pressure Channel: 3 Data 1: 0x40
Pitch Bend Channel: 3 Data 1: 0x7f Data 2: 0x7f (16383)
System Common MTC_QUARTER_FRAME Data 1: 0x2f
System Common SONG_POSITION_POINTER Data 1: 0x10 Data 2: 0x4e (10000)
System Common SONG_SELECT Data 1: 0x46
System Common TUNE_REQUEST
System Exclusive [10] F0 00 01 02 03 04 05 06 07 F7
System Exclusive [6+] F0 10 11 12 13 14
System Exclusive [6+] 15 16 17 18 19 1A
System Exclusive [6] 1B 1C 1D 1E 1F F7
Real-Time TIMING_CLOCK
Real-Time START
Real-Time CONTINUE
Real-Time STOP
Real-Time ACTIVE_SENSING
Real-Time SYSTEM_RESET
See also
MIDI Tutorial: Sending MIDI messages

Written by PieterP, 2021-06-28
https://github.com/tttapa/Control-Surface

void setup() {
midi.begin();
while (!Serial)
;
{ // Channel voice messages
uint8_t velocity = 127;
midi.sendNoteOff(note, velocity);
midi.sendNoteOn(note, velocity);
uint8_t pressure = 64;
midi.sendKeyPressure(note, pressure);
uint8_t value = 120;
midi.sendControlChange(controller, value);
midi.sendProgramChange(program);
Channel channel = CHANNEL_3;
midi.sendChannelPressure(channel, pressure);
uint16_t bend = 16383;
midi.sendPitchBend(channel, bend);
}
{ // System common messages
uint8_t messageType = 2;
uint8_t value = 15;
midi.sendMTCQuarterFrame(messageType, value);
uint16_t spp = 10000;
uint8_t song = 70;
midi.sendSongSelect(song);
}
{ // System exclusive messages
uint8_t sysex[] = {0xF0, 0x00, 0x01, 0x02, 0x03,
0x04, 0x5, 0x06, 0x07, 0xF7};
midi.sendSysEx(sysex);
uint8_t chunk1[] = {0xF0, 0x10, 0x11, 0x12, 0x13, 0x14};
uint8_t chunk2[] = {0x15, 0x16, 0x17, 0x18, 0x19, 0x1A};
uint8_t chunk3[] = {0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0xF7};
midi.sendSysEx(chunk1);
midi.sendSysEx(chunk2);
midi.sendSysEx(chunk3);
}
{ // Real-time messages
midi.sendStart();
midi.sendContinue();
midi.sendStop();
}
}
void loop() {
midi.update(); // discard incoming messages
}
constexpr Channel CHANNEL_2
Definition: Channel.hpp:119
constexpr Channel CHANNEL_6
Definition: Channel.hpp:123
constexpr Channel CHANNEL_9
Definition: Channel.hpp:126
constexpr Channel CHANNEL_3
Definition: Channel.hpp:120
The main header file that includes all Control-Surface header files.
A type-safe class for MIDI channels.
Definition: Channel.hpp:13
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
void sendSysEx(const uint8_t(&sysexdata)[N], Cable cable=CABLE_1)
Send a MIDI System Exclusive message.
void sendChannelPressure(MIDIChannelCable address, uint8_t pressure)
Send a MIDI Channel Pressure event.
Definition: MIDI_Sender.ipp:89
void sendStart(Cable cable=CABLE_1)
Send a MIDI Start message.
void sendMTCQuarterFrame(uint8_t data, Cable cable=CABLE_1)
Send a MIDI Time Code Quarter Frame.
void sendProgramChange(MIDIAddress address)
Send a MIDI Program Change event.
Definition: MIDI_Sender.ipp:78
void sendSystemReset(Cable cable=CABLE_1)
Send a MIDI System Reset message.
void sendActiveSensing(Cable cable=CABLE_1)
Send a MIDI Active Sensing message.
void sendStop(Cable cable=CABLE_1)
Send a MIDI Stop message.
void sendKeyPressure(MIDIAddress address, uint8_t pressure)
Send a MIDI Key Pressure event.
Definition: MIDI_Sender.ipp:42
void sendControlChange(MIDIAddress address, uint8_t value)
Send a MIDI Control Change event.
Definition: MIDI_Sender.ipp:54
void sendSongPositionPointer(uint16_t spp, Cable cable=CABLE_1)
Send a MIDI Song Position Pointer message.
void sendSongSelect(uint8_t song, Cable cable=CABLE_1)
Send a MIDI Song Select message.
void sendNoteOn(MIDIAddress address, uint8_t velocity)
Send a MIDI Note On event.
Definition: MIDI_Sender.ipp:20
void sendNoteOff(MIDIAddress address, uint8_t velocity)
Send a MIDI Note Off event.
Definition: MIDI_Sender.ipp:31
void sendTuneRequest(Cable cable=CABLE_1)
Send a MIDI Tune Request.
void sendTimingClock(Cable cable=CABLE_1)
Send a MIDI Timing Clock message.
void sendPitchBend(MIDIChannelCable address, uint16_t value)
Send a MIDI Pitch Bend event.
void sendContinue(Cable cable=CABLE_1)
Send a MIDI Continue message.
void begin() override
Start the Serial interface at the predefined baud rate.
void update() override
Read the MIDI interface and call the callback if a message was received.
A class for debug MIDI interfaces sending and receiving human-readable MIDI messages over the USB CDC...
constexpr uint8_t Channel_Volume
constexpr int8_t note(Note note, int8_t numOctave)
Get the MIDI note in the given octave.
Definition: Notes.hpp:56
constexpr Note C
C (Do)
Definition: Notes.hpp:40
constexpr uint8_t Harpsichord