diff options
| -rw-r--r-- | src/DSP/SchroederReverb.cpp | 4 | ||||
| -rw-r--r-- | src/DSP/SchroederReverb.h | 2 | ||||
| -rw-r--r-- | src/PluginProcessor.cpp | 3 | ||||
| -rw-r--r-- | src/PluginProcessor.h | 3 | ||||
| -rw-r--r-- | src/UI/PluginEditor.cpp | 26 | ||||
| -rw-r--r-- | src/UI/PluginEditor.h | 2 |
6 files changed, 26 insertions, 14 deletions
diff --git a/src/DSP/SchroederReverb.cpp b/src/DSP/SchroederReverb.cpp index 202c24d..1b4d3c9 100644 --- a/src/DSP/SchroederReverb.cpp +++ b/src/DSP/SchroederReverb.cpp @@ -12,7 +12,7 @@ SchroederReverb::prepare(double sampleRate, int samplesPerBlock) } void -SchroederReverb::process(float* sample) +SchroederReverb::process(float* sample, float dryWetMix) { juce::ScopedNoDenormals noDenormals; @@ -30,5 +30,5 @@ SchroederReverb::process(float* sample) allPassFilter0.process(&allPassIn); allPassFilter1.process(&allPassIn); - *sample = allPassIn; + *sample = dryWetMix * allPassIn + (1.0f - dryWetMix) * *sample; } diff --git a/src/DSP/SchroederReverb.h b/src/DSP/SchroederReverb.h index a5b3038..5db3def 100644 --- a/src/DSP/SchroederReverb.h +++ b/src/DSP/SchroederReverb.h @@ -9,7 +9,7 @@ class SchroederReverb public: void prepare(double sampleRate, int samplesPerBlock); void reset(); - void process(float* sample); + void process(float* sample, float dryWetMix); private: CombFilter combFilter0, combFilter1, combFilter2, combFilter3; diff --git a/src/PluginProcessor.cpp b/src/PluginProcessor.cpp index ec16ea9..b882df4 100644 --- a/src/PluginProcessor.cpp +++ b/src/PluginProcessor.cpp @@ -12,6 +12,7 @@ SchroederReverbAudioProcessor::SchroederReverbAudioProcessor() #endif ) { + addParameter(dryWetMix = new juce::AudioParameterFloat({"mix", 1}, "Mix", 0.0f, 1.0f, 0.5f)); } SchroederReverbAudioProcessor::~SchroederReverbAudioProcessor() {} @@ -162,7 +163,7 @@ SchroederReverbAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer, auto* channelData = buffer.getWritePointer(channel); for (int i = 0; i < buffer.getNumSamples(); ++i) { - schroederReverb.process(&channelData[i]); + schroederReverb.process(&channelData[i], dryWetMix->get()); } // ..do something to the data... } diff --git a/src/PluginProcessor.h b/src/PluginProcessor.h index ed9ae5f..27203ca 100644 --- a/src/PluginProcessor.h +++ b/src/PluginProcessor.h @@ -6,6 +6,8 @@ //============================================================================== class SchroederReverbAudioProcessor final : public juce::AudioProcessor { + friend class SchroederReverbAudioProcessorEditor; + public: //============================================================================== SchroederReverbAudioProcessor(); @@ -46,5 +48,6 @@ class SchroederReverbAudioProcessor final : public juce::AudioProcessor private: //============================================================================== SchroederReverb schroederReverb; + juce::AudioParameterFloat* dryWetMix; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SchroederReverbAudioProcessor) }; diff --git a/src/UI/PluginEditor.cpp b/src/UI/PluginEditor.cpp index b3b8256..aedb799 100644 --- a/src/UI/PluginEditor.cpp +++ b/src/UI/PluginEditor.cpp @@ -6,9 +6,21 @@ SchroederReverbAudioProcessorEditor::SchroederReverbAudioProcessorEditor( SchroederReverbAudioProcessor& p) : AudioProcessorEditor(&p), processorRef(p) { - juce::ignoreUnused(processorRef); - // Make sure that before the constructor has finished, you've set the - // editor's size to whatever you need it to be. + mixParam = processorRef.dryWetMix; + mixSlider.setSliderStyle(juce::Slider::LinearHorizontal); + mixSlider.setTextBoxStyle(juce::Slider::TextBoxRight, false, 50, 20); + mixSlider.setRange(0.0, 1.0, 0.01); + addAndMakeVisible(mixSlider); + + mixSlider.setValue(mixParam->get()); + mixSlider.onValueChange = [this]() + { + if (mixParam != nullptr) + { + *mixParam = (float)mixSlider.getValue(); + } + }; + setSize(400, 300); } @@ -18,17 +30,11 @@ SchroederReverbAudioProcessorEditor::~SchroederReverbAudioProcessorEditor() {} void SchroederReverbAudioProcessorEditor::paint(juce::Graphics& g) { - // (Our component is opaque, so we must completely fill the background with a solid colour) g.fillAll(getLookAndFeel().findColour(juce::ResizableWindow::backgroundColourId)); - - g.setColour(juce::Colours::white); - g.setFont(15.0f); - g.drawFittedText("Hello World!", getLocalBounds(), juce::Justification::centred, 1); } void SchroederReverbAudioProcessorEditor::resized() { - // This is generally where you'll want to lay out the positions of any - // subcomponents in your editor.. + mixSlider.setBounds(40, 80, getWidth() - 80, 20); } diff --git a/src/UI/PluginEditor.h b/src/UI/PluginEditor.h index 1f7a5bb..9e40c78 100644 --- a/src/UI/PluginEditor.h +++ b/src/UI/PluginEditor.h @@ -17,6 +17,8 @@ class SchroederReverbAudioProcessorEditor final : public juce::AudioProcessorEdi // This reference is provided as a quick way for your editor to // access the processor object that created it. SchroederReverbAudioProcessor& processorRef; + juce::Slider mixSlider; + juce::AudioParameterFloat* mixParam = nullptr; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SchroederReverbAudioProcessorEditor) }; |
