Serial <--> MIDI not always same result

My MIDI footcontroller is not working as i wanted.
Some times it seems ok, but something is wrong. I tried using it with Ableton Live. I can assign the buttons without problems, but then when i try to use it sometimes it seems that there are diferent messages being sent, or that the message in not really 100% sent.
Ex: i wanted to use the looper and when i press a button it “unpresses” after a couple of seconds, like if another message was sent to undo it! When i use exactly the same setup, but using the pedal from my digital piano, then everything works fine.

I can’t find what is going on so I have tried debugging in two diferent ways, and got two very diferent results:
1) using the serial to MIDI converter from SpikenzieLabs (and Processing).
I run the sketch and select the right options and then check what i am getting with the MIDI Monitor. For a button click i get:

TIME            SOURCE		MESSAGE         CHAN    DATA
*** ZERO ***	From Xilof OUT	Note On	1	F#-1	127

It seems ok to me...

2) with the HAIRLESS MIDI SERIAL
when i click the same button i get:

+11.657 - Serial In: Ch 1: Controller 10 value %3
+11.657 - Serial In: Ch 1: Note 18 on  velocity 127
+11.657 - MIDI In: Ch 1: Controller 32 value 83
+11.657 - MIDI In: Ch 1: Controller 72 value 79
+11.657 - MIDI In: Ch 1: Controller 82 value 84
+11.657 - MIDI In: Ch 1: Controller 33 value 13
+11.657 - MIDI In: Ch 1: Controller 10 value 13
+11.658 - MIDI In: Ch 1: Note 18 on  velocity 127

i have used the correct BAUD RATE, but I’m unsure about the other settings:
Data Bits: 8
Parity: None
Stop Bits:1
Flow Controll: None

I am sending my midi messages like this:

unsigned char notesMode1[8] = {12,14,16,17,18,19,21,22}; // from C0 to B0
.
.
.
if button is pressed {
   noteOn(0x90, notesMode1[buttonCount], 127)
}
.
.
.
void noteOn (int cmd, int pitch, int vel){
  Serial.write(cmd);
  Serial.write(pitch);
  Serial.write(vel);
} // end void noteOn

i think this are the relevant parts of the code...

Why is it getting so many messages? Can this be the reason why it works in such a strange way with Ableton?
This (note number 18) would be equal to a F# in Octave 0, right?
But the Midi Monitor tells me that it’s getting a F# in Octave -1.

I am also sending some Pot values and they are working without problem.

Hmmm, what a mess. Any help or ideas would be more than welcome!
Thank you!

Instead of send the midi messages out the serial port, try printing them out to the serial monitor of the arduino. This will eliminate the comms line and beyond as a source of errors. If the messages are right at that pint, then you know where to look. If they are not right, then it is all in the Arduino code ...

Good idea!

so i changed my code to:

void noteOn (int cmd, int pitch, int vel){
  Serial.print("  cmd: ");
  Serial.println(cmd);
  Serial.print("pitch: " );
  Serial.println(pitch);
  Serial.print("  vel: ");
  Serial.println(vel);
  Serial.println("= = = = = = = = =");
} // end void noteOn

and here is the print i got when i clicked the same button:

  cmd: 144
pitch: 18
  vel: 127
= = = = = = = = =

So it seams to me that the right message is being sent: Note On, note 18 (F#,octave0), 127 velocity.

This means something is going on with the conversion, right?
I have used the SpikenzieLabs converter in the past, and it always worked fine. But this was the first time using the Hairless MIDI SERIAL.
Does anyone have any experiences with it?

Thanks!

Have you considerd contact bounce on your foot switch?

Contact bounce could be an issue but I would expect you see multiple messages in the printing.

I don't have any experience with your computer based software, so can't help there.

no, i hadn't, :roll_eyes: but that may be a good idea.

But i would imagine with bounce something would happen very fast, like several signals, or a crazy signal being sent really fast, almost imediately after the "original" click (maybe < 50ms?)
What i am getting in Ableton is taking some time, maybe around 1.5~2 seconds.
Both in the Serial Monitor and in the MIDI Monitor (after converting with the SpikenzieLabs converter) i am getting "clean" results. only one message per click...

I don't know if this makes any difference, but i am using (good quality) Arcade Buttons and 10k Pull-up resistors. I am also sending the messages on Button Release (so i can have short and long clicks).

Is there a way to test the contact bounce?

i have tried it with Baud Rate 115200 and everything works fine. I have no idea why this is, but as i don't need to plug the foot controller to any other MIDI devices (just the computer), so i guess i will just leave it at 115200...

Thank you!
8)