arduino midi controller – step 1: play a tune

I’ve started working on a top secret MIDI controller project. I’m using the Arduino LilyPad microcontroller as the brains for my prototype, so the first task was learning how to make it speak MIDI. The physical connection seemed simple enough…pin2 to ground, pin4 to +5V through a 220 ohm resistor, pin5 to arduino transmit pin…so I dissected a midi cable.

Insanity Prevention Tip #1
The MIDI pins are not numbered in order.

I didn’t have internet access when I was first working on this, so I spent a few fruitless, frustrating hours trying different combinations of the wrong wires and pins. The situation wasn’t helped by the fact that I was using a 220 ohm potentiometer in lieu of a resistor(because I happened to have one). Eventually, I got it straightened out and had the tutorial note loop playing, so it was time to try writing some musical code.

Insanity Prevention Tip #2
There are 2 different conventions for numbering MIDI notes, depending on the manufacturer’s definition of “Middle C”. If the chart you are referencing is showing different note numbers than what is being played, try transposing your code up or down by an octave(or use a different chart). This anomaly is fairly obvious if you are playing musical tones, but can be somewhat mysterious and frustrating if you’re playing percussion or sound effects.

I’m not a very good drummer, but I have about 3 songs I can bust out if I ever happen upon a drum kit. One of them is the opening to “Sifting” by Nirvana. I hardcoded the arduino to play this beat on a loop on my Boss DR-660. Here’s my code.

For a slightly more complicated task, I programmed the arduino to play the synth opening to “Girl” by Beck on my microkorg. My code.

Not exactly right, but I was starting to hate the song so I quit before it got to that point. I just found this note duration tool, which would have been invaluable if I really cared about the timing. Next up is programming some continuous control…

    • Jake
    • August 23rd, 2010

    Nice work on the site btw. I have always wanted to do something like this…but find a lack of interesting shit to put up. what did you use?

  1. No trackbacks yet.

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 )

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

Follow

Get every new post delivered to your Inbox.