Initial implementation of performance bank switching in the UI menu.

pull/581/head
Kevin 11 months ago
parent 36d138f3da
commit 2109b576e3
  1. 23
      src/minidexed.cpp
  2. 4
      src/minidexed.h
  3. 31
      src/performanceconfig.cpp
  4. 3
      src/performanceconfig.h
  5. 85
      src/uimenu.cpp
  6. 2
      src/uimenu.h

@ -170,6 +170,8 @@ CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt,
SetParameter (ParameterCompressorEnable, 1);
SetPerformanceSelectChannel(m_pConfig->GetPerformanceSelectChannel());
SetParameter (ParameterPerformanceBank, 0);
};
bool CMiniDexed::Initialize (void)
@ -832,6 +834,10 @@ void CMiniDexed::SetParameter (TParameter Parameter, int nValue)
// Nothing more to do
break;
case ParameterPerformanceBank:
BankSelectPerformance(nValue);
break;
default:
assert (0);
break;
@ -1533,6 +1539,11 @@ unsigned CMiniDexed::GetLastPerformance()
return m_PerformanceConfig.GetLastPerformance();
}
unsigned CMiniDexed::GetLastPerformanceBank()
{
return m_PerformanceConfig.GetLastPerformanceBank();
}
unsigned CMiniDexed::GetActualPerformanceID()
{
return m_PerformanceConfig.GetActualPerformanceID();
@ -1551,6 +1562,13 @@ bool CMiniDexed::SetNewPerformance(unsigned nID)
return true;
}
unsigned CMiniDexed::SetFirstPerformance(void)
{
unsigned nID = m_PerformanceConfig.FindFirstPerformance();
SetNewPerformance(nID);
return nID;
}
bool CMiniDexed::DoSetNewPerformance (void)
{
m_bLoadPerformanceBusy = true;
@ -1668,6 +1686,11 @@ bool CMiniDexed::IsValidPerformance(unsigned nID)
return m_PerformanceConfig.IsValidPerformance(nID);
}
bool CMiniDexed::IsValidPerformanceBank(unsigned nBankID)
{
return m_PerformanceConfig.IsValidPerformanceBank(nBankID);
}
void CMiniDexed::SetVoiceName (std::string VoiceName, unsigned nTG)
{
assert (nTG < CConfig::ToneGenerators);

@ -121,9 +121,11 @@ public:
std::string GetPerformanceFileName(unsigned nID);
std::string GetPerformanceName(unsigned nID);
unsigned GetLastPerformance();
unsigned GetLastPerformanceBank();
unsigned GetActualPerformanceID();
void SetActualPerformanceID(unsigned nID);
bool SetNewPerformance(unsigned nID);
unsigned SetFirstPerformance(void);
bool SavePerformanceNewFile ();
bool DoSavePerformanceNewFile (void);
@ -133,6 +135,7 @@ public:
unsigned GetPerformanceSelectChannel (void);
void SetPerformanceSelectChannel (unsigned uCh);
bool IsValidPerformance(unsigned nID);
bool IsValidPerformanceBank(unsigned nBankID);
// Must match the order in CUIMenu::TParameter
enum TParameter
@ -146,6 +149,7 @@ public:
ParameterReverbDiffusion,
ParameterReverbLevel,
ParameterPerformanceSelectChannel,
ParameterPerformanceBank,
ParameterUnknown
};

