@@ -46,6 +46,18 @@ void Freeverb::prepare(const juce::dsp::ProcessSpec& spec)
4646 allpass1.prepare (spec);
4747 allpass2.prepare (spec);
4848 allpass3.prepare (spec);
49+
50+ // prepare lfo
51+ lfoParameters.frequency_Hz = 0.25 ;
52+ lfoParameters.waveform = generatorWaveform::kSin ;
53+ lfo.resize (spec.numChannels );
54+ for (auto & osc : lfo)
55+ {
56+ osc.setParameters (lfoParameters);
57+ osc.reset (spec.sampleRate );
58+ }
59+
60+ reset ();
4961}
5062
5163void Freeverb::processBlock (juce::AudioBuffer<float >& buffer, juce::MidiBuffer& midiMessages)
@@ -65,6 +77,10 @@ void Freeverb::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer&
6577 {
6678 auto * channelData = buffer.getWritePointer (channel);
6779
80+ lfoParameters = lfo[channel].getParameters ();
81+ lfoParameters.frequency_Hz = mParameters .modRate ;
82+ lfo[channel].setParameters (lfoParameters);
83+
6884 comb0.setDelay (1557 * mParameters .roomSize + (channel * mWidth ));
6985 comb1.setDelay (1617 * mParameters .roomSize + (channel * mWidth ));
7086 comb2.setDelay (1491 * mParameters .roomSize + (channel * mWidth ));
@@ -74,9 +90,11 @@ void Freeverb::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer&
7490 comb6.setDelay (1188 * mParameters .roomSize + (channel * mWidth ));
7591 comb7.setDelay (1116 * mParameters .roomSize + (channel * mWidth ));
7692
77- allpass0.setDelay (225 + (channel * mWidth ));
93+ int allpass0Delay = 225 + (channel * mWidth );
94+ int allpass2Delay = 441 + (channel * mWidth );
95+ allpass0.setDelay (allpass0Delay);
7896 allpass1.setDelay (556 + (channel * mWidth ));
79- allpass2.setDelay (441 + (channel * mWidth ) );
97+ allpass2.setDelay (allpass2Delay );
8098 allpass3.setDelay (341 + (channel * mWidth ));
8199
82100 // comb processing in parallel
@@ -116,7 +134,10 @@ void Freeverb::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer&
116134
117135 for (int sample = 0 ; sample < buffer.getNumSamples (); ++sample)
118136 {
119- allpass0Output = allpass0.popSample (channel);
137+ // LFO
138+ lfoOutput = lfo[channel].renderAudioOutput ();
139+
140+ allpass0Output = allpass0.popSample (channel, allpass0Delay + (lfoOutput.normalOutput * 1 .0f * mParameters .modDepth ));
120141 feedback = allpass0Output * allpassFeedbackCoefficient;
121142 feedforward = -channelData[sample] - allpass0Output * allpassFeedbackCoefficient;
122143 allpass0.pushSample (channel, channelData[sample] + feedback);
@@ -128,7 +149,7 @@ void Freeverb::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer&
128149 allpass1.pushSample (channel, channelData[sample] + feedback);
129150 channelData[sample] = allpass1Output + feedforward;
130151
131- allpass2Output = allpass2.popSample (channel);
152+ allpass2Output = allpass2.popSample (channel, allpass2Delay + (lfoOutput. quadPhaseOutput_neg * 1 . 0f * mParameters . modDepth ) );
132153 feedback = allpass2Output * allpassFeedbackCoefficient;
133154 feedforward = -channelData[sample] - allpass2Output * allpassFeedbackCoefficient;
134155 allpass2.pushSample (channel, channelData[sample] + feedback);
0 commit comments