cs-midi-docs/docs/examples/03-interfaces/06-applemidi.md

43 lines
1.3 KiB
Markdown

# 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`.
> **Reliability note:** AppleMIDI is implemented via the vendored
> [lathoub/Arduino-AppleMIDI-Library](https://github.com/lathoub/Arduino-AppleMIDI-Library)
> with a LwIPUDP adapter wrapping the lwIP raw UDP API and mDNS/Bonjour
> service advertisement. The protocol implementation is complete and the
> device does appear in Audio MIDI Setup, but in our testing the session
> would not reliably establish on at least one macOS host. We suspect this
> is device-specific — your mileage may vary. If you have success (or
> failure) on your setup, reports are welcome.
```cpp pico
#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);
}
}
```