Pages: [1]   Go Down
Author Topic: Need help going from Garageband Midi to Arduino Uno  (Read 830 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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-

http://www.kickstarter.com/projects/poleshadow/brobot-open-source-robotic-drummer-sci-fi-fantasy

And here we are on the news for it-
http://www.myfoxtampabay.com/story/19970093/2012/10/31/project-seeks-to-map-musics-magic


I have been pulling my hair out trying to get this to work, any help would be greatly appreciated! smiley
« Last Edit: April 12, 2013, 05:27:58 pm by jasongitar » Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 634
Posts: 34554
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

http://i73.photobucket.com/albums/i225/jasongitar/photo4_zps91d73de1.jpg
http://i73.photobucket.com/albums/i225/jasongitar/2_zpsdbcae38c.jpg
http://i73.photobucket.com/albums/i225/jasongitar/photo3_zps8c44d420.jpg
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

And here is the code for it-

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

void setup() {
 MIDI.begin(MIDI_CHANNEL_OMNI);   
 MIDI.setHandleNoteOn(HandleNoteOn);
 pinMode(2,OUTPUT);
 pinMode(3,OUTPUT);
 pinMode(4,OUTPUT);
 pinMode(5,OUTPUT);
 pinMode(6,OUTPUT);
 pinMode(7,OUTPUT);
 pinMode(8,OUTPUT);
 pinMode(9,OUTPUT);
 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();
 MIDI.read();
 for(int x=2; x<=10; x++){
    if(notesToShutOff[x] + noteDurations[x] < milliseconds){
     analogWrite(x,0);
    }
 }
}

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;
 }
}
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 634
Posts: 34554
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Rome, Italy
Offline Offline
Sr. Member
****
Karma: 20
Posts: 442
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, some problems with arrays:
Code:
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:

  noteDurations[10]
requires noteDuration to have been declared as
Code:
  int nodeDurations[11];

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

Pages: [1]   Go Up
Jump to: