Skip to content

Commit 1fe67be

Browse files
hyperbolistfranky47
authored andcommitted
makes changes requested in #232 discussion
1 parent a6c3a48 commit 1fe67be

File tree

3 files changed

+7
-39
lines changed

3 files changed

+7
-39
lines changed

src/MIDI.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,6 @@ class MidiInterface
236236
// MIDI Soft Thru
237237

238238
public:
239-
inline bool getThruState() const;
240-
241239
using ThruFilterCallback = bool (*)(const MidiMessage& inMessage);
242240
using ThruMapCallback = MidiMessage (*)(const MidiMessage& inMessage);
243241
inline MidiInterface& turnThruOn(ThruFilterCallback fptr = thruOn);
@@ -254,7 +252,7 @@ class MidiInterface
254252
}
255253

256254
private:
257-
void thruFilter();
255+
void processThru();
258256
static inline bool thruOn(const MidiMessage& inMessage) { (void)inMessage; return true; }
259257
static inline bool thruOff(const MidiMessage& inMessage) { (void)inMessage; return false; }
260258
static inline MidiMessage thruEcho(const MidiMessage& inMessage) { return inMessage; }

src/MIDI.hpp

+6-12
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ inline bool MidiInterface<Transport, Settings, Platform>::read(Channel inChannel
816816
if (channelMatch)
817817
launchCallback();
818818

819-
thruFilter();
819+
processThru();
820820

821821
return channelMatch;
822822
}
@@ -1397,13 +1397,7 @@ void MidiInterface<Transport, Settings, Platform>::launchCallback()
13971397
*/
13981398

13991399
template<class Transport, class Settings, class Platform>
1400-
inline bool MidiInterface<Transport, Settings, Platform>::getThruState() const
1401-
{
1402-
return mThruFilterCallback != thruOff;
1403-
}
1404-
1405-
template<class Transport, class Settings, class Platform>
1406-
inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Settings, Platform>::turnThruOn(ThruFilterCallback fptr)
1400+
inline void MidiInterface<Transport, Settings, Platform>::turnThruOn(ThruFilterCallback fptr)
14071401
{
14081402
mThruFilterCallback = fptr;
14091403
return *this;
@@ -1425,15 +1419,15 @@ inline MidiInterface<Transport, Settings, Platform>& MidiInterface<Transport, Se
14251419
// - Channel messages are passed to the output whether their channel
14261420
// is matching the input channel and the filter setting
14271421
template<class Transport, class Settings, class Platform>
1428-
void MidiInterface<Transport, Settings, Platform>::thruFilter()
1422+
void MidiInterface<Transport, Settings, Platform>::processThru()
14291423
{
14301424
if (!mThruFilterCallback(mMessage))
14311425
return;
14321426

14331427
MidiMessage thruMessage = mThruMapCallback(mMessage);
14341428

14351429
// First, check if the received message is Channel
1436-
if (mMessage.type >= NoteOff && mMessage.type <= PitchBend)
1430+
if (thruMessage.type >= NoteOff && thruMessage.type <= PitchBend)
14371431
{
14381432
send(thruMessage.type,
14391433
thruMessage.data1,
@@ -1443,7 +1437,7 @@ void MidiInterface<Transport, Settings, Platform>::thruFilter()
14431437
else
14441438
{
14451439
// Send the message to the output
1446-
switch (mMessage.type)
1440+
switch (thruMessage.type)
14471441
{
14481442
// Real Time and 1 byte
14491443
case Clock:
@@ -1453,7 +1447,7 @@ void MidiInterface<Transport, Settings, Platform>::thruFilter()
14531447
case ActiveSensing:
14541448
case SystemReset:
14551449
case TuneRequest:
1456-
sendRealTime(mMessage.type);
1450+
sendRealTime(thruMessage.type);
14571451
break;
14581452

14591453
case SystemExclusive:

test/unit-tests/tests/unit-tests_MidiThru.cpp

-24
Original file line numberDiff line numberDiff line change
@@ -59,30 +59,6 @@ MidiMessage thruMapNoteOnFullVelocity(const MidiMessage& inMessage)
5959

6060
// -----------------------------------------------------------------------------
6161

62-
TEST(MidiThru, defaultValues)
63-
{
64-
EXPECT_EQ(midi.getThruState(), true);
65-
midi.begin(); // Should not change the state
66-
EXPECT_EQ(midi.getThruState(), true);
67-
}
68-
69-
TEST(MidiThru, beginEnablesThru)
70-
{
71-
midi.turnThruOff();
72-
EXPECT_EQ(midi.getThruState(), false);
73-
midi.begin();
74-
EXPECT_EQ(midi.getThruState(), true);
75-
}
76-
77-
TEST(MidiThru, setGet)
78-
{
79-
midi.turnThruOff();
80-
EXPECT_EQ(midi.getThruState(), false);
81-
82-
midi.turnThruOn();
83-
EXPECT_EQ(midi.getThruState(), true);
84-
}
85-
8662
TEST(MidiThru, off)
8763
{
8864
midi.begin(MIDI_CHANNEL_OMNI);

0 commit comments

Comments
 (0)