Go Down

Topic: Serial Midi Converter (Read 5094 times) previous topic - next topic

AspireBear

Dec 22, 2011, 12:40 am Last Edit: Dec 22, 2011, 01:02 pm by AspireBear Reason: 1
:smiley-roll-sweat:
Hello,
I am making a midi drum and I have finished building it but my problem is that Serial MIDI Converter flashes me a red light on the Serial RX. From what I understand is that it should be showing a green light to show that it is receiving a midi signal. What does a midi line look like? I am running code that I found online:

Code: [Select]
//*******************************************************************************************************************
// User settable variables
//*******************************************************************************************************************

unsigned char PadNote[6] = {60,61,62,63,64,65};         // MIDI notes from 0 to 127 (Mid C = 60)

int PadCutOff[6] = {900,900,900,900,900,900};           // Minimum Analog value to cause a drum hit

int MaxPlayTime[6] = {90,90,90,90,90,90};               // Cycles before a 2nd hit is allowed

#define  midichannel 0;                              // MIDI channel from 0 to 15 (+1 in "real world")

boolean VelocityFlag  = true;                           // Velocity ON (true) or OFF (false)

//*******************************************************************************************************************
// Internal Use Variables
//*******************************************************************************************************************

boolean activePad[6] = {0,0,0,0,0,0};                   // Array of flags of pad currently playing
int PinPlayTime[6] = {0,0,0,0,0,0};                     // Counter since pad started to play

unsigned char status;

int pin = 0;    
int hitavg = 0;

//*******************************************************************************************************************
// Setup
//*******************************************************************************************************************

void setup()
{
 Serial.begin(57600);                                  // connect to the serial port 115200
}

//*******************************************************************************************************************
// Main Program
//*******************************************************************************************************************

void loop()
{
 for(int pin=0; pin < 6; pin++)
 {
   hitavg = analogRead(pin);                              // read the input pin

   if((hitavg > PadCutOff[pin]))
   {
     if((activePad[pin] == false))
     {
       if(VelocityFlag == true)
       {
//          hitavg = 127 / ((1023 - PadCutOff[pin]) / (hitavg - PadCutOff[pin]));    // With full range (Too sensitive ?)
         hitavg = (hitavg / 8 ) -1 ;                                                 // Upper range
       }
       else
       {
         hitavg = 127;
       }

       MIDI_TX(144,PadNote[pin],hitavg);
       PinPlayTime[pin] = 0;
       activePad[pin] = true;
     }
     else
     {
       PinPlayTime[pin] = PinPlayTime[pin] + 1;
     }
   }
   else if((activePad[pin] == true))
   {
     PinPlayTime[pin] = PinPlayTime[pin] + 1;
     
     if(PinPlayTime[pin] > MaxPlayTime[pin])
     {
       activePad[pin] = false;
       MIDI_TX(128,PadNote[pin],127);
     }
   }
 }
}


//*******************************************************************************************************************
// Transmit MIDI Message
//*******************************************************************************************************************
void MIDI_TX(unsigned char MESSAGE, unsigned char PITCH, unsigned char VELOCITY)
{  
 status = MESSAGE + midichannel;
 Serial.print(status);
 Serial.print(PITCH);
 Serial.print(VELOCITY);
 
}



Any ideas on how to resolve my issue?

Grumpy_Mike

Please modify that post. Select the code  and hit the # icon and save.
Next how have you got this wired up ?
It is not outputting at MIDI speeds so it must be sending stuff straight into the serial port. What application have you got that translates this into MIDI?

AspireBear

#2
Dec 22, 2011, 01:17 pm Last Edit: Dec 22, 2011, 01:27 pm by AspireBear Reason: 1
I did the following:

With the grounds from the piezos connected to one ground.
And I am using Serial Midi Converter on my Macbook, configured like so:
http://spikenzielabs.com/SpikenzieLabs/Serial_MIDI.html
And that is where my data shows that it is not midi formated... Are there better Midi apps for mac?
I tried changing my baud rate to 31250 and had the same problem.
Edit: I tried again with a baud rate of 31250 and Serial Midi Converter freezes when i select my output...

Grumpy_Mike

What version of the arduino IDE are you running?
Recent changes might make it not work.
Try replacing that function at the end with this:-
Code: [Select]
void MIDI_TX(unsigned char MESSAGE, unsigned char PITCH, unsigned char VELOCITY)

  status = MESSAGE + midichannel;
  Serial.write(status);
  Serial.write(PITCH);
  Serial.write(VELOCITY);
 
}

AspireBear

Wow! Your the best! That made all the difference, I fiddled with my settings in Ableton Live and now it works with that new line of code!
What I changed in Ableton was the in the Preferences > MIDI Sync and turned on all IAC Input and Output (Track & Remote) and it works!
Now I can drum away  :)

Thanks Grumpy_Mike.

#5
Nov 11, 2012, 09:13 pm Last Edit: Nov 12, 2012, 04:56 am by Thot Reason: 1


Try replacing that function at the end with this:-
Code: [Select]
void MIDI_TX(unsigned char MESSAGE, unsigned char PITCH, unsigned char VELOCITY)
{  
 status = MESSAGE + midichannel;
 Serial.write(status);
 Serial.write(PITCH);
 Serial.write(VELOCITY);
 
}



Grumpy_Mike, you are a genius!   :)

P.S. After thinking about it, I understand why this works and the previous version doesn't.
But I am puzzled on why did the previous version worked with older board, if it did.
There are three kind of people in the world: Those who can count, and those who can't

Go Up