diff --git a/source/DSP/ProPhatSynthesiser.h b/source/DSP/ProPhatSynthesiser.h index 5b96d7d..5f7a39b 100644 --- a/source/DSP/ProPhatSynthesiser.h +++ b/source/DSP/ProPhatSynthesiser.h @@ -26,16 +26,18 @@ #include "PhatVerb.h" #include "../Utility/Helpers.h" +enum class EffectType +{ + verb = 0, + chorus, + transitioning +}; + template class EffectsCrossfadeProcessor { public: - enum EffectType - { - verb = 0, - chorus, - transitioning - }; + EffectsCrossfadeProcessor() = default; @@ -170,14 +172,34 @@ class EffectsProcessor template void setEffectParam (juce::StringRef parameterID, T newValue) { - if (parameterID == ProPhatParameterIds::effectParam1ID.getParamID()) - reverbParams.roomSize = newValue; + const auto curEffect { effectCrossFader.getCurrentEffectType() }; + if (parameterID == ProPhatParameterIds::effectParam1ID.getParamID ()) + { + if (curEffect == EffectType::verb) + { + reverbParams.roomSize = newValue; + verbWrapper->processor.setParameters (reverbParams); + } + else if (curEffect == EffectType::chorus) + { + chorusWrapper->processor.setRate (static_cast (99.9) * newValue); + } + } else if (parameterID == ProPhatParameterIds::effectParam2ID.getParamID()) - reverbParams.wetLevel = newValue; + { + if (curEffect == EffectType::verb) + { + reverbParams.wetLevel = newValue; + verbWrapper->processor.setParameters (reverbParams); + } + else if (curEffect == EffectType::chorus) + { + chorusWrapper->processor.setDepth (newValue); + chorusWrapper->processor.setMix (newValue); + } + } else jassertfalse; //unknown effect parameter! - - verbWrapper->processor.setParameters (reverbParams); } void changeEffect() @@ -190,7 +212,7 @@ class EffectsProcessor //TODO: surround with trylock or something const auto currentEffectType { effectCrossFader.getCurrentEffectType() }; - if (currentEffectType == EffectsCrossfadeProcessor::EffectType::transitioning) + if (currentEffectType == EffectType::transitioning) { //copy the OG buffer into the individual processor ones fade_buffer1 = buffer; @@ -214,9 +236,9 @@ class EffectsProcessor auto audioBlock { juce::dsp::AudioBlock (buffer).getSubBlock ((size_t) startSample, (size_t) numSamples) }; auto context { juce::dsp::ProcessContextReplacing (audioBlock) }; - if (currentEffectType == EffectsCrossfadeProcessor::EffectType::verb) + if (currentEffectType == EffectType::verb) verbWrapper->process (context); - else if (currentEffectType == EffectsCrossfadeProcessor::EffectType::chorus) + else if (currentEffectType == EffectType::chorus) chorusWrapper->process (context); else jassertfalse; //unknown effect!! @@ -226,7 +248,6 @@ class EffectsProcessor std::unique_ptr, T>> chorusWrapper; std::unique_ptr, T>> verbWrapper; - PhatVerbParameters reverbParams { //manually setting all these because we need to set the default room size and wet level to 0 if we want to be able to retrieve @@ -240,7 +261,6 @@ class EffectsProcessor 0.0f //< Freeze mode - values < 0.5 are "normal" mode, values > 0.5 put the reverb into a continuous feedback loop. }; - juce::AudioBuffer fade_buffer1, fade_buffer2; EffectsCrossfadeProcessor effectCrossFader; };