Back at it! Add limiter plugin.

This commit is contained in:
wan-may 2023-03-20 21:13:47 -03:00
parent 994ff19596
commit eb1a82ac93
4 changed files with 96 additions and 1 deletions

View File

@ -3,4 +3,5 @@ add_subdirectory(yaw-tab)
add_subdirectory(yaw-shepard) add_subdirectory(yaw-shepard)
add_subdirectory(yaw-vowel) add_subdirectory(yaw-vowel)
add_subdirectory(yaw-totune) add_subdirectory(yaw-totune)
add_subdirectory(yaw-shep) add_subdirectory(yaw-shep)
add_subdirectory(yaw-brick)

View File

@ -0,0 +1,9 @@
dpf_add_plugin(yaw-brick
TARGETS vst2
FILES_DSP
dsp.cpp)
target_include_directories(yaw-brick PUBLIC
"."
"../../lib")

View File

@ -0,0 +1,17 @@
#ifndef DISTRHO_PLUGIN_INFO_H_INCLUDED
#define DISTRHO_PLUGIN_INFO_H_INCLUDED
#define DISTRHO_PLUGIN_BRAND "yaw-audio"
#define DISTRHO_PLUGIN_NAME "yaw-brick"
#define DISTRHO_PLUGIN_URI "https://yaw.man/plugins/yaw-brick"
#define DISTRHO_PLUGIN_IS_RT_SAFE 1
#define DISTRHO_PLUGIN_NUM_INPUTS 2
#define DISTRHO_PLUGIN_NUM_OUTPUTS 2
enum Parameters {
kParamLimit = 0, //Maximum gain.
kParamGain //Pre-amplification
};
#endif

68
src/yaw-brick/dsp.cpp Normal file
View File

@ -0,0 +1,68 @@
#include "DistrhoPlugin.hpp"
START_NAMESPACE_DISTRHO
class Limiter : public Plugin
{
public:
Limiter()
: Plugin(2, 0, 0)
{
}
protected:
const char *getLabel() const override { return "yaw-brick"; }
const char *getDescription() const override { return "Limiter"; }
const char *getMaker() const override { return "yaw-audio"; }
const char *getHomePage() const override { return "https://yaw.man/plugins/yaw-brick"; }
const char *getLicense() const override { return "Fuck you pay me"; }
uint32_t getVersion() const override { return d_version(1, 0, 0); }
int64_t getUniqueId() const override { return d_cconst('y', 'b', 'r', 'k'); }
void initParameter(uint32_t index, Parameter &parameter) override
{
parameter.hints = kParameterIsAutomable;
parameter.ranges.def = 0.0f;
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
parameter.name = "param";
parameter.symbol = "param";
}
void sampleRateChanged(double newRate) override
{}
float getParameterValue(uint32_t index) const override
{
return index ? gain : limit;
}
void setParameterValue(uint32_t idx, float val) override
{
if( idx ) { limit = val; }
else { gain = val; }
}
void run(const float **inputs, float **outputs, uint32_t frames) override
{
for (int chn = 0; chn < 2; ++chn)
{
for( uint32_t i = 0; i < frames; ++i){
float x = inputs[chn][i];
outputs[chn][i] = gain * limit * x / (1.f + gain * x);
}
}
}
private:
double limit = 0.0;
double gain = 0.0;
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Limiter)
};
Plugin *createPlugin()
{
return new Limiter();
}
END_NAMESPACE_DISTRHO