From 1fc79effed41b539e589e014782cbb5a1dd5997b Mon Sep 17 00:00:00 2001 From: Aleks Rutins Date: Fri, 14 Apr 2023 15:01:38 -0400 Subject: [PATCH] Add mix control --- dynamite.ttl | 13 +++++++++++-- plugin.cc | 18 ++++++++++++------ plugin.hh | 3 ++- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/dynamite.ttl b/dynamite.ttl index bb03d1b..e900514 100644 --- a/dynamite.ttl +++ b/dynamite.ttl @@ -52,8 +52,17 @@ a lv2:InputPort , lv2:ControlPort ; lv2:index 4 ; lv2:symbol "gain" ; - lv2:name "Gain" ; + lv2:name "Level" ; lv2:default 0.0 ; lv2:minimum -20.0 ; lv2:maximum 20.0 ; - ]. \ No newline at end of file + ] , + [ + a lv2:InputPort , lv2:ControlPort ; + lv2:index 5 ; + lv2:symbol "mix" ; + lv2:name "Mix" ; + lv2:default 0.5 ; + lv2:minimum 0.0 ; + lv2:maximum 1.0 ; + ] . \ No newline at end of file diff --git a/plugin.cc b/plugin.cc index ecbc349..d06aa28 100644 --- a/plugin.cc +++ b/plugin.cc @@ -18,6 +18,8 @@ namespace Dynamite { break; case GAIN: gain = (const float *)data; + case MIX: + mix = (const float *)data; } } @@ -27,13 +29,17 @@ namespace Dynamite { const float gainCoeff = dbCo(*gain); for(uint32_t pos = 0; pos < n_samples; pos++) { - output[pos] = input[pos] * coeff; - if(output[pos] > threshCoeff) { - output[pos] = threshCoeff; - } else if (output[pos] < -threshCoeff) { - output[pos] = -threshCoeff; + float dist = input[pos] * coeff; + + if(dist > threshCoeff) { + dist = threshCoeff; + } else if (dist < -threshCoeff) { + dist = -threshCoeff; } - output[pos] = output[pos] * gainCoeff; + + dist = dist * gainCoeff; + + output[pos] = (*mix * dist) + ((1.0 - *mix) * input[pos]); } } } \ No newline at end of file diff --git a/plugin.hh b/plugin.hh index b3f5847..396617c 100644 --- a/plugin.hh +++ b/plugin.hh @@ -6,13 +6,14 @@ using namespace LV2; namespace Dynamite { enum PluginPort { - IN, OUT, DRIVE, THRESHOLD, GAIN + IN, OUT, DRIVE, THRESHOLD, GAIN, MIX }; class Drive : public Plugin { const float *drive; const float *threshold; const float *gain; + const float *mix; const float *input; float *output; public: