recursinging
Well-known member
I have been trying to get USB MIDI and OSC over SLIP encoded serial to play nicely together using the standard https://github.com/CNMAT/OSC library with its included SLIPEncodedUSBSerial class.
There is a guard in place to prevent it from being compiled with any build flag other than USB_SERIAL - which it turns out is quite appropriate because it seems if this is removed, Either MIDI or OSC will work fine, but not both at the same time. Here is an little example program:
When the CMNAT OSC lib is modified to compile with the USB_MIDI_SERIAL build flag, my Teensy 3.6 will successfully inundate the connected PC with either OSC or MIDI messages as fast as they can be generated, given one of the two send* methods is removed. Both methods invoked together as with the example cause the Teensy to freeze after a small number of messages from both protocols. Leading me to believe there is some shared buffer being exhausted here.
Perhaps someone with better insight into the inner working of the USB serial and MIDI interfaces could shed a little light on this, Perhaps there is a way to work around it? I'd like to transport both protocols over the USB cable if possible.
There is a guard in place to prevent it from being compiled with any build flag other than USB_SERIAL - which it turns out is quite appropriate because it seems if this is removed, Either MIDI or OSC will work fine, but not both at the same time. Here is an little example program:
Code:
#include <Arduino.h>
#include <SLIPEncodedUSBSerial.h>
#include <OSCMessage.h>
SLIPEncodedUSBSerial SLIPSerial(Serial);
void sendMIDIMessage() {
usbMIDI.sendControlChange(10,10,10);
}
void sendOSCMessage() {
OSCMessage msg("/foo");
msg.add("bar");
SLIPSerial.beginPacket();
msg.send(SLIPSerial);
SLIPSerial.endPacket();
msg.empty();
}
void setup() {
SLIPSerial.begin(115200);
}
void loop() {
sendMIDIMessage();
sendOSCMessage();
}
When the CMNAT OSC lib is modified to compile with the USB_MIDI_SERIAL build flag, my Teensy 3.6 will successfully inundate the connected PC with either OSC or MIDI messages as fast as they can be generated, given one of the two send* methods is removed. Both methods invoked together as with the example cause the Teensy to freeze after a small number of messages from both protocols. Leading me to believe there is some shared buffer being exhausted here.
Perhaps someone with better insight into the inner working of the USB serial and MIDI interfaces could shed a little light on this, Perhaps there is a way to work around it? I'd like to transport both protocols over the USB cable if possible.