@ -1,3 +1,4 @@
//
// performanceconfig.cpp
//
@ -46,7 +47,7 @@ CPerformanceConfig::~CPerformanceConfig (void)
bool CPerformanceConfig::Init (void)
{
// Check intermal performance directory exists
DIR Directory;
DIR Directory;
FRESULT Result;
//Check if internal "performance" directory exists
Result = f_opendir (&Directory, "SD:/" PERFORMANCE_DIR);
@ -810,6 +811,11 @@ unsigned CPerformanceConfig::GetLastPerformance()
return m_nLastPerformance;
}
unsigned CPerformanceConfig::GetLastPerformanceBank()
{
return m_nLastPerformanceBank;
}
unsigned CPerformanceConfig::GetActualPerformanceID()
{
return m_nActualPerformance;
@ -1021,6 +1027,19 @@ void CPerformanceConfig::SetNewPerformance (unsigned nID)
LOGNOTE("Selecting Performance: %d (%s)", nID+1, FileN.c_str());
}
unsigned CPerformanceConfig::FindFirstPerformance (void)
{
for (int nID=0; nID < NUM_PERFORMANCES; nID++)
{
if (IsValidPerformance(nID))
{
return nID;
}
}
return 0; // Even though 0 is a valid performance, not much else to do
}
std::string CPerformanceConfig::GetNewPerformanceDefaultName(void)
{
std::string nIndex = "000000";
@ -1089,12 +1108,12 @@ bool CPerformanceConfig::ListPerformanceBanks()
}
unsigned nNumBanks = 0;
unsigned nHighestBank = 0;
m_nLastPerformanceBank = 0;
// Add in the default performance directory as the first bank
m_PerformanceBankName[0] = DEFAULT_PERFORMANCE_BANK_NAME;
nNumBanks = 1;
nHighestBank = 0;
m_nLastPerformanceBank = 0;
// List directories with names in format 01_Perf Bank Name
Result = f_findfirst (&Directory, &FileInfo, "SD:/" PERFORMANCE_DIR, "*");
@ -1126,9 +1145,9 @@ bool CPerformanceConfig::ListPerformanceBanks()
m_PerformanceBankName[nBankIndex] = BankName;
LOGNOTE ("Found performance bank %s (%d, %s)", OriFileName.c_str(), nBankIndex, BankName.c_str());
nNumBanks++;
if (nBankIndex > nHighestBank)
if (nBankIndex > m_nLastPerformanceBank)
{
nHighestBank = nBankIndex;
m_nLastPerformanceBank = nBankIndex;
}
}
else
@ -1156,7 +1175,7 @@ bool CPerformanceConfig::ListPerformanceBanks()
if (nNumBanks > 0)
{
LOGNOTE ("Number of Performance Banks: %d (last = %d)", nNumBanks, nHighestBank+1);
LOGNOTE ("Number of Performance Banks: %d (last = %d)", nNumBanks, m_nLastPerformanceBank+1);
}
f_closedir (&Directory);

@ -124,10 +124,12 @@ public:
bool ListPerformances();
//std::string m_DirName;
void SetNewPerformance (unsigned nID);
unsigned FindFirstPerformance (void);
std::string GetPerformanceFileName(unsigned nID);
std::string GetPerformanceFullFilePath(unsigned nID);
std::string GetPerformanceName(unsigned nID);
unsigned GetLastPerformance();
unsigned GetLastPerformanceBank();
void SetActualPerformanceID(unsigned nID);
unsigned GetActualPerformanceID();
bool CreateNewPerformanceFile(void);
@ -180,6 +182,7 @@ private:
unsigned m_nLastPerformance;
unsigned m_nActualPerformance = 0;
unsigned m_nPerformanceBank;
unsigned m_nLastPerformanceBank;
bool m_bPerformanceDirectoryExists;
//unsigned nMenuSelectedPerformance = 0;
std::string m_PerformanceFileName[NUM_PERFORMANCES];

