Go Down

Topic: Problems with MIDI (SOLVED) (Read 1 time) previous topic - next topic

OlivierG

Apr 09, 2011, 03:47 am Last Edit: Apr 09, 2011, 04:10 am by OlivierG Reason: 1
Hello,
I received this cable today and started experimenting with the Arduino and MIDI, like I've been wanted to for a while.

I started by going through the tutorial found on this website. Didn't get much luck getting any sound using Reaper's VSTis, but once I opened up Guitar Pro 5, it actually worked and the notes started coming, everything seemed fine. Then I tried the other example on another website where the pitch of the note is controlled by a potentiometer, and the note triggered by a switch. I tried that with MIDI-OX and it worked just fine.

It didn't last very long however and pretty soon it stopped working. Now I can't get anything showing in MIDI-OX even though it looks like the Arduino is still transmitting. I'm trying Stephen Hobley's MIDI test code (see below). If anyone had some suggestion on how to fix this it'd be mucho appreciated. Could it be the USB/MIDI cable interface that is just cheap crap? Or is it that, like I read somewhere, the TX pin can't be used for sending MIDI over USB if the Arduino is also connected to a USB port? Do I need external power for this?

Code: [Select]
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// MAKE MAGAZINE - MIDI TEST CODE
// Stephen Hobley 2008
// www.stephenhobley.com
////////////////////////////////////////////////////////////////////////////////////////////////////////

// Variables: ///////////////////////////////////////////////////////////////////////////////////////////
#define MIDICMD_NOTEON 0x90 // MIDI command (Note On, Channel 0)

/////////////////////////////////////////////////////////////////////////////////////////////////////////
//  Plays a MIDI note.
//  Format of MIDI note on
//  1<xxx><yyyy> - xxx is 001 (Note On), yyyy is the channel number - in our case 0000 - which is channel 0
//  0<xxxxxxx> - note number 0-127
//  0<yyyyyyy> - note velocity 0-127 - instead of sending a note off, you can send 0 in this field to silence a note
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void SendMIDI(char cmd, char data1, char data2)
{
 Serial.print(cmd);
 Serial.print(data1);
 Serial.print(data2);
}


/////////////////////////////////////////////////////////////////////////////////////////////////////////
// SETUP FUNCTION
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup()
{
 // Set MIDI baud rate:
 Serial.begin(31250);
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// MAIN LOOP
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void loop()
{
 // Loop through 6 inputs and find one that is different to how it was before
 // if is is LOW, then note on, HIGH then note off..
 for (int i= 60; i < 70; i++)
 {
   // NOTE_ON
   SendMIDI(MIDICMD_NOTEON, i, 127);
   delay(250);
 
   // NOTE OFF
   SendMIDI(MIDICMD_NOTEON, i, 0); // Silence the note
 }
}


EDIT: nevermind. It was indeed the fact that the Arduino was plugged in a USB port. Dug up a power supply, disconnected the USB cable, but I had to also change the port of the USB/MIDI interface and do some fancy dancing before it all worked. Joy...  :) :~ Oh well, now it works, but as someone mentioned, it'd be a good idea to put a disclaimer on the MIDI tutorial that an external power supply is required for that tutorial or it won't work...

Go Up