lathoub / Arduino-USBMIDI

Allows a microcontroller, with native USB capabilities, to appear as a MIDI device over USB to a connected computer
MIT License
148 stars 11 forks source link

MIDI.sendRealTime seems not working properly over USB #16

Open LinkeHand opened 2 years ago

LinkeHand commented 2 years ago

I installed the example code "AllEvents" on my Arduino Leonardo.

Most time, I do not get the Midi-NoteOn-Message from this example on my USB-Port. I Checked it with midi-ox unter windows 10 and even unter Ubuntu. It seems that sending a MIDI-SendRealTime message like "MIDI.sendRealTime(MidiType::Clock);" corrupts a following Midi-Message most times. I disabled the output on serial port an still got this error. I changed the MIDI-sendRealTime - Message from "Clock" to "Start". I get still this error.
I added a second MIDI-sendRealTime-Message in the example code. I only see the first MIDI.sendRealTime-Message in midi-ox.

I don't have a clue.

Regards Bernd

LinkeHand commented 2 years ago

Supplement: I reduced the example code AllEvents to this:

include

USBMIDI_CREATE_DEFAULT_INSTANCE();

unsigned long t0 = millis(); unsigned long tClock = millis();

using namespace MIDI_NAMESPACE;

// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void setup() {

}

// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void loop() {

// send a note every second // (dont cáll delay(1000) as it will stall the pipeline) if ((millis() - t0) > 1000) { t0 = millis();

byte note = random(1, 127);
byte velocity = 55;
byte channel = 1;

MIDI.sendNoteOn(note, velocity, channel);
MIDI.sendNoteOff(note, velocity, channel);

}

if ((millis() - tClock) > 100) { tClock = millis(); MIDI.sendRealTime(MidiType::Clock); } }

And here a a few lines out of my log in midi-ox:

00007BE4 5 -- F8 -- -- -- --- Timing Clock
00007C16 5 -- F8 -- -- -- --- Timing Clock
00007C36 5 -- F8 -- -- -- --- Timing Clock
00007C5A 5 -- F8 -- -- -- --- Timing Clock
00007C62 5 -- 80 0F 37 1 Eb 0 Note Off
00007C76 5 -- F8 -- -- -- --- Timing Clock
00007CA7 5 -- F8 -- -- -- --- Timing Clock
00007CD4 5 -- F8 -- -- -- --- Timing Clock
00007CF9 5 -- F8 -- -- -- --- Timing Clock
00007D2A 5 -- F8 -- -- -- --- Timing Clock

The complete log is here

Arduino-midi.log

regards Bernd