Search code examples
linuxterminalarduinomidialsa

Get MIDI note from USB interface on Arduino Yun


I am using an Arduino Yun and a MIDI to USB interface and my goal is to read the incoming MIDI note on the installed Linux operating system.

The goal is to have the computer on the Yun read the note and send it to the Arduino which then transmits a square wave over the pins at the note played on the piano.

But I can't figure out how to read from the USB interface; the Linux system is command line only and I can't figure out a good way to read the incoming note.


Solution

  • There is nothing special about USB; the USB MIDI driver makes the interface show up as a normal MIDI port, which can be accessed like any other MIDI port.

    If you want to write a shell script, the easiest way is probably to parse the output of aseqdump. See Translating MIDI input into computer keystrokes on Linux? for an example.

    If you want to write a C program, you have to use the ALSA sequencer API; consider using the aseqdump source code as a template.

    If you just want to send the raw MIDI bytes over the serial line, you can simply read them from /dev/snd/midiC?D?.