Make performance bank select asynchronous to MIDI and UI to stop corruptions on loading performances.

pull/581/head
Kevin 10 months ago
parent 66409c6739
commit 07cdafc1f2
  1. 71
      src/minidexed.cpp
  2. 11
      src/minidexed.h
  3. 18
      src/performanceconfig.cpp
  4. 5
      src/performanceconfig.h
  5. 6
      src/uimenu.cpp

@ -53,8 +53,11 @@ CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt,
m_bSavePerformance (false),
m_bSavePerformanceNewFile (false),
m_bSetNewPerformance (false),
m_bSetNewPerformanceBank (false),
m_bSetFirstPerformance (false),
m_bDeletePerformance (false),
m_bLoadPerformanceBusy(false)
m_bLoadPerformanceBusy(false),
m_bLoadPerformanceBankBusy(false)
{
assert (m_pConfig);
@ -302,14 +305,30 @@ void CMiniDexed::Process (bool bPlugAndPlayUpdated)
m_bSavePerformanceNewFile = false;
}
if (m_bSetNewPerformance && !m_bLoadPerformanceBusy)
if (m_bSetNewPerformanceBank && !m_bLoadPerformanceBusy && !m_bLoadPerformanceBankBusy)
{
DoSetNewPerformanceBank ();
if (m_nSetNewPerformanceBankID == GetActualPerformanceBankID())
{
m_bSetNewPerformanceBank = false;
}
// If there is no pending SetNewPerformance already, then see if we need to find the first performance to load
// NB: If called from the UI, then there will not be a SetNewPerformance, so load the first existing one.
// If called from MIDI, there will probably be a SetNewPerformance alongside the Bank select.
if (!m_bSetNewPerformance && m_bSetFirstPerformance)
{
DoSetFirstPerformance();
}
}
if (m_bSetNewPerformance && !m_bSetNewPerformanceBank && !m_bLoadPerformanceBusy && !m_bLoadPerformanceBankBusy)
{
DoSetNewPerformance ();
if (m_nSetNewPerformanceID == GetActualPerformanceID())
{
m_bSetNewPerformance = false;
}
}
if(m_bDeletePerformance)
@ -419,7 +438,7 @@ void CMiniDexed::BankSelectPerformance (unsigned nBank)
{
// Only change if we have the bank loaded
m_nVoiceBankIDPerformance = nBank;
GetPerformanceConfig ()->SetPerformanceBank (nBank);
SetNewPerformanceBank (nBank);
m_UI.ParameterChanged ();
}
@ -1566,6 +1585,16 @@ void CMiniDexed::SetActualPerformanceID(unsigned nID)
m_PerformanceConfig.SetActualPerformanceID(nID);
}
unsigned CMiniDexed::GetActualPerformanceBankID()
{
return m_PerformanceConfig.GetActualPerformanceBankID();
}
void CMiniDexed::SetActualPerformanceBankID(unsigned nBankID)
{
m_PerformanceConfig.SetActualPerformanceBankID(nBankID);
}
bool CMiniDexed::SetNewPerformance(unsigned nID)
{
m_bSetNewPerformance = true;
@ -1574,11 +1603,18 @@ bool CMiniDexed::SetNewPerformance(unsigned nID)
return true;
}
unsigned CMiniDexed::SetFirstPerformance(void)
bool CMiniDexed::SetNewPerformanceBank(unsigned nBankID)
{
unsigned nID = m_PerformanceConfig.FindFirstPerformance();
SetNewPerformance(nID);
return nID;
m_bSetNewPerformanceBank = true;
m_nSetNewPerformanceBankID = nBankID;
return true;
}
void CMiniDexed::SetFirstPerformance(void)
{
m_bSetFirstPerformance = true;
return;
}
bool CMiniDexed::DoSetNewPerformance (void)
@ -1602,6 +1638,25 @@ bool CMiniDexed::DoSetNewPerformance (void)
}
}
bool CMiniDexed::DoSetNewPerformanceBank (void)
{
m_bLoadPerformanceBankBusy = true;
unsigned nBankID = m_nSetNewPerformanceBankID;
m_PerformanceConfig.SetNewPerformanceBank(nBankID);
m_bLoadPerformanceBankBusy = false;
return true;
}
void CMiniDexed::DoSetFirstPerformance(void)
{
unsigned nID = m_PerformanceConfig.FindFirstPerformance();
SetNewPerformance(nID);
m_bSetFirstPerformance = false;
return;
}
bool CMiniDexed::SavePerformanceNewFile ()
{
m_bSavePerformanceNewFile = m_PerformanceConfig.GetInternalFolderOk() && m_PerformanceConfig.CheckFreePerformanceSlot();

@ -125,12 +125,17 @@ public:
unsigned GetLastPerformanceBank();
unsigned GetActualPerformanceID();
void SetActualPerformanceID(unsigned nID);
unsigned GetActualPerformanceBankID();
void SetActualPerformanceBankID(unsigned nBankID);
bool SetNewPerformance(unsigned nID);
unsigned SetFirstPerformance(void);
bool SetNewPerformanceBank(unsigned nBankID);
void SetFirstPerformance(void);
void DoSetFirstPerformance(void);
bool SavePerformanceNewFile ();
bool DoSavePerformanceNewFile (void);
bool DoSetNewPerformance (void);
bool DoSetNewPerformanceBank (void);
bool GetPerformanceSelectToLoad(void);
bool SavePerformance (bool bSaveAsDeault);
unsigned GetPerformanceSelectChannel (void);
@ -317,9 +322,13 @@ private:
bool m_bSavePerformanceNewFile;
bool m_bSetNewPerformance;
unsigned m_nSetNewPerformanceID;
bool m_bSetNewPerformanceBank;
unsigned m_nSetNewPerformanceBankID;
bool m_bSetFirstPerformance;
bool m_bDeletePerformance;
unsigned m_nDeletePerformanceID;
bool m_bLoadPerformanceBusy;
bool m_bLoadPerformanceBankBusy;
bool m_bSaveAsDeault;
};

@ -72,13 +72,13 @@ bool CPerformanceConfig::Init (void)
{
if (!m_PerformanceBankName[i].empty())
{
SetPerformanceBank(i);
SetNewPerformanceBank(i);
SetNewPerformance(0);
}
}
#endif
// Set to default initial bank
SetPerformanceBank(0);
SetNewPerformanceBank(0);
SetNewPerformance(0);
LOGNOTE ("Loaded Default Performance Bank - Last Performance: %d", m_nLastPerformance + 1); // Show "user facing" index
@ -840,6 +840,17 @@ void CPerformanceConfig::SetActualPerformanceID(unsigned nID)
m_nActualPerformance = nID;
}
unsigned CPerformanceConfig::GetActualPerformanceBankID()
{
return m_nActualPerformanceBank;
}
void CPerformanceConfig::SetActualPerformanceBankID(unsigned nBankID)
{
assert (nBankID < NUM_PERFORMANCE_BANKS);
m_nActualPerformanceBank = nBankID;
}
bool CPerformanceConfig::GetInternalFolderOk()
{
return m_bPerformanceDirectoryExists;
@ -1230,7 +1241,7 @@ bool CPerformanceConfig::ListPerformanceBanks()
return true;
}
void CPerformanceConfig::SetPerformanceBank(unsigned nBankID)
void CPerformanceConfig::SetNewPerformanceBank(unsigned nBankID)
{
assert (nBankID < NUM_PERFORMANCE_BANKS);
if (IsValidPerformanceBank(nBankID))
@ -1239,6 +1250,7 @@ void CPerformanceConfig::SetPerformanceBank(unsigned nBankID)
LOGNOTE("Selecting Performance Bank: %d", nBankID+1);
#endif
m_nPerformanceBank = nBankID;
m_nActualPerformanceBank = nBankID;
ListPerformances();
}
else

@ -132,6 +132,8 @@ public:
unsigned GetLastPerformanceBank();
void SetActualPerformanceID(unsigned nID);
unsigned GetActualPerformanceID();
void SetActualPerformanceBankID(unsigned nBankID);
unsigned GetActualPerformanceBankID();
bool CreateNewPerformanceFile(void);
bool GetInternalFolderOk();
std::string GetNewPerformanceDefaultName(void);
@ -142,7 +144,7 @@ public:
bool IsValidPerformance(unsigned nID);
bool ListPerformanceBanks(void);
void SetPerformanceBank(unsigned nBankID);
void SetNewPerformanceBank(unsigned nBankID);
unsigned GetPerformanceBank(void);
std::string GetPerformanceBankName(unsigned nBankID);
bool IsValidPerformanceBank(unsigned nBankID);
@ -181,6 +183,7 @@ private:
unsigned m_nLastPerformance;
unsigned m_nActualPerformance = 0;
unsigned m_nActualPerformanceBank = 0;
unsigned m_nPerformanceBank;
unsigned m_nLastPerformanceBank;
bool m_bPerformanceDirectoryExists;

@ -1569,7 +1569,7 @@ void CUIMenu::EditPerformanceBankNumber (CUIMenu *pUIMenu, TMenuEvent Event)
{
// 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();
pUIMenu->m_pMiniDexed->SetFirstPerformance();
}
break;
@ -1590,7 +1590,7 @@ void CUIMenu::EditPerformanceBankNumber (CUIMenu *pUIMenu, TMenuEvent Event)
if (!bPerformanceSelectToLoad)
{
pUIMenu->m_pMiniDexed->SetParameter (CMiniDexed::ParameterPerformanceBank, nValue);
pUIMenu->m_nSelectedPerformanceID = pUIMenu->m_pMiniDexed->SetFirstPerformance();
pUIMenu->m_pMiniDexed->SetFirstPerformance();
}
break;
@ -1598,7 +1598,7 @@ void CUIMenu::EditPerformanceBankNumber (CUIMenu *pUIMenu, TMenuEvent Event)
if (bPerformanceSelectToLoad)
{
pUIMenu->m_pMiniDexed->SetParameter (CMiniDexed::ParameterPerformanceBank, nValue);
pUIMenu->m_nSelectedPerformanceID = pUIMenu->m_pMiniDexed->SetFirstPerformance();
pUIMenu->m_pMiniDexed->SetFirstPerformance();
}
break;

Loading…
Cancel
Save