MIDI over USB - anyone got any experience with this?

I want to make a custom MIDI controller, essentially a copy of the DJTechTools MIDI Fighter. I was following this tutorial when I realised that the Teensy board does not have enough digital in ports, so now I'm thinking of going with an Arduino.

I have found this library for MIDI over USB which seems to allow me to do what I would need, but I'm a bit lost since I have found a number of other options (e.g. this library).

Has anyone done something similar and can share their thoughts / how they did it? Can you point me to useful threads on this forum? Thank you.

PS I have very little experience with electronics / embedded systems, I'm actually doing this project because I want to learn more (and hopefully make a fun little midi controller).

Hi, I'm the author of the MIDI Controller library.

Is there anything specific you'd like some help with?

The best way is to start simple, just a single potentiometer, or a single push button. These are the first examples you'll find when you start using the library.

The number of digital pins on the Teensy doesn't matter. You can easily multiplex it, by connecting the buttons in a matrix, or by using multiplexers or IO expanders, for example. The nice thing about the library is that it supports multiplexers right out of the box. I ordered some IO expanders as well, so I'll be adding support for them soon.

You can find development board comparisons on the library Wiki.
My "daily driver" MIDI development board is a Teensy 3.2.

Under the hood, the MIDI Controller uses the MIDIUSB library for MIDI over USB on some Arduino boards (Leonardo, Due, Zero, etc.). On Teensy, it uses the core Teensy functions, and on other boards, it just uses the serial port.

On the Wiki, you'll also find a page on how to connect the hardware.
There's also a more complete overview of all functions. For now, just stick with the examples, but if you need it, it's there.

If you need a more advanced library, you could check out my Control Surface library, it's a work in progress, an evolved version of the MIDI Controller library, that supports things like LEDs, audio output, OLED displays, MIDI over Bluetooth, etc.
I'm going to try to release the first version in a couple of weeks.

Pieter

1 Like

Thank you very much for your detailed and thorough reply! I had seen your project but I was a bit bewildered by other MIDI-USB github projects and blogposts of people using old school MIDI connectors.

If you know of any, could you link me to videos / posts of people who have done similar projects using your library? I find it helps a lot when I see the steps other people have done explicitly in order to get things to work, especially since this is my first Arduino project.

Gobs:
If you know of any, could you link me to videos / posts of people who have done similar projects using your library? I find it helps a lot when I see the steps other people have done explicitly in order to get things to work, especially since this is my first Arduino project.

I don't know any off the top of my head, the examples included with the library should get you started pretty quickly.

If you have any questions, you can just ask them here.

If you have trouble getting the connections right, they are independent of which library you use, so you can just look for other MIDI controller projects.

Here's the very first write-up I did on a MIDI controller, more than three years ago. The software back then was a hack, because there was no real MIDI USB support for Arduino. Everything about code you read on there is outdated, so just ignore it. It does give you an overview of the hardware aspects and the components required.

Sorry to bother you further, but I'm getting slightly confused about how to flash the Arduino Mega. Specifically my questions are:

  • If you want to get MIDI over USB to work, you need to 1) upload a sketch to the board 2) flash the firmware 3) now the Arduino should be recognised as USB device, correct? However to upload sketches again
  • Two links are provided for firmware on your GitHub, to the .hex file and to the HIDUINO GitHub page, I do not understand the difference?
  • In your documentation on the GitHub, you say that you have a script which will "download and install the firmware to the Arduino." Does this mean I didn't need to download the firmware in the first place?
  • On the HIDUINO page, there is a section in the quickstart that says the following:

If using the ISP method, an easier way of development is to flash the USB controller chip with HIDUINO just once. Then, in the Arduino IDE, select "Upload Using Programmer" and connect the ISP to the header block near the main chip. This means the Arduino sketch can be flashed from the IDE without commandline interaction via an ISP or DFU. While HIDUINO is loaded onto the USB controller, do not attempt Serial communication via Serial.print()/println(): this will interrupt MIDI serial stream on the USB controller.

I do not know what an ISP is (it's not explained in the Git), but this seems quite convenient. Is there any reason I wouldn't be able to do this? And what is an ISP?

TL;DR - I am confused about the different ways I can flash the Arduino, and some explanation of the differences however brief (if there are any) between following your GitHub ReadMe guide, the guide on the Arduino documentation and the HIDUINO guide would be helpful.

Gobs:
If you want to get MIDI over USB to work, you need to 1) upload a sketch to the board 2) flash the firmware 3) now the Arduino should be recognised as USB device, correct? However to upload sketches again

Correct. To upload sketches again, you have to 1) flash the Arduino Serial firmware again, 2) upload the new sketch, 3) upload the MIDI firmware again.

This is very cumbersome indeed, so I'd recommend using the Debug MIDI interface for debugging, so you don't have to reflash the firmware all the time. The Debug MIDI interface works with the standard Arduino firmware, and just prints out the MIDI messages to the Serial Monitor as plain text. MIDI_controller/examples/Ex.10.Debug-MIDI/Ex.10.Debug-MIDI.ino at master ยท tttapa/MIDI_controller ยท GitHub
You can also use the HairlessMIDI_Interface and use it with the Hairless MIDI<->Serial bridge.
Once that's working, you can upload your final sketch (with the normal USBMIDI_Interface!), and flash the MIDI firmware.

Gobs:
Two links are provided for firmware on your GitHub, to the .hex file and to the HIDUINO GitHub page, I do not understand the difference?

They are the same, the second (arduino_midi.hex) is just a direct download link (the first one is the file on GitHub). Use the second one (raw.githubusercontent...), and save it (CTRL+S).

Gobs:
In your documentation on the GitHub, you say that you have a script which will "download and install the firmware to the Arduino." Does this mean I didn't need to download the firmware in the first place?

The script is for Linux only. On Windows, you'll have do it the long way.

Gobs:
On the HIDUINO page, there is a section in the quickstart that says the following:

I do not know what an ISP is (it's not explained in the Git), but this seems quite convenient. Is there any reason I wouldn't be able to do this? And what is an ISP?

An ISP is an In-System Programmer.

The connection of the Arduino MEGA are as follows:

         USB            UART
Computer  โ‡†  ATmega16U2  โ‡†  ATmega2560

The main microcontroller of the MEGA is the ATmega2560, and it can't speak USB. So to upload sketches over USB, you need a second microcontroller, the ATmega16U2 that translates between USB and UART.
The ATmega2560 has a bootloader that receives a new sketch over the UART.
The 16U2 shows up on the computer as a serial communication device. This means it can't speak MIDI over USB.

When you flash the MIDI firmware to the ATmega16U2, it no longer shows up as a serial communication device, but as a USB MIDI device, and it translates between USB MIDI and UART MIDI.

However, now you can no longer upload sketches to the ATmega2560, because it only talks MIDI now.

There is a second way to upload sketches to the 2560: using an ISP over the SPI bus. This bypasses the 16U2 and the bootloader entirely, and it even erases the bootloader IIRC.
You need an extra device, the ISP programmer, that translates between USB and SPI.

         MIDI over USB       MIDI            SPI                USB
Computer     โ‡†    ATmega16U2  โ‡†  ATmega2560  โ‡†  ISP Programmer  โ‡†    Computer

Now you can use the USB port of the Arduino for MIDI, and the USB port of the programmer for uploading new sketches.
Because it requires extra hardware, and because I didn't want to complicate matters even further, I left that out.

As I said before, just use the debug interface and Hairless for prototyping, and then when you've tested it, flash the MIDI firmware as a final step. Then you don't have to worry about not being able to program the Arduino. If you want to go back, you can always flash the original Arduino firmware again.

As you've discovered, it's a complicated process. Teensies, Arduino Leonardos and Arduino Dues are just plug and play, because their main microcontrollers speak USB natively (including MIDI over USB).

The Arduino MEGA and UNO are just not suited for MIDI over USB. I added the instructions because some people don't have anything else, but if you have the choice, you'll spare yourself a lot of problems if you get a Teensy 3.x board.

Hope this clears some things up.
If you have any more questions, just ask!

Pieter