Added Backward compatibility for performances

pull/764/head
jnonis 7 months ago
parent fc6f7152f0
commit cd785aa046
  1. 37
      src/minidexed.cpp
  2. 5
      src/minidexed.h
  3. 81
      src/performanceconfig.cpp
  4. 3
      src/performanceconfig.h
  5. 29
      src/uimenu.cpp

@ -172,7 +172,7 @@ CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt,
// END setup tgmixer
// BEGIN setup reverb
m_SendFX = new AudioEffectNone(pConfig->GetSampleRate());
SetParameter (ParameterSendFXType, EFFECT_REVERB);
reverb_send_mixer = new AudioStereoMixer<CConfig::ToneGenerators>(pConfig->GetChunkSize()/2);
reverb = new AudioEffectPlateReverb(pConfig->GetSampleRate());
SetParameter (ParameterReverbEnable, 1);
@ -182,7 +182,6 @@ CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt,
SetParameter (ParameterReverbLowPass, 30);
SetParameter (ParameterReverbDiffusion, 65);
SetParameter (ParameterReverbLevel, 99);
SetParameter (ParameterSendFXType, 0);
// END setup reverb
SetParameter (ParameterCompressorEnable, 1);
@ -614,7 +613,10 @@ void CMiniDexed::setInsertFXType (unsigned nType, unsigned nTG)
void CMiniDexed::setSendFXType (unsigned nType)
{
m_SendFXSpinLock.Acquire();
delete m_SendFX;
if (m_SendFX != NULL)
{
delete m_SendFX;
}
m_SendFX = newAudioEffect(nType, m_pConfig->GetSampleRate());
m_SendFX->initializeSendFX();
m_SendFXSpinLock.Release();
@ -622,6 +624,12 @@ void CMiniDexed::setSendFXType (unsigned nType)
m_UI.ParameterChanged ();
}
void CMiniDexed::setSendFXLevel (unsigned nValue)
{
nValue = constrain((int)nValue, 0, 100);
m_SendFXLevel = (float32_t) nValue / 100.0f;
}
void CMiniDexed::SetReverbSend (unsigned nReverbSend, unsigned nTG)
{
nReverbSend=constrain((int)nReverbSend,0,99);
@ -847,6 +855,10 @@ void CMiniDexed::SetParameter (TParameter Parameter, int nValue)
setSendFXType(nValue);
break;
case ParameterSendFXLevel:
setSendFXLevel(nValue);
break;
case ParameterReverbEnable:
nValue=constrain((int)nValue,0,1);
m_ReverbSpinLock.Acquire ();
@ -913,7 +925,16 @@ void CMiniDexed::SetParameter (TParameter Parameter, int nValue)
int CMiniDexed::GetParameter (TParameter Parameter)
{
assert (Parameter < ParameterUnknown);
return m_nParameter[Parameter];
switch (Parameter)
{
case ParameterSendFXType:
return m_SendFX->getId();
case ParameterSendFXLevel:
return roundf(m_SendFXLevel * 100);
default:
return m_nParameter[Parameter];
}
}
void CMiniDexed::SetTGParameter (TTGParameter Parameter, int nValue, unsigned nTG)
@ -1244,10 +1265,10 @@ void CMiniDexed::ProcessSound (void)
m_SendFX->process(ReverbSendBuffer[indexL], ReverbSendBuffer[indexR], ReverbBuffer[indexL], ReverbBuffer[indexR], nFrames);
// scale down and add left reverb buffer by reverb level
arm_scale_f32(ReverbBuffer[indexL], reverb->get_level(), ReverbBuffer[indexL], nFrames);
arm_scale_f32(ReverbBuffer[indexL], m_SendFXLevel, ReverbBuffer[indexL], nFrames);
arm_add_f32(SampleBuffer[indexL], ReverbBuffer[indexL], SampleBuffer[indexL], nFrames);
// scale down and add right reverb buffer by reverb level
arm_scale_f32(ReverbBuffer[indexR], reverb->get_level(), ReverbBuffer[indexR], nFrames);
arm_scale_f32(ReverbBuffer[indexR], m_SendFXLevel, ReverbBuffer[indexR], nFrames);
arm_add_f32(SampleBuffer[indexR], ReverbBuffer[indexR], SampleBuffer[indexR], nFrames);
m_ReverbSpinLock.Release ();
@ -1385,6 +1406,7 @@ bool CMiniDexed::DoSavePerformance (void)
m_PerformanceConfig.SetSendFXParams (pParams);
pParams.clear();
pParams.shrink_to_fit();
m_PerformanceConfig.SetSendFXLevel (roundf(m_SendFXLevel * 100));
m_PerformanceConfig.SetReverbEnable (!!m_nParameter[ParameterReverbEnable]);
m_PerformanceConfig.SetReverbSize (m_nParameter[ParameterReverbSize]);
@ -1834,10 +1856,11 @@ void CMiniDexed::LoadPerformanceParameters(void)
SetParameter (ParameterCompressorEnable, m_PerformanceConfig.GetCompressorEnable () ? 1 : 0);
setSendFXType(m_PerformanceConfig.GetSendFX ());
std::vector<unsigned> pParams = m_PerformanceConfig.GetSendFXParams();
std::vector<unsigned> pParams = m_PerformanceConfig.GetSendFXParams ();
m_SendFX->setParameters(pParams);
pParams.clear();
pParams.shrink_to_fit();
SetParameter (ParameterSendFXLevel, m_PerformanceConfig.GetSendFXLevel ());
SetParameter (ParameterReverbEnable, m_PerformanceConfig.GetReverbEnable () ? 1 : 0);
SetParameter (ParameterReverbSize, m_PerformanceConfig.GetReverbSize ());

@ -97,6 +97,7 @@ public:
void setInsertFXType (unsigned nType, unsigned nTG);
void setSendFXType (unsigned nType);
void setSendFXLevel (unsigned nValue);
void SetReverbSend (unsigned nReverbSend, unsigned nTG); // 0 .. 127
@ -153,6 +154,7 @@ public:
{
ParameterCompressorEnable,
ParameterSendFXType,
ParameterSendFXLevel,
ParameterReverbEnable,
ParameterReverbSize,
ParameterReverbHighDamp,
@ -338,7 +340,8 @@ private:
AudioEffectPlateReverb* reverb;
AudioStereoMixer<CConfig::ToneGenerators>* tg_mixer;
AudioStereoMixer<CConfig::ToneGenerators>* reverb_send_mixer;
AudioEffect* m_SendFX;
AudioEffect* m_SendFX = NULL;
float32_t m_SendFXLevel = 1.0f;
CSpinLock* m_InsertFXSpinLock[CConfig::ToneGenerators];
CSpinLock m_SendFXSpinLock;

@ -209,16 +209,25 @@ 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);
m_nReverbLowDamp = m_Properties.GetNumber ("ReverbLowDamp", 50);
m_nReverbLowPass = m_Properties.GetNumber ("ReverbLowPass", 30);
m_nReverbDiffusion = m_Properties.GetNumber ("ReverbDiffusion", 65);
m_nReverbLevel = m_Properties.GetNumber ("ReverbLevel", 99);
m_nReverbLevel = m_Properties.GetNumber ("ReverbLevel", 100);
// Set EFFECT_REVERB as Default for backward compatibility
// EFFECT_REVERB 7
m_nSendFX = m_Properties.GetNumber ("SendFX", 7);
m_sSendFXParams = m_Properties.GetString ("SendFXParams", "");
m_nSendFXLevel = m_Properties.GetNumber ("SendFXLevel", m_nReverbLevel);
if (m_nSendFX == 7 && m_sSendFXParams.empty()) {
m_sSendFXParams = std::to_string(m_bReverbEnable == 1 ? 0 : 1) + "," + std::to_string(m_nReverbSize) + ","
+ std::to_string(m_nReverbHighDamp) + "," + std::to_string(m_nReverbLowDamp) + ","
+ std::to_string(m_nReverbLowPass) + "," + std::to_string(m_nReverbDiffusion) + ","
+ std::to_string(100);
}
return bResult;
}
@ -338,14 +347,53 @@ bool CPerformanceConfig::Save (void)
m_Properties.SetNumber ("SendFX", m_nSendFX);
m_Properties.SetString ("SendFXParams", m_sSendFXParams.c_str());
m_Properties.SetNumber ("SendFXLevel", m_nSendFXLevel);
// For backward compatibility
// EFFECT_REVERB 7
if (m_nSendFX == 7)
{
std::vector<unsigned> tokens;
std::string params = m_sSendFXParams;
char delimiter = ',';
std::stringstream ss(params);
std::string temp;
while (getline(ss, temp, delimiter))
{
tokens.push_back(stoi(temp));
}
for (size_t i = 0; i < tokens.size(); i++)
{
switch (i)
{
case 0:
m_Properties.SetNumber ("ReverbEnable", tokens[i] ? 1 : 0);
break;
case 1:
m_Properties.SetNumber ("ReverbSize", tokens[i]);
break;
case 2:
m_Properties.SetNumber ("ReverbHighDamp", tokens[i]);
break;
case 3:
m_Properties.SetNumber ("ReverbLowDamp", tokens[i]);
break;
case 4:
m_Properties.SetNumber ("ReverbLowPass", tokens[i]);
break;
case 5:
m_Properties.SetNumber ("ReverbDiffusion", tokens[i]);
break;
default:
break;
}
}
m_Properties.SetNumber ("ReverbLevel", m_nSendFXLevel);
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 ("ReverbLevel", m_nReverbLevel);
tokens.clear();
tokens.shrink_to_fit();
}
return m_Properties.Save ();
}
@ -569,6 +617,12 @@ std::vector<unsigned> CPerformanceConfig::GetSendFXParams (void) const
return tokens;
}
unsigned CPerformanceConfig::GetSendFXLevel (void) const
{
return m_nSendFXLevel;
}
bool CPerformanceConfig::GetReverbEnable (void) const
{
return m_bReverbEnable;
@ -627,6 +681,11 @@ void CPerformanceConfig::SetSendFXParams (std::vector<unsigned> pParams)
m_sSendFXParams = params;
}
void CPerformanceConfig::SetSendFXLevel (unsigned nValue)
{
m_nSendFXLevel = nValue;
}
void CPerformanceConfig::SetReverbEnable (bool bValue)
{
m_bReverbEnable = bValue;

@ -110,6 +110,7 @@ public:
bool GetCompressorEnable (void) const;
unsigned GetSendFX (void) const;
std::vector<unsigned> GetSendFXParams (void) const;
unsigned GetSendFXLevel (void) const;
bool GetReverbEnable (void) const;
unsigned GetReverbSize (void) const; // 0 .. 99
unsigned GetReverbHighDamp (void) const; // 0 .. 99
@ -121,6 +122,7 @@ public:
void SetCompressorEnable (bool bValue);
void SetSendFX (unsigned nValue);
void SetSendFXParams (std::vector<unsigned> pParams);
void SetSendFXLevel (unsigned nValue);
void SetReverbEnable (bool bValue);
void SetReverbSize (unsigned nValue);
void SetReverbHighDamp (unsigned nValue);
@ -208,6 +210,7 @@ private:
bool m_bCompressorEnable;
unsigned m_nSendFX;
std::string m_sSendFXParams;
unsigned m_nSendFXLevel;
bool m_bReverbEnable;
unsigned m_nReverbSize;
unsigned m_nReverbHighDamp;

@ -66,7 +66,7 @@ const CUIMenu::TMenuItem CUIMenu::s_TGMenu[] =
{"Pan", EditTGParameter, 0, CMiniDexed::TGParameterPan},
#endif
{"Insert FX", MenuHandlerInsertFX},
{"Reverb-Send", EditTGParameter, 0, CMiniDexed::TGParameterReverbSend},
{"Send FX", EditTGParameter, 0, CMiniDexed::TGParameterReverbSend},
{"Detune", EditTGParameter, 0, CMiniDexed::TGParameterMasterTune},
{"Cutoff", EditTGParameter, 0, CMiniDexed::TGParameterCutoff},
{"Resonance", EditTGParameter, 0, CMiniDexed::TGParameterResonance},
@ -81,10 +81,10 @@ const CUIMenu::TMenuItem CUIMenu::s_TGMenu[] =
const CUIMenu::TMenuItem CUIMenu::s_EffectsMenu[] =
{
{"Compress", EditGlobalParameter, 0, CMiniDexed::ParameterCompressorEnable},
{"Compress", EditGlobalParameter, 0, CMiniDexed::ParameterCompressorEnable},
{"Send FX", MenuHandlerSendFX},
#ifdef ARM_ALLOW_MULTI_CORE
{"Reverb", MenuHandler, s_ReverbMenu},
//{"Reverb", MenuHandler, s_ReverbMenu},
#endif
{0}
};
@ -126,6 +126,7 @@ const CUIMenu::TMenuItem CUIMenu::s_SendFXMenu[] =
{
{"Type:", EditGlobalParameter, 0, CMiniDexed::ParameterSendFXType},
{"Edit:", EditSendFX},
{"Level", EditGlobalParameter, 0, CMiniDexed::ParameterSendFXLevel},
{0}
};
@ -306,6 +307,7 @@ const CUIMenu::TParameter CUIMenu::s_GlobalParameter[CMiniDexed::ParameterUnknow
{
{0, 1, 1, ToOnOff}, // ParameterCompessorEnable
{0, 7, 1, ToFXType}, // ParameterSendFXType
{0, 100, 1}, // ParameterSendFXLevel
{0, 1, 1, ToOnOff}, // ParameterReverbEnable
{0, 99, 1}, // ParameterReverbSize
{0, 99, 1}, // ParameterReverbHighDamp
@ -331,7 +333,7 @@ const CUIMenu::TParameter CUIMenu::s_TGParameter[CMiniDexed::TGParameterUnknown]
{0, 99, 1}, // TGParameterCutoff
{0, 99, 1}, // TGParameterResonance
{0, CMIDIDevice::ChannelUnknown-1, 1, ToMIDIChannel}, // TGParameterMIDIChannel
{0, 99, 1}, // TGParameterReverbSend
{0, 100, 1}, // TGParameterReverbSend
{0, 12, 1}, // TGParameterPitchBendRange
{0, 12, 1}, // TGParameterPitchBendStep
{0, 1, 1, ToPortaMode}, // TGParameterPortamentoMode
@ -815,7 +817,10 @@ void CUIMenu::MenuHandlerSendFX (CUIMenu *pUIMenu, TMenuEvent Event)
// Create Paramter with type label
std::string value;
value.append(pUIMenu->m_pCurrentMenu[pUIMenu->m_nCurrentSelection].Name);
value.append(getFXTypeName(fxType));
if (pUIMenu->m_nCurrentSelection < 2)
{
value.append(getFXTypeName(fxType));
}
pUIMenu->m_pUI->DisplayWrite (
pUIMenu->m_pParentMenu[pUIMenu->m_nCurrentMenuItem].Name,
@ -1100,8 +1105,8 @@ void CUIMenu::EditInsertFX (CUIMenu *pUIMenu, TMenuEvent Event)
{
unsigned nTG = pUIMenu->m_nMenuStackParameter[pUIMenu->m_nCurrentMenuDepth-2];
int fxType = pUIMenu->m_pMiniDexed->GetTGParameter(CMiniDexed::TGParameterInsertFXType, nTG);
pUIMenu->m_pCurrentMenu = getInsertFXMenuItem(fxType);
int nFXType = pUIMenu->m_pMiniDexed->GetTGParameter(CMiniDexed::TGParameterInsertFXType, nTG);
pUIMenu->m_pCurrentMenu = getInsertFXMenuItem(nFXType);
switch (Event)
{
@ -1109,6 +1114,10 @@ void CUIMenu::EditInsertFX (CUIMenu *pUIMenu, TMenuEvent Event)
break;
case MenuEventSelect: // push menu
if (nFXType == 0)
{
break;
}
assert (pUIMenu->m_nCurrentMenuDepth < MaxMenuDepth);
pUIMenu->m_MenuStackParent[pUIMenu->m_nCurrentMenuDepth] = pUIMenu->m_pParentMenu;
pUIMenu->m_MenuStackMenu[pUIMenu->m_nCurrentMenuDepth] = pUIMenu->m_pCurrentMenu;
@ -1155,7 +1164,7 @@ void CUIMenu::EditInsertFX (CUIMenu *pUIMenu, TMenuEvent Event)
pUIMenu->m_pUI->DisplayWrite (
TG.c_str (),
getFXTypeName(fxType).c_str(),
getFXTypeName(nFXType).c_str(),
pUIMenu->m_pCurrentMenu[pUIMenu->m_nCurrentSelection].Name,
pUIMenu->m_nCurrentSelection > 0,
!!pUIMenu->m_pCurrentMenu[pUIMenu->m_nCurrentSelection+1].Name);
@ -1246,6 +1255,10 @@ void CUIMenu::EditSendFX (CUIMenu *pUIMenu, TMenuEvent Event)
break;
case MenuEventSelect: // push menu
if (nFXType == 0)
{
break;
}
assert (pUIMenu->m_nCurrentMenuDepth < MaxMenuDepth);
pUIMenu->m_MenuStackParent[pUIMenu->m_nCurrentMenuDepth] = pUIMenu->m_pParentMenu;
pUIMenu->m_MenuStackMenu[pUIMenu->m_nCurrentMenuDepth] = pUIMenu->m_pCurrentMenu;

Loading…
Cancel
Save