Skip to content

Commit

Permalink
Expand Program Change messages across banks (#464)
Browse files Browse the repository at this point in the history
* 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".
  • Loading branch information
diyelectromusic authored Apr 17, 2023
1 parent 7e0251e commit 582c740
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class CConfig // Configuration for MiniDexed
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
Expand Down Expand Up @@ -159,6 +160,7 @@ class CConfig // Configuration for MiniDexed
bool m_bIgnoreAllNotesOff;
bool m_bMIDIAutoVoiceDumpOnPC;
bool m_bHeaderlessSysExVoices;
bool m_bExpandPCAcrossBanks;

bool m_bLCDEnabled;
unsigned m_nLCDPinEnable;
Expand Down
25 changes: 23 additions & 2 deletions src/minidexed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/minidexed.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ MIDIRXProgramChange=1
IgnoreAllNotesOff=0
MIDIAutoVoiceDumpOnPC=1
HeaderlessSysExVoices=0
ExpandPCAcrossBanks=1

# HD44780 LCD
LCDEnabled=1
Expand Down

0 comments on commit 582c740

Please sign in to comment.