garubi
Well-known member
The context:
In my MIDI Drawbar controller based on Teensy LC I use both usbMIDI and serial MIDI (i.e MIDI IN and OUT with DIN plugs).
The whole thing is configured so it can accept MIDI messages from both the IN (usb and serial), merges them with those generated by itself as a controller, then output them to both OUTs (usb and serial).
The issue:
While serial MIDI IN to serial MIDI out doesn't have any problem, when I try serial IN to usbOUT i get any sort of random MIDI messages and values.
I really can't understand what's wrong with the thru/merge implementation: I more or less derived it from the "Interface_3x3" example (obviously reduced to 1x1).
Here is a stripped down script that only merges and forward messages from serial IN to usb and that can be used to reproduce the problem, just open a midi monitor that reads the usbMIDI and try some note on note off or CC...
I'm really confused because, looking at the Arduino's Serial monitor output, looks like the serial MIDI IN Type is just wrong before being used by usbMIDI, but on the other way it just can't be wrong since it is sent right to the serial MIDI OUT (this thru part is handled directly by the MIDI library)...
Note that if I just output data generated by the controller to usbMIDI I've got no errors at all.
Technical info:
Libraries used in my sketch: (don't think they matter since even the super-stripped-down sketch abve shows the problem...)
Any suggestion is appreciated!
Thank you
Stefano
In my MIDI Drawbar controller based on Teensy LC I use both usbMIDI and serial MIDI (i.e MIDI IN and OUT with DIN plugs).
The whole thing is configured so it can accept MIDI messages from both the IN (usb and serial), merges them with those generated by itself as a controller, then output them to both OUTs (usb and serial).
- link to the project summary (where are the schematics too): https://hackaday.io/project/162255-midi-drawbars-commander
- link to the full source code: https://github.com/garubi/MIDI-Drawbars-Commander
The issue:
While serial MIDI IN to serial MIDI out doesn't have any problem, when I try serial IN to usbOUT i get any sort of random MIDI messages and values.
I really can't understand what's wrong with the thru/merge implementation: I more or less derived it from the "Interface_3x3" example (obviously reduced to 1x1).
Here is a stripped down script that only merges and forward messages from serial IN to usb and that can be used to reproduce the problem, just open a midi monitor that reads the usbMIDI and try some note on note off or CC...
Code:
#include <MIDI.h>
// Create the Serial MIDI ports
MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI1);
// A variable to know how long the LED has been turned on
elapsedMillis ledOnMillis;
void setup() {
Serial.begin(115200);
pinMode(13, OUTPUT); // LED pin
digitalWrite(13, LOW);
MIDI1.begin(MIDI_CHANNEL_OMNI);
}
void loop() {
bool activity = false;
if (MIDI1.read()) {
// get a MIDI IN1 (Serial) message
byte type = MIDI1.getType();
byte channel = MIDI1.getChannel();
byte data1 = MIDI1.getData1();
byte data2 = MIDI1.getData2();
Serial.println(type, HEX);
Serial.println(channel, HEX);
Serial.println(data1, HEX);
Serial.println(data2, HEX);
Serial.println("---------------");
// forward the message to USB MIDI virtual cable #0
if (type != midi::SystemExclusive) {
// Normal messages, simply give the data to the usbMIDI.send()
usbMIDI.send(type, data1, data2, channel, 0);
} else {
// SysEx messages are special. The message length is given in data1 & data2
unsigned int SysExLength = data1 + data2 * 256;
usbMIDI.sendSysEx(SysExLength, MIDI1.getSysExArray(), true, 0);
}
activity = true;
}
// blink the LED when any activity has happened
if (activity) {
digitalWriteFast(13, HIGH); // LED on
ledOnMillis = 0;
}
if (ledOnMillis > 15) {
digitalWriteFast(13, LOW); // LED off
}
}
I'm really confused because, looking at the Arduino's Serial monitor output, looks like the serial MIDI IN Type is just wrong before being used by usbMIDI, but on the other way it just can't be wrong since it is sent right to the serial MIDI OUT (this thru part is handled directly by the MIDI library)...
Note that if I just output data generated by the controller to usbMIDI I've got no errors at all.
Technical info:
- Teensy LC
- Arduino ver 1.8.7 on Windows 10
- Teensyduino ver 1.44
Libraries used in my sketch: (don't think they matter since even the super-stripped-down sketch abve shows the problem...)
- #include <Wire.h>
- #include <Adafruit_MCP23017.h>
- #include <Bounce2.h>
- #include <MIDI.h>
- #include <ResponsiveAnalogRead.h>
Any suggestion is appreciated!
Thank you
Stefano