feat(filter): Add modulation support and LFO integration
This commit is contained in:
parent
3c3fec9b90
commit
fe594a5494
6 changed files with 131 additions and 20 deletions
|
|
@ -3,9 +3,12 @@
|
|||
#include "DistrhoPluginInfo.h"
|
||||
|
||||
#include "../../core/Filter.hpp"
|
||||
#include "../../core/Oscillator.hpp"
|
||||
|
||||
START_NAMESPACE_DISTRHO
|
||||
|
||||
const int BUFFER_SIZE = 16384;
|
||||
|
||||
class SquidgeFilter : public Plugin {
|
||||
|
||||
public:
|
||||
|
|
@ -17,8 +20,8 @@ public:
|
|||
};
|
||||
|
||||
SquidgeFilter() // Note: Constructor name must match class name
|
||||
: Plugin(kParameterCount, 0, 0),
|
||||
filter_(1000.0f, 0.707f, 48000.0f) { // Default: 1kHz, Q=0.707
|
||||
: Plugin(kParameterCount, 0, 0), filter_(1000.0f, 0.707f, 48000.0f),
|
||||
lfo_(4.0f) { // Default: 1kHz, Q=0.707
|
||||
filter_.setType(Filter::kLowPass);
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +97,6 @@ protected:
|
|||
filter_.setQ(value);
|
||||
break;
|
||||
case kParamType:
|
||||
// Clamp value to valid enum range
|
||||
int typeIdx = static_cast<int>(std::fmin(std::fmax(value, 0.0f), 3.0f));
|
||||
filter_.setType(static_cast<Filter::FilterType>(typeIdx));
|
||||
break;
|
||||
|
|
@ -102,15 +104,21 @@ protected:
|
|||
}
|
||||
|
||||
void run(const float **inputs, float **outputs, uint32_t frames) override {
|
||||
filter_.processStereo(inputs[0], inputs[1], outputs[0], outputs[1], frames);
|
||||
lfo_.process(lfoBuffer_, frames);
|
||||
|
||||
filter_.processStereo(inputs[0], inputs[1], outputs[0], outputs[1], frames,
|
||||
lfoBuffer_);
|
||||
}
|
||||
|
||||
void sampleRateChanged(double newSr) override {
|
||||
filter_.setSampleRate(static_cast<float>(newSr));
|
||||
lfo_.setSampleRate(newSr);
|
||||
}
|
||||
|
||||
private:
|
||||
Filter filter_;
|
||||
Oscillator lfo_;
|
||||
float lfoBuffer_[BUFFER_SIZE];
|
||||
|
||||
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SquidgeFilter);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue