Ferraganchos & Pinchos

Or how to rip all this stuff out of my head…

OpenPipe breakout MIDI over USB with Arduino

UPDATE (October, 1st 2012)!!! We’ve moved to www.openpipe.cc.

Playing OpenPipe with PWM sound is amazing 🙂 but I got tired too soon. So the next step was to send MIDI commands in order to connect to a more realistic sound sampler/synthsizer like Garageband, Reason, etc.

OpenPipe breakout connected to Arduino Mega

There are several ways to address “Arduino sending MIDI commands” issue:

  • Send MIDI commands using MIDI DIN connector (MIDI Shield, etc.). A bit outdated?
  • Send MIDI commands using USB serial port and translate It to MIDI commands using PC software app. You can search “serial to MIDI” in Google. It’s OK but cumbersome.
  • Implement USB MIDI compliant class in Arduino. “The USB-HID specification has a specific type for MIDI input and MIDI output, which nearly all commercial musical controllers on the market use for class-compliant (driverless!) MIDI I/O.” (source)

IMHO the last option is the one because you need no additional software nor drivers (at least for Linux and Mac). How does it works?

Traditionally, Arduino boards used FTDI chip in order to translate UART to USB virtual serial port. Recent Arduinos changed this FTDI chip for an Atmel IC (atmega8u2, atmega16u2) capable of running UART-USB firmware (default) but also some other cool firmwares (ladyada wrote a good FAQ on this point). Flashing different firmwares your Arduino could act as a mouse, a keyboard, a MIDI device, and so on… (darran is doing a good job compiling this LUFA based firmwares for Arduino). The only drawback is that you need to reflash the Atmel IC  again if you want to update the Arduino sketch (You can’t please everyone… so far).

So here is the spet-by-step guide sumarizing how I proceeded with my Arduino Mega.

Download USB-MIDI firmware (Mega and UNO), demo and source from here. You can upload demo sketch (.pde) to the Arduino board as usual. Then we need to update atmega8u2 firmware (.hex).

Here you can find detailed information about flashing atmega8u2. Basically you need to reset atmega8u2 in order to enter DFU mode and the use dfu-programmer (sudo apt-get install dfu-programmer). In order to reset atmega8u2 connect RESET and GND pins in ISP header. The Arduino Mega pins are located the same way as Arduino UNO (see picture).

You can check that atmega8u2 is in DFU mode executing ‘lsusb’ after and before reset. The USB ID should have changed. Then flash Arduino-usbmidi-0.2-mega2560.hex.

sudo dfu-programmer at90usb82 erase

sudo dfu-programmer at90usb82 flash Arduino-usbmidi-0.2-mega2560.hex

sudo dfu-programmer at90usb82 reset

Now you can check if everything is working fine. Disconnect the Arduino and connect it again in order to boot as a MIDI device. Executing lsusb you shoud see somethin similar to:

Bus 003 Device 002: ID 03eb:2048 Atmel Corp. LUFA MIDI Demo Application

At this moment you have demo firmware running on Arduino, sending notes using UART, and atmega8u2 running MIDI device firmware translating UART commands to MIDI over USB protocol. Connecting a MIDI sniffer  (I’ve used KMidimon) you should see NOTE ON and NOTE OFF MIDI events.

Everything looks fine, so we are ready to flash OpenPipe breakout firmware…. but we need to restore atmega8u2 default firmware (the usbserial) before. Default firmware is located at /usr/share/arduino/hardware/arduino/firmwares/arduino-usbserial. In order to reflash again, enter DFU mode and then execute:

sudo dfu-programmer at90usb82 erase

sudo dfu-programmer at90usb82 flash Arduino-usbserial-mega.hex

sudo dfu-programmer at90usb82 reset

Now we can upload OpenPipe breakout sketch. I’ve mixed darran demo and OpenPipe breakout PWM code here. Then change atmega8u2 firmware again…

So the development process is:

  1. With default atmega8u2 firmware upload Arduino sketch
  2. Reset and flash atmega8u2 with MIDI firmware
  3. Reset the board and use It as MIDI device
  4. Reflash default firmware to atmega8u2
  5. GOTO 1

I’m sure we will be able to have composite firmwares with SERIAL and MIDI soon 🙂

Here is a geek playing galician bagpipes themes with several MIDI instruments in GarageBand…


Single Post Navigation

10 thoughts on “OpenPipe breakout MIDI over USB with Arduino

  1. Valerio on said:

    Hola, me gustaria realizar este puntero con el arduino nano, es posible, el código seria válido??
    Muchas gracias

    • Hola Valerio,

      La vesión MIDI USB no la podrás realizar con el Arduino Nano porque no tiene el chip necesario para cargarle el firmware MIDI USB. Podrías realizar una versión MIDI estandar utilizando el puerto serie.

      • Valerio on said:

        Muchas gracias por contestar Xulio , mi idea era la de realizar el proyecto anterior con PWM, pero por tu respuesta veo que es perfectamente posible, el nano lo compré en su dia para intentar hacerlo basado en un código que encontré en internet, pero no fuí capaz,…
        Ahora al volver a buscar y aparecer tu proyecto me vuelve de nuevo las ganas.
        Mi problema !no soy programador¡, pero si estoy aprendiendo a tocar la gaita, eso sí la digitación es la asturiana, pero todo será ponerse a ello.

        Un saludo y muchas gracias por contestar

      • Hola Valerio,

        Ya contarás como te va con el Nano. Y no te preocupes por no ser programador, que Arduino está aqui precisamente para eso 🙂
        La forma de cambiar la digitación está explicada en el código. Si no lo entiendes avisa.



  2. inkisicao on said:

    Hello again.

    Didn’t you needed to solder a 10K resistor in the back of arduino?

  3. Pingback: OpenPipe Breakout & Arduino Musical Shield « Ferraganchos & Pinchos

  4. Pingback: Arduino as MIDI Adventure, PT III | Learn as you go

  5. Pingback: OpenPipe MIDI-USB Shield « OpenPipe

  6. Pingback: OpenPipe

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: