SquidgeDSP/plugins/SquidgeDistortion/SquidgeDistortion.cpp

75 lines
1.9 KiB
C++
Raw Normal View History

2026-08-02 05:37:06 +01:00
#include "DistrhoPlugin.hpp"
#include "DistrhoPluginInfo.h"
2026-08-02 20:14:51 +01:00
#include "../../core/Clipper.hpp"
#include "../../core/Gain.hpp"
2026-08-02 05:37:06 +01:00
START_NAMESPACE_DISTRHO
class SquidgeDistortion : public Plugin {
2026-08-02 20:14:51 +01:00
2026-08-02 05:37:06 +01:00
public:
2026-08-02 20:14:51 +01:00
enum Parameters {
kParamGain,
kParameterCount // must be last
};
SquidgeDistortion() : Plugin(kParameterCount, 0, 0), gain_(2.0f) {}
2026-08-02 05:37:06 +01:00
protected:
const char *getLabel() const override { return "SquidgeDistortion"; }
const char *getDescription() const override {
return "Simple distortion plugin.";
}
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', 'D', 'T'); }
2026-08-02 05:37:06 +01:00
2026-08-02 20:14:51 +01:00
void initParameter(uint32_t index, Parameter &parameter) override {
parameter.unit = "!";
switch (index) {
case kParamGain:
parameter.name = "Gain";
parameter.symbol = "gain";
parameter.ranges.min = 1.0f;
parameter.ranges.def = 2.0f;
parameter.ranges.max = 10.0f;
parameter.hints = kParameterIsAutomatable;
break;
}
}
float getParameterValue(uint32_t index) const override {
switch (index) {
case kParamGain:
return gain_.getGain();
}
return 0.0f;
}
void setParameterValue(uint32_t index, float value) override {
switch (index) {
case kParamGain:
gain_.setGain(value);
break;
}
}
void run(const float **inputs, float **outputs, uint32_t frames) override {
gain_.processStereo(inputs[0], inputs[1], outputs[0], outputs[1], frames);
clipper_.processStereo(outputs[0], outputs[1], outputs[0], outputs[1],
frames);
}
2026-08-02 05:37:06 +01:00
private:
2026-08-02 20:14:51 +01:00
Gain gain_;
Clipper clipper_;
2026-08-02 05:37:06 +01:00
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SquidgeDistortion);
};
Plugin *createPlugin() { return new SquidgeDistortion(); }
END_NAMESPACE_DISTRHO