60 lines
1.4 KiB
Markdown
60 lines
1.4 KiB
Markdown
# Send All MIDI Messages
|
|
|
|
Demonstrates every MIDI message type: channel voice, system common, system exclusive, and real-time.
|
|
|
|
> Original: `Send-All-MIDI-Messages.ino`
|
|
|
|
```cpp pico
|
|
#include "pico/stdlib.h"
|
|
#include "pico/cyw43_arch.h"
|
|
#include <cs_midi.h>
|
|
|
|
using namespace cs;
|
|
|
|
BluetoothMIDI_Interface midi;
|
|
|
|
int main() {
|
|
stdio_init_all();
|
|
if (cyw43_arch_init()) return 1;
|
|
midi.begin();
|
|
|
|
// Channel voice messages
|
|
MIDIAddress note = {MIDI_Notes::C[4], Channel_6};
|
|
midi.sendNoteOn(note, 127);
|
|
midi.sendNoteOff(note, 127);
|
|
midi.sendKeyPressure(note, 64);
|
|
|
|
MIDIAddress controller = {MIDI_CC::Channel_Volume, Channel_2};
|
|
midi.sendControlChange(controller, 120);
|
|
|
|
MIDIAddress program = {MIDI_PC::Harpsichord, Channel_9};
|
|
midi.sendProgramChange(program);
|
|
|
|
midi.sendChannelPressure(Channel_3, 64);
|
|
midi.sendPitchBend(Channel_3, 16383);
|
|
|
|
// System common messages
|
|
midi.sendMTCQuarterFrame(2, 15);
|
|
midi.sendSongPositionPointer(10000);
|
|
midi.sendSongSelect(70);
|
|
midi.sendTuneRequest();
|
|
|
|
// System exclusive
|
|
uint8_t sysex[] = {0xF0, 0x00, 0x01, 0x02, 0x03, 0xF7};
|
|
midi.sendSysEx(sysex);
|
|
|
|
// Real-time messages
|
|
midi.sendTimingClock();
|
|
midi.sendStart();
|
|
midi.sendContinue();
|
|
midi.sendStop();
|
|
midi.sendActiveSensing();
|
|
midi.sendSystemReset();
|
|
|
|
while (true) {
|
|
midi.update();
|
|
sleep_ms(1);
|
|
}
|
|
}
|
|
```
|