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,
|
2026-08-02 22:58:56 +01:00
|
|
|
kParamClipMode,
|
2026-08-02 20:14:51 +01:00
|
|
|
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"; }
|
2026-08-02 17:17:23 +01:00
|
|
|
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 ¶meter) override {
|
|
|
|
|
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;
|
2026-08-02 22:58:56 +01:00
|
|
|
break;
|
|
|
|
|
case kParamClipMode:
|
|
|
|
|
parameter.name = "Clip Mode";
|
|
|
|
|
parameter.symbol = "clipmode";
|
|
|
|
|
parameter.ranges.min = 0.0f;
|
|
|
|
|
parameter.ranges.def = 0.0f;
|
|
|
|
|
parameter.ranges.max = Clipper::kClipperModeCount - 1;
|
|
|
|
|
parameter.hints = kParameterIsAutomatable | kParameterIsInteger;
|
|
|
|
|
parameter.enumValues.count = Clipper::kClipperModeCount;
|
|
|
|
|
parameter.enumValues.restrictedMode = true;
|
2026-08-03 15:35:36 +01:00
|
|
|
|
|
|
|
|
static const ParameterEnumerationValue
|
|
|
|
|
sClipModes[Clipper::kClipperModeCount] = {
|
|
|
|
|
{0.0f, "Soft"}, {1.0f, "Hard"}, {2.0f, "Fold"}};
|
|
|
|
|
parameter.enumValues.values =
|
|
|
|
|
const_cast<ParameterEnumerationValue *>(sClipModes);
|
2026-08-02 20:14:51 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float getParameterValue(uint32_t index) const override {
|
|
|
|
|
switch (index) {
|
|
|
|
|
case kParamGain:
|
|
|
|
|
return gain_.getGain();
|
2026-08-02 22:58:56 +01:00
|
|
|
case kParamClipMode:
|
|
|
|
|
return (float)clipper_.getMode();
|
2026-08-02 20:14:51 +01:00
|
|
|
}
|
|
|
|
|
return 0.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setParameterValue(uint32_t index, float value) override {
|
|
|
|
|
switch (index) {
|
|
|
|
|
case kParamGain:
|
|
|
|
|
gain_.setGain(value);
|
|
|
|
|
break;
|
2026-08-02 22:58:56 +01:00
|
|
|
case kParamClipMode:
|
|
|
|
|
clipper_.setMode((Clipper::ClipperMode)value);
|
|
|
|
|
break;
|
2026-08-02 20:14:51 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|