Ich habe ein weiteres Update an der USB-MIDI-Dokumentationsseite vorgenommen , um einen Abschnitt „Empfangen großer systemexklusiver Nachrichten“ hinzuzufügen.
Well, changing the lines delayMicroseconds_WhileDiscardingInput(50000); to delayMicroseconds_WhileDiscardingInput(20000); to effectively wait 20ms after each message, did not improve the failure rate: 22 fails [truncated 3 bytes short] out of 6000 messages.I wait 20ms after each sent patch block !
After long tests, I have now also found errors when sending SysEx data from Teensy 4.1 to the PC
I sent SysEx data from Jeannie Midi-Out to M-Audio MIDISPORT2x2 Interface to PC. No errors detected.
Been playing with the sketch in MSG# 100 on a T3.6. Using a two year old Lenovo laptop, Win10 upgraded to 11, fresh IDE1.8.19 TD 1.58. No edits have been done on any library. Monitoring with Bomes.
After many button presses eventually do see Sysex messages with three bytes missing.
Uncommented usb_midi_flush_output(), same result as above.
Repeated with delayMicroseconds_WhileDiscardingInput(20000). Eventually Sysex messages pop up with three bytes missing.
Have had the T3.6 hang so Bomes displays no further input. Exit and Restart Bomes still no input, need to reboot T3.6.
//*****************************************************************
// Send SysEx data to usbMidi or MIDI 5pol (c) 6.2023
//*****************************************************************
#include <MIDI.h>
#include <usb_midi.h>
#include <Bounce2.h>
#define chunkSize 401
#define Blocknumbers 128
#define delayAmt 130 // about 3.0KB/s
#define buttonPin PIN_A3
const int ledPin = 13;
Bounce myButton = Bounce();
boolean startFlag = false;
byte data[chunkSize];
MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI); // MIDI 5pol
//***************************************************************
// init setup
//***************************************************************
void setup() {
MIDI.begin(); // MIDI 5pol
usbMIDI.begin(); // usbMIDI
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
myButton.attach(buttonPin);
myButton.interval(5); // 5ms zum Entprellen
fillBuff();
}
//****************************************************************
// fill buffer
//****************************************************************
void fillBuff() {
unsigned scratch;
// set Start and End Byte for SysEx
data[0] = 0xF0;
data[chunkSize - 1] = 0xF7;
// fill with data
for (uint16_t ct = 1; ct < (chunkSize-1); ct++) {
scratch = (ct & 0b01111111);
data[ct] = scratch;
}
}
//***************************************************************
// transmit SysEx data
//***************************************************************
void sendSysExData () {
usbMIDI.sendSysEx(chunkSize, data, true); // usbMidi
//MIDI.sendSysEx(chunkSize, data, true); // Midi 5pol Teensy 4.1 Pin 1 (TX1)
digitalWrite(ledPin, HIGH);
}
//**************************************************************
// loop
//**************************************************************
void loop() {
// press Key for transmit SysEx data
myButton.update();
if (myButton.fallingEdge()) {
startFlag = true;
}
// send SysEx Blocks
if (startFlag == true){
for (uint8_t i = 0; i < Blocknumbers; i++) {
sendSysExData();
delay(delayAmt);
}
startFlag = false;
digitalWrite(ledPin, LOW);
}
}
This is a test program for Teensy 4.1 to send 128 SysEx data blocks via usbMidi or Midi 5pol to the pc.
Number of blocks and waiting time between send a block can be changed.
All attempts with active usb_midi_flush_output() in USB.c file cause receive errors.
My synthesizers (DeepMind 6, Waldorf Blofeld) have usbMIDI transfer rate about 2.0-3.0 KB/s
Code://***************************************************************** // Send SysEx data to usbMidi or MIDI 5pol (c) 6.2023 //***************************************************************** #include <MIDI.h> #include <usb_midi.h> #include <Bounce2.h> #define chunkSize 401 #define Blocknumbers 128 #define delayAmt 130 // about 3.0KB/s #define buttonPin PIN_A3 const int ledPin = 13; Bounce myButton = Bounce(); boolean startFlag = false; byte data[chunkSize]; MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI); // MIDI 5pol //*************************************************************** // init setup //*************************************************************** void setup() { MIDI.begin(); // MIDI 5pol usbMIDI.begin(); // usbMIDI pinMode(ledPin, OUTPUT); pinMode(buttonPin, INPUT_PULLUP); myButton.attach(buttonPin); myButton.interval(5); // 5ms zum Entprellen fillBuff(); } //**************************************************************** // fill buffer //**************************************************************** void fillBuff() { unsigned scratch; // set Start and End Byte for SysEx data[0] = 0xF0; data[chunkSize - 1] = 0xF7; // fill with data for (uint16_t ct = 1; ct < (chunkSize-1); ct++) { scratch = (ct & 0b01111111); data[ct] = scratch; } } //*************************************************************** // transmit SysEx data //*************************************************************** void sendSysExData () { usbMIDI.sendSysEx(chunkSize, data, true); // usbMidi //MIDI.sendSysEx(chunkSize, data, true); // Midi 5pol Teensy 4.1 Pin 1 (TX1) digitalWrite(ledPin, HIGH); } //************************************************************** // loop //************************************************************** void loop() { // press Key for transmit SysEx data myButton.update(); if (myButton.fallingEdge()) { startFlag = true; } // send SysEx Blocks if (startFlag == true){ for (uint8_t i = 0; i < Blocknumbers; i++) { sendSysExData(); delay(delayAmt); } startFlag = false; digitalWrite(ledPin, LOW); } }
If flush_usb is commented out, there are no transmission errors. Even with very small waiting times (2ms very fast about 195 KB/s, 130 normal about 3.0 KB/s) between the SysEx blocks.
Greetings from germany. Rolf