Sandwich
Member
Hey there!
I'm having trouble making software serial MIDI connections. I have everything wired up and it works flawlessly on true Serial1-SerialX pins, but when I try to implement the software ones I'm not getting anything. Using my setup (with USB set to MIDI in the arduino sketch upload) I'm able to monitor MIDI commands over the USB jack as well as with equipment on the outbound DIN ports. And both USB and DIN ports work fine and communicate all directions when all connections are hardware serial, but no data seems to be getting transferred over software serial at all. I've stripped down the sketch to be pretty basic at this point trying to troubleshoot the issue:
Thanks for any help!
I'm having trouble making software serial MIDI connections. I have everything wired up and it works flawlessly on true Serial1-SerialX pins, but when I try to implement the software ones I'm not getting anything. Using my setup (with USB set to MIDI in the arduino sketch upload) I'm able to monitor MIDI commands over the USB jack as well as with equipment on the outbound DIN ports. And both USB and DIN ports work fine and communicate all directions when all connections are hardware serial, but no data seems to be getting transferred over software serial at all. I've stripped down the sketch to be pretty basic at this point trying to troubleshoot the issue:
Code:
#include <Arduino.h>
#include <MIDI.h>
#include <USBHost_t36.h> // access to USB MIDI devices (plugged into 2nd USB port)
#include <SoftwareSerial.h>
//pins for software bit-banged MIDI DIM ports
SoftwareSerial softSerial1(4, 5); //rx, tx
// Create the Serial MIDI ports
MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI1);
MIDI_CREATE_INSTANCE(SoftwareSerial, softSerial1, MIDI2);
void setup() {
//Serial.begin(115200); //for serial connection over usb to PC
//initialize DIN connectors
MIDI1.begin(MIDI_CHANNEL_OMNI);
MIDI2.begin(MIDI_CHANNEL_OMNI);
}
void loop() {
if (MIDI1.read()) {
sendMIDI(MIDI1.getType(), MIDI1.getChannel(), MIDI1.getData1(), MIDI1.getData2(), MIDI1.getSysExArray());
}
if (MIDI2.read()) {
sendMIDI(MIDI2.getType(), MIDI2.getChannel(), MIDI2.getData1(), MIDI2.getData2(), MIDI2.getSysExArray());
}
if (usbMIDI.read()) {
sendMIDI(usbMIDI.getType(), usbMIDI.getChannel(), usbMIDI.getData1(), usbMIDI.getData2(), usbMIDI.getSysExArray()); //usbMIDI.getCable());
}
}
// When messages are received, this function sends the message to all the devices
void sendMIDI(byte type, byte channel, byte data1, byte data2, const uint8_t *sysexarray) {
if (type != midi::SystemExclusive) {
midi::MidiType mtype = (midi::MidiType)type;
// Normal messages, simply give the data to the usbMIDI.send()
MIDI1.send(mtype, data1, data2, channel);
MIDI2.send(mtype, data1, data2, channel);
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;
MIDI1.sendSysEx(SysExLength, sysexarray, true);
MIDI2.sendSysEx(SysExLength, sysexarray, true);
usbMIDI.sendSysEx(SysExLength, sysexarray, true, 0);
}
usbMIDI.send_now();
}
Thanks for any help!