From 08f6f53d129e8473f1bd14f097a3e4eea7eab21f Mon Sep 17 00:00:00 2001 From: Eric Sherman Date: Fri, 6 Aug 2021 03:10:36 -0400 Subject: [PATCH] makes changes requested in #232 discussion --- src/MIDI.h | 4 +--- src/MIDI.hpp | 16 ++++--------- test/unit-tests/tests/unit-tests_MidiThru.cpp | 24 ------------------- 3 files changed, 6 insertions(+), 38 deletions(-) diff --git a/src/MIDI.h b/src/MIDI.h index 86e2ccb..fb0ef06 100644 --- a/src/MIDI.h +++ b/src/MIDI.h @@ -236,8 +236,6 @@ private: // MIDI Soft Thru public: - inline bool getThruState() const; - using ThruFilterCallback = bool (*)(const MidiMessage& inMessage); using ThruMapCallback = MidiMessage (*)(const MidiMessage& inMessage); inline void turnThruOn(ThruFilterCallback fptr = thruOn); @@ -246,7 +244,7 @@ public: inline void setThruMap(ThruMapCallback fptr) { mThruMapCallback = fptr; } private: - void thruFilter(); + void processThru(); static inline bool thruOn(const MidiMessage& inMessage) { (void)inMessage; return true; } static inline bool thruOff(const MidiMessage& inMessage) { (void)inMessage; return false; } static inline MidiMessage thruEcho(const MidiMessage& inMessage) { return inMessage; } diff --git a/src/MIDI.hpp b/src/MIDI.hpp index 5af823a..50da225 100644 --- a/src/MIDI.hpp +++ b/src/MIDI.hpp @@ -769,7 +769,7 @@ inline bool MidiInterface::read(Channel inChannel if (channelMatch) launchCallback(); - thruFilter(); + processThru(); return channelMatch; } @@ -1341,12 +1341,6 @@ void MidiInterface::launchCallback() @{ */ -template -inline bool MidiInterface::getThruState() const -{ - return mThruFilterCallback != thruOff; -} - template inline void MidiInterface::turnThruOn(ThruFilterCallback fptr) { @@ -1375,7 +1369,7 @@ inline void MidiInterface::UpdateLastSentTime() // - Channel messages are passed to the output whether their channel // is matching the input channel and the filter setting template -void MidiInterface::thruFilter() +void MidiInterface::processThru() { if (!mThruFilterCallback(mMessage)) return; @@ -1383,7 +1377,7 @@ void MidiInterface::thruFilter() MidiMessage thruMessage = mThruMapCallback(mMessage); // First, check if the received message is Channel - if (mMessage.type >= NoteOff && mMessage.type <= PitchBend) + if (thruMessage.type >= NoteOff && thruMessage.type <= PitchBend) { send(thruMessage.type, thruMessage.data1, @@ -1393,7 +1387,7 @@ void MidiInterface::thruFilter() else { // Send the message to the output - switch (mMessage.type) + switch (thruMessage.type) { // Real Time and 1 byte case Clock: @@ -1403,7 +1397,7 @@ void MidiInterface::thruFilter() case ActiveSensing: case SystemReset: case TuneRequest: - sendRealTime(mMessage.type); + sendRealTime(thruMessage.type); break; case SystemExclusive: diff --git a/test/unit-tests/tests/unit-tests_MidiThru.cpp b/test/unit-tests/tests/unit-tests_MidiThru.cpp index 27319a7..b89c262 100644 --- a/test/unit-tests/tests/unit-tests_MidiThru.cpp +++ b/test/unit-tests/tests/unit-tests_MidiThru.cpp @@ -59,30 +59,6 @@ MidiMessage thruMapNoteOnFullVelocity(const MidiMessage& inMessage) // ----------------------------------------------------------------------------- -TEST(MidiThru, defaultValues) -{ - EXPECT_EQ(midi.getThruState(), true); - midi.begin(); // Should not change the state - EXPECT_EQ(midi.getThruState(), true); -} - -TEST(MidiThru, beginEnablesThru) -{ - midi.turnThruOff(); - EXPECT_EQ(midi.getThruState(), false); - midi.begin(); - EXPECT_EQ(midi.getThruState(), true); -} - -TEST(MidiThru, setGet) -{ - midi.turnThruOff(); - EXPECT_EQ(midi.getThruState(), false); - - midi.turnThruOn(); - EXPECT_EQ(midi.getThruState(), true); -} - TEST(MidiThru, off) { midi.begin(MIDI_CHANNEL_OMNI);