Skip to content

Commit 3f1a9e1

Browse files
committed
Update dpf, move smoothers there and split convolver class
Signed-off-by: falkTX <falktx@falktx.com>
1 parent 5984d57 commit 3f1a9e1

File tree

9 files changed

+161
-317
lines changed

9 files changed

+161
-317
lines changed

Diff for: dpf-widgets

Diff for: plugins/AB-InputSelector/OneKnobPlugin.cpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "DistrhoPluginInfo.h"
2020

2121
#include "OneKnobPlugin.hpp"
22-
#include "LinearSmoother.hpp"
2322

2423
START_NAMESPACE_DISTRHO
2524

@@ -31,9 +30,11 @@ class OneKnobInputSelectorPlugin : public OneKnobPlugin
3130
OneKnobInputSelectorPlugin()
3231
: OneKnobPlugin()
3332
{
33+
abSmooth.setTimeConstant(1e-3f);
34+
abSmooth.setTargetValue((kParameterRanges[kParameterSelect].def + 100.0f) / 200.0f);
35+
3436
init();
3537
sampleRateChanged(getSampleRate());
36-
abSmooth.setTimeConstant(1e-3f);
3738
}
3839

3940
protected:
@@ -117,7 +118,8 @@ class OneKnobInputSelectorPlugin : public OneKnobPlugin
117118
{
118119
OneKnobPlugin::setParameterValue(index, value);
119120

120-
// TODO do something extra here? if not, remove this
121+
if (index == kParameterSelect)
122+
abSmooth.setTargetValue((value + 100.0f) / 200.0f);
121123
}
122124

123125
void loadProgram(const uint32_t index) override
@@ -144,8 +146,7 @@ class OneKnobInputSelectorPlugin : public OneKnobPlugin
144146
{
145147
OneKnobPlugin::activate();
146148

147-
abSmooth.setTarget((parameters[kParameterSelect] + 100.0f) / 200.0f);
148-
abSmooth.clearToTarget();
149+
abSmooth.clearToTargetValue();
149150
}
150151

151152
void run(const float** const inputs, float** const outputs, const uint32_t frames) override
@@ -157,8 +158,6 @@ class OneKnobInputSelectorPlugin : public OneKnobPlugin
157158
/* */ float* const lo = outputs[0];
158159
/* */ float* const ro = outputs[1];
159160

160-
abSmooth.setTarget((parameters[kParameterSelect] + 100.0f) / 200.0f);
161-
162161
float sel, As, Bs;
163162
for (uint32_t i = 0; i < frames; ++i)
164163
{
@@ -181,7 +180,7 @@ class OneKnobInputSelectorPlugin : public OneKnobPlugin
181180
}
182181

183182
// -------------------------------------------------------------------
184-
LinearSmoother abSmooth;
183+
LinearValueSmoother abSmooth;
185184

186185
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(OneKnobInputSelectorPlugin)
187186
};

Diff for: plugins/AB-OutputSelector/OneKnobPlugin.cpp

+8-9
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "DistrhoPluginInfo.h"
2020

2121
#include "OneKnobPlugin.hpp"
22-
#include "LinearSmoother.hpp"
2322

2423
START_NAMESPACE_DISTRHO
2524

@@ -31,9 +30,11 @@ class OneKnobOutputSelectorPlugin : public OneKnobPlugin
3130
OneKnobOutputSelectorPlugin()
3231
: OneKnobPlugin()
3332
{
33+
abSmooth.setTimeConstant(1e-3f);
34+
abSmooth.setTargetValue((kParameterRanges[kParameterSelect].def + 100.0f) / 200.0f);
35+
3436
init();
3537
sampleRateChanged(getSampleRate());
36-
abSmooth.setTimeConstant(1e-3f);
3738
}
3839

3940
protected:
@@ -117,7 +118,8 @@ class OneKnobOutputSelectorPlugin : public OneKnobPlugin
117118
{
118119
OneKnobPlugin::setParameterValue(index, value);
119120

120-
// TODO do something extra here? if not, remove this
121+
if (index == kParameterSelect)
122+
abSmooth.setTargetValue((value + 100.0f) / 200.0f);
121123
}
122124

123125
void loadProgram(const uint32_t index) override
@@ -137,15 +139,14 @@ class OneKnobOutputSelectorPlugin : public OneKnobPlugin
137139
{
138140
OneKnobPlugin::sampleRateChanged(newSampleRate);
139141

140-
abSmooth.setSampleRate((float)newSampleRate);
142+
abSmooth.setSampleRate(newSampleRate);
141143
}
142144

143145
void activate() override
144146
{
145147
OneKnobPlugin::activate();
146148

147-
abSmooth.setTarget((parameters[kParameterSelect] + 100.0f) / 200.0f);
148-
abSmooth.clearToTarget();
149+
abSmooth.clearToTargetValue();
149150
}
150151

