Store Midi FX settings into performance

pull/764/head
Javier Nonis 6 months ago
parent 6cd3a82253
commit 652db3e05f
  1. 12
      src/minidexed.cpp
  2. 105
      src/performanceconfig.cpp
  3. 9
      src/performanceconfig.h

@ -1511,6 +1511,12 @@ bool CMiniDexed::DoSavePerformance (void)
pParams.clear();
pParams.shrink_to_fit();
m_PerformanceConfig.SetMidiFX (m_MidiArp[nTG]->getId(), nTG);
std::vector<unsigned> pMidiFXParams = m_MidiArp[nTG]->getParameters();
m_PerformanceConfig.SetMidiFXParams (pMidiFXParams, nTG);
pMidiFXParams.clear();
pMidiFXParams.shrink_to_fit();
m_PerformanceConfig.SetDetune (m_nMasterTune[nTG], nTG);
m_PerformanceConfig.SetCutoff (m_nCutoff[nTG], nTG);
m_PerformanceConfig.SetResonance (m_nResonance[nTG], nTG);
@ -1968,6 +1974,12 @@ void CMiniDexed::LoadPerformanceParameters(void)
pParams.clear();
pParams.shrink_to_fit();
setMidiFXType(m_PerformanceConfig.GetMidiFX (nTG), nTG);
std::vector<unsigned> pMidiFXParams = m_PerformanceConfig.GetMidiFXParams(nTG);
m_MidiArp[nTG]->setParameters(pMidiFXParams);
pMidiFXParams.clear();
pMidiFXParams.shrink_to_fit();
m_nNoteLimitLow[nTG] = m_PerformanceConfig.GetNoteLimitLow (nTG);
m_nNoteLimitHigh[nTG] = m_PerformanceConfig.GetNoteLimitHigh (nTG);
m_nNoteShift[nTG] = m_PerformanceConfig.GetNoteShift (nTG);

@ -139,6 +139,12 @@ bool CPerformanceConfig::Load (void)
PropertyName.Format ("InsertFXParams%u", nTG+1);
m_sInsertFXParams[nTG] = m_Properties.GetString (PropertyName, "");
PropertyName.Format ("MidiFX%u", nTG+1);
m_nMidiFX[nTG] = m_Properties.GetNumber (PropertyName, 0);
PropertyName.Format ("MidiFXParams%u", nTG+1);
m_sMidiFXParams[nTG] = m_Properties.GetString (PropertyName, "");
PropertyName.Format ("Detune%u", nTG+1);
m_nDetune[nTG] = m_Properties.GetSignedNumber (PropertyName, 0);
@ -274,6 +280,12 @@ bool CPerformanceConfig::Save (void)
PropertyName.Format ("InsertFXParams%u", nTG+1);
m_Properties.SetString (PropertyName, m_sInsertFXParams[nTG].c_str());
PropertyName.Format ("MidiFX%u", nTG+1);
m_Properties.SetNumber (PropertyName, m_nMidiFX[nTG]);
PropertyName.Format ("MidiFXParams%u", nTG+1);
m_Properties.SetString (PropertyName, m_sMidiFXParams[nTG].c_str());
PropertyName.Format ("Detune%u", nTG+1);
m_Properties.SetSignedNumber (PropertyName, m_nDetune[nTG]);
@ -437,21 +449,19 @@ unsigned CPerformanceConfig::GetInsertFX (unsigned nTG) const
std::vector<unsigned> CPerformanceConfig::GetInsertFXParams (unsigned nTG) const
{
assert (nTG < CConfig::ToneGenerators);
std::vector<unsigned> tokens;
std::string params = m_sInsertFXParams[nTG];
if (params.empty()) {
return tokens;
return StringToVector(m_sInsertFXParams[nTG]);
}
char delimiter = ',';
std::stringstream ss(params);
std::string temp;
while (getline(ss, temp, delimiter))
unsigned CPerformanceConfig::GetMidiFX (unsigned nTG) const
{
tokens.push_back(stoi(temp));
assert (nTG < CConfig::ToneGenerators);
return m_nMidiFX[nTG];
}
return tokens;
std::vector<unsigned> CPerformanceConfig::GetMidiFXParams (unsigned nTG) const
{
assert (nTG < CConfig::ToneGenerators);
return StringToVector(m_sMidiFXParams[nTG]);
}
int CPerformanceConfig::GetDetune (unsigned nTG) const
@ -535,16 +545,19 @@ void CPerformanceConfig::SetInsertFX (unsigned nValue, unsigned nTG)
void CPerformanceConfig::SetInsertFXParams (std::vector<unsigned> pParams, unsigned nTG)
{
assert (nTG < CConfig::ToneGenerators);
m_sInsertFXParams[nTG] = VectorToString(pParams);
}
std::string params = "";
for (size_t i = 0; i < pParams.size(); i++)
void CPerformanceConfig::SetMidiFX (unsigned nValue, unsigned nTG)
{
if (i != 0) {
params += ",";
}
params += std::to_string(pParams[i]);
assert (nTG < CConfig::ToneGenerators);
m_nMidiFX[nTG] = nValue;
}
m_sInsertFXParams[nTG] = params;
void CPerformanceConfig::SetMidiFXParams (std::vector<unsigned> pParams, unsigned nTG)
{
assert (nTG < CConfig::ToneGenerators);
m_sMidiFXParams[nTG] = VectorToString(pParams);
}
void CPerformanceConfig::SetDetune (int nValue, unsigned nTG)
@ -601,20 +614,7 @@ unsigned CPerformanceConfig::GetSendFX (void) const
std::vector<unsigned> CPerformanceConfig::GetSendFXParams (void) const
{
std::vector<unsigned> tokens;
std::string params = m_sSendFXParams;
if (params.empty()) {
return tokens;
}
char delimiter = ',';
std::stringstream ss(params);
std::string temp;
while (getline(ss, temp, delimiter))
{
tokens.push_back(stoi(temp));
}
return tokens;
return StringToVector(m_sSendFXParams);
}
unsigned CPerformanceConfig::GetSendFXLevel (void) const
@ -670,15 +670,7 @@ void CPerformanceConfig::SetSendFX (unsigned nValue)
void CPerformanceConfig::SetSendFXParams (std::vector<unsigned> pParams)
{
std::string params = "";
for (size_t i = 0; i < pParams.size(); i++)
{
if (i != 0) {
params += ",";
}
params += std::to_string(pParams[i]);
}
m_sSendFXParams = params;
m_sSendFXParams = VectorToString(pParams);
}
void CPerformanceConfig::SetSendFXLevel (unsigned nValue)
@ -1490,3 +1482,34 @@ bool CPerformanceConfig::IsValidPerformanceBank(unsigned nBankID)
}
return true;
}
std::string CPerformanceConfig::VectorToString (std::vector<unsigned> pParams)
{
std::string params = "";
for (size_t i = 0; i < pParams.size(); i++)
{
if (i != 0) {
params += ",";
}
params += std::to_string(pParams[i]);
}
return params;
}
std::vector<unsigned> CPerformanceConfig::StringToVector (std::string sParams) const
{
std::vector<unsigned> tokens;
if (sParams.empty()) {
return tokens;
}
char delimiter = ',';
std::stringstream ss(sParams);
std::string temp;
while (getline(ss, temp, delimiter))
{
tokens.push_back(stoi(temp));
}
return tokens;
}

