Skip to content

Commit

Permalink
added param for doppler strength
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Weidauer committed Jun 24, 2024
1 parent 739309d commit 08e8ed8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions source/PluginParameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ juce::AudioProcessorValueTreeState::ParameterLayout PluginParameters::createPara
params.push_back(std::make_unique<juce::AudioParameterBool>(DOPPLER_ID,
DOPPLER_NAME,
defaultDopplerParam));

params.push_back(std::make_unique<juce::AudioParameterFloat>(DOPPLER_STRENGTH_ID,
DOPPLER_STRENGTH_NAME,
dopplerStrengthRange,
defaultDopplerStrengthParam));

params.push_back(std::make_unique<juce::AudioParameterBool>(LFO_START_ID,
LFO_START_NAME,
Expand Down
6 changes: 5 additions & 1 deletion source/PluginParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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";

Expand All @@ -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 };
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 5 additions & 3 deletions source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,13 @@ void AudioPluginAudioProcessor::processBlock (juce::AudioBuffer<float>& 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 {
Expand All @@ -263,7 +263,7 @@ void AudioPluginAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer,
buffer.setSample(1, sample, delayLineRight.popSample(0));
}

buffer.applyGain(0.5);
buffer.applyGain(0.3);


}
Expand Down Expand Up @@ -308,6 +308,8 @@ void AudioPluginAudioProcessor::parameterChanged(const String &parameterID, floa
paramDistance.store(newValue);
} else if (parameterID == PluginParameters::DOPPLER_ID.getParamID()) {
paramDoppler.store(static_cast<bool>(newValue));
} else if (parameterID == PluginParameters::DOPPLER_STRENGTH_ID.getParamID()){
paramDopplerStrength.store(newValue);
}
if (parameterID == PluginParameters::PRESETS_ID.getParamID()) {
int selectedOption = static_cast<int>(newValue);
Expand Down
1 change: 1 addition & 0 deletions source/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class AudioPluginAudioProcessor final : public juce::AudioProcessor, private juc
std::atomic<float> paramZLFODepth { 0.0f };
std::atomic<float> paramZLFOPhase { 0.0f };
std::atomic<float> paramZLFOOffset { 0.0f };
std::atomic<float> paramDopplerStrength { 1.0f };


float lastDistanceGain = 0.0f;
Expand Down

0 comments on commit 08e8ed8

Please sign in to comment.