From 427b30baa7123afcc67bc8723189524c0266bc67 Mon Sep 17 00:00:00 2001 From: Javier Nonis Date: Fri, 27 Dec 2024 18:39:27 -0300 Subject: [PATCH] FX Code clean up --- src/minidexed.cpp | 123 ++++++++-------------------------------------- src/minidexed.h | 11 +---- src/uimenu.cpp | 23 --------- 3 files changed, 22 insertions(+), 135 deletions(-) diff --git a/src/minidexed.cpp b/src/minidexed.cpp index 2807adf..6a3937a 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -240,14 +240,6 @@ CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt, // BEGIN setup reverb SetParameter (ParameterSendFXType, AudioEffectPlateReverb::ID); reverb_send_mixer = new AudioStereoMixer(pConfig->GetChunkSize()/2); - reverb = new AudioEffectPlateReverb(pConfig->GetSampleRate()); - SetParameter (ParameterReverbEnable, 1); - SetParameter (ParameterReverbSize, 70); - SetParameter (ParameterReverbHighDamp, 50); - SetParameter (ParameterReverbLowDamp, 50); - SetParameter (ParameterReverbLowPass, 30); - SetParameter (ParameterReverbDiffusion, 65); - SetParameter (ParameterReverbLevel, 99); // END setup reverb SetParameter (ParameterCompressorEnable, 1); @@ -1081,8 +1073,6 @@ void CMiniDexed::ControllersRefresh (unsigned nTG) void CMiniDexed::SetParameter (TParameter Parameter, int nValue) { - assert (reverb); - assert (Parameter < ParameterUnknown); m_nParameter[Parameter] = nValue; @@ -1104,55 +1094,6 @@ void CMiniDexed::SetParameter (TParameter Parameter, int nValue) setSendFXLevel(nValue); break; - case ParameterReverbEnable: - nValue=constrain((int)nValue,0,1); - m_ReverbSpinLock.Acquire (); - reverb->setBypass (!nValue); - m_ReverbSpinLock.Release (); - break; - - case ParameterReverbSize: - nValue=constrain((int)nValue,0,99); - m_ReverbSpinLock.Acquire (); - reverb->size (nValue / 99.0f); - m_ReverbSpinLock.Release (); - break; - - case ParameterReverbHighDamp: - nValue=constrain((int)nValue,0,99); - m_ReverbSpinLock.Acquire (); - reverb->hidamp (nValue / 99.0f); - m_ReverbSpinLock.Release (); - break; - - case ParameterReverbLowDamp: - nValue=constrain((int)nValue,0,99); - m_ReverbSpinLock.Acquire (); - reverb->lodamp (nValue / 99.0f); - m_ReverbSpinLock.Release (); - break; - - case ParameterReverbLowPass: - nValue=constrain((int)nValue,0,99); - m_ReverbSpinLock.Acquire (); - reverb->lowpass (nValue / 99.0f); - m_ReverbSpinLock.Release (); - break; - - case ParameterReverbDiffusion: - nValue=constrain((int)nValue,0,99); - m_ReverbSpinLock.Acquire (); - reverb->diffusion (nValue / 99.0f); - m_ReverbSpinLock.Release (); - break; - - case ParameterReverbLevel: - nValue=constrain((int)nValue,0,99); - m_ReverbSpinLock.Acquire (); - reverb->level (nValue / 99.0f); - m_ReverbSpinLock.Release (); - break; - case ParameterPerformanceSelectChannel: // Nothing more to do break; @@ -1569,33 +1510,27 @@ void CMiniDexed::ProcessSound (void) tg_mixer->getMix(SampleBuffer[indexL], SampleBuffer[indexR]); // BEGIN adding reverb - if (m_nParameter[ParameterReverbEnable]) - { - float32_t ReverbBuffer[2][nFrames]; - float32_t ReverbSendBuffer[2][nFrames]; - - arm_fill_f32(0.0f, ReverbBuffer[indexL], nFrames); - arm_fill_f32(0.0f, ReverbBuffer[indexR], nFrames); - arm_fill_f32(0.0f, ReverbSendBuffer[indexR], nFrames); - arm_fill_f32(0.0f, ReverbSendBuffer[indexL], nFrames); - - m_SendFXSpinLock.Acquire (); - m_ReverbSpinLock.Acquire (); - - reverb_send_mixer->getMix(ReverbSendBuffer[indexL], ReverbSendBuffer[indexR]); - //reverb->doReverb(ReverbSendBuffer[indexL],ReverbSendBuffer[indexR],ReverbBuffer[indexL], ReverbBuffer[indexR],nFrames); - 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], 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], m_SendFXLevel, ReverbBuffer[indexR], nFrames); - arm_add_f32(SampleBuffer[indexR], ReverbBuffer[indexR], SampleBuffer[indexR], nFrames); - - m_ReverbSpinLock.Release (); - m_SendFXSpinLock.Release (); - } + float32_t ReverbBuffer[2][nFrames]; + float32_t ReverbSendBuffer[2][nFrames]; + + arm_fill_f32(0.0f, ReverbBuffer[indexL], nFrames); + arm_fill_f32(0.0f, ReverbBuffer[indexR], nFrames); + arm_fill_f32(0.0f, ReverbSendBuffer[indexR], nFrames); + arm_fill_f32(0.0f, ReverbSendBuffer[indexL], nFrames); + + m_SendFXSpinLock.Acquire (); + + reverb_send_mixer->getMix(ReverbSendBuffer[indexL], ReverbSendBuffer[indexR]); + 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], 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], m_SendFXLevel, ReverbBuffer[indexR], nFrames); + arm_add_f32(SampleBuffer[indexR], ReverbBuffer[indexR], SampleBuffer[indexR], nFrames); + + m_SendFXSpinLock.Release (); // END adding reverb // swap stereo channels if needed prior to writing back out @@ -1745,14 +1680,6 @@ bool CMiniDexed::DoSavePerformance (void) pParams.shrink_to_fit(); m_PerformanceConfig.SetSendFXLevel (roundf(m_SendFXLevel * 100)); - m_PerformanceConfig.SetReverbEnable (!!m_nParameter[ParameterReverbEnable]); - m_PerformanceConfig.SetReverbSize (m_nParameter[ParameterReverbSize]); - m_PerformanceConfig.SetReverbHighDamp (m_nParameter[ParameterReverbHighDamp]); - m_PerformanceConfig.SetReverbLowDamp (m_nParameter[ParameterReverbLowDamp]); - m_PerformanceConfig.SetReverbLowPass (m_nParameter[ParameterReverbLowPass]); - m_PerformanceConfig.SetReverbDiffusion (m_nParameter[ParameterReverbDiffusion]); - m_PerformanceConfig.SetReverbLevel (m_nParameter[ParameterReverbLevel]); - m_PerformanceConfig.SetTempo (m_nTempo); if(m_bSaveAsDeault) @@ -2248,14 +2175,6 @@ void CMiniDexed::LoadPerformanceParameters(void) pParams.shrink_to_fit(); SetParameter (ParameterSendFXLevel, m_PerformanceConfig.GetSendFXLevel ()); - 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 (ParameterReverbLevel, m_PerformanceConfig.GetReverbLevel ()); - SetParameter (ParameterTempo, m_PerformanceConfig.GetTempo ()); } diff --git a/src/minidexed.h b/src/minidexed.h index 20b2af9..694c66f 100644 --- a/src/minidexed.h +++ b/src/minidexed.h @@ -166,13 +166,6 @@ public: ParameterCompressorEnable, ParameterSendFXType, ParameterSendFXLevel, - ParameterReverbEnable, - ParameterReverbSize, - ParameterReverbHighDamp, - ParameterReverbLowDamp, - ParameterReverbLowPass, - ParameterReverbDiffusion, - ParameterReverbLevel, ParameterPerformanceSelectChannel, ParameterPerformanceBank, ParameterTempo, @@ -349,7 +342,6 @@ private: CPerformanceTimer m_GetChunkTimer; bool m_bProfileEnabled; - AudioEffectPlateReverb* reverb; AudioStereoMixer* tg_mixer; AudioStereoMixer* reverb_send_mixer; AudioEffect* m_SendFX = NULL; @@ -358,8 +350,7 @@ private: CSpinLock* m_MidiArpSpinLock[CConfig::AllToneGenerators]; CSpinLock* m_InsertFXSpinLock[CConfig::AllToneGenerators]; CSpinLock m_SendFXSpinLock; - CSpinLock m_ReverbSpinLock; - + bool m_bSavePerformance; bool m_bSavePerformanceNewFile; bool m_bSetNewPerformance; diff --git a/src/uimenu.cpp b/src/uimenu.cpp index 09e55c7..e80165f 100644 --- a/src/uimenu.cpp +++ b/src/uimenu.cpp @@ -142,22 +142,6 @@ const CUIMenu::TMenuItem CUIMenu::s_SendFXMenu[] = {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}, - {"Low pass", EditGlobalParameter, 0, CMiniDexed::ParameterReverbLowPass}, - {"Diffusion", EditGlobalParameter, 0, CMiniDexed::ParameterReverbDiffusion}, - {"Level", EditGlobalParameter, 0, CMiniDexed::ParameterReverbLevel}, - {0} -}; - -#endif - const CUIMenu::TMenuItem CUIMenu::s_InsertFX[] = { {"Type:", EditTGParameter2, 0, CMiniDexed::TGParameterInsertFXType}, @@ -431,13 +415,6 @@ const CUIMenu::TParameter CUIMenu::s_GlobalParameter[CMiniDexed::ParameterUnknow {0, 1, 1, ToOnOff}, // ParameterCompressorEnable {0, AudioEffects::Types::UNKNOWN - 1, 1, ToFXType}, // ParameterSendFXType {0, 100, 1}, // ParameterSendFXLevel - {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}, // ParameterReverbLevel {0, CMIDIDevice::ChannelUnknown-1, 1, ToMIDIChannel}, // ParameterPerformanceSelectChannel {0, NUM_PERFORMANCE_BANKS, 1}, // ParameterPerformanceBank {30, 250, 1} // ParameterTempo