@ -51,6 +51,8 @@ public:
unsigned GetPan (unsigned nTG) const; // 0 .. 127
unsigned GetInsertFX (unsigned nTG) const; // 0 .. X
std::vector<unsigned> GetInsertFXParams (unsigned nTG) const;
unsigned GetMidiFX (unsigned nTG) const; // 0 .. X
std::vector<unsigned> GetMidiFXParams (unsigned nTG) const;
int GetDetune (unsigned nTG) const; // -99 .. 99
unsigned GetCutoff (unsigned nTG) const; // 0 .. 99
unsigned GetResonance (unsigned nTG) const; // 0 .. 99
@ -81,6 +83,8 @@ public:
void SetPan (unsigned nValue, unsigned nTG);
void SetInsertFX (unsigned nValue, unsigned nTG);
void SetInsertFXParams (std::vector<unsigned> pParams, unsigned nTG);
void SetMidiFX (unsigned nValue, unsigned nTG);
void SetMidiFXParams (std::vector<unsigned> pParams, unsigned nTG);
void SetDetune (int nValue, unsigned nTG);
void SetCutoff (unsigned nValue, unsigned nTG);
void SetResonance (unsigned nValue, unsigned nTG);
@ -170,6 +174,8 @@ private:
unsigned m_nPan[CConfig::ToneGenerators];
unsigned m_nInsertFX[CConfig::ToneGenerators];
std::string m_sInsertFXParams[CConfig::ToneGenerators];
unsigned m_nMidiFX[CConfig::ToneGenerators];
std::string m_sMidiFXParams[CConfig::ToneGenerators];
int m_nDetune[CConfig::ToneGenerators];
unsigned m_nCutoff[CConfig::ToneGenerators];
unsigned m_nResonance[CConfig::ToneGenerators];
@ -218,6 +224,9 @@ private:
unsigned m_nReverbLowPass;
unsigned m_nReverbDiffusion;
unsigned m_nReverbLevel;
std::string VectorToString (std::vector<unsigned> pParams);
std::vector<unsigned> StringToVector (std::string sParams) const;
};
#endif

Loading…
Cancel
Save