@@ -40,8 +40,6 @@ inline MidiInterface<Transport, Settings, Platform>::MidiInterface(Transport& in
40
40
, mPendingMessageIndex (0 )
41
41
, mCurrentRpnNumber (0xffff )
42
42
, mCurrentNrpnNumber (0xffff )
43
- , mThruActivated (true )
44
- , mThruFilterMode (Thru::Full)
45
43
, mLastMessageSentTime (0 )
46
44
, mLastMessageReceivedTime (0 )
47
45
, mSenderActiveSensingPeriodicity (0 )
@@ -93,8 +91,8 @@ void MidiInterface<Transport, Settings, Platform>::begin(Channel inChannel)
93
91
mMessage .data2 = 0 ;
94
92
mMessage .length = 0 ;
95
93
96
- mThruFilterMode = Thru::Full ;
97
- mThruActivated = mTransport . thruActivated ;
94
+ mThruFilterCallback = thruOn ;
95
+ mThruMapCallback = thruEcho ;
98
96
}
99
97
100
98
// -----------------------------------------------------------------------------
@@ -771,7 +769,7 @@ inline bool MidiInterface<Transport, Settings, Platform>::read(Channel inChannel
771
769
if (channelMatch)
772
770
launchCallback ();
773
771
774
- thruFilter (inChannel );
772
+ thruFilter ();
775
773
776
774
return channelMatch;
777
775
}
@@ -1343,42 +1341,22 @@ void MidiInterface<Transport, Settings, Platform>::launchCallback()
1343
1341
@{
1344
1342
*/
1345
1343
1346
- /* ! \brief Set the filter for thru mirroring
1347
- \param inThruFilterMode a filter mode
1348
-
1349
- @see Thru::Mode
1350
- */
1351
- template <class Transport , class Settings , class Platform >
1352
- inline void MidiInterface<Transport, Settings, Platform>::setThruFilterMode(Thru::Mode inThruFilterMode)
1353
- {
1354
- mThruFilterMode = inThruFilterMode;
1355
- mThruActivated = mThruFilterMode != Thru::Off;
1356
- }
1357
-
1358
- template <class Transport , class Settings , class Platform >
1359
- inline Thru::Mode MidiInterface<Transport, Settings, Platform>::getFilterMode() const
1360
- {
1361
- return mThruFilterMode ;
1362
- }
1363
-
1364
1344
template <class Transport , class Settings , class Platform >
1365
1345
inline bool MidiInterface<Transport, Settings, Platform>::getThruState() const
1366
1346
{
1367
- return mThruActivated ;
1347
+ return mThruFilterCallback != thruOff ;
1368
1348
}
1369
1349
1370
1350
template <class Transport , class Settings , class Platform >
1371
- inline void MidiInterface<Transport, Settings, Platform>::turnThruOn(Thru::Mode inThruFilterMode )
1351
+ inline void MidiInterface<Transport, Settings, Platform>::turnThruOn(ThruFilterCallback fptr )
1372
1352
{
1373
- mThruActivated = true ;
1374
- mThruFilterMode = inThruFilterMode;
1353
+ mThruFilterCallback = fptr;
1375
1354
}
1376
1355
1377
1356
template <class Transport , class Settings , class Platform >
1378
1357
inline void MidiInterface<Transport, Settings, Platform>::turnThruOff()
1379
1358
{
1380
- mThruActivated = false ;
1381
- mThruFilterMode = Thru::Off;
1359
+ mThruFilterCallback = thruOff;
1382
1360
}
1383
1361
1384
1362
template <class Transport , class Settings , class Platform >
@@ -1397,51 +1375,20 @@ inline void MidiInterface<Transport, Settings, Platform>::UpdateLastSentTime()
1397
1375
// - Channel messages are passed to the output whether their channel
1398
1376
// is matching the input channel and the filter setting
1399
1377
template <class Transport , class Settings , class Platform >
1400
- void MidiInterface<Transport, Settings, Platform>::thruFilter(Channel inChannel )
1378
+ void MidiInterface<Transport, Settings, Platform>::thruFilter()
1401
1379
{
1402
- // If the feature is disabled, don't do anything.
1403
- if (!mThruActivated || (mThruFilterMode == Thru::Off))
1404
- return ;
1380
+ if (!mThruFilterCallback (mMessage ))
1381
+ return ;
1382
+
1383
+ MidiMessage thruMessage = mThruMapCallback (mMessage );
1405
1384
1406
1385
// First, check if the received message is Channel
1407
1386
if (mMessage .type >= NoteOff && mMessage .type <= PitchBend)
1408
1387
{
1409
- const bool filter_condition = ((mMessage .channel == inChannel) ||
1410
- (inChannel == MIDI_CHANNEL_OMNI));
1411
-
1412
- // Now let's pass it to the output
1413
- switch (mThruFilterMode )
1414
- {
1415
- case Thru::Full:
1416
- send (mMessage .type ,
1417
- mMessage .data1 ,
1418
- mMessage .data2 ,
1419
- mMessage .channel );
1420
- break ;
1421
-
1422
- case Thru::SameChannel:
1423
- if (filter_condition)
1424
- {
1425
- send (mMessage .type ,
1426
- mMessage .data1 ,
1427
- mMessage .data2 ,
1428
- mMessage .channel );
1429
- }
1430
- break ;
1431
-
1432
- case Thru::DifferentChannel:
1433
- if (!filter_condition)
1434
- {
1435
- send (mMessage .type ,
1436
- mMessage .data1 ,
1437
- mMessage .data2 ,
1438
- mMessage .channel );
1439
- }
1440
- break ;
1441
-
1442
- default :
1443
- break ;
1444
- }
1388
+ send (thruMessage.type ,
1389
+ thruMessage.data1 ,
1390
+ thruMessage.data2 ,
1391
+ thruMessage.channel );
1445
1392
}
1446
1393
else
1447
1394
{
@@ -1461,19 +1408,19 @@ void MidiInterface<Transport, Settings, Platform>::thruFilter(Channel inChannel)
1461
1408
1462
1409
case SystemExclusive:
1463
1410
// Send SysEx (0xf0 and 0xf7 are included in the buffer)
1464
- sendSysEx (getSysExArrayLength (), getSysExArray () , true );
1411
+ sendSysEx (thruMessage. getSysExSize (), thruMessage. sysexArray , true );
1465
1412
break ;
1466
1413
1467
1414
case SongSelect:
1468
- sendSongSelect (mMessage .data1 );
1415
+ sendSongSelect (thruMessage .data1 );
1469
1416
break ;
1470
1417
1471
1418
case SongPosition:
1472
- sendSongPosition (mMessage .data1 | ((unsigned )mMessage .data2 << 7 ));
1419
+ sendSongPosition (thruMessage .data1 | ((unsigned )thruMessage .data2 << 7 ));
1473
1420
break ;
1474
1421
1475
1422
case TimeCodeQuarterFrame:
1476
- sendTimeCodeQuarterFrame (mMessage .data1 ,mMessage .data2 );
1423
+ sendTimeCodeQuarterFrame (thruMessage .data1 ,thruMessage .data2 );
1477
1424
break ;
1478
1425
1479
1426
default :
0 commit comments