56 lines
1.1 KiB
Markdown
56 lines
1.1 KiB
Markdown
# MIDI over USB
|
|
|
|
> Original: [MIDI over USB](https://tttapa.github.io/Control-Surface/Doxygen/d8/d4a/md_pages_MIDI-over-USB.html)
|
|
|
|
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:
|
|
|
|
```cmake pico
|
|
set(CS_MIDI_USB ON)
|
|
```
|
|
|
|
Your project needs two additional files:
|
|
|
|
- `tusb_config.h` — TinyUSB configuration
|
|
- `usb_descriptors.c` — USB device/configuration/string descriptors
|
|
|
|
Reference copies are in `lib/cs-midi/templates/`.
|
|
|
|
## Usage
|
|
|
|
```cpp pico
|
|
#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:
|
|
|
|
```cpp pico
|
|
BluetoothMIDI_Interface ble;
|
|
USBMIDI_Interface usb;
|
|
BidirectionalMIDI_PipeFactory<1> pipes;
|
|
// In main: ble | pipes | usb;
|
|
```
|