151152
void run(const float** const inputs, float** const outputs, const uint32_t frames) override
@@ -157,8 +158,6 @@ class OneKnobOutputSelectorPlugin : public OneKnobPlugin
157158
/* */ float* const l2 = outputs[2];
158159
/* */ float* const r2 = outputs[3];
159160

160-
abSmooth.setTarget((parameters[kParameterSelect] + 100.0f) / 200.0f);
161-
162161
float sel, As, Bs;
163162
for (uint32_t i = 0; i < frames; ++i)
164163
{
@@ -183,7 +182,7 @@ class OneKnobOutputSelectorPlugin : public OneKnobPlugin
183182
}
184183

185184
// -------------------------------------------------------------------
186-
LinearSmoother abSmooth;
185+
LinearValueSmoother abSmooth;
187186

188187
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(OneKnobOutputSelectorPlugin)
189188
};

Diff for: plugins/ConvolutionReverb/OneKnobPlugin.cpp

+20-95
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "DistrhoPluginInfo.h"
2020

2121
#include "OneKnobPlugin.hpp"
22-
#include "LinearSmoother.hpp"
2322
#include "Korg35Filters.hpp"
2423

2524
#include "Semaphore.hpp"
@@ -30,83 +29,11 @@
3029
#include "dr_wav.h"
3130
// -Wunused-variable
3231
#include "r8brain/CDSPResampler.h"
33-
#include "FFTConvolver/TwoStageFFTConvolver.h"
3432

35-
START_NAMESPACE_DISTRHO
36-
37-
#if defined(_MOD_DEVICE_DUO)
38-
static constexpr const size_t headBlockSize = 256;
39-
static constexpr const size_t tailBlockSize = 4096;
40-
#elif defined(_MOD_DEVICE_DWARF)
41-
static constexpr const size_t headBlockSize = 128;
42-
static constexpr const size_t tailBlockSize = 2048;
43-
#else
44-
static constexpr const size_t headBlockSize = 128;
45-
static constexpr const size_t tailBlockSize = 1024;
46-
#endif
47-
48-
// -----------------------------------------------------------------------
49-
50-
class TwoStageThreadedConvolver : public fftconvolver::TwoStageFFTConvolver,
51-
private Thread
52-
{
53-
Semaphore semBgProcStart;
54-
Semaphore semBgProcFinished;
55-
56-
public:
57-
TwoStageThreadedConvolver()
58-
: fftconvolver::TwoStageFFTConvolver(),
59-
Thread("TwoStageThreadedConvolver"),
60-
semBgProcStart(1),
61-
semBgProcFinished(0)
62-
{
63-
}
64-
65-
~TwoStageThreadedConvolver() override
66-
{
67-
stop();
68-
}
69-
70-
void start()
71-
{
72-
startThread(true);
73-
}
74-
75-
void stop()
76-
{
77-
signalThreadShouldExit();
78-
semBgProcStart.post();
79-
stopThread(5000);
80-
}
81-
82-
protected:
83-
void startBackgroundProcessing() override
84-
{
85-
semBgProcStart.post();
86-
}
87-
88-
void waitForBackgroundProcessing() override
89-
{
90-
if (isThreadRunning() && !shouldThreadExit())
91-
semBgProcFinished.wait();
92-
}
93-
94-
void run() override
95-
{
96-
while (!shouldThreadExit())
97-
{
98-
semBgProcStart.wait();
33+
// must be last
34+
#include "TwoStageThreadedConvolver.hpp"
9935

100-
if (shouldThreadExit())
101-
break;
102-
103-
doBackgroundProcessing();
104-
semBgProcFinished.post();
105-
}
106-
}
107-
108-
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(TwoStageThreadedConvolver)
109-
};
36+
START_NAMESPACE_DISTRHO
11037

11138
// -----------------------------------------------------------------------
11239

@@ -130,8 +57,8 @@ class OneKnobConvolutionReverbPlugin : public OneKnobPlugin
13057
smoothDryLevel.setTimeConstant(0.1f);
13158
smoothWetLevel.setTimeConstant(0.1f);
13259

133-
smoothDryLevel.setTarget(std::pow(10.f, 0.05f * kParameterRanges[kParameterDryLevel].def));
134-
smoothWetLevel.setTarget(std::pow(10.f, 0.05f * kParameterRanges[kParameterWetLevel].def));
60+
smoothDryLevel.setTargetValue(std::pow(10.f, 0.05f * kParameterRanges[kParameterDryLevel].def));
61+
smoothWetLevel.setTargetValue(std::pow(10.f, 0.05f * kParameterRanges[kParameterWetLevel].def));
13562
}
13663

