Skip to content

Commit 08f6f53

Browse files
committed
makes changes requested in #232 discussion
1 parent 0020607 commit 08f6f53

File tree

3 files changed

+6
-38
lines changed

3 files changed

+6
-38
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 void turnThruOn(ThruFilterCallback fptr = thruOn);
@@ -246,7 +244,7 @@ class MidiInterface
246244
inline void setThruMap(ThruMapCallback fptr) { mThruMapCallback = fptr; }
247245

248246
private:
249-
void thruFilter();
247+
void processThru();
250248
static inline bool thruOn(const MidiMessage& inMessage) { (void)inMessage; return true; }
251249
static inline bool thruOff(const MidiMessage& inMessage) { (void)inMessage; return false; }
252250
static inline MidiMessage thruEcho(const MidiMessage& inMessage) { return inMessage; }

src/MIDI.hpp

+5-11
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ inline bool MidiInterface<Transport, Settings, Platform>::read(Channel inChannel
769769
if (channelMatch)
770770
launchCallback();
771771

772-
thruFilter();
772+
processThru();
773773

774774
return channelMatch;
775775
}
@@ -1341,12 +1341,6 @@ void MidiInterface<Transport, Settings, Platform>::launchCallback()
13411341
@{
13421342
*/
13431343

1344-
template<class Transport, class Settings, class Platform>
1345-
inline bool MidiInterface<Transport, Settings, Platform>::getThruState() const
1346-
{
1347-
return mThruFilterCallback != thruOff;
1348-
}
1349-
13501344
template<class Transport, class Settings, class Platform>
13511345
inline void MidiInterface<Transport, Settings, Platform>::turnThruOn(ThruFilterCallback fptr)
13521346
{
@@ -1375,15 +1369,15 @@ inline void MidiInterface<Transport, Settings, Platform>::UpdateLastSentTime()
13751369
// - Channel messages are passed to the output whether their channel
13761370
// is matching the input channel and the filter setting
13771371
template<class Transport, class Settings, class Platform>
1378-
void MidiInterface<Transport, Settings, Platform>::thruFilter()
1372+
void MidiInterface<Transport, Settings, Platform>::processThru()
13791373
{
13801374
if (!mThruFilterCallback(mMessage))
13811375
return;
13821376

13831377
MidiMessage thruMessage = mThruMapCallback(mMessage);
13841378

13851379
// First, check if the received message is Channel
1386-
if (mMessage.type >= NoteOff && mMessage.type <= PitchBend)
1380+
if (thruMessage.type >= NoteOff && thruMessage.type <= PitchBend)
13871381
{
13881382
send(thruMessage.type,
13891383
thruMessage.data1,
@@ -1393,7 +1387,7 @@ void MidiInterface<Transport, Settings, Platform>::thruFilter()
13931387
else
13941388
{
13951389
// Send the message to the output
1396-
switch (mMessage.type)
1390+
switch (thruMessage.type)
13971391
{
13981392
// Real Time and 1 byte
13991393
case Clock:
@@ -1403,7 +1397,7 @@ void MidiInterface<Transport, Settings, Platform>::thruFilter()
14031397
case ActiveSensing:
14041398
case SystemReset:
14051399
case TuneRequest:
1406-
sendRealTime(mMessage.type);
1400+
sendRealTime(thruMessage.type);
14071401
break;
14081402

14091403
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)