From e3df1dcdbd524af2be934c7b2a57f8c35fb0a0ca Mon Sep 17 00:00:00 2001 From: probonopd Date: Sun, 24 Apr 2022 11:59:18 +0200 Subject: [PATCH] Make it possible to disable MIDI Program Change messages (#159) MIDIRXProgramChange parameter https://github.com/fp64lib/MiniDexed/commit/3af6cb533167927bfd98ff2d2f745254cf1ed4c6 Thanks @fp64lib --- src/config.cpp | 8 ++++++++ src/config.h | 3 +++ src/mididevice.cpp | 14 ++++---------- src/minidexed.ini | 1 + 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index 8194ace..31a148c 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -67,6 +67,9 @@ void CConfig::Load (void) } } } + + m_bMIDIRXProgramChange = m_Properties.GetNumber ("MIDIRXProgramChange", 1) != 0; + m_bLCDEnabled = m_Properties.GetNumber ("LCDEnabled", 0) != 0; m_nLCDPinEnable = m_Properties.GetNumber ("LCDPinEnable", 17); @@ -126,6 +129,11 @@ const char *CConfig::GetMIDIThruOut (void) const return m_MIDIThruOut.c_str (); } +bool CConfig::GetMIDIRXProgramChange (void) const +{ + return m_bMIDIRXProgramChange; +} + bool CConfig::GetLCDEnabled (void) const { return m_bLCDEnabled; diff --git a/src/config.h b/src/config.h index e5597cc..5c4ada6 100644 --- a/src/config.h +++ b/src/config.h @@ -73,6 +73,8 @@ public: unsigned GetMIDIBaudRate (void) const; const char *GetMIDIThruIn (void) const; // "" if not specified const char *GetMIDIThruOut (void) const; // "" if not specified + bool GetMIDIRXProgramChange (void) const; // true if not specified + // HD44780 LCD // GPIO pin numbers are chip numbers, not header positions @@ -108,6 +110,7 @@ private: unsigned m_nMIDIBaudRate; std::string m_MIDIThruIn; std::string m_MIDIThruOut; + bool m_bMIDIRXProgramChange; bool m_bLCDEnabled; unsigned m_nLCDPinEnable; diff --git a/src/mididevice.cpp b/src/mididevice.cpp index 06ca51b..837d8e9 100644 --- a/src/mididevice.cpp +++ b/src/mididevice.cpp @@ -208,15 +208,7 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign break; case MIDI_CC_DETUNE_LEVEL: - if (pMessage[2] == 0) - { - // "0 to 127, with 0 being no celeste (detune) effect applied at all." - m_pSynthesizer->SetMasterTune (0, nTG); - } - else - { - m_pSynthesizer->SetMasterTune (maplong (pMessage[2], 1, 127, -99, 99), nTG); - } + m_pSynthesizer->SetMasterTune (maplong (pMessage[2], 0, 127, -99, 99), nTG); break; case MIDI_CC_ALL_SOUND_OFF: @@ -230,7 +222,9 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign break; case MIDI_PROGRAM_CHANGE: - m_pSynthesizer->ProgramChange (pMessage[1], nTG); + // do program change only if enabled in config + if( m_pConfig->GetMIDIRXProgramChange() ) + m_pSynthesizer->ProgramChange (pMessage[1], nTG); break; case MIDI_PITCH_BEND: { diff --git a/src/minidexed.ini b/src/minidexed.ini index 46b69cc..327b649 100644 --- a/src/minidexed.ini +++ b/src/minidexed.ini @@ -14,6 +14,7 @@ ChannelsSwapped=0 # MIDI MIDIBaudRate=31250 #MIDIThru=umidi1,ttyS1 +MIDIRXProgramChange=1 # HD44780 LCD LCDEnabled=1