13764
~OneKnobConvolutionReverbPlugin() override
@@ -261,11 +188,11 @@ class OneKnobConvolutionReverbPlugin : public OneKnobPlugin
261188
{
262189
case kParameterDryLevel:
263190
if (!bypassed)
264-
smoothDryLevel.setTarget(std::pow(10.f, 0.05f * value));
191+
smoothDryLevel.setTargetValue(std::pow(10.f, 0.05f * value));
265192
break;
266193
case kParameterWetLevel:
267194
if (!bypassed)
268-
smoothWetLevel.setTarget(std::pow(10.f, 0.05f * value));
195+
smoothWetLevel.setTargetValue(std::pow(10.f, 0.05f * value));
269196
break;
270197
case kParameterHighPassFilter:
271198
korgFilterL.setFrequency(value);
@@ -274,21 +201,21 @@ class OneKnobConvolutionReverbPlugin : public OneKnobPlugin
274201
case kParameterTrails:
275202
trails = value > 0.5f;
276203
if (bypassed)
277-
smoothWetLevel.setTarget(trails ? std::pow(10.f, 0.05f * parameters[kParameterWetLevel]) : 0.f);
204+
smoothWetLevel.setTargetValue(trails ? std::pow(10.f, 0.05f * parameters[kParameterWetLevel]) : 0.f);
278205
break;
279206
case kParameterBypass:
280207
bypassed = value > 0.5f;
281208
if (bypassed)
282209
{
283-
smoothDryLevel.setTarget(1.f);
284-
smoothWetLevel.setTarget(trails ? std::pow(10.f, 0.05f * parameters[kParameterWetLevel]) : 0.f);
210+
smoothDryLevel.setTargetValue(1.f);
211+
smoothWetLevel.setTargetValue(trails ? std::pow(10.f, 0.05f * parameters[kParameterWetLevel]) : 0.f);
285212
}
286213
else
287214
{
288215
korgFilterL.reset();
289216
korgFilterR.reset();
290-
smoothDryLevel.setTarget(std::pow(10.f, 0.05f * parameters[kParameterDryLevel]));
291-
smoothWetLevel.setTarget(std::pow(10.f, 0.05f * parameters[kParameterWetLevel]));
217+
smoothDryLevel.setTargetValue(std::pow(10.f, 0.05f * parameters[kParameterDryLevel]));
218+
smoothWetLevel.setTargetValue(std::pow(10.f, 0.05f * parameters[kParameterWetLevel]));
292219
}
293220
break;
294221
}
@@ -308,8 +235,8 @@ class OneKnobConvolutionReverbPlugin : public OneKnobPlugin
308235
korgFilterL.reset();
309236
korgFilterR.reset();
310237

311-
smoothDryLevel.clearToTarget();
312-
smoothWetLevel.clearToTarget();
238+
smoothDryLevel.clearToTargetValue();
239+
smoothWetLevel.clearToTargetValue();
313240
}
314241

315242
void setState(const char* const key, const char* const value) override
@@ -401,12 +328,10 @@ class OneKnobConvolutionReverbPlugin : public OneKnobPlugin
401328
}
402329

403330
newConvolverL = new TwoStageThreadedConvolver();
404-
newConvolverL->init(headBlockSize, tailBlockSize, irBufL, numFrames);
405-
newConvolverL->start();
331+
newConvolverL->init(irBufL, numFrames);
406332

407333
newConvolverR = new TwoStageThreadedConvolver();
408-
newConvolverR->init(headBlockSize, tailBlockSize, irBufR, numFrames);
409-
newConvolverR->start();
334+
newConvolverR->init(irBufR, numFrames);
410335

411336
{
412337
const MutexLocker cml(mutex);
@@ -441,8 +366,8 @@ class OneKnobConvolutionReverbPlugin : public OneKnobPlugin
441366
korgFilterL.reset();
442367
korgFilterR.reset();
443368

444-
smoothDryLevel.clearToTarget();
445-
smoothWetLevel.clearToTarget();
369+
smoothDryLevel.clearToTargetValue();
370+
smoothWetLevel.clearToTargetValue();
446371

447372
OneKnobPlugin::activate();
448373
}
@@ -639,8 +564,8 @@ class OneKnobConvolutionReverbPlugin : public OneKnobPlugin
639564
uint32_t bufferSize = 0;
640565

641566
// smoothed parameters
642-
LinearSmoother smoothDryLevel;
643-
LinearSmoother smoothWetLevel;
567+
LinearValueSmoother smoothDryLevel;
568+
LinearValueSmoother smoothWetLevel;
644569

645570
// buffers for placing highpass signal before convolution
646571
float* highpassBufL = nullptr;

0 commit comments

Comments
 (0)