feat: implement basic distortion
This commit is contained in:
parent
6ccb93615f
commit
ce7844d7af
2 changed files with 49 additions and 14 deletions
|
|
@ -9,6 +9,8 @@
|
||||||
#define DISTRHO_PLUGIN_NUM_INPUTS 2
|
#define DISTRHO_PLUGIN_NUM_INPUTS 2
|
||||||
#define DISTRHO_PLUGIN_NUM_OUTPUTS 2
|
#define DISTRHO_PLUGIN_NUM_OUTPUTS 2
|
||||||
|
|
||||||
|
#define DISTRHO_PLUGIN_NUM_PARAMETERS 1
|
||||||
|
|
||||||
#define DISTRHO_PLUGIN_WANT_PROGRAMS 0
|
#define DISTRHO_PLUGIN_WANT_PROGRAMS 0
|
||||||
#define DISTRHO_PLUGIN_WANT_STATE 0
|
#define DISTRHO_PLUGIN_WANT_STATE 0
|
||||||
|
|
||||||
|
|
@ -20,12 +22,4 @@
|
||||||
|
|
||||||
#define DISTRHO_PLUGIN_CLAP_ID "moe.liam.squidgesoft.SquidgeDistortion"
|
#define DISTRHO_PLUGIN_CLAP_ID "moe.liam.squidgesoft.SquidgeDistortion"
|
||||||
|
|
||||||
enum Parameters {
|
|
||||||
kGain,
|
|
||||||
kTone,
|
|
||||||
kVolume,
|
|
||||||
// add your parameters here
|
|
||||||
kParameterCount // must be last
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1,12 +1,19 @@
|
||||||
#include "DistrhoPlugin.hpp"
|
#include "DistrhoPlugin.hpp"
|
||||||
#include "DistrhoPluginInfo.h"
|
#include "DistrhoPluginInfo.h"
|
||||||
|
|
||||||
|
#include "../../core/Clipper.hpp"
|
||||||
|
#include "../../core/Gain.hpp"
|
||||||
|
|
||||||
START_NAMESPACE_DISTRHO
|
START_NAMESPACE_DISTRHO
|
||||||
|
|
||||||
class SquidgeDistortion : public Plugin {
|
class SquidgeDistortion : public Plugin {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SquidgeDistortion()
|
enum Parameters {
|
||||||
: Plugin(kParameterCount, 0, 0), gain(1.0), tone(1.0), volume(1.0) {}
|
kParamGain,
|
||||||
|
kParameterCount // must be last
|
||||||
|
};
|
||||||
|
SquidgeDistortion() : Plugin(kParameterCount, 0, 0), gain_(2.0f) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const char *getLabel() const override { return "SquidgeDistortion"; }
|
const char *getLabel() const override { return "SquidgeDistortion"; }
|
||||||
|
|
@ -18,12 +25,46 @@ protected:
|
||||||
uint32_t getVersion() const override { return d_version(0, 1, 0); }
|
uint32_t getVersion() const override { return d_version(0, 1, 0); }
|
||||||
int64_t getUniqueId() const override { return d_cconst('S', 'Q', 'D', 'T'); }
|
int64_t getUniqueId() const override { return d_cconst('S', 'Q', 'D', 'T'); }
|
||||||
|
|
||||||
void run(const float **inputs, float **outputs, uint32_t frames) override {}
|
void initParameter(uint32_t index, Parameter ¶meter) 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);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float gain;
|
Gain gain_;
|
||||||
float tone;
|
Clipper clipper_;
|
||||||
float volume;
|
|
||||||
|
|
||||||
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SquidgeDistortion);
|
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SquidgeDistortion);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue