diff --git a/Makefile b/Makefile index 06e9521..ed9a92c 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # ------------------------------ # # Define your plugins here as space-separated names -PLUGINS = SquidgeDistortion +PLUGINS = SquidgeDistortion SquidgeFilter # -------------------------------------------------------------- diff --git a/plugins/SquidgeFilter/DistrhoPluginInfo.h b/plugins/SquidgeFilter/DistrhoPluginInfo.h new file mode 100644 index 0000000..4e6a319 --- /dev/null +++ b/plugins/SquidgeFilter/DistrhoPluginInfo.h @@ -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 \ No newline at end of file diff --git a/plugins/SquidgeFilter/Makefile b/plugins/SquidgeFilter/Makefile new file mode 100644 index 0000000..4d6640f --- /dev/null +++ b/plugins/SquidgeFilter/Makefile @@ -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) + diff --git a/plugins/SquidgeFilter/SquidgeFilter.cpp b/plugins/SquidgeFilter/SquidgeFilter.cpp new file mode 100644 index 0000000..1339b3f --- /dev/null +++ b/plugins/SquidgeFilter/SquidgeFilter.cpp @@ -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(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(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(std::fmin(std::fmax(value, 0.0f), 3.0f)); + filter_.setType(static_cast(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(newSr)); + } + +private: + Filter filter_; + + DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SquidgeFilter); +}; + +Plugin *createPlugin() { return new SquidgeFilter(); } + +END_NAMESPACE_DISTRHO \ No newline at end of file