diff --git a/dynamite.ttl b/dynamite.ttl index 7d48a35..d1b7f1d 100644 --- a/dynamite.ttl +++ b/dynamite.ttl @@ -45,6 +45,15 @@ lv2:symbol "threshold" ; lv2:name "Threshold" ; lv2:default 10.0 ; - lv2:minimum 0.0 ; - lv2:maximum 1.0 ; + lv2:minimum -60.0 ; + lv2:maximum 0.0 ; + ] , + [ + a lv2:InputPort , lv2:ControlPort ; + lv2:index 4 ; + lv2:symbol "gain" ; + lv2:name "Gain" ; + lv2:default 0.0 ; + lv2:minimum -20.0 ; + lv2:maximum 20.0 ; ]. \ No newline at end of file diff --git a/plugin.cc b/plugin.cc index 4ddfdb9..ecbc349 100644 --- a/plugin.cc +++ b/plugin.cc @@ -16,19 +16,24 @@ namespace Dynamite { case THRESHOLD: threshold = (const float *)data; break; + case GAIN: + gain = (const float *)data; } } void Drive::run(uint32_t n_samples) { const float coeff = dbCo(*drive); + const float threshCoeff = dbCo(*threshold); + const float gainCoeff = dbCo(*gain); for(uint32_t pos = 0; pos < n_samples; pos++) { output[pos] = input[pos] * coeff; - if(output[pos] > *threshold) { - output[pos] = *threshold; - } else if (output[pos] < -*threshold) { - output[pos] = -*threshold; + if(output[pos] > threshCoeff) { + output[pos] = threshCoeff; + } else if (output[pos] < -threshCoeff) { + output[pos] = -threshCoeff; } + output[pos] = output[pos] * gainCoeff; } } } \ No newline at end of file diff --git a/plugin.hh b/plugin.hh index 919d59b..b3f5847 100644 --- a/plugin.hh +++ b/plugin.hh @@ -6,12 +6,13 @@ using namespace LV2; namespace Dynamite { enum PluginPort { - IN, OUT, DRIVE, THRESHOLD + IN, OUT, DRIVE, THRESHOLD, GAIN }; class Drive : public Plugin { const float *drive; const float *threshold; + const float *gain; const float *input; float *output; public: