Skip to content

Commit 582c740

Browse files
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".
1 parent 7e0251e commit 582c740

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

src/config.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ void CConfig::Load (void)
7272
m_bIgnoreAllNotesOff = m_Properties.GetNumber ("IgnoreAllNotesOff", 0) != 0;
7373
m_bMIDIAutoVoiceDumpOnPC = m_Properties.GetNumber ("MIDIAutoVoiceDumpOnPC", 1) != 0;
7474
m_bHeaderlessSysExVoices = m_Properties.GetNumber ("HeaderlessSysExVoices", 0) != 0;
75+
m_bExpandPCAcrossBanks = m_Properties.GetNumber ("ExpandPCAcrossBanks", 1) != 0;
7576

7677
m_bLCDEnabled = m_Properties.GetNumber ("LCDEnabled", 0) != 0;
7778
m_nLCDPinEnable = m_Properties.GetNumber ("LCDPinEnable", 4);
@@ -185,6 +186,11 @@ bool CConfig::GetHeaderlessSysExVoices (void) const
185186
return m_bHeaderlessSysExVoices;
186187
}
187188

189+
bool CConfig::GetExpandPCAcrossBanks (void) const
190+
{
191+
return m_bExpandPCAcrossBanks;
192+
}
193+
188194
bool CConfig::GetLCDEnabled (void) const
189195
{
190196
return m_bLCDEnabled;

src/config.h

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class CConfig // Configuration for MiniDexed
7878
bool GetIgnoreAllNotesOff (void) const;
7979
bool GetMIDIAutoVoiceDumpOnPC (void) const; // true if not specified
8080
bool GetHeaderlessSysExVoices (void) const; // false if not specified
81+
bool GetExpandPCAcrossBanks (void) const; // true if not specified
8182

8283
// HD44780 LCD
8384
// GPIO pin numbers are chip numbers, not header positions
@@ -159,6 +160,7 @@ class CConfig // Configuration for MiniDexed
159160
bool m_bIgnoreAllNotesOff;
160161
bool m_bMIDIAutoVoiceDumpOnPC;
161162
bool m_bHeaderlessSysExVoices;
163+
bool m_bExpandPCAcrossBanks;
162164

163165
bool m_bLCDEnabled;
164166
unsigned m_nLCDPinEnable;

src/minidexed.cpp

+23-2
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,34 @@ void CMiniDexed::ProgramChange (unsigned nProgram, unsigned nTG)
413413
{
414414
assert (m_pConfig);
415415

416-
nProgram=constrain((int)nProgram,0,31);
416+
unsigned nBankOffset;
417+
bool bPCAcrossBanks = m_pConfig->GetExpandPCAcrossBanks();
418+
if (bPCAcrossBanks)
419+
{
420+
// Note: This doesn't actually change the bank in use
421+
// but will allow PC messages of 0..127
422+
// to select across four consecutive banks of voices.
423+
//
424+
// So if the current bank = 5 then:
425+
// PC 0-31 = Bank 5, Program 0-31
426+
// PC 32-63 = Bank 6, Program 0-31
427+
// PC 64-95 = Bank 7, Program 0-31
428+
// PC 96-127 = Bank 8, Program 0-31
429+
nProgram=constrain((int)nProgram,0,127);
430+
nBankOffset = nProgram >> 5;
431+
nProgram = nProgram % 32;
432+
}
433+
else
434+
{
435+
nBankOffset = 0;
436+
nProgram=constrain((int)nProgram,0,31);
437+
}
417438

418439
assert (nTG < CConfig::ToneGenerators);
419440
m_nProgram[nTG] = nProgram;
420441

421442
uint8_t Buffer[156];
422-
m_SysExFileLoader.GetVoice (m_nVoiceBankID[nTG], nProgram, Buffer);
443+
m_SysExFileLoader.GetVoice (m_nVoiceBankID[nTG]+nBankOffset, nProgram, Buffer);
423444

424445
assert (m_pTG[nTG]);
425446
m_pTG[nTG]->loadVoiceParameters (Buffer);

src/minidexed.ini

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ MIDIRXProgramChange=1
1818
IgnoreAllNotesOff=0
1919
MIDIAutoVoiceDumpOnPC=1
2020
HeaderlessSysExVoices=0
21+
ExpandPCAcrossBanks=1
2122

2223
# HD44780 LCD
2324
LCDEnabled=1

0 commit comments

Comments
 (0)