1.1 KiB
1.1 KiB
MIDI over USB
Original: MIDI over USB
USB MIDI uses TinyUSB to present the device as a standard USB MIDI class-compliant device. No drivers needed on macOS, Windows, or Linux.
Setup
Enable in CMake:
set(CS_MIDI_USB ON)
Your project needs two additional files:
tusb_config.h— TinyUSB configurationusb_descriptors.c— USB device/configuration/string descriptors
Reference copies are in lib/cs-midi/templates/.
Usage
#include "pico/stdlib.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();
Control_Surface.begin();
while (true) {
Control_Surface.loop();
sleep_ms(1);
}
}
No cyw43_arch_init() needed for USB-only configurations.
Combining with BLE
Enable both CS_MIDI_BLE and CS_MIDI_USB, then route between them:
BluetoothMIDI_Interface ble;
USBMIDI_Interface usb;
BidirectionalMIDI_PipeFactory<1> pipes;
// In main: ble | pipes | usb;