aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Kaiser2025-10-06 16:30:31 +0200
committerDominik Kaiser2025-10-06 16:31:36 +0200
commit5795493239b56a3b8a6d93b8861c1f7259f92896 (patch)
tree0683476fc86347ff26a6c6dd512566e89443c326
parent1861458f4fa4647379d372858222d6481beaa015 (diff)
downloadSchroederReverb-5795493239b56a3b8a6d93b8861c1f7259f92896.tar.gz
SchroederReverb-5795493239b56a3b8a6d93b8861c1f7259f92896.zip
Cleanup
-rw-r--r--src/DSP/AllPassFilter.cpp16
-rw-r--r--src/DSP/AllPassFilter.h4
-rw-r--r--src/DSP/CombFilter.cpp13
-rw-r--r--src/DSP/CombFilter.h4
-rw-r--r--src/DSP/SchroederReverb.cpp24
-rw-r--r--src/DSP/SchroederReverb.h2
-rw-r--r--src/PluginProcessor.cpp87
-rw-r--r--src/UI/PluginEditor.h2
8 files changed, 46 insertions, 106 deletions
diff --git a/src/DSP/AllPassFilter.cpp b/src/DSP/AllPassFilter.cpp
index a051fd4..f250656 100644
--- a/src/DSP/AllPassFilter.cpp
+++ b/src/DSP/AllPassFilter.cpp
@@ -9,24 +9,20 @@ AllPassFilter::prepare(double sampleRate, int samplesPerBlock, int delayInSample
delayBuffer.resize(maxDelaySamples, 0.0f);
std::fill(delayBuffer.begin(), delayBuffer.end(), 0.0f);
delayBufferWritePos = 0;
- this->delayInSamples_ = delayInSamples;
+ this->delayInSamples = delayInSamples;
this->gain = gain;
}
void
-AllPassFilter::process(float* sample)
+AllPassFilter::process(float& sample)
{
int delayBufferLength = (int)delayBuffer.size();
int delayReadPos
- = (delayBufferWritePos - delayInSamples_ + delayBufferLength) % delayBufferLength;
-
+ = (delayBufferWritePos - delayInSamples + delayBufferLength) % delayBufferLength;
float delayedSample = delayBuffer[delayReadPos];
- float xn = *sample;
-
- float bufferInput = xn + gain * delayedSample;
- float yn = -gain * xn + delayedSample;
+
+ delayBuffer[delayBufferWritePos] = sample + gain * delayedSample;
+ sample = -gain * sample + delayedSample;
- delayBuffer[delayBufferWritePos] = bufferInput;
- *sample = yn;
delayBufferWritePos = (delayBufferWritePos + 1) % delayBufferLength;
}
diff --git a/src/DSP/AllPassFilter.h b/src/DSP/AllPassFilter.h
index b989122..78342fc 100644
--- a/src/DSP/AllPassFilter.h
+++ b/src/DSP/AllPassFilter.h
@@ -7,11 +7,11 @@ class AllPassFilter
public:
void prepare(double sampleRate, int samplesPerBlock, int delayInSamples, float gain);
void reset();
- void process(float* sample);
+ void process(float& sample);
private:
std::vector<float> delayBuffer;
int delayBufferWritePos = 0;
- int delayInSamples_ = 0;
+ int delayInSamples = 0;
float gain = 0.7f;
};
diff --git a/src/DSP/CombFilter.cpp b/src/DSP/CombFilter.cpp
index dc4de96..8390675 100644
--- a/src/DSP/CombFilter.cpp
+++ b/src/DSP/CombFilter.cpp
@@ -9,19 +9,20 @@ CombFilter::prepare(double sampleRate, int samplesPerBlock, int delayInSamples,
delayBuffer.resize(maxDelaySamples, 0.0f);
std::fill(delayBuffer.begin(), delayBuffer.end(), 0.0f);
delayBufferWritePos = 0;
- this->delayInSamples_ = delayInSamples;
+ this->delayInSamples = delayInSamples;
this->gain = gain;
}
void
-CombFilter::process(float* sample)
+CombFilter::process(float& sample)
{
int delayBufferLength = (int)delayBuffer.size();
int delayReadPos
- = (delayBufferWritePos - delayInSamples_ + delayBufferLength) % delayBufferLength;
+ = (delayBufferWritePos - delayInSamples + delayBufferLength) % delayBufferLength;
float delayedSample = delayBuffer[delayReadPos];
- float yn = *sample + gain * delayedSample;
- delayBuffer[delayBufferWritePos] = yn;
+
+ delayBuffer[delayBufferWritePos] = sample + gain * delayedSample;
+ sample = delayedSample;
+
delayBufferWritePos = (delayBufferWritePos + 1) % delayBufferLength;
- *sample = delayedSample;
}
diff --git a/src/DSP/CombFilter.h b/src/DSP/CombFilter.h
index 4e435cd..6eada89 100644
--- a/src/DSP/CombFilter.h
+++ b/src/DSP/CombFilter.h
@@ -7,11 +7,11 @@ class CombFilter
public:
void prepare(double sampleRate, int samplesPerBlock, int delayInSamples, float gain);
void reset();
- void process(float* sample);
+ void process(float& sample);
private:
std::vector<float> delayBuffer;
int delayBufferWritePos = 0;
- int delayInSamples_ = 0;
+ int delayInSamples = 0;
float gain = 0.7f;
};
diff --git a/src/DSP/SchroederReverb.cpp b/src/DSP/SchroederReverb.cpp
index 1b4d3c9..b631765 100644
--- a/src/DSP/SchroederReverb.cpp
+++ b/src/DSP/SchroederReverb.cpp
@@ -12,23 +12,23 @@ SchroederReverb::prepare(double sampleRate, int samplesPerBlock)
}
void
-SchroederReverb::process(float* sample, float dryWetMix)
+SchroederReverb::process(float& sample, float dryWetMix)
{
juce::ScopedNoDenormals noDenormals;
- float in0 = *sample;
- float in1 = *sample;
- float in2 = *sample;
- float in3 = *sample;
+ float in0 = sample;
+ float in1 = sample;
+ float in2 = sample;
+ float in3 = sample;
- combFilter0.process(&in0);
- combFilter1.process(&in1);
- combFilter2.process(&in2);
- combFilter3.process(&in3);
+ combFilter0.process(in0);
+ combFilter1.process(in1);
+ combFilter2.process(in2);
+ combFilter3.process(in3);
float allPassIn = 0.25f * (in0 + in1 + in2 + in3);
- allPassFilter0.process(&allPassIn);
- allPassFilter1.process(&allPassIn);
+ allPassFilter0.process(allPassIn);
+ allPassFilter1.process(allPassIn);
- *sample = dryWetMix * allPassIn + (1.0f - dryWetMix) * *sample;
+ sample = dryWetMix * allPassIn + (1.0f - dryWetMix) * sample;
}
diff --git a/src/DSP/SchroederReverb.h b/src/DSP/SchroederReverb.h
index 5db3def..c6e5110 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, float dryWetMix);
+ void process(float& sample, float dryWetMix);
private:
CombFilter combFilter0, combFilter1, combFilter2, combFilter3;
diff --git a/src/PluginProcessor.cpp b/src/PluginProcessor.cpp
index b882df4..770f7a2 100644
--- a/src/PluginProcessor.cpp
+++ b/src/PluginProcessor.cpp
@@ -4,15 +4,10 @@
//==============================================================================
SchroederReverbAudioProcessor::SchroederReverbAudioProcessor()
: AudioProcessor(BusesProperties()
-#if !JucePlugin_IsMidiEffect
-#if !JucePlugin_IsSynth
.withInput("Input", juce::AudioChannelSet::stereo(), true)
-#endif
- .withOutput("Output", juce::AudioChannelSet::stereo(), true)
-#endif
- )
+ .withOutput("Output", juce::AudioChannelSet::stereo(), true))
{
- addParameter(dryWetMix = new juce::AudioParameterFloat({"mix", 1}, "Mix", 0.0f, 1.0f, 0.5f));
+ addParameter(dryWetMix = new juce::AudioParameterFloat({ "mix", 1 }, "Mix", 0.0f, 1.0f, 0.5f));
}
SchroederReverbAudioProcessor::~SchroederReverbAudioProcessor() {}
@@ -27,44 +22,32 @@ SchroederReverbAudioProcessor::getName() const
bool
SchroederReverbAudioProcessor::acceptsMidi() const
{
-#if JucePlugin_WantsMidiInput
- return true;
-#else
return false;
-#endif
}
bool
SchroederReverbAudioProcessor::producesMidi() const
{
-#if JucePlugin_ProducesMidiOutput
- return true;
-#else
return false;
-#endif
}
bool
SchroederReverbAudioProcessor::isMidiEffect() const
{
-#if JucePlugin_IsMidiEffect
- return true;
-#else
return false;
-#endif
}
double
SchroederReverbAudioProcessor::getTailLengthSeconds() const
{
+ // TODO: Change number after implementing Decay
return 0.0;
}
int
SchroederReverbAudioProcessor::getNumPrograms()
{
- return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs,
- // so this should be at least 1, even if you're not really implementing programs.
+ return 1;
}
int
@@ -96,41 +79,19 @@ SchroederReverbAudioProcessor::changeProgramName(int index, const juce::String&
void
SchroederReverbAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBlock)
{
- // Use this method as the place to do any pre-playback
- // initialisation that you need..
schroederReverb.prepare(sampleRate, samplesPerBlock);
}
void
SchroederReverbAudioProcessor::releaseResources()
{
- // When playback stops, you can use this as an opportunity to free up any
- // spare memory, etc.
}
+// The plugin only supports layouts with the same number of input and output channels
bool
SchroederReverbAudioProcessor::isBusesLayoutSupported(const BusesLayout& layouts) const
{
-#if JucePlugin_IsMidiEffect
- juce::ignoreUnused(layouts);
- return true;
-#else
- // This is the place where you check if the layout is supported.
- // In this template code we only support mono or stereo.
- // Some plugin hosts, such as certain GarageBand versions, will only
- // load plugins that support stereo bus layouts.
- if (layouts.getMainOutputChannelSet() != juce::AudioChannelSet::mono()
- && layouts.getMainOutputChannelSet() != juce::AudioChannelSet::stereo())
- return false;
-
- // This checks if the input layout matches the output layout
-#if !JucePlugin_IsSynth
- if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
- return false;
-#endif
-
- return true;
-#endif
+ return layouts.getMainOutputChannelSet() == layouts.getMainInputChannelSet();
}
void
@@ -138,34 +99,23 @@ SchroederReverbAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer,
juce::MidiBuffer& midiMessages)
{
juce::ignoreUnused(midiMessages);
-
juce::ScopedNoDenormals noDenormals;
- auto totalNumInputChannels = getTotalNumInputChannels();
- auto totalNumOutputChannels = getTotalNumOutputChannels();
-
- // In case we have more outputs than inputs, this code clears any output
- // channels that didn't contain input data, (because these aren't
- // guaranteed to be empty - they may contain garbage).
- // This is here to avoid people getting screaming feedback
- // when they first compile a plugin, but obviously you don't need to keep
- // this code if your algorithm always overwrites all the output channels.
- for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
+
+ int totalNumInputChannels = getTotalNumInputChannels();
+ int totalNumOutputChannels = getTotalNumOutputChannels();
+
+ // Clear extra channels
+ for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear(i, 0, buffer.getNumSamples());
- // This is the place where you'd normally do the guts of your plugin's
- // audio processing...
- // Make sure to reset the state if your inner loop is processing
- // the samples and the outer loop is handling the channels.
- // Alternatively, you can process the samples with the channels
- // interleaved by keeping the same state.
for (int channel = 0; channel < totalNumInputChannels; ++channel)
{
- auto* channelData = buffer.getWritePointer(channel);
+ float* channelData = buffer.getWritePointer(channel);
for (int i = 0; i < buffer.getNumSamples(); ++i)
{
- schroederReverb.process(&channelData[i], dryWetMix->get());
+ // Apply effect to sample
+ schroederReverb.process(channelData[i], dryWetMix->get());
}
- // ..do something to the data...
}
}
@@ -173,7 +123,7 @@ SchroederReverbAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer,
bool
SchroederReverbAudioProcessor::hasEditor() const
{
- return true; // (change this to false if you choose to not supply an editor)
+ return true;
}
juce::AudioProcessorEditor*
@@ -186,17 +136,12 @@ SchroederReverbAudioProcessor::createEditor()
void
SchroederReverbAudioProcessor::getStateInformation(juce::MemoryBlock& destData)
{
- // You should use this method to store your parameters in the memory block.
- // You could do that either as raw data, or use the XML or ValueTree classes
- // as intermediaries to make it easy to save and load complex data.
juce::ignoreUnused(destData);
}
void
SchroederReverbAudioProcessor::setStateInformation(const void* data, int sizeInBytes)
{
- // You should use this method to restore your parameters from this memory block,
- // whose contents will have been created by the getStateInformation() call.
juce::ignoreUnused(data, sizeInBytes);
}
diff --git a/src/UI/PluginEditor.h b/src/UI/PluginEditor.h
index 9e40c78..ad42bf8 100644
--- a/src/UI/PluginEditor.h
+++ b/src/UI/PluginEditor.h
@@ -14,8 +14,6 @@ class SchroederReverbAudioProcessorEditor final : public juce::AudioProcessorEdi
void resized() override;
private:
- // 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;