feat: added mixer component and add wet/dry mix to distortion
This commit is contained in:
parent
9acddeb29c
commit
c6f8cb1e0e
4 changed files with 122 additions and 4 deletions
|
|
@ -1,20 +1,28 @@
|
|||
#include "DistrhoDetails.hpp"
|
||||
#include "DistrhoPlugin.hpp"
|
||||
#include "DistrhoPluginInfo.h"
|
||||
|
||||
#include "../../core/Clipper.hpp"
|
||||
#include "../../core/Gain.hpp"
|
||||
#include "../../core/Mixer.hpp"
|
||||
|
||||
START_NAMESPACE_DISTRHO
|
||||
|
||||
class SquidgeDistortion : public Plugin {
|
||||
|
||||
public:
|
||||
enum MixerChannels { kChannelDry, kChannelWet, KChannelCount };
|
||||
enum Parameters {
|
||||
kParamGain,
|
||||
kParamClipMode,
|
||||
kParamMixVolume,
|
||||
kParameterCount // must be last
|
||||
};
|
||||
SquidgeDistortion() : Plugin(kParameterCount, 0, 0), gain_(2.0f) {}
|
||||
SquidgeDistortion()
|
||||
: Plugin(kParameterCount, 0, 0), gain_(2.0f), mixer_(1.0f) {
|
||||
mixer_.setInputGain(kChannelDry, 0.0f);
|
||||
mixer_.setInputGain(kChannelWet, 1.0f);
|
||||
}
|
||||
|
||||
protected:
|
||||
const char *getLabel() const override { return "SquidgeDistortion"; }
|
||||
|
|
@ -52,6 +60,14 @@ protected:
|
|||
parameter.enumValues.values =
|
||||
const_cast<ParameterEnumerationValue *>(sClipModes);
|
||||
break;
|
||||
case kParamMixVolume:
|
||||
parameter.name = "Dry/Wet";
|
||||
parameter.symbol = "drywetvolume";
|
||||
parameter.ranges.min = 0.0f;
|
||||
parameter.ranges.def = 1.0f;
|
||||
parameter.ranges.max = 1.0f;
|
||||
parameter.hints = kParameterIsAutomatable;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -61,6 +77,8 @@ protected:
|
|||
return gain_.getGain();
|
||||
case kParamClipMode:
|
||||
return (float)clipper_.getMode();
|
||||
case kParamMixVolume:
|
||||
return mixer_.getInputGain(kChannelWet);
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
|
@ -73,18 +91,30 @@ protected:
|
|||
case kParamClipMode:
|
||||
clipper_.setMode((Clipper::ClipperMode)value);
|
||||
break;
|
||||
case kParamMixVolume:
|
||||
mixer_.setInputGain(kChannelWet, value);
|
||||
mixer_.setInputGain(kChannelDry, 1.0f - 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],
|
||||
gain_.processStereo(inputs[0], inputs[1], wetBufferL_, wetBufferR_, frames);
|
||||
clipper_.processStereo(wetBufferL_, wetBufferR_, wetBufferL_, wetBufferR_,
|
||||
frames);
|
||||
|
||||
const float *inputsL[2] = {inputs[0], wetBufferL_};
|
||||
const float *inputsR[2] = {inputs[1], wetBufferR_};
|
||||
|
||||
mixer_.processStereo(inputsL, inputsR, outputs[0], outputs[1], frames);
|
||||
}
|
||||
|
||||
private:
|
||||
Gain gain_;
|
||||
Clipper clipper_;
|
||||
Mixer<2> mixer_;
|
||||
float wetBufferL_[4096];
|
||||
float wetBufferR_[4096];
|
||||
|
||||
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SquidgeDistortion);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue