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.

pull/461/head
diyelectromusic 2 years ago
parent 65159b014e
commit d3b68dc264
  1. 22
      src/minidexed.cpp
  2. 1
      src/minidexed.h
  3. 62
      src/sysexfileloader.cpp
  4. 3
      src/sysexfileloader.h
  5. 11
      src/uimenu.cpp

@ -61,6 +61,7 @@ CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt,
for (unsigned i = 0; i < CConfig::ToneGenerators; i++) for (unsigned i = 0; i < CConfig::ToneGenerators; i++)
{ {
m_nVoiceBankID[i] = 0; m_nVoiceBankID[i] = 0;
m_nVoiceBankIDMSB[i] = 0;
m_nProgram[i] = 0; m_nProgram[i] = 0;
m_nVolume[i] = 100; m_nVolume[i] = 100;
m_nPan[i] = 64; m_nPan[i] = 64;
@ -371,10 +372,9 @@ void CMiniDexed::BankSelect (unsigned nBank, unsigned nTG)
assert (nTG < CConfig::ToneGenerators); assert (nTG < CConfig::ToneGenerators);
unsigned nHighestBank = GetSysExFileLoader ()->GetNumHighestBank(); if (GetSysExFileLoader ()->IsValidBank(nBank))
if (nBank <= nHighestBank)
{ {
// Only change if we have the bank loaded
m_nVoiceBankID[nTG] = nBank; m_nVoiceBankID[nTG] = nBank;
m_UI.ParameterChanged (); m_UI.ParameterChanged ();
@ -386,11 +386,14 @@ void CMiniDexed::BankSelectMSB (unsigned nBankMSB, unsigned nTG)
nBankMSB=constrain((int)nBankMSB,0,127); nBankMSB=constrain((int)nBankMSB,0,127);
assert (nTG < CConfig::ToneGenerators); assert (nTG < CConfig::ToneGenerators);
unsigned nBank = m_nVoiceBankID[nTG]; // MIDI Spec 1.0 "BANK SELECT" states:
unsigned nBankLSB = nBank & 0x7F; // "The transmitter must transmit the MSB and LSB as a pair,
nBank = (nBankMSB << 7) + nBankLSB; // and the Program Change must be sent immediately after
// the Bank Select pair."
BankSelect(nBank, nTG); //
// So it isn't possible to validate the selected bank ID until
// we receive both MSB and LSB so just store the MSB for now.
m_nVoiceBankIDMSB[nTG] = nBankMSB;
} }
void CMiniDexed::BankSelectLSB (unsigned nBankLSB, unsigned nTG) void CMiniDexed::BankSelectLSB (unsigned nBankLSB, unsigned nTG)
@ -399,9 +402,10 @@ void CMiniDexed::BankSelectLSB (unsigned nBankLSB, unsigned nTG)
assert (nTG < CConfig::ToneGenerators); assert (nTG < CConfig::ToneGenerators);
unsigned nBank = m_nVoiceBankID[nTG]; unsigned nBank = m_nVoiceBankID[nTG];
unsigned nBankMSB = nBank >> 7; unsigned nBankMSB = m_nVoiceBankIDMSB[nTG];
nBank = (nBankMSB << 7) + nBankLSB; nBank = (nBankMSB << 7) + nBankLSB;
// Now should have both MSB and LSB so enable the BankSelect
BankSelect(nBank, nTG); BankSelect(nBank, nTG);
} }

@ -231,6 +231,7 @@ private:
CDexedAdapter *m_pTG[CConfig::ToneGenerators]; CDexedAdapter *m_pTG[CConfig::ToneGenerators];
unsigned m_nVoiceBankID[CConfig::ToneGenerators]; unsigned m_nVoiceBankID[CConfig::ToneGenerators];
unsigned m_nVoiceBankIDMSB[CConfig::ToneGenerators];
unsigned m_nProgram[CConfig::ToneGenerators]; unsigned m_nProgram[CConfig::ToneGenerators];
unsigned m_nVolume[CConfig::ToneGenerators]; unsigned m_nVolume[CConfig::ToneGenerators];
unsigned m_nPan[CConfig::ToneGenerators]; unsigned m_nPan[CConfig::ToneGenerators];

@ -192,6 +192,68 @@ std::string CSysExFileLoader::GetBankName (unsigned nBankID)
return "NO NAME"; return "NO NAME";
} }
unsigned CSysExFileLoader::GetNextBankUp (unsigned nBankID)
{
// Find the next loaded bank "up" from the provided bank ID
for (unsigned id=nBankID+1; id <= m_nNumHighestBank; id++)
{
if (IsValidBank(id))
{
return id;
}
}
// Handle wrap-around
for (unsigned id=0; id<nBankID; id++)
{
if (IsValidBank(id))
{
return id;
}
}
// If we get here there are no other banks!
return nBankID;
}
unsigned CSysExFileLoader::GetNextBankDown (unsigned nBankID)
{
// Find the next loaded bank "down" from the provided bank ID
for (int id=((int)nBankID)-1; id >= 0; id--)
{
if (IsValidBank((unsigned)id))
{
return id;
}
}
// Handle wrap-around
for (unsigned id=m_nNumHighestBank; id>nBankID; id--)
{
if (IsValidBank(id))
{
return id;
}
}
// If we get here there are no other banks!
return nBankID;
}
bool CSysExFileLoader::IsValidBank (unsigned nBankID)
{
// Use a valid "status start/end" as an indicator of a loaded bank
if ((m_pVoiceBank[nBankID]->StatusStart == 0xF0) &&
(m_pVoiceBank[nBankID]->StatusEnd == 0xF7))
{
return true;
}
else
{
return false;
}
}
unsigned CSysExFileLoader::GetNumHighestBank (void) unsigned CSysExFileLoader::GetNumHighestBank (void)
{ {
return m_nNumHighestBank; return m_nNumHighestBank;

@ -58,6 +58,9 @@ public:
std::string GetBankName (unsigned nBankID); // 0 .. MaxVoiceBankID std::string GetBankName (unsigned nBankID); // 0 .. MaxVoiceBankID
unsigned GetNumHighestBank (); // 0 .. MaxVoiceBankID unsigned GetNumHighestBank (); // 0 .. MaxVoiceBankID
bool IsValidBank (unsigned nBankID);
unsigned GetNextBankUp (unsigned nBankID);
unsigned GetNextBankDown (unsigned nBankID);
void GetVoice (unsigned nBankID, // 0 .. MaxVoiceBankID void GetVoice (unsigned nBankID, // 0 .. MaxVoiceBankID
unsigned nVoiceID, // 0 .. 31 unsigned nVoiceID, // 0 .. 31

@ -486,7 +486,6 @@ void CUIMenu::EditGlobalParameter (CUIMenu *pUIMenu, TMenuEvent Event)
void CUIMenu::EditVoiceBankNumber (CUIMenu *pUIMenu, TMenuEvent Event) void CUIMenu::EditVoiceBankNumber (CUIMenu *pUIMenu, TMenuEvent Event)
{ {
unsigned nTG = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth-1]; unsigned nTG = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth-1];
int nHighestBank = pUIMenu->m_pMiniDexed->GetSysExFileLoader ()->GetNumHighestBank();
int nValue = pUIMenu->m_pMiniDexed->GetTGParameter (CMiniDexed::TGParameterVoiceBank, nTG); int nValue = pUIMenu->m_pMiniDexed->GetTGParameter (CMiniDexed::TGParameterVoiceBank, nTG);
@ -496,19 +495,13 @@ void CUIMenu::EditVoiceBankNumber (CUIMenu *pUIMenu, TMenuEvent Event)
break; break;
case MenuEventStepDown: case MenuEventStepDown:
if (--nValue < 0) nValue = pUIMenu->m_pMiniDexed->GetSysExFileLoader ()->GetNextBankDown(nValue);
{
nValue = 0;
}
pUIMenu->m_pMiniDexed->SetTGParameter ( pUIMenu->m_pMiniDexed->SetTGParameter (
CMiniDexed::TGParameterVoiceBank, nValue, nTG); CMiniDexed::TGParameterVoiceBank, nValue, nTG);
break; break;
case MenuEventStepUp: case MenuEventStepUp:
if (++nValue > (int) nHighestBank) nValue = pUIMenu->m_pMiniDexed->GetSysExFileLoader ()->GetNextBankUp(nValue);
{
nValue = nHighestBank;
}
pUIMenu->m_pMiniDexed->SetTGParameter ( pUIMenu->m_pMiniDexed->SetTGParameter (
CMiniDexed::TGParameterVoiceBank, nValue, nTG); CMiniDexed::TGParameterVoiceBank, nValue, nTG);
break; break;

Loading…
Cancel
Save