Skip to content

stuffmatic/zephyr-usb-midi

Repository files navigation

zephyr-usb-midi

This is a USB MIDI 1.0 device class driver for the Zephyr RTOS, which allows sending and receiving MIDI data (including system exclusive messages) over USB.

The current implementation, which uses Zephyr's soon-to-be legacy USB stack, is usable but should be considered work in progress and needs more testing before it's ready for real world use. If you run into any issues, please consider reporting them or submitting a PR.

Usage

The USB MIDI device class driver is contained in a Zephyr module. The sample app's CMakeLists.txt file shows one way of adding this module to an app.

The public API is defined in usb_midi.h.

Sample app

The sample app shows how to send and receive MIDI data. Note on/off messages are sent periodically when connected to a host. The app should work on dev boards with at least one button and three LEDs, for example stm32f4_disco and nrf52840dk_nrf52840.

  • Button 1 - Send sysex message
  • LED 1 - On when the device is connected to a host
  • LED 2 - Flashes when MIDI data is received
  • LED 3 - Flashes when MIDI data is sent
zephyr_usb_midi_sample.mp4

Configuration options

  • CONFIG_USB_DEVICE_MIDI- Set to y to enable the USB MIDI device class driver.
  • CONFIG_USB_MIDI_NUM_INPUTS - The number of jacks through which MIDI data flows into the device. Between 0 and 16 (inclusive). Defaults to 1.
  • CONFIG_USB_MIDI_NUM_OUTPUTS - The number of jacks through which MIDI data flows out of the device. Between 0 and 16 (inclusive). Defaults to 1.
  • CONFIG_USB_MIDI_USE_CUSTOM_JACK_NAMES - Set to y to use custom input and output jack names defined by the options below.
  • CONFIG_USB_MIDI_INPUT_JACK_n_NAME - the name of input jack n, where n is the cable number of the jack.
  • CONFIG_USB_MIDI_OUTPUT_JACK_n_NAME - the name of output jack n, where n is the cable number of the jack.