Skip to content

Instantly share code, notes, and snippets.

@2xAA
Last active October 5, 2021 21:22
Show Gist options
  • Save 2xAA/0440c78915707a7a6e914106ba1aaa1c to your computer and use it in GitHub Desktop.
Save 2xAA/0440c78915707a7a6e914106ba1aaa1c to your computer and use it in GitHub Desktop.
Alternate firmware for genMDM devices to work as a Port 2 Serial cable for rhargreaves/mega-drive-midi-interface without Hairless MIDI Bridge
#include <SoftwareSerial.h>
#include "MIDIUSB.h"
SoftwareSerial softSerial(11, 2);
byte incomingDinMidiMessage[3];
byte incomingUsbMidiMessage[3];
void setup() {
Serial1.begin(31250);
softSerial.begin(4800);
}
void sendBytes(byte message[]) {
softSerial.write(message, 3);
}
void loop() {
if (Serial1.available()) {
Serial1.readBytes(incomingDinMidiMessage, 3);
sendBytes(incomingDinMidiMessage);
}
midiEventPacket_t rx;
do {
rx = MidiUSB.read();
if (rx.header != 0) {
incomingUsbMidiMessage[0] = rx.byte1;
incomingUsbMidiMessage[1] = rx.byte2;
incomingUsbMidiMessage[2] = rx.byte3;
sendBytes(incomingUsbMidiMessage);
}
} while (rx.header != 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment