Improve compressor and reverb effects (#69)

* Can be switched on/off in "Effects" sub-menu in UI
* Compressor is switched on/off for all TGs
* Read effects parameters from performance.ini
pull/72/head
Rene Stange 3 years ago committed by GitHub
parent fcafaea364
commit 32d196057d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/dexedadapter.h
  2. 83
      src/minidexed.cpp
  3. 2
      src/minidexed.h
  4. 20
      src/performance.ini
  5. 50
      src/performanceconfig.cpp
  6. 19
      src/performanceconfig.h
  7. 30
      src/uimenu.cpp
  8. 1
      src/uimenu.h

@ -33,11 +33,6 @@ public:
CDexedAdapter (uint8_t maxnotes, int rate) CDexedAdapter (uint8_t maxnotes, int rate)
: Dexed (maxnotes, rate) : Dexed (maxnotes, rate)
{ {
Dexed::setCompressor(true);
if(Dexed::getCompressor()==true)
printf("Dexed-Compressor: enabled\n");
else
printf("Dexed-Compressor: disabled\n");
} }
void loadVoiceParameters (uint8_t* data) void loadVoiceParameters (uint8_t* data)

@ -113,8 +113,11 @@ CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt,
} }
#endif #endif
SetParameter (ParameterCompressorEnable, 1);
// BEGIN setup reverb // BEGIN setup reverb
reverb = new AudioEffectPlateReverb(pConfig->GetSampleRate()); reverb = new AudioEffectPlateReverb(pConfig->GetSampleRate());
SetParameter (ParameterReverbEnable, 1);
SetParameter (ParameterReverbSize, 70); SetParameter (ParameterReverbSize, 70);
SetParameter (ParameterReverbHighDamp, 50); SetParameter (ParameterReverbHighDamp, 50);
SetParameter (ParameterReverbLowDamp, 50); SetParameter (ParameterReverbLowDamp, 50);
@ -171,6 +174,16 @@ bool CMiniDexed::Initialize (void)
m_nNoteLimitHigh[nTG] = m_PerformanceConfig.GetNoteLimitHigh (nTG); m_nNoteLimitHigh[nTG] = m_PerformanceConfig.GetNoteLimitHigh (nTG);
m_nNoteShift[nTG] = m_PerformanceConfig.GetNoteShift (nTG); m_nNoteShift[nTG] = m_PerformanceConfig.GetNoteShift (nTG);
} }
// Effects
SetParameter (ParameterCompressorEnable, m_PerformanceConfig.GetCompressorEnable () ? 1 : 0);
SetParameter (ParameterReverbEnable, m_PerformanceConfig.GetReverbEnable () ? 1 : 0);
SetParameter (ParameterReverbSize, m_PerformanceConfig.GetReverbSize ());
SetParameter (ParameterReverbHighDamp, m_PerformanceConfig.GetReverbHighDamp ());
SetParameter (ParameterReverbLowDamp, m_PerformanceConfig.GetReverbLowDamp ());
SetParameter (ParameterReverbLowPass, m_PerformanceConfig.GetReverbLowPass ());
SetParameter (ParameterReverbDiffusion, m_PerformanceConfig.GetReverbDiffusion ());
SetParameter (ParameterReverbSend, m_PerformanceConfig.GetReverbSend ());
} }
else else
{ {
@ -491,25 +504,62 @@ void CMiniDexed::SetParameter (TParameter Parameter, int nValue)
assert (Parameter < ParameterUnknown); assert (Parameter < ParameterUnknown);
m_nParameter[Parameter] = nValue; m_nParameter[Parameter] = nValue;
float fValue = nValue / 99.0;
m_ReverbSpinLock.Acquire ();
switch (Parameter) switch (Parameter)
{ {
case ParameterReverbSize: reverb->size (fValue); break; case ParameterCompressorEnable:
case ParameterReverbHighDamp: reverb->hidamp (fValue); break; for (unsigned nTG = 0; nTG < CConfig::ToneGenerators; nTG++)
case ParameterReverbLowDamp: reverb->lodamp (fValue); break; {
case ParameterReverbLowPass: reverb->lowpass (fValue); break; assert (m_pTG[nTG]);
case ParameterReverbDiffusion: reverb->diffusion (fValue); break; m_pTG[nTG]->setCompressor (!!nValue);
case ParameterReverbSend: reverb->send (fValue); break; }
break;
case ParameterReverbEnable:
m_ReverbSpinLock.Acquire ();
reverb->set_bypass (!nValue);
m_ReverbSpinLock.Release ();
break;
case ParameterReverbSize:
m_ReverbSpinLock.Acquire ();
reverb->size (nValue / 99.0);
m_ReverbSpinLock.Release ();
break;
case ParameterReverbHighDamp:
m_ReverbSpinLock.Acquire ();
reverb->hidamp (nValue / 99.0);
m_ReverbSpinLock.Release ();
break;
case ParameterReverbLowDamp:
m_ReverbSpinLock.Acquire ();
reverb->lodamp (nValue / 99.0);
m_ReverbSpinLock.Release ();
break;
case ParameterReverbLowPass:
m_ReverbSpinLock.Acquire ();
reverb->lowpass (nValue / 99.0);
m_ReverbSpinLock.Release ();
break;
case ParameterReverbDiffusion:
m_ReverbSpinLock.Acquire ();
reverb->diffusion (nValue / 99.0);
m_ReverbSpinLock.Release ();
break;
case ParameterReverbSend:
m_ReverbSpinLock.Acquire ();
reverb->send (nValue / 99.0);
m_ReverbSpinLock.Release ();
break;
default: default:
assert (0); assert (0);
break; break;
} }
m_ReverbSpinLock.Release ();
} }
int CMiniDexed::GetParameter (TParameter Parameter) int CMiniDexed::GetParameter (TParameter Parameter)
@ -717,9 +767,12 @@ void CMiniDexed::ProcessSound (void)
} }
// BEGIN adding reverb // BEGIN adding reverb
m_ReverbSpinLock.Acquire (); if (m_nParameter[ParameterReverbEnable])
reverb->doReverb(nFrames,SampleBuffer); {
m_ReverbSpinLock.Release (); m_ReverbSpinLock.Acquire ();
reverb->doReverb(nFrames,SampleBuffer);
m_ReverbSpinLock.Release ();
}
// END adding reverb // END adding reverb
if (m_pSoundDevice->Write (SampleBuffer, sizeof SampleBuffer) != (int) sizeof SampleBuffer) if (m_pSoundDevice->Write (SampleBuffer, sizeof SampleBuffer) != (int) sizeof SampleBuffer)

@ -77,6 +77,8 @@ public:
enum TParameter enum TParameter
{ {
ParameterCompressorEnable,
ParameterReverbEnable,
ParameterReverbSize, ParameterReverbSize,
ParameterReverbHighDamp, ParameterReverbHighDamp,
ParameterReverbLowDamp, ParameterReverbLowDamp,

@ -100,3 +100,23 @@ Detune8=0
NoteLimitLow8=0 NoteLimitLow8=0
NoteLimitHigh8=127 NoteLimitHigh8=127
NoteShift8=0 NoteShift8=0
# Effects
#CompressorEnable=1 # 0: off, 1: on
#ReverbEnable=1 # 0: off, 1: on
#ReverbSize=70 # 0 .. 99
#ReverbHighDamp=50 # 0 .. 99
#ReverbLowDamp=50 # 0 .. 99
#ReverbLowPass=30 # 0 .. 99
#ReverbDiffusion=65 # 0 .. 99
#ReverbSend=80 # 0 .. 99
# Effects
CompressorEnable=1
ReverbEnable=1
ReverbSize=70
ReverbHighDamp=50
ReverbLowDamp=50
ReverbLowPass=30
ReverbDiffusion=65
ReverbSend=80

@ -91,6 +91,16 @@ bool CPerformanceConfig::Load (void)
m_nNoteShift[nTG] = m_Properties.GetSignedNumber (PropertyName, 0); m_nNoteShift[nTG] = m_Properties.GetSignedNumber (PropertyName, 0);
} }
m_bCompressorEnable = m_Properties.GetNumber ("CompressorEnable", 1) != 0;
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_nReverbSend = m_Properties.GetNumber ("ReverbSend", 80);
return bResult; return bResult;
} }
@ -147,3 +157,43 @@ int CPerformanceConfig::GetNoteShift (unsigned nTG) const
assert (nTG < CConfig::ToneGenerators); assert (nTG < CConfig::ToneGenerators);
return m_nNoteShift[nTG]; return m_nNoteShift[nTG];
} }
bool CPerformanceConfig::GetCompressorEnable (void) const
{
return m_bCompressorEnable;
}
bool CPerformanceConfig::GetReverbEnable (void) const
{
return m_bReverbEnable;
}
unsigned CPerformanceConfig::GetReverbSize (void) const
{
return m_nReverbSize;
}
unsigned CPerformanceConfig::GetReverbHighDamp (void) const
{
return m_nReverbHighDamp;
}
unsigned CPerformanceConfig::GetReverbLowDamp (void) const
{
return m_nReverbLowDamp;
}
unsigned CPerformanceConfig::GetReverbLowPass (void) const
{
return m_nReverbLowPass;
}
unsigned CPerformanceConfig::GetReverbDiffusion (void) const
{
return m_nReverbDiffusion;
}
unsigned CPerformanceConfig::GetReverbSend (void) const
{
return m_nReverbSend;
}

