Offline
Newbie
Karma: 0
Posts: 11
we are what we think
|
 |
« on: January 19, 2013, 07:18:47 pm » |
Hi, everybody...the king of Arduino's beginners is in the house! I'm starting to develope a project to transform a MIDI sequence played from a DAW software (ABLETON LIVE), in a sequence of outputs signals from Digital ports of Arduino uno. Everything must be (of course) via USB in a continuos flux. Someone has an experience about it? In details I'm not sure how can trasform the Arduino in a MIDI Port recognizable from may OSX and softhware (?)
Thanx a lot
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 11
we are what we think
|
 |
« Reply #1 on: January 20, 2013, 04:32:42 pm » |
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 269
Posts: 25417
Solder is electric glue
|
 |
« Reply #2 on: January 22, 2013, 02:17:03 am » |
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 11
we are what we think
|
 |
« Reply #3 on: January 22, 2013, 04:28:34 pm » |
A step ahead for my job ...Thanks a lot!
|
|
|
|
|
Logged
|
|
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 269
Posts: 25417
Solder is electric glue
|
 |
« Reply #5 on: January 22, 2013, 05:43:14 pm » |
Sorry don't know where it has gone. Copy it from here. /* Midi Shield - Mike Cook May 2009 * ----------------- * listen for MIDI serial data, * sends MIDI note on with push button on Pin 2 #####################################################################################################################################################
HARDWARE NOTE: The MIDI Socket is connected to arduino RX through an opto-isolator to invert the MIDI signal and separate the circuits of individual instruments.
#################################################################################################################################################### */
//variables setup
byte incomingByte; byte note; byte button; int noteDown = LOW; int state=0; // state machine variable 0 = command waiting : 1 = note waitin : 2 = velocity waiting byte channel = 1; // MIDI channel to respond to (in this case channel 2) change this to change the channel number // MIDI channel = the value in 'channel' + 1
//setup: declaring inputs and outputs and begin serial void setup() {
pinMode(13,OUTPUT); // LED to light up pinMode(2,INPUT); // push button to read digitalWrite(2,HIGH); // enable internal pull up resistors button = digitalRead(2); // initialise push button state state = 0; // initialise state machine variable //start serial with MIDI baud rate 31250 or another standard speed for debugging Serial.begin(31250); digitalWrite(13,LOW); // Turn LED off }
//loop: wait for serial data, and interpret the message void loop () { checkIn(); // see if anything has arrived at the input checkButton(); } void checkButton(){ if(button != digitalRead(2)) { // only do stuff on a change button = digitalRead(2); // get new state of button if(button == HIGH) noteSend(0x80, 65, 0); else noteSend(0x90, 65, 127); } }
// plays a MIDI note void noteSend(byte cmd, byte data1, byte data2) { cmd = cmd | channel; // merge channel number Serial.print((byte)cmd); // command Serial.print((byte)data1); // note number Serial.print((byte)data2); // velocity } void checkIn(){ if (Serial.available() > 0) { // read the incoming byte: incomingByte = Serial.read();
switch (state){ case 0: // look for as status-byte, our channel, note on // if (incomingByte== (144 | channel)){ // un comment and comment the line below - to read only one channel if ((incomingByte & 0xf0) == 0x90){ // this reads all channels noteDown = HIGH; state=1; } // look for as status-byte, our channel, note off // if (incomingByte== (128 | channel)){ // un comment and comment the line below - to read only one channel if ((incomingByte & 0xf0) == 0x80){ // this reads all channels noteDown = LOW; state=1; } case 1: // get the note to play or stop if(incomingByte < 128) { note=incomingByte; state=2; } else{ state = 0; // reset state machine as this should be a note number } break; case 2: // get the velocity if(incomingByte < 128) { doNote(note, incomingByte, noteDown); // do something withh the note on message } state = 0; // reset state machine to start } } }
void doNote(byte note, byte velocity, int down){ // if velocity = 0 on a 'Note ON' command, treat it as a note off if ((down == HIGH) && (velocity == 0)){ down = LOW; } // do something with the note message // this just toggles Pin 13 and ignores the note value and velocity if(down == LOW) digitalWrite(13, LOW); else digitalWrite(13, HIGH);
}
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 11
we are what we think
|
 |
« Reply #6 on: January 22, 2013, 06:12:17 pm » |
Grazie mille Mike.
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 269
Posts: 25417
Solder is electric glue
|
 |
« Reply #7 on: January 23, 2013, 02:32:42 am » |
That was code for an older version of the IDE, sorry just spotted this, you need to use write not print to output MIDI void noteSend(byte cmd, byte data1, byte data2) { cmd = cmd | channel; // merge channel number Serial.write((byte)cmd); // command Serial.write((byte)data1); // note number Serial.write((byte)data2); // velocity
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 11
we are what we think
|
 |
« Reply #8 on: January 23, 2013, 08:47:55 am » |
ok
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 11
we are what we think
|
 |
« Reply #9 on: January 28, 2013, 01:05:54 pm » |
Hello Mike, when I connect the serial pin 0 RX to pin n°6 of 6N139 the Arduino's program generate an error while transfer the code.
avrdude: stk500_getsync(): not in sync: resp=0xfc
Do you know what's wrong?
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 269
Posts: 25417
Solder is electric glue
|
 |
« Reply #10 on: January 28, 2013, 03:50:38 pm » |
You can't use the hardware MIDI interface at the same time as you upload stuff. You have to switch it out. See the switches in my MIDI shield on my site.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 11
we are what we think
|
 |
« Reply #11 on: February 01, 2013, 09:02:10 am » |
Yes it works! But all notes goes out from port 13.Can you write an example string for sending only one note (c3) to out port 2 please?
Thanks a lot
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 269
Posts: 25417
Solder is electric glue
|
 |
« Reply #12 on: February 01, 2013, 12:07:33 pm » |
But all notes goes out from port 13. Sorry I don't understand what you mean by that, could you explain.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 11
we are what we think
|
 |
« Reply #13 on: February 01, 2013, 03:28:44 pm » |
ok I'll try ...at moment,loading your code, every midi note-on I'm gonna play goes out to digital port 13, but I'd need that 6 different Midi note goes out separately in 6 digital output.I'm sorry Mike, I hope to be enought clear... 
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 269
Posts: 25417
Solder is electric glue
|
 |
« Reply #14 on: February 01, 2013, 04:59:32 pm » |
No I don't get it. What code is this?
If it is the last code I posted then pin 13 is used only to light up an LED not push a note out on.
If it is the MIDI glock then pin 13 is the strobe that enables the solenoid drivers, not the output to the solenoid drivers they are on pins 2 to 9.
|
|
|
|
|
Logged
|
|
|
|
|
|