diff --git a/src/dexedadapter.h b/src/dexedadapter.h index a7c77cc..7f2badc 100644 --- a/src/dexedadapter.h +++ b/src/dexedadapter.h @@ -33,11 +33,6 @@ public: CDexedAdapter (uint8_t maxnotes, int 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) diff --git a/src/minidexed.cpp b/src/minidexed.cpp index b462b69..cc501e4 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -113,8 +113,11 @@ CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt, } #endif + SetParameter (ParameterCompressorEnable, 1); + // BEGIN setup reverb reverb = new AudioEffectPlateReverb(pConfig->GetSampleRate()); + SetParameter (ParameterReverbEnable, 1); SetParameter (ParameterReverbSize, 70); SetParameter (ParameterReverbHighDamp, 50); SetParameter (ParameterReverbLowDamp, 50); @@ -171,6 +174,16 @@ bool CMiniDexed::Initialize (void) m_nNoteLimitHigh[nTG] = m_PerformanceConfig.GetNoteLimitHigh (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 { @@ -491,25 +504,62 @@ void CMiniDexed::SetParameter (TParameter Parameter, int nValue) assert (Parameter < ParameterUnknown); m_nParameter[Parameter] = nValue; - float fValue = nValue / 99.0; - - m_ReverbSpinLock.Acquire (); - switch (Parameter) { - case ParameterReverbSize: reverb->size (fValue); break; - case ParameterReverbHighDamp: reverb->hidamp (fValue); break; - case ParameterReverbLowDamp: reverb->lodamp (fValue); break; - case ParameterReverbLowPass: reverb->lowpass (fValue); break; - case ParameterReverbDiffusion: reverb->diffusion (fValue); break; - case ParameterReverbSend: reverb->send (fValue); break; + case ParameterCompressorEnable: + for (unsigned nTG = 0; nTG < CConfig::ToneGenerators; nTG++) + { + assert (m_pTG[nTG]); + m_pTG[nTG]->setCompressor (!!nValue); + } + 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: assert (0); break; } - - m_ReverbSpinLock.Release (); } int CMiniDexed::GetParameter (TParameter Parameter) @@ -717,9 +767,12 @@ void CMiniDexed::ProcessSound (void) } // BEGIN adding reverb - m_ReverbSpinLock.Acquire (); - reverb->doReverb(nFrames,SampleBuffer); - m_ReverbSpinLock.Release (); + if (m_nParameter[ParameterReverbEnable]) + { + m_ReverbSpinLock.Acquire (); + reverb->doReverb(nFrames,SampleBuffer); + m_ReverbSpinLock.Release (); + } // END adding reverb if (m_pSoundDevice->Write (SampleBuffer, sizeof SampleBuffer) != (int) sizeof SampleBuffer) diff --git a/src/minidexed.h b/src/minidexed.h index 2f991f0..e59922f 100644 --- a/src/minidexed.h +++ b/src/minidexed.h @@ -77,6 +77,8 @@ public: enum TParameter { + ParameterCompressorEnable, + ParameterReverbEnable, ParameterReverbSize, ParameterReverbHighDamp, ParameterReverbLowDamp, diff --git a/src/performance.ini b/src/performance.ini index 4b9fb0e..837fae7 100644 --- a/src/performance.ini +++ b/src/performance.ini @@ -100,3 +100,23 @@ Detune8=0 NoteLimitLow8=0 NoteLimitHigh8=127 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 diff --git a/src/performanceconfig.cpp b/src/performanceconfig.cpp index f03443a..927e2e6 100644 --- a/src/performanceconfig.cpp +++ b/src/performanceconfig.cpp @@ -91,6 +91,16 @@ bool CPerformanceConfig::Load (void) 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; } @@ -147,3 +157,43 @@ int CPerformanceConfig::GetNoteShift (unsigned nTG) const assert (nTG < CConfig::ToneGenerators); 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; +} diff --git a/src/performanceconfig.h b/src/performanceconfig.h index 41b0649..b29d90b 100644 --- a/src/performanceconfig.h +++ b/src/performanceconfig.h @@ -46,6 +46,16 @@ public: unsigned GetNoteLimitHigh (unsigned nTG) const; // 0 .. 127 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: CPropertiesFatFsFile m_Properties; @@ -58,6 +68,15 @@ private: unsigned m_nNoteLimitLow[CConfig::ToneGenerators]; unsigned m_nNoteLimitHigh[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 diff --git a/src/uimenu.cpp b/src/uimenu.cpp index c2cd38d..2b1ddc7 100644 --- a/src/uimenu.cpp +++ b/src/uimenu.cpp @@ -48,8 +48,8 @@ const CUIMenu::TMenuItem CUIMenu::s_MainMenu[] = {"TG6", MenuHandler, s_TGMenu, 5}, {"TG7", MenuHandler, s_TGMenu, 6}, {"TG8", MenuHandler, s_TGMenu, 7}, - {"Reverb", MenuHandler, s_ReverbMenu}, #endif + {"Effects", MenuHandler, s_EffectsMenu}, {0} }; @@ -67,10 +67,20 @@ const CUIMenu::TMenuItem CUIMenu::s_TGMenu[] = {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 const CUIMenu::TMenuItem CUIMenu::s_ReverbMenu[] = { + {"Enable", EditGlobalParameter, 0, CMiniDexed::ParameterReverbEnable}, {"Size", EditGlobalParameter, 0, CMiniDexed::ParameterReverbSize}, {"High damp", EditGlobalParameter, 0, CMiniDexed::ParameterReverbHighDamp}, {"Low damp", EditGlobalParameter, 0, CMiniDexed::ParameterReverbLowDamp}, @@ -139,14 +149,16 @@ const CUIMenu::TMenuItem CUIMenu::s_OperatorMenu[] = }; // must match CMiniDexed::TParameter -const CUIMenu::TParameter CUIMenu::s_GlobalParameter[CMiniDexed::TGParameterUnknown] = -{ - {0, 99, 1}, // ParameterReverbSize - {0, 99, 1}, // ParameterReverbHighDamp - {0, 99, 1}, // ParameterReverbLowDamp - {0, 99, 1}, // ParameterReverbLowPass - {0, 99, 1}, // ParameterReverbDiffusion - {0, 99, 1}, // ParameterReverbSend +const CUIMenu::TParameter CUIMenu::s_GlobalParameter[CMiniDexed::ParameterUnknown] = +{ + {0, 1, 1, ToOnOff}, // ParameterCompessorEnable + {0, 1, 1, ToOnOff}, // ParameterReverbEnable + {0, 99, 1}, // ParameterReverbSize + {0, 99, 1}, // ParameterReverbHighDamp + {0, 99, 1}, // ParameterReverbLowDamp + {0, 99, 1}, // ParameterReverbLowPass + {0, 99, 1}, // ParameterReverbDiffusion + {0, 99, 1} // ParameterReverbSend }; // must match CMiniDexed::TTGParameter diff --git a/src/uimenu.h b/src/uimenu.h index e6d9df4..a590a82 100644 --- a/src/uimenu.h +++ b/src/uimenu.h @@ -118,6 +118,7 @@ private: static const TMenuItem s_MenuRoot[]; static const TMenuItem s_MainMenu[]; static const TMenuItem s_TGMenu[]; + static const TMenuItem s_EffectsMenu[]; static const TMenuItem s_ReverbMenu[]; static const TMenuItem s_EditVoiceMenu[]; static const TMenuItem s_OperatorMenu[];