I have tested the physical connectors on my breadboard for both serialmidi & serialmidi2 and they work. The RX1 pin on the Teensy is the only one that actually receives the input from serialmidi. When I send the TX1 pin to serialmidi2 out, there's nothing even though I set the RX & TX pins for Serial2. Here's the code:
#include <Control_Surface.h>
// Create two MIDI interfaces
USBMIDI_Interface usbmidi;
HardwareSerialMIDI_Interface serialmidi {Serial1, MIDI_BAUD};
HardwareSerialMIDI_Interface serialmidi2 {Serial2, MIDI_BAUD};
// Create a MIDI pipe factory to connect the MIDI interfaces to Control Surface
BidirectionalMIDI_PipeFactory<2> pipes;
// Custom MIDI callback that prints incoming messages.
struct MyMIDI_Callbacks : FineGrainedMIDI_Callbacks<MyMIDI_Callbacks> {
// Note how this ^ name is identical to the argument used here ^
void onNoteOff(Channel channel, uint8_t note, uint8_t velocity, Cable cable) {
Serial << "Note Off: " << channel << ", note " << note << ", velocity "
<< velocity << ", " << cable << endl;
}
void onNoteOn(Channel channel, uint8_t note, uint8_t velocity, Cable cable) {
Serial << "Note On: " << channel << ", note " << note << ", velocity "
<< velocity << ", " << cable << endl;
}
void onKeyPressure(Channel channel, uint8_t note, uint8_t pressure,
Cable cable) {
Serial << "Key Pressure: " << channel << ", note " << note << ", pressure "
<< pressure << ", " << cable << endl;
}
void onControlChange(Channel channel, uint8_t controller, uint8_t value,
Cable cable) {
Serial << "Control Change: " << channel << ", controller " << controller
<< ", value " << value << ", " << cable << endl;
}
void onProgramChange(Channel channel, uint8_t program, Cable cable) {
Serial << "Program Change: " << channel << ", program " << program << ", "
<< cable << endl;
}
void onChannelPressure(Channel channel, uint8_t pressure, Cable cable) {
Serial << "Channel Pressure: " << channel << ", pressure " << pressure
<< ", " << cable << endl;
}
void onPitchBend(Channel channel, uint16_t bend, Cable cable) {
Serial << "Pitch Bend: " << channel << ", bend " << bend << ", " << cable
<< endl;
}
} callback;
// Add some MIDI elements to show that the MIDI interfaces actually work
CCPotentiometer pot {A17, MIDI_CC::General_Purpose_Controller_1};
CCPotentiometer pot1 {A16, {0x12, CHANNEL_1}};
NoteLED led {LED_BUILTIN, 0x3C};
MIDI_Pipe passthrough;
void setup() {
Serial2.setRX(34);
Serial2.setTX(35);
Serial.begin(115200); // For printing the messages
// Manually connect the MIDI interfaces to Control Surface
Control_Surface | pipes | usbmidi; // Main communication between T4.1 and USB
serialmidi >> passthrough >> usbmidi;
usbmidi | pipes | serialmidi2;
usbmidi.setCallbacks(callback); // Attach the custom callback
serialmidi.setCallbacks(callback); // Attach the custom callback
serialmidi2.setCallbacks(callback); // Attach the custom callback
// Initialize Control Surface _after_ connecting the interfaces
Control_Surface.begin();
}
void loop() {
Control_Surface.loop();
}