uimenu: Add "Save > Performance" function (#72)

* Saves the performance config to performance.ini
* Comments in an existing file will be overwritten
* Function displays "Completed" and returns to "Save" menu
pull/74/head
Rene Stange 3 years ago committed by GitHub
parent 9c5dea76b0
commit f03ff27f72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 28
      src/minidexed.cpp
  2. 2
      src/minidexed.h
  3. 156
      src/performanceconfig.cpp
  4. 21
      src/performanceconfig.h
  5. 36
      src/uimenu.cpp
  6. 5
      src/uimenu.h

@ -788,3 +788,31 @@ void CMiniDexed::ProcessSound (void)
} }
#endif #endif
bool CMiniDexed::SavePerformance (void)
{
for (unsigned nTG = 0; nTG < CConfig::ToneGenerators; nTG++)
{
m_PerformanceConfig.SetBankNumber (m_nVoiceBankID[nTG], nTG);
m_PerformanceConfig.SetVoiceNumber (m_nProgram[nTG], nTG);
m_PerformanceConfig.SetMIDIChannel (m_nMIDIChannel[nTG], nTG);
m_PerformanceConfig.SetVolume (m_nVolume[nTG], nTG);
m_PerformanceConfig.SetPan (m_nPan[nTG], nTG);
m_PerformanceConfig.SetDetune (m_nMasterTune[nTG], nTG);
m_PerformanceConfig.SetNoteLimitLow (m_nNoteLimitLow[nTG], nTG);
m_PerformanceConfig.SetNoteLimitHigh (m_nNoteLimitHigh[nTG], nTG);
m_PerformanceConfig.SetNoteShift (m_nNoteShift[nTG], nTG);
}
m_PerformanceConfig.SetCompressorEnable (!!m_nParameter[ParameterCompressorEnable]);
m_PerformanceConfig.SetReverbEnable (!!m_nParameter[ParameterReverbEnable]);
m_PerformanceConfig.SetReverbSize (m_nParameter[ParameterReverbSize]);
m_PerformanceConfig.SetReverbHighDamp (m_nParameter[ParameterReverbHighDamp]);
m_PerformanceConfig.SetReverbLowDamp (m_nParameter[ParameterReverbLowDamp]);
m_PerformanceConfig.SetReverbLowPass (m_nParameter[ParameterReverbLowPass]);
m_PerformanceConfig.SetReverbDiffusion (m_nParameter[ParameterReverbDiffusion]);
m_PerformanceConfig.SetReverbSend (m_nParameter[ParameterReverbSend]);
return m_PerformanceConfig.Save ();
}

@ -112,6 +112,8 @@ public:
std::string GetVoiceName (unsigned nTG); std::string GetVoiceName (unsigned nTG);
bool SavePerformance (void);
private: private:
int16_t ApplyNoteLimits (int16_t pitch, unsigned nTG); // returns < 0 to ignore note int16_t ApplyNoteLimits (int16_t pitch, unsigned nTG); // returns < 0 to ignore note

@ -104,6 +104,68 @@ bool CPerformanceConfig::Load (void)
return bResult; return bResult;
} }
bool CPerformanceConfig::Save (void)
{
m_Properties.RemoveAll ();
for (unsigned nTG = 0; nTG < CConfig::ToneGenerators; nTG++)
{
CString PropertyName;
PropertyName.Format ("BankNumber%u", nTG+1);
m_Properties.SetNumber (PropertyName, m_nBankNumber[nTG]);
PropertyName.Format ("VoiceNumber%u", nTG+1);
m_Properties.SetNumber (PropertyName, m_nVoiceNumber[nTG]+1);
PropertyName.Format ("MIDIChannel%u", nTG+1);
unsigned nMIDIChannel = m_nMIDIChannel[nTG];
if (nMIDIChannel < CMIDIDevice::Channels)
{
nMIDIChannel++;
}
else if (nMIDIChannel == CMIDIDevice::OmniMode)
{
nMIDIChannel = 255;
}
else
{
nMIDIChannel = 0;
}
m_Properties.SetNumber (PropertyName, nMIDIChannel);
PropertyName.Format ("Volume%u", nTG+1);
m_Properties.SetNumber (PropertyName, m_nVolume[nTG]);
PropertyName.Format ("Pan%u", nTG+1);
m_Properties.SetNumber (PropertyName, m_nPan[nTG]);
PropertyName.Format ("Detune%u", nTG+1);
m_Properties.SetSignedNumber (PropertyName, m_nDetune[nTG]);
PropertyName.Format ("NoteLimitLow%u", nTG+1);
m_Properties.SetNumber (PropertyName, m_nNoteLimitLow[nTG]);
PropertyName.Format ("NoteLimitHigh%u", nTG+1);
m_Properties.SetNumber (PropertyName, m_nNoteLimitHigh[nTG]);
PropertyName.Format ("NoteShift%u", nTG+1);
m_Properties.SetSignedNumber (PropertyName, m_nNoteShift[nTG]);
}
m_Properties.SetNumber ("CompressorEnable", m_bCompressorEnable ? 1 : 0);
m_Properties.SetNumber ("ReverbEnable", m_bReverbEnable ? 1 : 0);
m_Properties.SetNumber ("ReverbSize", m_nReverbSize);
m_Properties.SetNumber ("ReverbHighDamp", m_nReverbHighDamp);
m_Properties.SetNumber ("ReverbLowDamp", m_nReverbLowDamp);
m_Properties.SetNumber ("ReverbLowPass", m_nReverbLowPass);
m_Properties.SetNumber ("ReverbDiffusion", m_nReverbDiffusion);
m_Properties.SetNumber ("ReverbSend", m_nReverbSend);
return m_Properties.Save ();
}
unsigned CPerformanceConfig::GetBankNumber (unsigned nTG) const unsigned CPerformanceConfig::GetBankNumber (unsigned nTG) const
{ {
assert (nTG < CConfig::ToneGenerators); assert (nTG < CConfig::ToneGenerators);
@ -158,6 +220,60 @@ int CPerformanceConfig::GetNoteShift (unsigned nTG) const
return m_nNoteShift[nTG]; return m_nNoteShift[nTG];
} }
void CPerformanceConfig::SetBankNumber (unsigned nValue, unsigned nTG)
{
assert (nTG < CConfig::ToneGenerators);
m_nBankNumber[nTG] = nValue;
}
void CPerformanceConfig::SetVoiceNumber (unsigned nValue, unsigned nTG)
{
assert (nTG < CConfig::ToneGenerators);
m_nVoiceNumber[nTG] = nValue;
}
void CPerformanceConfig::SetMIDIChannel (unsigned nValue, unsigned nTG)
{
assert (nTG < CConfig::ToneGenerators);
m_nMIDIChannel[nTG] = nValue;
}
void CPerformanceConfig::SetVolume (unsigned nValue, unsigned nTG)
{
assert (nTG < CConfig::ToneGenerators);
m_nVolume[nTG] = nValue;
}
void CPerformanceConfig::SetPan (unsigned nValue, unsigned nTG)
{
assert (nTG < CConfig::ToneGenerators);
m_nPan[nTG] = nValue;
}
void CPerformanceConfig::SetDetune (int nValue, unsigned nTG)
{
assert (nTG < CConfig::ToneGenerators);
m_nDetune[nTG] = nValue;
}
void CPerformanceConfig::SetNoteLimitLow (unsigned nValue, unsigned nTG)
{
assert (nTG < CConfig::ToneGenerators);
m_nNoteLimitLow[nTG] = nValue;
}
void CPerformanceConfig::SetNoteLimitHigh (unsigned nValue, unsigned nTG)
{
assert (nTG < CConfig::ToneGenerators);
m_nNoteLimitHigh[nTG] = nValue;
}
void CPerformanceConfig::SetNoteShift (int nValue, unsigned nTG)
{
assert (nTG < CConfig::ToneGenerators);
m_nNoteShift[nTG] = nValue;
}
bool CPerformanceConfig::GetCompressorEnable (void) const bool CPerformanceConfig::GetCompressorEnable (void) const
{ {
return m_bCompressorEnable; return m_bCompressorEnable;
@ -197,3 +313,43 @@ unsigned CPerformanceConfig::GetReverbSend (void) const
{ {
return m_nReverbSend; return m_nReverbSend;
} }
void CPerformanceConfig::SetCompressorEnable (bool bValue)
{
m_bCompressorEnable = bValue;
}
void CPerformanceConfig::SetReverbEnable (bool bValue)
{
m_bReverbEnable = bValue;
}
void CPerformanceConfig::SetReverbSize (unsigned nValue)
{
m_nReverbSize = nValue;
}
void CPerformanceConfig::SetReverbHighDamp (unsigned nValue)
{
m_nReverbHighDamp = nValue;
}
void CPerformanceConfig::SetReverbLowDamp (unsigned nValue)
{
m_nReverbLowDamp = nValue;
}
void CPerformanceConfig::SetReverbLowPass (unsigned nValue)
{
m_nReverbLowPass = nValue;
}
void CPerformanceConfig::SetReverbDiffusion (unsigned nValue)
{
m_nReverbDiffusion = nValue;
}
void CPerformanceConfig::SetReverbSend (unsigned nValue)
{
m_nReverbSend = nValue;
}

@ -35,6 +35,8 @@ public:
bool Load (void); bool Load (void);
bool Save (void);
// TG# // TG#
unsigned GetBankNumber (unsigned nTG) const; // 0 .. 127 unsigned GetBankNumber (unsigned nTG) const; // 0 .. 127
unsigned GetVoiceNumber (unsigned nTG) const; // 0 .. 31 unsigned GetVoiceNumber (unsigned nTG) const; // 0 .. 31
@ -46,6 +48,16 @@ public:
unsigned GetNoteLimitHigh (unsigned nTG) const; // 0 .. 127 unsigned GetNoteLimitHigh (unsigned nTG) const; // 0 .. 127
int GetNoteShift (unsigned nTG) const; // -24 .. 24 int GetNoteShift (unsigned nTG) const; // -24 .. 24
void SetBankNumber (unsigned nValue, unsigned nTG);
void SetVoiceNumber (unsigned nValue, unsigned nTG);
void SetMIDIChannel (unsigned nValue, unsigned nTG);
void SetVolume (unsigned nValue, unsigned nTG);
void SetPan (unsigned nValue, unsigned nTG);
void SetDetune (int nValue, unsigned nTG);
void SetNoteLimitLow (unsigned nValue, unsigned nTG);
void SetNoteLimitHigh (unsigned nValue, unsigned nTG);
void SetNoteShift (int nValue, unsigned nTG);
// Effects // Effects
bool GetCompressorEnable (void) const; bool GetCompressorEnable (void) const;
bool GetReverbEnable (void) const; bool GetReverbEnable (void) const;
@ -56,6 +68,15 @@ public:
unsigned GetReverbDiffusion (void) const; // 0 .. 99 unsigned GetReverbDiffusion (void) const; // 0 .. 99
unsigned GetReverbSend (void) const; // 0 .. 99 unsigned GetReverbSend (void) const; // 0 .. 99
void SetCompressorEnable (bool bValue);
void SetReverbEnable (bool bValue);
void SetReverbSize (unsigned nValue);
void SetReverbHighDamp (unsigned nValue);
void SetReverbLowDamp (unsigned nValue);
void SetReverbLowPass (unsigned nValue);
void SetReverbDiffusion (unsigned nValue);
void SetReverbSend (unsigned nValue);
private: private:
CPropertiesFatFsFile m_Properties; CPropertiesFatFsFile m_Properties;

@ -51,6 +51,7 @@ const CUIMenu::TMenuItem CUIMenu::s_MainMenu[] =
{"TG8", MenuHandler, s_TGMenu, 7}, {"TG8", MenuHandler, s_TGMenu, 7},
#endif #endif
{"Effects", MenuHandler, s_EffectsMenu}, {"Effects", MenuHandler, s_EffectsMenu},
{"Save", MenuHandler, s_SaveMenu},
{0} {0}
}; };
@ -149,6 +150,12 @@ const CUIMenu::TMenuItem CUIMenu::s_OperatorMenu[] =
{0} {0}
}; };
const CUIMenu::TMenuItem CUIMenu::s_SaveMenu[] =
{
{"Performance", SavePerformance},
{0}
};
// must match CMiniDexed::TParameter // must match CMiniDexed::TParameter
const CUIMenu::TParameter CUIMenu::s_GlobalParameter[CMiniDexed::ParameterUnknown] = const CUIMenu::TParameter CUIMenu::s_GlobalParameter[CMiniDexed::ParameterUnknown] =
{ {
@ -647,6 +654,27 @@ void CUIMenu::EditOPParameter (CUIMenu *pUIMenu, TMenuEvent Event)
nValue > rParam.Minimum, nValue < rParam.Maximum); nValue > rParam.Minimum, nValue < rParam.Maximum);
} }
void CUIMenu::SavePerformance (CUIMenu *pUIMenu, TMenuEvent Event)
{
if (Event != MenuEventUpdate)
{
return;
}
bool bOK = pUIMenu->m_pMiniDexed->SavePerformance ();
const char *pMenuName =
pUIMenu->m_MenuStackParent[pUIMenu->m_nCurrentMenuDepth-1]
[pUIMenu->m_nMenuStackItem[pUIMenu->m_nCurrentMenuDepth-1]].Name;
pUIMenu->m_pUI->DisplayWrite (pMenuName,
pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name,
bOK ? "Completed" : "Error",
false, false);
CTimer::Get ()->StartKernelTimer (MSEC2HZ (1500), TimerHandler, 0, pUIMenu);
}
string CUIMenu::GetGlobalValueString (unsigned nParameter, int nValue) string CUIMenu::GetGlobalValueString (unsigned nParameter, int nValue)
{ {
string Result; string Result;
@ -863,3 +891,11 @@ void CUIMenu::TGShortcutHandler (TMenuEvent Event)
EventHandler (MenuEventUpdate); EventHandler (MenuEventUpdate);
} }
} }
void CUIMenu::TimerHandler (TKernelTimerHandle hTimer, void *pParam, void *pContext)
{
CUIMenu *pThis = static_cast<CUIMenu *> (pContext);
assert (pThis);
pThis->EventHandler (MenuEventBack);
}

