diff --git a/source/PluginParameters.cpp b/source/PluginParameters.cpp index d743b8a..6354063 100644 --- a/source/PluginParameters.cpp +++ b/source/PluginParameters.cpp @@ -37,6 +37,11 @@ juce::AudioProcessorValueTreeState::ParameterLayout PluginParameters::createPara params.push_back(std::make_unique(DOPPLER_ID, DOPPLER_NAME, defaultDopplerParam)); + + params.push_back(std::make_unique(DOPPLER_STRENGTH_ID, + DOPPLER_STRENGTH_NAME, + dopplerStrengthRange, + defaultDopplerStrengthParam)); params.push_back(std::make_unique(LFO_START_ID, LFO_START_NAME, diff --git a/source/PluginParameters.h b/source/PluginParameters.h index 73d20bf..ff54470 100644 --- a/source/PluginParameters.h +++ b/source/PluginParameters.h @@ -29,6 +29,7 @@ class PluginParameters { PRESETS_ID = {"param_presets", 1}, VIEW_ID = {"param_view", 1}, DOPPLER_ID = {"param_doppler", 1}, + DOPPLER_STRENGTH_ID = {"param_doppler_strength", 1}, SOFA_CHOICE_ID = {"param_sofa_choices", 1}, INTERP_ID = {"param_nearest_neighbour_interp", 1}; @@ -58,6 +59,7 @@ class PluginParameters { PRESETS_NAME = "Presets", VIEW_NAME = "View", DOPPLER_NAME = "Doppler Effect Enabled", + DOPPLER_STRENGTH_NAME = "Doppler Effect Strength", SOFA_CHOICE_NAME = "Sofa Choices", INTERP_NAME = "Nearest Neighbour Interpolation"; @@ -75,6 +77,7 @@ class PluginParameters { const inline static float defaultZParam { 0.f }; const inline static bool defaultLFOStartParam { false }; const inline static bool defaultDopplerParam { false }; + const inline static float defaultDopplerStrengthParam { 1.f }; const inline static float defaultXLFORateParam { 0.f }; const inline static float defaultXLFODepthParam { 0.f }; const inline static float defaultXLFOPhaseParam { 0.f }; @@ -108,7 +111,8 @@ class PluginParameters { zLFORateRange {0.0f, 1.5f, 0.1f}, zLFODepthRange {0.0f, 100.f, 0.1f}, zLFOPhaseRange {-180.f, 180.f, 1.f}, - zLFOOffsetRange {-HALF_CUBE_EDGE_LENGTH, HALF_CUBE_EDGE_LENGTH, 0.01f}; + zLFOOffsetRange {-HALF_CUBE_EDGE_LENGTH, HALF_CUBE_EDGE_LENGTH, 0.01f}, + dopplerStrengthRange {0.0, 10.0, 0.01f}; private: diff --git a/source/PluginProcessor.cpp b/source/PluginProcessor.cpp index 65e4037..5efe3d7 100644 --- a/source/PluginProcessor.cpp +++ b/source/PluginProcessor.cpp @@ -236,13 +236,13 @@ void AudioPluginAudioProcessor::processBlock (juce::AudioBuffer& buffer, // Apply Distance Compensation float distance = paramDistance.load(); - float distanceGain = 0.2 / (jmax(0.0f, distance) + 1); + float distanceGain = 1.0 / (jmax(0.0f, distance) + 1); buffer.applyGainRamp(0, buffer.getNumSamples(), lastDistanceGain, distanceGain); lastDistanceGain = distanceGain; // APPLY DELAY if (paramDoppler.load()) { // dopplereffect enabled - float doppler_delay = distance / 343 * getSampleRate(); + float doppler_delay = paramDopplerStrength * distance / 343 * getSampleRate(); smoothDelayLeft.setTargetValue( delayTimeLeft + doppler_delay); smoothDelayRight.setTargetValue( delayTimeRight + doppler_delay ); } else { @@ -263,7 +263,7 @@ void AudioPluginAudioProcessor::processBlock (juce::AudioBuffer& buffer, buffer.setSample(1, sample, delayLineRight.popSample(0)); } - buffer.applyGain(0.5); + buffer.applyGain(0.3); } @@ -308,6 +308,8 @@ void AudioPluginAudioProcessor::parameterChanged(const String ¶meterID, floa paramDistance.store(newValue); } else if (parameterID == PluginParameters::DOPPLER_ID.getParamID()) { paramDoppler.store(static_cast(newValue)); + } else if (parameterID == PluginParameters::DOPPLER_STRENGTH_ID.getParamID()){ + paramDopplerStrength.store(newValue); } if (parameterID == PluginParameters::PRESETS_ID.getParamID()) { int selectedOption = static_cast(newValue); diff --git a/source/PluginProcessor.h b/source/PluginProcessor.h index fa05fd9..3f1a95e 100644 --- a/source/PluginProcessor.h +++ b/source/PluginProcessor.h @@ -113,6 +113,7 @@ class AudioPluginAudioProcessor final : public juce::AudioProcessor, private juc std::atomic paramZLFODepth { 0.0f }; std::atomic paramZLFOPhase { 0.0f }; std::atomic paramZLFOOffset { 0.0f }; + std::atomic paramDopplerStrength { 1.0f }; float lastDistanceGain = 0.0f;