Daft MIDI problems


I am a total newb so please excuse how pathetic this is.

I’ve been trying to test sending MIDI data from an arduino via the serial port. I’m using MIDI yoke and a serial-midi converter to send the data to some other software (in this case Anvil Studio). Sending a note on and a note off message works but the following code does not:

#include <MIDI.h>

void setup() {
MIDI.begin(4); // Launch MIDI with default options
Serial.begin(57600); // input channel is set to 4

void loop() {

MIDI.sendNoteOn(42,127,1); // Send a Note
MIDI.sendNoteOn(45, 127, 1);
delay(1000); // Wait for a second
MIDI.sendNoteOff(45,0,1); // Stop the note


The first note is received, played and stopped. The second note (pitch 45) is not received at all. I should be able to send two notes down the same channel (practically) simultaneously, right? Any obvious mistakes? What else might be causing this?

Just a thought but as you are sending at 57600 bauds maybe a buffer is getting full somewhere along the line. What happens if you put a small delay between the two note on calls?

You could also try setting the baud rate to 38400 to see if that helps.


I’ve tried using a different baud rates. I set the new baud rates in my code, in the serial-midi converter and by changing the port properties in windows device manager. I tried a half-second delay between the sendNoteOn/Off messages. Still no joy. I’ve spent quite a lot of time rifling erratically through the internet but I’m really not sure what to look for.

I’m using Midi Yoke 1.75, the serial-midi converter from http://www.spikenzielabs.com, Windows Vista…

What other information might be useful for anyone trying to help me?

Another wild guess. I notice in the code for the midi library that if you send two or more commands of the same type in a row it doesn't repeat the command byte each time. This is part of the Midi spec but perhaps your midi device (or Midi-Yoke?) doesn't handle it properly. See if this works:

void loop() {

    MIDI.sendNoteOn(42,127,1);  // Send a Note
    MIDI.sendNoteOff(45,0, 1);
    MIDI.sendNoteOn(45, 127, 1);
    delay(1000);      // Wait for a second
    MIDI.sendNoteOff(45,0,1);   // Stop the note


This may not change anything at all. But if it sort of works, what will happen is that both notes will sound and then note 42 will go off but 45 might stay on.

You should also try changing each sendNoteOff to a sendNoteOn with a velocity of zero. Apparently, some devices don't even respond to NoteOff. Pete

I would search for a MIDI monitor program for your OS. These receive or spy on MIDI messages and display them so you can see exactly what is being sent. That will show if you are suffering from a "running status" problem.

You got it el supremo. The problem was indeed with sending multiple messages of the same type.

In the future, I'll have to consider the firmware switching option or a small hardware change to cut out Midi Yoke.

For now though, I'm sure I can just send a useless message after every important one and get on with playing with the Arduino.

Thanks to all who helped.

If you don't mind meddling with the library, I can attach a version of midi.cpp which doesn't do that. It's an easy change.


That would be great. Is it just a case of replacing the existing file with the new one?

Yep, make a backup copy of the existing file first. Rename it to something like midi_original.xcpp so that the IDE won’t try to use it. Then replace it with the attached file.


MIDI.cpp (11.9 KB)