diff --git a/examples/ThruFilterMap/ThruFilterMap.ino b/examples/ThruFilterMap/ThruFilterMap.ino index be04679..40c2f56 100644 --- a/examples/ThruFilterMap/ThruFilterMap.ino +++ b/examples/ThruFilterMap/ThruFilterMap.ino @@ -1,7 +1,5 @@ #include -using Message = midi::Message; - MIDI_CREATE_DEFAULT_INSTANCE(); /** @@ -17,7 +15,7 @@ MIDI_CREATE_DEFAULT_INSTANCE(); * allowing to use a keyboard to change patches on a MIDI device. */ -bool filter(const Message& message) +bool filter(const MIDIMessage& message) { if (message.type == midi::NoteOn) { @@ -27,10 +25,10 @@ bool filter(const Message& message) return false; } -Message map(const Message& message) +MIDIMessage map(const MIDIMessage& message) { // Make a copy of the message - Message output(message); + MIDIMessage output(message); if (message.type == midi::NoteOn) { output.type = midi::ProgramChange; diff --git a/src/serialMIDI.h b/src/serialMIDI.h index e69e9b2..f783439 100644 --- a/src/serialMIDI.h +++ b/src/serialMIDI.h @@ -52,7 +52,7 @@ public: public: static const bool thruActivated = true; - + void begin() { // Initialise the Serial port @@ -103,9 +103,12 @@ END_MIDI_NAMESPACE Example: MIDI_CREATE_INSTANCE(HardwareSerial, Serial2, midi2); Then call midi2.begin(), midi2.read() etc.. */ -#define MIDI_CREATE_INSTANCE(Type, SerialPort, Name) \ - MIDI_NAMESPACE::SerialMIDI serial##Name(SerialPort);\ - MIDI_NAMESPACE::MidiInterface> Name((MIDI_NAMESPACE::SerialMIDI&)serial##Name); +#define MIDI_CREATE_INSTANCE(Type, SerialPort, Name) \ + using Name##SerialTransport = MIDI_NAMESPACE::SerialMIDI; \ + using Name##Interface = MIDI_NAMESPACE::MidiInterface; \ + using Name##Message = Name##Interface::MidiMessage; \ + Name##SerialTransport serial##Name(SerialPort); \ + Name##Interface Name((Name##SerialTransport&)serial##Name); #if defined(ARDUINO_SAM_DUE) || defined(USBCON) || defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MKL26Z64__) // Leonardo, Due and other USB boards use Serial1 by default. @@ -125,6 +128,9 @@ END_MIDI_NAMESPACE @see DefaultSettings @see MIDI_CREATE_INSTANCE */ -#define MIDI_CREATE_CUSTOM_INSTANCE(Type, SerialPort, Name, Settings) \ - MIDI_NAMESPACE::SerialMIDI serial##Name(SerialPort);\ - MIDI_NAMESPACE::MidiInterface, Settings> Name((MIDI_NAMESPACE::SerialMIDI&)serial##Name); +#define MIDI_CREATE_CUSTOM_INSTANCE(Type, SerialPort, Name, Settings) \ + using Name##SerialTransport = MIDI_NAMESPACE::SerialMIDI; \ + using Name##Interface = MIDI_NAMESPACE::MidiInterface; \ + using Name##Message = Name##Interface::MidiMessage; \ + Name##SerialTransport serial##Name(SerialPort); \ + Name##Interface Name((Name##SerialTransport&)serial##Name);