a god damn doozy

This commit is contained in:
pszsh 2026-03-07 10:42:15 -08:00
parent a8d3b6177f
commit 3927d073e9
8 changed files with 191 additions and 6 deletions

View File

@ -26,6 +26,32 @@ int main() {
}
```
## Build
cs-midi is a static library meant to be included in a pico-sdk project:
```cmake
add_subdirectory(lib/cs-midi)
target_link_libraries(your_target cs_midi)
```
CMake options (set before `add_subdirectory()`):
| Option | Default | Description |
|--------|---------|-------------|
| `CS_MIDI_BLE` | ON | BLE MIDI via BTstack |
| `CS_MIDI_USB` | OFF | USB MIDI via TinyUSB |
| `CS_MIDI_SERIAL` | OFF | Serial MIDI over UART |
| `CS_MIDI_APPLEMIDI` | OFF | AppleMIDI (RTP-MIDI over WiFi) |
USB MIDI requires `tusb_config.h` and `usb_descriptors.c` in your project — see `templates/` for reference files.
To compile-verify all examples standalone:
```sh
cd lib/cs-midi && make tests
```
## Differences from Control Surface
- `#include <cs_midi.h>` replaces `#include <Control_Surface.h>`

View File

@ -85,7 +85,10 @@ These classes are available in cs-midi and work identically to their Control Sur
| Class | Template | Description |
|-------|----------|-------------|
| `BluetoothMIDI_Interface` | | BLE MIDI interface |
| `BluetoothMIDI_Interface` | | BLE MIDI via BTstack |
| `USBMIDI_Interface` | | USB MIDI device via TinyUSB |
| `HardwareSerialMIDI_Interface` | | 5-pin DIN MIDI over UART |
| `AppleMIDI_Interface` | | RTP-MIDI over WiFi (AppleMIDI/Bonjour) |
### MIDI Routing
@ -201,7 +204,6 @@ Full Mackie Control protocol support — VU meters, V-Pots, LCD, time display, e
| Class | Description |
|-------|-------------|
| `USBMIDI_Interface` | USB MIDI device interface |
| `USBHostMIDI_Interface` | USB Host MIDI interface |
| `GenericUSBMIDI_Interface` | Configurable USB MIDI backend |
| `USBDebugMIDI_Interface` | Serial monitor debug output |
@ -210,7 +212,6 @@ Full Mackie Control protocol support — VU meters, V-Pots, LCD, time display, e
| Class | Description |
|-------|-------------|
| `HardwareSerialMIDI_Interface` | 5-pin DIN MIDI over UART |
| `SoftwareSerialMIDI_Interface` | Software serial MIDI |
| `HairlessMIDI_Interface` | Hairless MIDI serial bridge |

View File

@ -0,0 +1,26 @@
# USB MIDI
USB MIDI device interface via TinyUSB.
Requires `tusb_config.h` and `usb_descriptors.c` in the project — see `lib/cs-midi/templates/` for reference files. Link `tinyusb_device` and `tinyusb_board` in CMake.
```cpp
#include "pico/stdlib.h"
#include "tusb.h"
#include <cs_midi.h>
using namespace cs;
USBMIDI_Interface midi;
NoteButton button {5, {MIDI_Notes::C[4], Channel_1}};
int main() {
stdio_init_all();
tusb_init();
Control_Surface.begin();
while (true) {
Control_Surface.loop();
}
}
```

View File

@ -0,0 +1,25 @@
# Serial MIDI
Classic 5-pin DIN MIDI over hardware UART at 31250 baud.
Constructor: `HardwareSerialMIDI_Interface(uart_inst_t *uart, uint tx_pin, uint rx_pin)`
```cpp
#include "pico/stdlib.h"
#include <cs_midi.h>
using namespace cs;
HardwareSerialMIDI_Interface midi {uart0, 12, 13};
CCRotaryEncoder enc {{0, 2}, {16, Channel_1}, 1, 4};
int main() {
stdio_init_all();
Control_Surface.begin();
while (true) {
Control_Surface.loop();
sleep_ms(1);
}
}
```

View File

@ -0,0 +1,34 @@
# Dual MIDI (BLE + USB)
Multiple MIDI interfaces with pipe routing. Elements send to both transports simultaneously.
```cpp
#include "pico/stdlib.h"
#include "pico/cyw43_arch.h"
#include "tusb.h"
#include <cs_midi.h>
using namespace cs;
BluetoothMIDI_Interface ble;
USBMIDI_Interface usb;
MIDI_PipeFactory<2> pipes;
NoteButton button {5, {MIDI_Notes::C[4], Channel_1}};
CCRotaryEncoder enc {{0, 2}, {16, Channel_1}, 1, 4};
int main() {
stdio_init_all();
if (cyw43_arch_init()) return 1;
tusb_init();
Control_Surface >> pipes >> ble;
Control_Surface >> pipes >> usb;
Control_Surface.begin();
while (true) {
Control_Surface.loop();
}
}
```

View File

@ -0,0 +1,33 @@
# AppleMIDI (RTP-MIDI over WiFi)
RTP-MIDI over WiFi — appears as a Bonjour MIDI device in macOS Audio MIDI Setup,
Windows rtpMIDI, and iOS. Requires WiFi connection before `Control_Surface.begin()`.
Build with `CS_MIDI_APPLEMIDI=ON`.
```cpp
#include "pico/stdlib.h"
#include "pico/cyw43_arch.h"
#include <cs_midi.h>
using namespace cs;
AppleMIDI_Interface midi {"PicoW-MIDI", 5004};
NoteButton button {5, {MIDI_Notes::C[4], Channel_1}};
CCRotaryEncoder enc {{0, 2}, {16, Channel_1}, 1, 4};
int main() {
stdio_init_all();
if (cyw43_arch_init()) return 1;
cyw43_arch_enable_sta_mode();
cyw43_arch_wifi_connect_blocking("SSID", "PASS", CYW43_AUTH_WPA2_AES_PSK);
Control_Surface.begin();
while (true) {
Control_Surface.loop();
sleep_ms(1);
}
}
```

View File

@ -0,0 +1,39 @@
# Dual Transport (BLE + AppleMIDI)
BLE for direct iOS/macOS connection, AppleMIDI for DAW integration over WiFi.
Elements send to both transports simultaneously via pipe routing.
Build with `CS_MIDI_BLE=ON CS_MIDI_APPLEMIDI=ON`.
```cpp
#include "pico/stdlib.h"
#include "pico/cyw43_arch.h"
#include <cs_midi.h>
using namespace cs;
BluetoothMIDI_Interface ble;
AppleMIDI_Interface applemidi {"PicoW-MIDI", 5004};
MIDI_PipeFactory<2> pipes;
NoteButton button {5, {MIDI_Notes::C[4], Channel_1}};
CCRotaryEncoder enc {{0, 2}, {16, Channel_1}, 1, 4};
int main() {
stdio_init_all();
if (cyw43_arch_init()) return 1;
cyw43_arch_enable_sta_mode();
cyw43_arch_wifi_connect_blocking("SSID", "PASS", CYW43_AUTH_WPA2_AES_PSK);
Control_Surface >> pipes >> ble;
Control_Surface >> pipes >> applemidi;
Control_Surface.begin();
while (true) {
Control_Surface.loop();
sleep_ms(1);
}
}
```

View File

@ -44,6 +44,9 @@ Extraction status of [tttapa/Control-Surface](https://github.com/tttapa/Control-
### MIDI Interfaces
- [x] `BluetoothMIDI_Interface` — BLE MIDI via BTstack (pico-native)
- [x] `USBMIDI_Interface` — USB MIDI device via TinyUSB
- [x] `HardwareSerialMIDI_Interface` — 5-pin DIN MIDI over UART (31250 baud)
- [x] `AppleMIDI_Interface` — RTP-MIDI over WiFi with mDNS/Bonjour discovery
- [x] `MIDI_Pipe` / `MIDI_PipeFactory<N>` / `BidirectionalMIDI_PipeFactory<N>`
- [x] `Control_Surface` singleton — declarative begin/loop lifecycle
@ -66,8 +69,6 @@ Extraction status of [tttapa/Control-Surface](https://github.com/tttapa/Control-
output-side examples.*
### Additional MIDI Interfaces
- [ ] USB MIDI Interface (TinyUSB)
- [ ] Serial/Hardware MIDI Interface
- [ ] Debug MIDI Interface (serial monitor output)
### Display Elements
@ -84,4 +85,4 @@ output-side examples.*
### Advanced Features
- [ ] MIDI input fine-grained callbacks (per-message-type)
- [ ] SysEx send/receive helpers
- [ ] AppleMIDI (RTP-MIDI over WiFi)
- [x] AppleMIDI (RTP-MIDI over WiFi)