Skip to content

Commit

Permalink
Save Send FX configuration in performance
Browse files Browse the repository at this point in the history
  • Loading branch information
jnonis committed Jul 8, 2024
1 parent 7c2638c commit 751b69d
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 5 deletions.
14 changes: 14 additions & 0 deletions src/minidexed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1379,6 +1379,13 @@ bool CMiniDexed::DoSavePerformance (void)
}

m_PerformanceConfig.SetCompressorEnable (!!m_nParameter[ParameterCompressorEnable]);

m_PerformanceConfig.SetSendFX (m_SendFX->getId());
std::vector<unsigned> 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]);
Expand Down Expand Up @@ -1825,6 +1832,13 @@ void CMiniDexed::LoadPerformanceParameters(void)

// Effects
SetParameter (ParameterCompressorEnable, m_PerformanceConfig.GetCompressorEnable () ? 1 : 0);

setSendFXType(m_PerformanceConfig.GetSendFX ());
std::vector<unsigned> 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 ());
Expand Down
55 changes: 51 additions & 4 deletions src/performanceconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -385,7 +391,7 @@ std::vector<unsigned> CPerformanceConfig::GetInsertFXParams (unsigned nTG) const
assert (nTG < CConfig::ToneGenerators);

std::vector<unsigned> tokens;
std::string params = m_nInsertFXParams[nTG];
std::string params = m_sInsertFXParams[nTG];
if (params.empty()) {
return tokens;
}
Expand Down Expand Up @@ -490,7 +496,7 @@ void CPerformanceConfig::SetInsertFXParams (std::vector<unsigned> pParams, unsig
}
params += std::to_string(pParams[i]);
}
m_nInsertFXParams[nTG] = params;
m_sInsertFXParams[nTG] = params;
}

void CPerformanceConfig::SetDetune (int nValue, unsigned nTG)
Expand Down Expand Up @@ -540,6 +546,29 @@ bool CPerformanceConfig::GetCompressorEnable (void) const
return m_bCompressorEnable;
}

unsigned CPerformanceConfig::GetSendFX (void) const
{
return m_nSendFX;
}

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;
}

bool CPerformanceConfig::GetReverbEnable (void) const
{
return m_bReverbEnable;
Expand Down Expand Up @@ -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<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;
}

void CPerformanceConfig::SetReverbEnable (bool bValue)
{
m_bReverbEnable = bValue;
Expand Down
8 changes: 7 additions & 1 deletion src/performanceconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ class CPerformanceConfig // Performance configuration

// Effects
bool GetCompressorEnable (void) const;
unsigned GetSendFX (void) const;
std::vector<unsigned> GetSendFXParams (void) const;
bool GetReverbEnable (void) const;
unsigned GetReverbSize (void) const; // 0 .. 99
unsigned GetReverbHighDamp (void) const; // 0 .. 99
Expand All @@ -117,6 +119,8 @@ class CPerformanceConfig // Performance configuration
unsigned GetReverbLevel (void) const; // 0 .. 99

void SetCompressorEnable (bool bValue);
void SetSendFX (unsigned nValue);
void SetSendFXParams (std::vector<unsigned> pParams);
void SetReverbEnable (bool bValue);
void SetReverbSize (unsigned nValue);
void SetReverbHighDamp (unsigned nValue);
Expand Down Expand Up @@ -163,7 +167,7 @@ class CPerformanceConfig // Performance configuration
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];
Expand Down Expand Up @@ -202,6 +206,8 @@ class CPerformanceConfig // Performance configuration
std::string NewPerformanceName="";

bool m_bCompressorEnable;
unsigned m_nSendFX;
std::string m_sSendFXParams;
bool m_bReverbEnable;
unsigned m_nReverbSize;
unsigned m_nReverbHighDamp;
Expand Down

0 comments on commit 751b69d

Please sign in to comment.