From 751b69da3f7f4018004eb216882eec9c74d8dfd3 Mon Sep 17 00:00:00 2001 From: jnonis Date: Mon, 8 Jul 2024 22:35:56 +0000 Subject: [PATCH] Save Send FX configuration in performance --- src/minidexed.cpp | 14 ++++++++++ src/performanceconfig.cpp | 55 ++++++++++++++++++++++++++++++++++++--- src/performanceconfig.h | 8 +++++- 3 files changed, 72 insertions(+), 5 deletions(-) diff --git a/src/minidexed.cpp b/src/minidexed.cpp index db2d024..8308529 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -1379,6 +1379,13 @@ bool CMiniDexed::DoSavePerformance (void) } m_PerformanceConfig.SetCompressorEnable (!!m_nParameter[ParameterCompressorEnable]); + + m_PerformanceConfig.SetSendFX (m_SendFX->getId()); + std::vector pParams = m_SendFX->getParameters(); + m_PerformanceConfig.SetSendFXParams (pParams); + pParams.clear(); + pParams.shrink_to_fit(); + m_PerformanceConfig.SetReverbEnable (!!m_nParameter[ParameterReverbEnable]); m_PerformanceConfig.SetReverbSize (m_nParameter[ParameterReverbSize]); m_PerformanceConfig.SetReverbHighDamp (m_nParameter[ParameterReverbHighDamp]); @@ -1825,6 +1832,13 @@ void CMiniDexed::LoadPerformanceParameters(void) // Effects SetParameter (ParameterCompressorEnable, m_PerformanceConfig.GetCompressorEnable () ? 1 : 0); + + setSendFXType(m_PerformanceConfig.GetSendFX ()); + std::vector pParams = m_PerformanceConfig.GetSendFXParams(); + m_SendFX->setParameters(pParams); + pParams.clear(); + pParams.shrink_to_fit(); + SetParameter (ParameterReverbEnable, m_PerformanceConfig.GetReverbEnable () ? 1 : 0); SetParameter (ParameterReverbSize, m_PerformanceConfig.GetReverbSize ()); SetParameter (ParameterReverbHighDamp, m_PerformanceConfig.GetReverbHighDamp ()); diff --git a/src/performanceconfig.cpp b/src/performanceconfig.cpp index ea30a54..792ae9e 100644 --- a/src/performanceconfig.cpp +++ b/src/performanceconfig.cpp @@ -137,7 +137,7 @@ bool CPerformanceConfig::Load (void) m_nInsertFX[nTG] = m_Properties.GetNumber (PropertyName, 0); PropertyName.Format ("InsertFXParams%u", nTG+1); - m_nInsertFXParams[nTG] = m_Properties.GetString (PropertyName, ""); + m_sInsertFXParams[nTG] = m_Properties.GetString (PropertyName, ""); PropertyName.Format ("Detune%u", nTG+1); m_nDetune[nTG] = m_Properties.GetSignedNumber (PropertyName, 0); @@ -209,6 +209,9 @@ bool CPerformanceConfig::Load (void) m_bCompressorEnable = m_Properties.GetNumber ("CompressorEnable", 1) != 0; + m_nSendFX = m_Properties.GetNumber ("SendFX", 0); + m_sSendFXParams = m_Properties.GetString ("SendFXParams", ""); + m_bReverbEnable = m_Properties.GetNumber ("ReverbEnable", 1) != 0; m_nReverbSize = m_Properties.GetNumber ("ReverbSize", 70); m_nReverbHighDamp = m_Properties.GetNumber ("ReverbHighDamp", 50); @@ -260,7 +263,7 @@ bool CPerformanceConfig::Save (void) m_Properties.SetNumber (PropertyName, m_nInsertFX[nTG]); PropertyName.Format ("InsertFXParams%u", nTG+1); - m_Properties.SetString (PropertyName, m_nInsertFXParams[nTG].c_str()); + m_Properties.SetString (PropertyName, m_sInsertFXParams[nTG].c_str()); PropertyName.Format ("Detune%u", nTG+1); m_Properties.SetSignedNumber (PropertyName, m_nDetune[nTG]); @@ -333,6 +336,9 @@ bool CPerformanceConfig::Save (void) m_Properties.SetNumber ("CompressorEnable", m_bCompressorEnable ? 1 : 0); + m_Properties.SetNumber ("SendFX", m_nSendFX); + m_Properties.SetString ("SendFXParams", m_sSendFXParams.c_str()); + m_Properties.SetNumber ("ReverbEnable", m_bReverbEnable ? 1 : 0); m_Properties.SetNumber ("ReverbSize", m_nReverbSize); m_Properties.SetNumber ("ReverbHighDamp", m_nReverbHighDamp); @@ -385,7 +391,7 @@ std::vector CPerformanceConfig::GetInsertFXParams (unsigned nTG) const assert (nTG < CConfig::ToneGenerators); std::vector tokens; - std::string params = m_nInsertFXParams[nTG]; + std::string params = m_sInsertFXParams[nTG]; if (params.empty()) { return tokens; } @@ -490,7 +496,7 @@ void CPerformanceConfig::SetInsertFXParams (std::vector pParams, unsig } params += std::to_string(pParams[i]); } - m_nInsertFXParams[nTG] = params; + m_sInsertFXParams[nTG] = params; } void CPerformanceConfig::SetDetune (int nValue, unsigned nTG) @@ -540,6 +546,29 @@ bool CPerformanceConfig::GetCompressorEnable (void) const return m_bCompressorEnable; } +unsigned CPerformanceConfig::GetSendFX (void) const +{ + return m_nSendFX; +} + +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; +} + bool CPerformanceConfig::GetReverbEnable (void) const { return m_bReverbEnable; @@ -580,6 +609,24 @@ void CPerformanceConfig::SetCompressorEnable (bool bValue) m_bCompressorEnable = bValue; } +void CPerformanceConfig::SetSendFX (unsigned nValue) +{ + m_nSendFX = 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; +} + void CPerformanceConfig::SetReverbEnable (bool bValue) { m_bReverbEnable = bValue; diff --git a/src/performanceconfig.h b/src/performanceconfig.h index ccea378..a567694 100644 --- a/src/performanceconfig.h +++ b/src/performanceconfig.h @@ -108,6 +108,8 @@ public: // Effects bool GetCompressorEnable (void) const; + unsigned GetSendFX (void) const; + std::vector GetSendFXParams (void) const; bool GetReverbEnable (void) const; unsigned GetReverbSize (void) const; // 0 .. 99 unsigned GetReverbHighDamp (void) const; // 0 .. 99 @@ -117,6 +119,8 @@ public: unsigned GetReverbLevel (void) const; // 0 .. 99 void SetCompressorEnable (bool bValue); + void SetSendFX (unsigned nValue); + void SetSendFXParams (std::vector pParams); void SetReverbEnable (bool bValue); void SetReverbSize (unsigned nValue); void SetReverbHighDamp (unsigned nValue); @@ -163,7 +167,7 @@ private: unsigned m_nVolume[CConfig::ToneGenerators]; unsigned m_nPan[CConfig::ToneGenerators]; unsigned m_nInsertFX[CConfig::ToneGenerators]; - std::string m_nInsertFXParams[CConfig::ToneGenerators]; + std::string m_sInsertFXParams[CConfig::ToneGenerators]; int m_nDetune[CConfig::ToneGenerators]; unsigned m_nCutoff[CConfig::ToneGenerators]; unsigned m_nResonance[CConfig::ToneGenerators]; @@ -202,6 +206,8 @@ private: std::string NewPerformanceName=""; bool m_bCompressorEnable; + unsigned m_nSendFX; + std::string m_sSendFXParams; bool m_bReverbEnable; unsigned m_nReverbSize; unsigned m_nReverbHighDamp;