Skip to content

Commit 7419f9a

Browse files
committed
added LFOs to all; adjusted out levels; added early reflection mono flag
1 parent b3217f6 commit 7419f9a

9 files changed

Lines changed: 158 additions & 45 deletions

Source/ConcertHallB.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void LargeConcertHallB::prepare(const juce::dsp::ProcessSpec& spec)
6767
allpassR4Outer.prepare(monoSpec);
6868

6969
lfoParameters.frequency_Hz = 0.5;
70-
lfoParameters.waveform = generatorWaveform::kTriangle;
70+
lfoParameters.waveform = generatorWaveform::kSin;
7171
lfo.setParameters(lfoParameters);
7272
lfo.reset(spec.sampleRate);
7373
}
@@ -338,7 +338,7 @@ void LargeConcertHallB::processBlock(juce::AudioBuffer<float>& buffer, juce::Mid
338338
{
339339
if (destChannel < 2)
340340
{
341-
buffer.setSample(destChannel, sample, channelOutput.at(destChannel));
341+
buffer.setSample(destChannel, sample, channelOutput.at(destChannel) * 3.0); // scale here, since output scalars are numerous and I don't want to mess with the ratio
342342
}
343343
}
344344
}

Source/DattorroVerb.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void DattorroPlate::prepare(const juce::dsp::ProcessSpec& spec)
4646

4747
// prepare lfo
4848
lfoParameters.frequency_Hz = 0.25;
49-
lfoParameters.waveform = generatorWaveform::kTriangle;
49+
lfoParameters.waveform = generatorWaveform::kSin;
5050
lfo.setParameters(lfoParameters);
5151
lfo.reset(spec.sampleRate);
5252
reset();
@@ -149,7 +149,7 @@ void DattorroPlate::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuf
149149
channelDataA[sample] += summingB * mParameters.decayTime;
150150

151151
// modulated APF1
152-
allpassOutput = modulatedAPF1.popSample(channel, modAPF1Delay + (lfoOutput.normalOutput * 12 * mParameters.modDepth));
152+
allpassOutput = modulatedAPF1.popSample(channel, modAPF1Delay + (lfoOutput.normalOutput * 12.0f * mParameters.modDepth));
153153
feedback = allpassOutput * decayDiffusion1 * mParameters.diffusion;
154154
feedforward = -channelDataA[sample] - allpassOutput * decayDiffusion1 * mParameters.diffusion;
155155
modulatedAPF1.pushSample(channel, channelDataA[sample] + feedback);
@@ -195,7 +195,7 @@ void DattorroPlate::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuf
195195
channelDataB[sample] += summingA * mParameters.decayTime;
196196

197197
// modulated APF2
198-
allpassOutput = modulatedAPF2.popSample(channel, modAPF2Delay + (lfoOutput.quadPhaseOutput_pos * 12 * mParameters.modDepth));
198+
allpassOutput = modulatedAPF2.popSample(channel, modAPF2Delay + (lfoOutput.quadPhaseOutput_pos * 12.0f * mParameters.modDepth));
199199
feedback = allpassOutput * decayDiffusion2 * mParameters.diffusion;
200200
feedforward = -channelDataB[sample] - allpassOutput * decayDiffusion2 * mParameters.diffusion;
201201
modulatedAPF2.pushSample(channel, channelDataB[sample] + feedback);

Source/EarlyReflections.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,16 @@ void EarlyReflections::processBlock(juce::AudioBuffer<float>& buffer, juce::Midi
6464
channel1Output += earlyReflectionsDelayLine.getSampleAtDelay(0, 3948 * mParameters.roomSize) * mInitialLevel * mParameters.decayTime;
6565
channel1Output += earlyReflectionsDelayLine.getSampleAtDelay(0, 9462 * mParameters.roomSize) * mInitialLevel * pow(mParameters.decayTime, 2);
6666

67-
// right into left HRTF and vice versa
68-
leftHRTFDelay.pushSample(0, channel1Output);
69-
rightHRTFDelay.pushSample(0, channel0Output);
70-
71-
// filter HRTFs and add to outputs
72-
channel0Output += leftHRTFFilter.processSample(0, leftHRTFDelay.popSample(0));
73-
channel1Output += rightHRTFFilter.processSample(0, rightHRTFDelay.popSample(0));
67+
if (!monoFlag)
68+
{
69+
// right into left HRTF and vice versa
70+
leftHRTFDelay.pushSample(0, channel1Output);
71+
rightHRTFDelay.pushSample(0, channel0Output);
72+
73+
// filter HRTFs and add to outputs
74+
channel0Output += leftHRTFFilter.processSample(0, leftHRTFDelay.popSample(0));
75+
channel1Output += rightHRTFFilter.processSample(0, rightHRTFDelay.popSample(0));
76+
}
7477

7578
// outputs into original stereo buffer
7679
for (int destChannel = 0; destChannel < numChannels; ++destChannel)

Source/EarlyReflections.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class EarlyReflections : public ReverbProcessorBase
3434
ReverbProcessorParameters& getParameters() override;
3535

3636
void setParameters(const ReverbProcessorParameters& params) override;
37+
38+
void setMonoFlag(const bool newMonoFlag) { monoFlag = newMonoFlag; }
3739
private:
3840
ReverbProcessorParameters mParameters;
3941

@@ -43,11 +45,13 @@ class EarlyReflections : public ReverbProcessorBase
4345
juce::dsp::FirstOrderTPTFilter<float> leftHRTFFilter;
4446
juce::dsp::FirstOrderTPTFilter<float> rightHRTFFilter;
4547

46-
float channel0Output = 0;
47-
float channel1Output = 0;
48+
float channel0Output { 0 };
49+
float channel1Output { 0 };
50+
51+
float mPreDelayTime { 441 };
52+
float mInitialLevel { 1.0 };
4853

49-
float mPreDelayTime = 441;
50-
float mInitialLevel = 0.5;
54+
bool monoFlag { false };
5155
};
5256

5357
////==============================================================================

Source/Freeverb.cpp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

5163
void 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);

Source/Freeverb.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <JuceHeader.h>
1212

13+
#include "LFO.h"
1314
#include "ProcessorBase.h"
1415
#include "Utilities.h"
1516

@@ -50,10 +51,14 @@ class Freeverb : public ReverbProcessorBase
5051
juce::dsp::FirstOrderTPTFilter<float> dampingFilter6;
5152
juce::dsp::FirstOrderTPTFilter<float> dampingFilter7;
5253

53-
juce::dsp::DelayLine<float> allpass0 {1000};
54-
juce::dsp::DelayLine<float> allpass1 {1000};
55-
juce::dsp::DelayLine<float> allpass2 {1000};
56-
juce::dsp::DelayLine<float> allpass3 {1000};
54+
juce::dsp::DelayLine<float> allpass0 {22050};
55+
juce::dsp::DelayLine<float> allpass1 {22050};
56+
juce::dsp::DelayLine<float> allpass2 {22050};
57+
juce::dsp::DelayLine<float> allpass3 {22050};
58+
59+
OscillatorParameters lfoParameters;
60+
SignalGenData lfoOutput;
61+
std::vector<LFO> lfo;
5762

5863
float comb0Output = 0;
5964
float comb1Output = 0;

0 commit comments

Comments
 (0)