63 lines
1.9 KiB
Markdown
63 lines
1.9 KiB
Markdown
# Banks and Selectors
|
||
|
||
> Original: [Bank support](https://tttapa.github.io/Control-Surface/Doxygen/db/dbd/classBank.html)
|
||
|
||
Banks allow a single physical control to address multiple MIDI parameters by switching the active bank.
|
||
|
||
## How banks work
|
||
|
||
`Bank<N>` manages N settings. Bankable elements compute their effective address as:
|
||
|
||
effective_address = base_address + (bank_setting × offset)
|
||
|
||
The offset is set when constructing the bank, and the base address is set per-element.
|
||
|
||
```cpp pico
|
||
Bank<4> bank(2); // 4 settings, offset 2 between each
|
||
```
|
||
|
||
With base address 16, the four banks produce addresses 16, 18, 20, 22.
|
||
|
||
## Bank types
|
||
|
||
- `BankType::ChangeAddress` — shifts the CC/note number
|
||
- `BankType::ChangeChannel` — shifts the MIDI channel
|
||
|
||
## Selectors
|
||
|
||
Selectors control which bank setting is active:
|
||
|
||
| Class | Description |
|
||
|-------|-------------|
|
||
| `EncoderSelector<N>` | Rotary encoder cycles banks |
|
||
| `IncrementDecrementSelector<N>` | Two buttons: up/down |
|
||
| `IncrementSelector<N>` | Single button, wraps around |
|
||
| `ManyButtonsSelector<N>` | One button per bank |
|
||
| `SwitchSelector` | Two-position toggle |
|
||
| `ProgramChangeSelector<N>` | Incoming MIDI PC selects bank |
|
||
|
||
```cpp pico
|
||
IncrementDecrementSelector<4> selector {bank, {2, 3}, Wrap::Wrap};
|
||
```
|
||
|
||
## Transposer
|
||
|
||
`Transposer<Min, Max>` is a specialized bank that offsets note numbers:
|
||
|
||
```cpp pico
|
||
Transposer<-12, 12> transposer;
|
||
IncrementDecrementSelector<25> transposeSelect {transposer, {2, 3}, Wrap::Clamp};
|
||
```
|
||
|
||
## Bankable input elements
|
||
|
||
All input elements (`CCValue`, `NoteLED`, etc.) have bankable variants:
|
||
|
||
```cpp pico
|
||
Bankable::CCValue<4> cc {{bank, BankType::ChangeAddress}, {16, Channel_1}};
|
||
```
|
||
|
||
## Bankable output elements
|
||
|
||
Bankable output elements (`Bankable::NoteButton`, `Bankable::CCPotentiometer`, etc.) are not yet implemented (Phase 11). Bank switching currently works with input elements and selectors only.
|