Go Down

Topic: Need help going from Garageband Midi to Arduino Uno (Read 1 time) previous topic - next topic

Apr 11, 2013, 05:15 pm Last Edit: Apr 13, 2013, 12:27 am by jasongitar Reason: 1
Please help-

*Update* Code and Photos are posted below this post.

So, to start out I have a midi file that plays in Garageband on a Macbook Pro. I have it set so the midi
track uses a midiO plugin for the signal to go to Hairless Midi software which from there converts the
midi signals to the Arduino. From there the Arduino controls solenoids to play drums. So to make a long story
short I am using midi on my Mac to play actual drums using the Aduino. Basically a robot drummer.

I have everything installed correctly, and a friend of mine wrote the code for the Arduino to make it work.

Here is the problem, originally we had it working on PC, but it was very very unstable, and then it just
completely stopped working all together. I tried converting everything to Mac hoping that it would work
a little better. At this point I can't get the Arduino to capture the midi from the computer. The friend
who wrote the code, said the baud rate needs to be set right, but we have no idea how to figure out
how to find the baud rate. And honestly I don't even know is that is even the problem. When I press
play in Garageband the signal does get to the Arduino for a second or two, but then everything just completely
freezes and it's a brand new Macbook Pro, so I have no idea why this is happening.

Is anyone familiar with this concept? If you are do you think you can walk me through it? I am a total newbie
to Arduino, but very excited and passionate about as learning as much as I can. If you want to hear a little
bit more about this project, we were able to get it successfully funded on Kickstarter. Here is our video
for it-


And here we are on the news for it-

I have been pulling my hair out trying to get this to work, any help would be greatly appreciated! :)


Lots of words but no way anyone is going to know what is going wrong because you do not describe how it is wired up and you have not posted the code.

Good point, yeah I am a newbie! Still learning how all this stuff works. I will post a picture of how it is all wired and figure out how to post the code. Thank you for the heads up :)

Here are a couple of up close pictures to show how it is wired, hopefully these show up-


And here is the code for it-

Code: [Select]
#include <MIDI.h>
int milliseconds;
int notesToShutOff[10];
int noteDurations[10];

void setup() {
noteDurations[2] = 50; // bass
noteDurations[3] = 10;
noteDurations[4] = 10;
noteDurations[5] = 40; // snare
noteDurations[6] = 100; // nothing
noteDurations[7] = 10;
noteDurations[8] = 10;
noteDurations[9] = 40;
noteDurations[10] = 40;

void loop() {
milliseconds = millis();
for(int x=2; x<=10; x++){
    if(notesToShutOff[x] + noteDurations[x] < milliseconds){

void HandleNoteOn(byte channel, byte note, byte velocity) {
if(note >= 35 && note <= 44 && velocity > 0){
    //velocity = (velocity * 2);
    int myPin=note-33; // to get a pinnumber between 2 and 9
    analogWrite(myPin, 255);
    notesToShutOff[myPin] = milliseconds;


When I said how had you wired it up I was rather hopeing for a diagram. It is impossible to tell anything from those pictures.
Fine on the arduino code but when you use a libarie you should include a link to it.
However, the important bit of code is the one on the computer converting midi output to serial, unless you have a midi shield and midi USB device.


Hi, some problems with arrays:
Code: [Select]

int notesToShutOff[10];
int noteDurations[10];
// ...
noteDurations[10] = 40;
// ...
for(int x=2; x<=10; x++){
  if(notesToShutOff[x] + noteDurations[x] < milliseconds)
// ...
if(note >= 35 && note <= 44 && velocity > 0){
    int myPin=note-33; // to get a pinnumber between 2 and 9
    analogWrite(myPin, 255);
    notesToShutOff[myPin] = milliseconds;
// ...

Now, the index for the elements of an array declared as something[10] has a range from 0 to 9, thus
Code: [Select]


requires noteDuration to have been declared as
Code: [Select]

  int nodeDurations[11];

Same for notesToShutOff.
Also consider that myPin can be 44 - 33 = 11, which would require a declaration such as noteDuration[12].

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131