1.3 KiB
1.3 KiB
First Input
Original: Getting Started — First Input
A minimal sketch that receives MIDI and drives outputs (LEDs).
MIDI input elements
Input elements listen for specific MIDI messages and update their state. NoteLED drives a GPIO pin high when its note is active:
NoteLED led {25, {MIDI_Notes::C[4], Channel_1}};
An array of LEDs responding to consecutive notes:
NoteLED leds[] {
{16, MIDI_Notes::C[4]},
{17, MIDI_Notes::D[4]},
{18, MIDI_Notes::E[4]},
{19, MIDI_Notes::F[4]},
};
Value readers store the incoming value without driving hardware:
CCValue ccVal {{MIDI_CC::Channel_Volume, Channel_1}};
Access the current value with ccVal.getValue().
Complete example
#include "pico/stdlib.h"
#include "pico/cyw43_arch.h"
#include <cs_midi.h>
using namespace cs;
BluetoothMIDI_Interface midi;
NoteLED led {25, {MIDI_Notes::C[4], Channel_1}};
CCValue volume {{MIDI_CC::Channel_Volume, Channel_1}};
int main() {
stdio_init_all();
if (cyw43_arch_init()) return 1;
Control_Surface.begin();
while (true) {
Control_Surface.loop();
uint8_t v = volume.getValue();
(void)v;
sleep_ms(1);
}
}