61 lines
1.3 KiB
Markdown
61 lines
1.3 KiB
Markdown
# First Input
|
|
|
|
> Original: [Getting Started — First Input](https://tttapa.github.io/Control-Surface/Doxygen/d5/d7d/md_pages_Getting-Started.html)
|
|
|
|
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:
|
|
|
|
```cpp pico
|
|
NoteLED led {25, {MIDI_Notes::C[4], Channel_1}};
|
|
```
|
|
|
|
An array of LEDs responding to consecutive notes:
|
|
|
|
```cpp pico
|
|
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:
|
|
|
|
```cpp pico
|
|
CCValue ccVal {{MIDI_CC::Channel_Volume, Channel_1}};
|
|
```
|
|
|
|
Access the current value with `ccVal.getValue()`.
|
|
|
|
## Complete example
|
|
|
|
```cpp pico
|
|
#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);
|
|
}
|
|
}
|
|
```
|