Skip to content

Commit 21cb8f4

Browse files
committed
MidiThru: Can now block midi spam
MIDIThruBlockSpam=1 When enabled we dont forward 1 byte messages of MIDI_TIMING_CLOCK or MIDI_ACTIVE_SENSING if defaults to off => keep forwarding these
1 parent 8653924 commit 21cb8f4

3 files changed

Lines changed: 31 additions & 15 deletions

File tree

src/config.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ void CConfig::Load (void)
123123
}
124124
}
125125

126+
m_bMIDIThruBlockSpam = m_Properties.GetNumber ("MIDIThruBlockSpam", 0) != 0;
127+
126128
m_bMIDIRXProgramChange = m_Properties.GetNumber ("MIDIRXProgramChange", 1) != 0;
127129
m_bIgnoreAllNotesOff = m_Properties.GetNumber ("IgnoreAllNotesOff", 0) != 0;
128130
m_bMIDIAutoVoiceDumpOnPC = m_Properties.GetNumber ("MIDIAutoVoiceDumpOnPC", 0) != 0;
@@ -361,6 +363,11 @@ const char *CConfig::GetMIDIThru2Out (void) const
361363
return m_MIDIThru2Out.c_str ();
362364
}
363365

366+
bool CConfig::GetMIDIThruBlockSpam (void) const
367+
{
368+
return m_bMIDIThruBlockSpam;
369+
}
370+
364371
bool CConfig::GetMIDIRXProgramChange (void) const
365372
{
366373
return m_bMIDIRXProgramChange;

src/config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ class CConfig // Configuration for MiniDexed
126126
const char *GetMIDIThruOut (void) const; // "" if not specified
127127
const char *GetMIDIThru2In (void) const; // "" if not specified
128128
const char *GetMIDIThru2Out (void) const; // "" if not specified
129+
bool GetMIDIThruBlockSpam (void) const; // false if not specified
129130
bool GetMIDIRXProgramChange (void) const; // true if not specified
130131
bool GetIgnoreAllNotesOff (void) const;
131132
bool GetMIDIAutoVoiceDumpOnPC (void) const; // false if not specified
@@ -282,6 +283,7 @@ class CConfig // Configuration for MiniDexed
282283
std::string m_MIDIThruOut;
283284
std::string m_MIDIThru2In;
284285
std::string m_MIDIThru2Out;
286+
bool m_bMIDIThruBlockSpam;
285287
bool m_bMIDIRXProgramChange;
286288
bool m_bIgnoreAllNotesOff;
287289
bool m_bMIDIAutoVoiceDumpOnPC;

src/mididevice.cpp

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -189,27 +189,34 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
189189
}
190190
*/
191191

192+
bool blockSpamThru = m_pConfig->GetMIDIThruBlockSpam();
192193
// Handle MIDI Thru
193-
if (m_DeviceName.compare (m_pConfig->GetMIDIThruIn ()) == 0)
194-
{
195-
TDeviceMap::const_iterator Iterator;
194+
bool canThru = ( (nLength > 1) || !blockSpamThru
195+
|| (pMessage[0] != MIDI_TIMING_CLOCK && pMessage[0] != MIDI_ACTIVE_SENSING) );
196196

197-
Iterator = s_DeviceMap.find (m_pConfig->GetMIDIThruOut ());
198-
if (Iterator != s_DeviceMap.end ())
197+
if (canThru)
198+
{
199+
if (m_DeviceName.compare (m_pConfig->GetMIDIThruIn ()) == 0)
199200
{
200-
Iterator->second->Send (pMessage, nLength, nCable);
201-
}
202-
}
201+
TDeviceMap::const_iterator Iterator;
203202

204-
// Handle MIDI Thru 2
205-
if (m_DeviceName.compare (m_pConfig->GetMIDIThru2In ()) == 0)
206-
{
207-
TDeviceMap::const_iterator Iterator;
203+
Iterator = s_DeviceMap.find (m_pConfig->GetMIDIThruOut ());
204+
if (Iterator != s_DeviceMap.end ())
205+
{
206+
Iterator->second->Send (pMessage, nLength, nCable);
207+
}
208+
}
208209

209-
Iterator = s_DeviceMap.find (m_pConfig->GetMIDIThru2Out ());
210-
if (Iterator != s_DeviceMap.end ())
210+
// Handle MIDI Thru 2
211+
if (m_DeviceName.compare (m_pConfig->GetMIDIThru2In ()) == 0)
211212
{
212-
Iterator->second->Send (pMessage, nLength, nCable);
213+
TDeviceMap::const_iterator Iterator;
214+
215+
Iterator = s_DeviceMap.find (m_pConfig->GetMIDIThru2Out ());
216+
if (Iterator != s_DeviceMap.end ())
217+
{
218+
Iterator->second->Send (pMessage, nLength, nCable);
219+
}
213220
}
214221
}
215222

0 commit comments

Comments
 (0)