From 582c7407412130fa9fb2f7686c2dd9d98f1e7b47 Mon Sep 17 00:00:00 2001 From: Kevin <68612569+diyelectromusic@users.noreply.github.com> Date: Mon, 17 Apr 2023 17:54:59 +0100 Subject: [PATCH] Expand Program Change messages across banks (#464) * Fix for Issue #457 - changed m_nNumLoadedBanks to be m_nNumHighestBank and updated functionality in menus accordingly. * Fix for Issue #460 implements MIDI Bank Select MSB/LSB based on PR #395 submitted by @abscisys * Fix for Issue #458 to not show blank banks in the menus. Also handles MIDI bank select messages and won't change banks if the final selected bank isn't loaded. * Firm up bank validity handling slightly. * Fix for Issue #459 Initial support for loading of headerless SysEx voice banks as a configuraton option * Fix for Issue #459 Added config option for headerless SysEx voice banks. * Implement option to allow MIDI Program Change messages to select aross four consecutive banks as discussed in Issue #391. Note: It does not check if consecutive banks are loaded. That is down to the user. The default is "enabled". --- src/config.cpp | 6 ++++++ src/config.h | 2 ++ src/minidexed.cpp | 25 +++++++++++++++++++++++-- src/minidexed.ini | 1 + 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index 44ac32f..c40d29a 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -72,6 +72,7 @@ void CConfig::Load (void) m_bIgnoreAllNotesOff = m_Properties.GetNumber ("IgnoreAllNotesOff", 0) != 0; m_bMIDIAutoVoiceDumpOnPC = m_Properties.GetNumber ("MIDIAutoVoiceDumpOnPC", 1) != 0; m_bHeaderlessSysExVoices = m_Properties.GetNumber ("HeaderlessSysExVoices", 0) != 0; + m_bExpandPCAcrossBanks = m_Properties.GetNumber ("ExpandPCAcrossBanks", 1) != 0; m_bLCDEnabled = m_Properties.GetNumber ("LCDEnabled", 0) != 0; m_nLCDPinEnable = m_Properties.GetNumber ("LCDPinEnable", 4); @@ -185,6 +186,11 @@ bool CConfig::GetHeaderlessSysExVoices (void) const return m_bHeaderlessSysExVoices; } +bool CConfig::GetExpandPCAcrossBanks (void) const +{ + return m_bExpandPCAcrossBanks; +} + bool CConfig::GetLCDEnabled (void) const { return m_bLCDEnabled; diff --git a/src/config.h b/src/config.h index bc5e7c6..a316be8 100644 --- a/src/config.h +++ b/src/config.h @@ -78,6 +78,7 @@ public: bool GetIgnoreAllNotesOff (void) const; bool GetMIDIAutoVoiceDumpOnPC (void) const; // true if not specified bool GetHeaderlessSysExVoices (void) const; // false if not specified + bool GetExpandPCAcrossBanks (void) const; // true if not specified // HD44780 LCD // GPIO pin numbers are chip numbers, not header positions @@ -159,6 +160,7 @@ private: bool m_bIgnoreAllNotesOff; bool m_bMIDIAutoVoiceDumpOnPC; bool m_bHeaderlessSysExVoices; + bool m_bExpandPCAcrossBanks; bool m_bLCDEnabled; unsigned m_nLCDPinEnable; diff --git a/src/minidexed.cpp b/src/minidexed.cpp index 6acda43..0bb7c14 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -413,13 +413,34 @@ void CMiniDexed::ProgramChange (unsigned nProgram, unsigned nTG) { assert (m_pConfig); - nProgram=constrain((int)nProgram,0,31); + unsigned nBankOffset; + bool bPCAcrossBanks = m_pConfig->GetExpandPCAcrossBanks(); + if (bPCAcrossBanks) + { + // Note: This doesn't actually change the bank in use + // but will allow PC messages of 0..127 + // to select across four consecutive banks of voices. + // + // So if the current bank = 5 then: + // PC 0-31 = Bank 5, Program 0-31 + // PC 32-63 = Bank 6, Program 0-31 + // PC 64-95 = Bank 7, Program 0-31 + // PC 96-127 = Bank 8, Program 0-31 + nProgram=constrain((int)nProgram,0,127); + nBankOffset = nProgram >> 5; + nProgram = nProgram % 32; + } + else + { + nBankOffset = 0; + nProgram=constrain((int)nProgram,0,31); + } assert (nTG < CConfig::ToneGenerators); m_nProgram[nTG] = nProgram; uint8_t Buffer[156]; - m_SysExFileLoader.GetVoice (m_nVoiceBankID[nTG], nProgram, Buffer); + m_SysExFileLoader.GetVoice (m_nVoiceBankID[nTG]+nBankOffset, nProgram, Buffer); assert (m_pTG[nTG]); m_pTG[nTG]->loadVoiceParameters (Buffer); diff --git a/src/minidexed.ini b/src/minidexed.ini index 2f5ce5b..27d622c 100644 --- a/src/minidexed.ini +++ b/src/minidexed.ini @@ -18,6 +18,7 @@ MIDIRXProgramChange=1 IgnoreAllNotesOff=0 MIDIAutoVoiceDumpOnPC=1 HeaderlessSysExVoices=0 +ExpandPCAcrossBanks=1 # HD44780 LCD LCDEnabled=1