Wednesday, 19 December 2012

Arduino MIDI Controller (Note + Control Change) Tutorial


1. Overview

This is an example project for getting Arduino to work as MIDI device. There is three buttons to trigger notes and one potentiometer to control change. It's been tested on Win 7 x64, however should work on x86 and older system versions.




2. Shopping list

  • Arduino board
  • Breadboard
  • Push buttons (each button for controlling one note)
  • Rotary potentiometer (for CC - Control Change), code on mine says "B50K", but most should work
  • 10k resistors for push buttons connection
  • Some wires, USB cable to connect Arduino, 
  • Optional: some Lego Technics for push buttons & potentiometer base + masking tape to keep things steady 

3. The plan













4. Software

  • Arduino MIDI Library - get v3.2, copy files to Arduino/libraries
  • LoopBe1 - virtual MIDI cable
  • Hairless MIDI<->Serial Bridge - used to read serial data from Arduino and send it to virtual MIDI device
  • DAW or other music software to make some noise:) (on video I'm using new generation tracker - Renoise. Ableton Live, Cubase or any will do)

5. Arduino Code

Get the code

6. Wire it up

  1. Start LoopBe1 (tray icon)
  2. Open music software, go to preferences and select LoopBe1 as MIDI input device
  3. Open Arduino editor, connect board and upload program
  4. Open Hairless MIDI, select Arduino COM port (i.e. COM4), check "Serial<->MIDI Bridge On"
  5. That's it!

7. References





24 comments:

  1. Superb tutorial, thanks - this is by far the easiest one to understand that I have been able to find, and lots of comments in the Arduino code for the modifications that I needed. Thanks so much!

    ReplyDelete
  2. Video is private, please correct

    ReplyDelete
  3. Hello! Thanks for the tutorial!
    But i have a problem...
    I've connected my arduino UNO via usb to my pc, and used your code and libraries, but almost always, hairless show me this message...
    "+176.52 - Error: got unexpected data byte 0x1." (the byte changes with the movement of the pot), and a very few times, the program reads a correct midi data...

    I have only the pot connected to my arduino...

    ReplyDelete
    Replies
    1. Hmm.. Hard to say. But you get it working sometimes and sometimes is error?

      Delete
  4. Thanks so much for this - just what I was looking for. Very clear tutorial and very clear comments in the coding making it easy for me to understand and modify. Champion!

    ReplyDelete
    Replies
    1. Thanks, I'm really glad to hear it could help people :-)

      Delete
  5. Hi! Really nice tutorial and code. Cant wait to get this up and working. Problem is, everything works beside getting daw to receive midi. Hairless recognize and gives me signal everytime I push the buttons, I send the signal to ipMIDI Port 1 (which is the updated version of LoopBe1, and everything seems ok. In Ableton Live I choose ipMIDI port 1 as a midi input, but it dont receive any data at all. Do you know what could be the problem?

    ReplyDelete
    Replies
    1. When I for example push a button while having the "Debug MIDI messages" checked, it says Serial In: Ch1: Note 55 on velocity 127. So I dont understand where the problem is.

      Delete
    2. It looks like there's an issue on live..

      Delete
    3. Thank you for reply. I just found the reason, and of course it was a scenario of me being silly. The problem was that IPMidi had been turned off because I just have the demo. Now everything seems to work. Again, thank you for beautiful code.

      Delete
  6. Hi! this is so helpful!!! But how to put more pins?
    thank you :)

    ReplyDelete
  7. https://www.google.ie/search?q=arduino+shift+register+74hc595&ie=UTF-8&oe=UTF-8&hl=en-ie&client=safari

    ReplyDelete
  8. It's possible to use midi out connector?

    ReplyDelete
    Replies
    1. Yes, it is, but not exactly like in this example. Check out Arduino MIDI library, it comes with code snippets

      Delete
  9. It's possible to use sanwa buttons???

    ReplyDelete
  10. I cant set it in cubase 8 LE

    ReplyDelete
  11. Dear friend how to exit audio, which pin used.

    ReplyDelete
    Replies
    1. It's only for Midi, your synthesiser is responsible for producing sounds

      Delete
  12. Thank you, everything works but I have a problem. I'd like to add more potentiometers, I did it but when I add the second one it's not stable because it changes continuously the note. In other words I assigned to the first potentiometer the command MIDI.sendControlChange(1, analogValue1, 1); and to the second MIDI.sendControlChange(2, analogValue2, 1); but in this mode the first potentiometer works correctly but the second one is unstable.
    Any advice?

    ReplyDelete
    Replies
    1. It's been a long time since I did that but as far as I remember there will always be some fluctuation in analog reading, however if it's large I'd look at the hardware first and maybe swap potentiometers and observe if they act the same way...

      Delete
  13. Have you tried the ESP32? It can do a lot more than Arduino with BT/BLE and WiFi built in, for cheaper than an UNO board. I can talk to my esp32 with my AI App and BLE using Koban's Arduino ESP32 BLE lib and the BLE extension in AI. I want to go direct to the ESP32 and wire a MIDI port to it. Another guy has begun to put the ESP32 harddward and MIDI lib part of this together and the the ESP32 hardware has a two good DACs and libs for most sound formats to output to external DACs so it can turn MIDI into wav output to file, web or a pins. I saw your post in the AI forum where I have posted about MIDI.

    ReplyDelete
  14. Great tutorial.. i have some problem, whenever i connect to hairless, it always show 127 and 0 velocity randomly even i unplug all the wiring from arduino... can you help me?

    ReplyDelete