@ -46,6 +46,16 @@ public:
unsigned GetNoteLimitHigh (unsigned nTG) const; // 0 .. 127 unsigned GetNoteLimitHigh (unsigned nTG) const; // 0 .. 127
int GetNoteShift (unsigned nTG) const; // -24 .. 24 int GetNoteShift (unsigned nTG) const; // -24 .. 24
// Effects
bool GetCompressorEnable (void) const;
bool GetReverbEnable (void) const;
unsigned GetReverbSize (void) const; // 0 .. 99
unsigned GetReverbHighDamp (void) const; // 0 .. 99
unsigned GetReverbLowDamp (void) const; // 0 .. 99
unsigned GetReverbLowPass (void) const; // 0 .. 99
unsigned GetReverbDiffusion (void) const; // 0 .. 99
unsigned GetReverbSend (void) const; // 0 .. 99
private: private:
CPropertiesFatFsFile m_Properties; CPropertiesFatFsFile m_Properties;
@ -58,6 +68,15 @@ private:
unsigned m_nNoteLimitLow[CConfig::ToneGenerators]; unsigned m_nNoteLimitLow[CConfig::ToneGenerators];
unsigned m_nNoteLimitHigh[CConfig::ToneGenerators]; unsigned m_nNoteLimitHigh[CConfig::ToneGenerators];
int m_nNoteShift[CConfig::ToneGenerators]; int m_nNoteShift[CConfig::ToneGenerators];
bool m_bCompressorEnable;
bool m_bReverbEnable;
unsigned m_nReverbSize;
unsigned m_nReverbHighDamp;
unsigned m_nReverbLowDamp;
unsigned m_nReverbLowPass;
unsigned m_nReverbDiffusion;
unsigned m_nReverbSend;
}; };
#endif #endif