@ -214,7 +214,8 @@ const CUIMenu::TParameter CUIMenu::s_GlobalParameter[CMiniDexed::ParameterUnknow
{0, 99, 1}, // ParameterReverbLowPass
{0, 99, 1}, // ParameterReverbDiffusion
{0, 99, 1}, // ParameterReverbLevel
{0, CMIDIDevice::ChannelUnknown-1, 1, ToMIDIChannel} // ParameterPerformanceSelectChannel
{0, CMIDIDevice::ChannelUnknown-1, 1, ToMIDIChannel}, // ParameterPerformanceSelectChannel
{0, NUM_PERFORMANCE_BANKS, 1} // ParameterPerformanceBank
};
// must match CMiniDexed::TTGParameter
@ -327,6 +328,7 @@ const CUIMenu::TMenuItem CUIMenu::s_PerformanceMenu[] =
{"Load", PerformanceMenu, 0, 0},
{"Save", MenuHandler, s_SaveMenu},
{"Delete", PerformanceMenu, 0, 1},
{"Bank", EditPerformanceBankNumber, 0, 0},
{"PCCH", EditGlobalParameter, 0, CMiniDexed::ParameterPerformanceSelectChannel},
{0}
};
@ -1510,6 +1512,87 @@ void CUIMenu::PerformanceMenu (CUIMenu *pUIMenu, TMenuEvent Event)
}
}
void CUIMenu::EditPerformanceBankNumber (CUIMenu *pUIMenu, TMenuEvent Event)
{
bool bPerformanceSelectToLoad = pUIMenu->m_pMiniDexed->GetPerformanceSelectToLoad();
unsigned nLastPerformanceBank = pUIMenu->m_pMiniDexed->GetLastPerformanceBank();
unsigned nValue = pUIMenu->m_nSelectedPerformanceBankID;
unsigned nStart = nValue;
std::string Value;
switch (Event)
{
case MenuEventUpdate:
break;
case MenuEventStepDown:
do
{
if (nValue == 0)
{
// Wrap around
nValue = nLastPerformanceBank;
}
else if (nValue > 0)
{
--nValue;
}
} while ((pUIMenu->m_pMiniDexed->IsValidPerformanceBank(nValue) != true) && (nValue != nStart));
pUIMenu->m_nSelectedPerformanceBankID = nValue;
if (!bPerformanceSelectToLoad)
{
// Switch to the new bank and select the first performance voice
pUIMenu->m_pMiniDexed->SetParameter (CMiniDexed::ParameterPerformanceBank, nValue);
pUIMenu->m_nSelectedPerformanceID = pUIMenu->m_pMiniDexed->SetFirstPerformance();
}
break;
case MenuEventStepUp:
do
{
if (nValue == nLastPerformanceBank)
{
// Wrap around
nValue = 0;
}
else if (nValue < nLastPerformanceBank)
{
++nValue;
}
} while ((pUIMenu->m_pMiniDexed->IsValidPerformanceBank(nValue) != true) && (nValue != nStart));
pUIMenu->m_nSelectedPerformanceBankID = nValue;
if (!bPerformanceSelectToLoad)
{
pUIMenu->m_pMiniDexed->SetParameter (CMiniDexed::ParameterPerformanceBank, nValue);
pUIMenu->m_nSelectedPerformanceID = pUIMenu->m_pMiniDexed->SetFirstPerformance();
}
break;
case MenuEventSelect:
if (bPerformanceSelectToLoad)
{
pUIMenu->m_pMiniDexed->SetParameter (CMiniDexed::ParameterPerformanceBank, nValue);
pUIMenu->m_nSelectedPerformanceID = pUIMenu->m_pMiniDexed->SetFirstPerformance();
}
break;
default:
return;
}
Value = pUIMenu->m_pMiniDexed->GetPerformanceConfig ()->GetPerformanceBankName(nValue);
std::string nPSelected = "";
if(nValue == (unsigned)pUIMenu->m_pMiniDexed->GetParameter (CMiniDexed::ParameterPerformanceBank))
{
nPSelected= "[L]";
}
pUIMenu->m_pUI->DisplayWrite (pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name, nPSelected.c_str(),
Value.c_str (),
nValue > 0,
nValue < pUIMenu->m_pMiniDexed->GetLastPerformanceBank()-1);
}
void CUIMenu::InputTxt (CUIMenu *pUIMenu, TMenuEvent Event)
{
unsigned nTG=0;

@ -91,6 +91,7 @@ private:
static void EditTGParameterModulation (CUIMenu *pUIMenu, TMenuEvent Event);
static void PerformanceMenu (CUIMenu *pUIMenu, TMenuEvent Event);
static void SavePerformanceNewFile (CUIMenu *pUIMenu, TMenuEvent Event);
static void EditPerformanceBankNumber (CUIMenu *pUIMenu, TMenuEvent Event);
static std::string GetGlobalValueString (unsigned nParameter, int nValue);
static std::string GetTGValueString (unsigned nTGParameter, int nValue);
@ -169,6 +170,7 @@ private:
bool m_bPerformanceDeleteMode=false;
bool m_bConfirmDeletePerformance=false;
unsigned m_nSelectedPerformanceID =0;
unsigned m_nSelectedPerformanceBankID =0;
bool m_bSplashShow=false;
};

Loading…
Cancel
Save