@ -24,6 +24,7 @@
#define _uimenu_h #define _uimenu_h
#include <string> #include <string>
#include <circle/timer.h>
class CMiniDexed; class CMiniDexed;
class CUserInterface; class CUserInterface;
@ -81,6 +82,7 @@ private:
static void EditTGParameter (CUIMenu *pUIMenu, TMenuEvent Event); static void EditTGParameter (CUIMenu *pUIMenu, TMenuEvent Event);
static void EditVoiceParameter (CUIMenu *pUIMenu, TMenuEvent Event); static void EditVoiceParameter (CUIMenu *pUIMenu, TMenuEvent Event);
static void EditOPParameter (CUIMenu *pUIMenu, TMenuEvent Event); static void EditOPParameter (CUIMenu *pUIMenu, TMenuEvent Event);
static void SavePerformance (CUIMenu *pUIMenu, TMenuEvent Event);
static std::string GetGlobalValueString (unsigned nParameter, int nValue); static std::string GetGlobalValueString (unsigned nParameter, int nValue);
static std::string GetTGValueString (unsigned nTGParameter, int nValue); static std::string GetTGValueString (unsigned nTGParameter, int nValue);
@ -102,6 +104,8 @@ private:
void TGShortcutHandler (TMenuEvent Event); void TGShortcutHandler (TMenuEvent Event);
static void TimerHandler (TKernelTimerHandle hTimer, void *pParam, void *pContext);
private: private:
CUserInterface *m_pUI; CUserInterface *m_pUI;
CMiniDexed *m_pMiniDexed; CMiniDexed *m_pMiniDexed;
@ -126,6 +130,7 @@ private:
static const TMenuItem s_ReverbMenu[]; static const TMenuItem s_ReverbMenu[];
static const TMenuItem s_EditVoiceMenu[]; static const TMenuItem s_EditVoiceMenu[];
static const TMenuItem s_OperatorMenu[]; static const TMenuItem s_OperatorMenu[];
static const TMenuItem s_SaveMenu[];
static const TParameter s_GlobalParameter[]; static const TParameter s_GlobalParameter[];
static const TParameter s_TGParameter[]; static const TParameter s_TGParameter[];

Loading…
Cancel
Save