@ -48,8 +48,8 @@ const CUIMenu::TMenuItem CUIMenu::s_MainMenu[] =
{"TG6", MenuHandler, s_TGMenu, 5}, {"TG6", MenuHandler, s_TGMenu, 5},
{"TG7", MenuHandler, s_TGMenu, 6}, {"TG7", MenuHandler, s_TGMenu, 6},
{"TG8", MenuHandler, s_TGMenu, 7}, {"TG8", MenuHandler, s_TGMenu, 7},
{"Reverb", MenuHandler, s_ReverbMenu},
#endif #endif
{"Effects", MenuHandler, s_EffectsMenu},
{0} {0}
}; };
@ -67,10 +67,20 @@ const CUIMenu::TMenuItem CUIMenu::s_TGMenu[] =
{0} {0}
}; };
const CUIMenu::TMenuItem CUIMenu::s_EffectsMenu[] =
{
{"Compress", EditGlobalParameter, 0, CMiniDexed::ParameterCompressorEnable},
#ifdef ARM_ALLOW_MULTI_CORE
{"Reverb", MenuHandler, s_ReverbMenu},
#endif
{0}
};
#ifdef ARM_ALLOW_MULTI_CORE #ifdef ARM_ALLOW_MULTI_CORE
const CUIMenu::TMenuItem CUIMenu::s_ReverbMenu[] = const CUIMenu::TMenuItem CUIMenu::s_ReverbMenu[] =
{ {
{"Enable", EditGlobalParameter, 0, CMiniDexed::ParameterReverbEnable},
{"Size", EditGlobalParameter, 0, CMiniDexed::ParameterReverbSize}, {"Size", EditGlobalParameter, 0, CMiniDexed::ParameterReverbSize},
{"High damp", EditGlobalParameter, 0, CMiniDexed::ParameterReverbHighDamp}, {"High damp", EditGlobalParameter, 0, CMiniDexed::ParameterReverbHighDamp},
{"Low damp", EditGlobalParameter, 0, CMiniDexed::ParameterReverbLowDamp}, {"Low damp", EditGlobalParameter, 0, CMiniDexed::ParameterReverbLowDamp},
@ -139,14 +149,16 @@ const CUIMenu::TMenuItem CUIMenu::s_OperatorMenu[] =
}; };
// must match CMiniDexed::TParameter // must match CMiniDexed::TParameter
const CUIMenu::TParameter CUIMenu::s_GlobalParameter[CMiniDexed::TGParameterUnknown] = const CUIMenu::TParameter CUIMenu::s_GlobalParameter[CMiniDexed::ParameterUnknown] =
{ {
{0, 99, 1}, // ParameterReverbSize {0, 1, 1, ToOnOff}, // ParameterCompessorEnable
{0, 99, 1}, // ParameterReverbHighDamp {0, 1, 1, ToOnOff}, // ParameterReverbEnable
{0, 99, 1}, // ParameterReverbLowDamp {0, 99, 1}, // ParameterReverbSize
{0, 99, 1}, // ParameterReverbLowPass {0, 99, 1}, // ParameterReverbHighDamp
{0, 99, 1}, // ParameterReverbDiffusion {0, 99, 1}, // ParameterReverbLowDamp
{0, 99, 1}, // ParameterReverbSend {0, 99, 1}, // ParameterReverbLowPass
{0, 99, 1}, // ParameterReverbDiffusion
{0, 99, 1} // ParameterReverbSend
}; };
// must match CMiniDexed::TTGParameter // must match CMiniDexed::TTGParameter

@ -118,6 +118,7 @@ private:
static const TMenuItem s_MenuRoot[]; static const TMenuItem s_MenuRoot[];
static const TMenuItem s_MainMenu[]; static const TMenuItem s_MainMenu[];
static const TMenuItem s_TGMenu[]; static const TMenuItem s_TGMenu[];
static const TMenuItem s_EffectsMenu[];
static const TMenuItem s_ReverbMenu[]; static const TMenuItem s_ReverbMenu[];
static const TMenuItem s_EditVoiceMenu[]; static const TMenuItem s_EditVoiceMenu[];
static const TMenuItem s_OperatorMenu[]; static const TMenuItem s_OperatorMenu[];

Loading…
Cancel
Save