Skip to content

Commit

Permalink
Update CustomBaudRate.ino
Browse files Browse the repository at this point in the history
override DefaultSerialSettings to override BaudRate (and not DefaultSettings )
  • Loading branch information
lathoub authored Jan 11, 2022
1 parent 7c0d716 commit 2d64cc3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions examples/CustomBaudRate/CustomBaudRate.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

// Override the default MIDI baudrate to
// a decoding program such as Hairless MIDI (set baudrate to 115200)

struct CustomBaudRate : public MIDI_NAMESPACE::DefaultSettings {
struct CustomBaudRateSettings : public MIDI_NAMESPACE::DefaultSerialSettings {
static const long BaudRate = 115200;
};

#if defined(ARDUINO_SAM_DUE) || defined(USBCON) || defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MKL26Z64__)
// Leonardo, Due and other USB boards use Serial1 by default.
MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial1, MIDI, CustomBaudRate);
MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings> serialMIDI(Serial1);
MIDI_NAMESPACE::MidiInterface<MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings>> MIDI((MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings>&)serialMIDI);
#else
MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial, MIDI, CustomBaudRate);
MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings> serialMIDI(Serial);
MIDI_NAMESPACE::MidiInterface<MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings>> MIDI((MIDI_NAMESPACE::SerialMIDI<HardwareSerial, CustomBaudRateSettings>&)serialMIDI);
#endif

void setup() {
Expand All @@ -28,4 +29,4 @@ void loop() {
MIDI.sendNoteOff(42, 0, 1); // Stop the note
digitalWrite(LED_BUILTIN, LOW);
}
}
}

0 comments on commit 2d64cc3

Please sign in to comment.