Go Down

Topic: MIDI Xilophone (over serial) to Ableton (Read 33387 times) previous topic - next topic


Soooo, i am now trying to build a little MIDI "Xilophone".

I followed this schematics:

(found here: http://www.jdeboi.com/portfolio/electronics.html)

i have now finished all the connections and they seem to be working.
When i press any of the piezo disks i get a little flash on the TX light on my Arduino UNO board. (this means it is transmitting, or??!?)
When i open the Serial Monitor i get this:

Is this how it is supposed to look like?

My next step was to try to convert the serial data into MIDI.
I am on a Mac, so i have created a new "IAC Device".
Then I used the serial to MIDI converter from SpikenzieLabs and used this new IAC Device.
i have tried several different configurations, different port ins, different port outs, baud rates,...

As you can see there on the image, i also get there the green light in the RX (receiving?).
But i do NOT get it in the TX...

When i now try to connect it to Ableton (making a Manual Mapping) i cannot get it to work.
I have turned on the IAC Device on the Preferences and sometimes i even get a "Midi in light" blink (very rarelly), but when i try to map it it doesn't really work!

Does someone have an idea of what i'm doing wrong?



The baud rate must be the same on the arduino and what the Mac is expecting.
It is unlikely you will see anything useful in the serial monitor. Google for a MIDI monitor.
This will show you if something is arriving in the Mac.


thanks, that was a good idea. i did't know such a program existed.
i tried Snoize and i got NO signal of MIDI!!  =(

What could the problem be?
How can i know the baud rate that the mac is waiting?
At this point i have:   Serial.begin(57600);

This is how the whole code looks like:

Code: [Select]
//Jenna deBoisblanc, 2011
//Code adapted from:
//Mark Demers' code, Copywrite 2009 (http://spikenzielabs.com/SpikenzieLabs/DrumKitKit.html)
//Georg Mill's YAAMIDrum (www.georgmill.de/)
//Arduino on the 4051 (http://www.arduino.cc/playground/Learning/4051)

unsigned char PadNote[8] = {60,62,64,65,67,69,71,72};
unsigned char status;
int PadCutOff[8] = {80,110,110,110,80,110,110,110};
int MaxPlayTime[8] = {90,90,90,90,90,90,90,90};
#define midichannel 0;
boolean activePad[8] = {0,0,0,0,0,0,0,0};                   // Array of flags of pad currently playing
int PinPlayTime[8] = {0,0,0,0,0,0,0,0};                     // Counter since pad started to play
boolean VelocityFlag = false;

int analogPin = A0;   
int hitavg = 0;
int pad = 0;

byte byte1;
byte byte2;
byte byte3;

int r0 = 0;      //value of select pin at the 4051 (s0)
int r1 = 0;      //value of select pin at the 4051 (s1)
int r2 = 0;      //value of select pin at the 4051 (s2)
int count = 0;   //which y pin we are selecting

int multiplex1[8];
int multiplex2[8];
int multiplex3[8];

// Setup   

void setup()
  pinMode(2, OUTPUT);    // s0
  pinMode(3, OUTPUT);    // s1
  pinMode(4, OUTPUT);    // s2

// Main Program   

void loop (){


void readSensors (int analogPin) {

  for (count=0; count<=7; count++) {

    // select the bit
    r2 = bitRead(count,0);    // use this with arduino 0013 (and newer versions)   
    r1 = bitRead(count,1);    // use this with arduino 0013 (and newer versions)   
    r0 = bitRead(count,2);    // use this with arduino 0013 (and newer versions)   
    //r0 = count & 0x01;      // old version of setting the bits
    //r1 = (count>>1) & 0x01;      // old version of setting the bits
    //r2 = (count>>2) & 0x01;

    digitalWrite(2, r0);
    digitalWrite(3, r1);
    digitalWrite(4, r2);
      //Read and store the input value at a location in the array
     multiplex1[count] = analogRead(analogPin);
     //Serial.print(" ");
      // }
      //else if(analogPin==1){
      //  multiplex2[count] = analogRead(analogPin);
      //else if(analogPin==2){
      //  multiplex3[count] = analogRead(analogPin);
      // }

void checkSensors(int analogPin){

  for(int pin=0; pin <=7; pin++){
      hitavg = multiplex1[pin];
    else if(analogPin==1){
      hitavg = multiplex2[pin];
    else if(analogPin==2){
      hitavg = multiplex3[pin];

    if((hitavg > PadCutOff[pin])){
      if((activePad[pad] == false)){
        if(VelocityFlag == true){
          hitavg = (hitavg / 8) -1;
          hitavg = 127;
        PinPlayTime[pad] = 0;
        activePad[pad] = true;
       else {
         PinPlayTime[pad] = PinPlayTime[pad] + 1;
    else if((activePad[pad] == true)) //the pad is active, but it is not greater than cutoff
      PinPlayTime[pad] = PinPlayTime[pad] + 1;
      if(PinPlayTime[pad] > MaxPlayTime[pad])
        activePad[pad] = false;

void midiLoopback(){
  if(Serial.available() > 0){
      byte1 = Serial.read();
      byte2 = Serial.read();
      byte3 = Serial.read();
      MIDI_TX(byte1, byte2, byte3);

// Transmit MIDI Message   
void MIDI_TX(unsigned char MESSAGE, unsigned char PITCH, unsigned char VELOCITY)
  status = MESSAGE + midichannel;

Thank you


As you have :-
Serial.begin(57600) ;
Then you need to set the Serial <> Midi baud rate to the same value, that is 57600.
Only then will you be able to see anything in the MIDI monitor. 


hey, thanks, that was good advice.

i have now done some experimenting with the baud rates.
First i have left it at 57600 and tried the Serial2Midi also at the same rate. It doesn't work! I get only the red light flashing.
Then i tried several other combinations, and noticed that when i set the baud rate in the Converter a little bit lower then in the Arduino (like for example Arduino: 57600, Converter: 38400), then i get green lights blinking.

So i opened the MIDI Monitor and was, at first, happy. Now i can, at least, get some kind of readings there.
The problem is that the readings are erratic, so not so useful as MIDI!

When baud rates are the same, the MIDI Monitor doesn't read anything at all.
When baud rate are slightly different (like in the example above) then the MIDI Monitor reads a lot.

Here is an example (Arduino's baud rate was at 57600):

All those readings on the MIDI Monitor (on the left) are from only ONE piezo disk touch.
Sometimes i get more, sometimes i get less...

If i open the serial monitor from the Arduino software and set it to the right rate (57600), then i get for one touch:

Any ideas???

= = = = = = = =
Another thing...

When i read down the code, i notice that there are lots of place using the //
Like here:

or here:

Is this supposed to be like that or i'm i actually supposed to change parts of the code according to my "setup" of the piezo disks?

Well, once again, thank you for your help!


When baud rates are the same, the MIDI Monitor doesn't read anything at all.
When baud rate are slightly different (like in the example above) then the MIDI Monitor reads a lot.

The baud rate has to be exactly the same on both devices. Try making it 9600 on both the arduino and the serial to MIDI software. What sort of arduino do you have?
If they are not the same you get rubbish.

Your value of 1446412712864127 is correct this is the message
144 - note on channel 1
64 - the MIDI value of the note
127 - the velocity of the note on event, a bit like the volume
128 - note off on channel 1
64 - the MIDI value of the note
127 - the after touch of the note off event

The code is fine for the setup you have, you can add another two multiplexed inputs by uncommeting those lines.


My board is an Arduino Uno that i got about two weeks ago.

I just tried to set both baud rates at the same, but then i get red lights on the Serial to MIDI converter and i get no signal at all in the MIDI Monitor.
(on the serial monitor in the Arduino software i get the same values as before)

I tried 9600, 57600 and 115200 (always the same on both the arduino and the software), but got always the same result!


How are you changing the speed on the arduino.
You must change the Serial.begin(9600)
And upload the sketch again.


Yes, that is how i am changing it. i Open the sketch in the Arduino software, I change the Serial.begin that is in the void setup and then i upload it.

I also noticed i get a red light on the RX and NO light at all in the TX of the Serial to MIDI converter.


OK how are you running the serial <> MIDI app.
Try running it direct from processing, you have to down load the library it is asking for before it will run, but the .pde processing source code is in the download package.
I couldn't get the serial <> MIDI app running directly on my Mac but it works through processing.


Sorry, but i have no idea of what it means to run it from processing.   =/
I have been running it just by double clicking it.
but yes, with it there is a folder with a "Serial_MIDI_Converter_V2C.pde" and "Serial_MIDI_Converter_V2C.java" files.
i have opened the .pde file in Arduino's software, but then what should i do with it?
Should i upload it to the arduino?

If i open it in Arduino's software and then open the serial monitor from there i get:
1446912712869127 (which i assume are also the same midi values as before...)

i am feeling soooooooo lost with this!!


Mar 25, 2012, 04:53 pm Last Edit: Mar 25, 2012, 05:01 pm by Grumpy_Mike Reason: 1
If i open it in Arduino's software and then open the serial monitor from there i get:
1446912712869127 (which i assume are also the same midi values as before...)

Yes this is the same as before and shows your arduino and sensors are working correctly. What is not working is the bit that converts this serial data into MIDI. The arduino's serial monitor must be closed when you attempt to use serial <> MIDI.

Processing is a language, a bit like the aruino but it runs on your computer.
Down load it from here:-
And install it ( it is just clicking )

Then down load the "themidibus" library from:-
Unzip it and put it in the libraries folder which is inside the Processing folder that the Processing language created when you installed it.

Then go into the Processing folder and create a folder called Serial_MIDI_Converter_V2C, and put that source file Serial_MIDI_Converter_V2C.pde inside it.

Then run the Processing application and use the menu File -> Sketchbook -> Serial_MIDI_Converter_V2C to load it in. Run it from the arrow in the top corner.
Choose Bus 1.
If you choose Java Sound Synthesizer, when offered, then you should be able to hear your taps on your sensors.


Aaaaaaahhhhh, i can feel that we are getting close!!!

I have installed the Processing software (which, by the way, seems like a nice software to explore...) and also instaled the midibus library.
i opened the "Serial_MIDI_Converter_V2C" pde file in Processing but then got an error message when i tried to run it.

it sais:
The function returnList() does not exist.

and it highlights this line of the code:
String midiport[][] = myBus.returnList();

Any ideas on what is wring with this line?


Odd I searched all that code and there is no mention of returnList(),
can you copy ALL the error message and paste it in the reply.


Have you got the same source as me, that line you changed by editing doesn't exist either.
It might be worth downloading this code again.
I downloaded it this morning, unfortunately it is too long to post.

Go Up