cs-midi-docs/docs/manual/04-output-elements/_index.md

72 lines
2.4 KiB
Markdown

# MIDI Output Elements
> Original: [MIDI output elements](https://tttapa.github.io/Control-Surface/Doxygen/d7/dcd/group__MIDIOutputElements.html)
Output elements read physical controls and send MIDI messages. They register with `Control_Surface` on construction and update automatically in the `loop()` cycle.
## Buttons
| Class | Description | Constructor |
|-------|-------------|-------------|
| `NoteButton` | Note On/Off on press/release | `{pin, address}` |
| `CCButton` | CC 127/0 on press/release | `{pin, address}` |
| `PCButton` | Program Change on press | `{pin, address}` |
| `NoteButtonLatched` | Toggle Note each press | `{pin, address}` |
| `NoteButtonLatching` | Note while held, toggles | `{pin, address}` |
| `CCButtonLatched` | Toggle CC each press | `{pin, address}` |
| `CCButtonLatching` | CC while held, toggles | `{pin, address}` |
| `NoteChordButton` | Multiple notes on press | `{pin, address, chord}` |
## Button arrays and matrices
| Class | Description |
|-------|-------------|
| `NoteButtons<N>` | Array of N sequential note buttons |
| `CCButtons<N>` | Array of N sequential CC buttons |
| `NoteButtonMatrix<R,C>` | Row/column scanned note grid |
| `CCButtonMatrix<R,C>` | Row/column scanned CC grid |
## Potentiometers
| Class | Description |
|-------|-------------|
| `CCPotentiometer` | Analog input → CC 0-127 |
| `PBPotentiometer` | Analog input → 14-bit Pitch Bend |
| `CCPotentiometer` with `map()` | Custom mapping to calibrate or apply curves |
```cpp pico
CCPotentiometer pot {26, {MIDI_CC::Channel_Volume, Channel_1}};
pot.map(myMappingFunction);
```
## Encoders
| Class | Description |
|-------|-------------|
| `CCRotaryEncoder` | Relative CC from quadrature encoder |
| `CCAbsoluteEncoder` | Absolute CC position from encoder |
| `PBAbsoluteEncoder` | 14-bit Pitch Bend from encoder |
| `BorrowedCCRotaryEncoder` | Shared encoder reference |
| `CCIncrementDecrementButtons` | Two buttons for CC inc/dec |
```cpp pico
CCRotaryEncoder enc {{0, 1}, {MIDI_CC::Pan, Channel_1}, 1, 4};
```
Constructor: `{pin_pair, address, speed_multiplier, pulses_per_click}`.
## Program changers
| Class | Description |
|-------|-------------|
| `ProgramChanger<N>` | Selectable list of N program changes |
```cpp pico
ProgramChanger<4> pc {{
{MIDI_PC::Harpsichord, Channel_1},
{MIDI_PC::Organ, Channel_1},
{MIDI_PC::Guitar, Channel_1},
{MIDI_PC::Piano, Channel_1},
}};
```