diff --git a/src/minidexed.cpp b/src/minidexed.cpp index 6e2f4c9..a3185e3 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -1510,6 +1510,12 @@ bool CMiniDexed::DoSavePerformance (void) m_PerformanceConfig.SetInsertFXParams (pParams, nTG); pParams.clear(); pParams.shrink_to_fit(); + + m_PerformanceConfig.SetMidiFX (m_MidiArp[nTG]->getId(), nTG); + std::vector 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); @@ -1967,6 +1973,12 @@ void CMiniDexed::LoadPerformanceParameters(void) m_InsertFX[nTG]->setParameters(pParams); pParams.clear(); pParams.shrink_to_fit(); + + setMidiFXType(m_PerformanceConfig.GetMidiFX (nTG), nTG); + std::vector 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); diff --git a/src/performanceconfig.cpp b/src/performanceconfig.cpp index dfe1efc..ce82378 100644 --- a/src/performanceconfig.cpp +++ b/src/performanceconfig.cpp @@ -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 CPerformanceConfig::GetInsertFXParams (unsigned nTG) const { assert (nTG < CConfig::ToneGenerators); + return StringToVector(m_sInsertFXParams[nTG]); +} - std::vector tokens; - std::string params = m_sInsertFXParams[nTG]; - if (params.empty()) { - return tokens; - } +unsigned CPerformanceConfig::GetMidiFX (unsigned nTG) const +{ + assert (nTG < CConfig::ToneGenerators); + return m_nMidiFX[nTG]; +} - char delimiter = ','; - std::stringstream ss(params); - std::string temp; - while (getline(ss, temp, delimiter)) - { - tokens.push_back(stoi(temp)); - } - return tokens; +std::vector 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 pParams, unsigned nTG) { assert (nTG < CConfig::ToneGenerators); + m_sInsertFXParams[nTG] = VectorToString(pParams); +} - std::string params = ""; - for (size_t i = 0; i < pParams.size(); i++) - { - if (i != 0) { - params += ","; - } - params += std::to_string(pParams[i]); - } - m_sInsertFXParams[nTG] = params; +void CPerformanceConfig::SetMidiFX (unsigned nValue, unsigned nTG) +{ + assert (nTG < CConfig::ToneGenerators); + m_nMidiFX[nTG] = nValue; +} + +void CPerformanceConfig::SetMidiFXParams (std::vector 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 CPerformanceConfig::GetSendFXParams (void) const { - std::vector 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 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 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 CPerformanceConfig::StringToVector (std::string sParams) const +{ + std::vector 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; +} + diff --git a/src/performanceconfig.h b/src/performanceconfig.h index f6e5632..48e224a 100644 --- a/src/performanceconfig.h +++ b/src/performanceconfig.h @@ -51,6 +51,8 @@ public: unsigned GetPan (unsigned nTG) const; // 0 .. 127 unsigned GetInsertFX (unsigned nTG) const; // 0 .. X std::vector GetInsertFXParams (unsigned nTG) const; + unsigned GetMidiFX (unsigned nTG) const; // 0 .. X + std::vector 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 pParams, unsigned nTG); + void SetMidiFX (unsigned nValue, unsigned nTG); + void SetMidiFXParams (std::vector 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 pParams); + std::vector StringToVector (std::string sParams) const; }; #endif