feat: adding filter plugin
This commit is contained in:
parent
a80c6276a8
commit
3c3fec9b90
4 changed files with 157 additions and 1 deletions
2
Makefile
2
Makefile
|
|
@ -3,7 +3,7 @@
|
||||||
# ------------------------------ #
|
# ------------------------------ #
|
||||||
|
|
||||||
# Define your plugins here as space-separated names
|
# Define your plugins here as space-separated names
|
||||||
PLUGINS = SquidgeDistortion
|
PLUGINS = SquidgeDistortion SquidgeFilter
|
||||||
|
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
25
plugins/SquidgeFilter/DistrhoPluginInfo.h
Normal file
25
plugins/SquidgeFilter/DistrhoPluginInfo.h
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
#ifndef DISTRHO_PLUGIN_INFO_H_INCLUDED
|
||||||
|
#define DISTRHO_PLUGIN_INFO_H_INCLUDED
|
||||||
|
|
||||||
|
#define DISTRHO_PLUGIN_NAME "SquidgeFilter"
|
||||||
|
#define DISTRHO_PLUGIN_AUTHOR "SquidgeSoft"
|
||||||
|
#define DISTRHO_PLUGIN_URI "moe.liam.squidgesoft.SquidgeFilter"
|
||||||
|
#define DISTRHO_PLUGIN_CATEGORY "fx"
|
||||||
|
|
||||||
|
#define DISTRHO_PLUGIN_NUM_INPUTS 2
|
||||||
|
#define DISTRHO_PLUGIN_NUM_OUTPUTS 2
|
||||||
|
|
||||||
|
#define DISTRHO_PLUGIN_NUM_PARAMETERS 3
|
||||||
|
|
||||||
|
#define DISTRHO_PLUGIN_WANT_PROGRAMS 0
|
||||||
|
#define DISTRHO_PLUGIN_WANT_STATE 0
|
||||||
|
|
||||||
|
#define DISTRHO_PLUGIN_HAS_UI 0
|
||||||
|
#define DISTRHO_PLUGIN_IS_SYNTH 0
|
||||||
|
|
||||||
|
#define DISTRHO_PLUGIN_PRIV_ID "moe.liam.squidgesoft.SquidgeFilter"
|
||||||
|
#define DISTRHO_PLUGIN_BRAND "SquidgeSoft"
|
||||||
|
|
||||||
|
#define DISTRHO_PLUGIN_CLAP_ID "moe.liam.squidgesoft.SquidgeFilter"
|
||||||
|
|
||||||
|
#endif
|
||||||
11
plugins/SquidgeFilter/Makefile
Normal file
11
plugins/SquidgeFilter/Makefile
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/usr/bin/make -f
|
||||||
|
NAME = SquidgeFilter
|
||||||
|
|
||||||
|
FILES_DSP = SquidgeFilter.cpp ../../core/Filter.cpp
|
||||||
|
|
||||||
|
TARGETS = vst3 clap
|
||||||
|
|
||||||
|
include ../../dpf/Makefile.plugins.mk
|
||||||
|
|
||||||
|
all: $(TARGETS)
|
||||||
|
|
||||||
120
plugins/SquidgeFilter/SquidgeFilter.cpp
Normal file
120
plugins/SquidgeFilter/SquidgeFilter.cpp
Normal file
|
|
@ -0,0 +1,120 @@
|
||||||
|
#include "DistrhoDetails.hpp"
|
||||||
|
#include "DistrhoPlugin.hpp"
|
||||||
|
#include "DistrhoPluginInfo.h"
|
||||||
|
|
||||||
|
#include "../../core/Filter.hpp"
|
||||||
|
|
||||||
|
START_NAMESPACE_DISTRHO
|
||||||
|
|
||||||
|
class SquidgeFilter : public Plugin {
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum Parameters {
|
||||||
|
kParamFreq,
|
||||||
|
kParamResonance,
|
||||||
|
kParamType,
|
||||||
|
kParameterCount // must be last
|
||||||
|
};
|
||||||
|
|
||||||
|
SquidgeFilter() // Note: Constructor name must match class name
|
||||||
|
: Plugin(kParameterCount, 0, 0),
|
||||||
|
filter_(1000.0f, 0.707f, 48000.0f) { // Default: 1kHz, Q=0.707
|
||||||
|
filter_.setType(Filter::kLowPass);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
const char *getLabel() const override { return "SquidgeFilter"; }
|
||||||
|
const char *getDescription() const override {
|
||||||
|
return "Simple State Variable Filter.";
|
||||||
|
}
|
||||||
|
const char *getMaker() const override { return "SquidgeSoft"; }
|
||||||
|
const char *getLicense() const override { return "GPL3"; }
|
||||||
|
uint32_t getVersion() const override { return d_version(0, 1, 0); }
|
||||||
|
int64_t getUniqueId() const override { return d_cconst('S', 'Q', 'F', 'T'); }
|
||||||
|
|
||||||
|
void initParameter(uint32_t index, Parameter ¶meter) override {
|
||||||
|
switch (index) {
|
||||||
|
case kParamFreq:
|
||||||
|
parameter.name = "Frequency";
|
||||||
|
parameter.symbol = "frequency";
|
||||||
|
parameter.ranges.min = 20.0f;
|
||||||
|
parameter.ranges.def = 1000.0f;
|
||||||
|
parameter.ranges.max = 20000.0f;
|
||||||
|
parameter.hints = kParameterIsAutomatable | kParameterIsLogarithmic;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kParamResonance:
|
||||||
|
parameter.name = "Resonance";
|
||||||
|
parameter.symbol = "resonance";
|
||||||
|
parameter.ranges.min = 0.1f;
|
||||||
|
parameter.ranges.def = 0.707f;
|
||||||
|
parameter.ranges.max = 20.0f;
|
||||||
|
parameter.hints = kParameterIsAutomatable;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kParamType:
|
||||||
|
parameter.name = "Filter Type";
|
||||||
|
parameter.symbol = "type";
|
||||||
|
parameter.ranges.min = 0.0f;
|
||||||
|
parameter.ranges.def = 0.0f;
|
||||||
|
parameter.ranges.max = Filter::kFilterTypeCount - 1;
|
||||||
|
parameter.hints = kParameterIsAutomatable | kParameterIsInteger;
|
||||||
|
parameter.enumValues.count = Filter::kFilterTypeCount;
|
||||||
|
parameter.enumValues.restrictedMode = true;
|
||||||
|
|
||||||
|
static const ParameterEnumerationValue sTypes[Filter::kFilterTypeCount] =
|
||||||
|
{{0.0f, "Low Pass"},
|
||||||
|
{1.0f, "High Pass"},
|
||||||
|
{2.0f, "Band Pass"},
|
||||||
|
{3.0f, "Notch"}};
|
||||||
|
parameter.enumValues.values =
|
||||||
|
const_cast<ParameterEnumerationValue *>(sTypes);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float getParameterValue(uint32_t index) const override {
|
||||||
|
switch (index) {
|
||||||
|
case kParamFreq:
|
||||||
|
return filter_.getCutOff();
|
||||||
|
case kParamResonance:
|
||||||
|
return filter_.getQ();
|
||||||
|
case kParamType:
|
||||||
|
return static_cast<float>(filter_.getType());
|
||||||
|
}
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setParameterValue(uint32_t index, float value) override {
|
||||||
|
switch (index) {
|
||||||
|
case kParamFreq:
|
||||||
|
filter_.setCutOff(value);
|
||||||
|
break;
|
||||||
|
case kParamResonance:
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void run(const float **inputs, float **outputs, uint32_t frames) override {
|
||||||
|
filter_.processStereo(inputs[0], inputs[1], outputs[0], outputs[1], frames);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sampleRateChanged(double newSr) override {
|
||||||
|
filter_.setSampleRate(static_cast<float>(newSr));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Filter filter_;
|
||||||
|
|
||||||
|
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SquidgeFilter);
|
||||||
|
};
|
||||||
|
|
||||||
|
Plugin *createPlugin() { return new SquidgeFilter(); }
|
||||||
|
|
||||||
|
END_NAMESPACE_DISTRHO
|
||||||
Loading…
Add table
Add a link
Reference in a new issue