Add mix control

This commit is contained in:
Aleks Rutins 2023-04-14 15:01:38 -04:00
parent 3bec579af5
commit 1fc79effed
3 changed files with 25 additions and 9 deletions

View file

@ -52,8 +52,17 @@
a lv2:InputPort , lv2:ControlPort ; a lv2:InputPort , lv2:ControlPort ;
lv2:index 4 ; lv2:index 4 ;
lv2:symbol "gain" ; lv2:symbol "gain" ;
lv2:name "Gain" ; lv2:name "Level" ;
lv2:default 0.0 ; lv2:default 0.0 ;
lv2:minimum -20.0 ; lv2:minimum -20.0 ;
lv2:maximum 20.0 ; lv2:maximum 20.0 ;
] ,
[
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 ;
] . ] .

View file

@ -18,6 +18,8 @@ namespace Dynamite {
break; break;
case GAIN: case GAIN:
gain = (const float *)data; gain = (const float *)data;
case MIX:
mix = (const float *)data;
} }
} }
@ -27,13 +29,17 @@ namespace Dynamite {
const float gainCoeff = dbCo(*gain); const float gainCoeff = dbCo(*gain);
for(uint32_t pos = 0; pos < n_samples; pos++) { for(uint32_t pos = 0; pos < n_samples; pos++) {
output[pos] = input[pos] * coeff; float dist = input[pos] * coeff;
if(output[pos] > threshCoeff) {
output[pos] = threshCoeff; if(dist > threshCoeff) {
} else if (output[pos] < -threshCoeff) { dist = threshCoeff;
output[pos] = -threshCoeff; } else if (dist < -threshCoeff) {
dist = -threshCoeff;
} }
output[pos] = output[pos] * gainCoeff;
dist = dist * gainCoeff;
output[pos] = (*mix * dist) + ((1.0 - *mix) * input[pos]);
} }
} }
} }

View file

@ -6,13 +6,14 @@ using namespace LV2;
namespace Dynamite { namespace Dynamite {
enum PluginPort { enum PluginPort {
IN, OUT, DRIVE, THRESHOLD, GAIN IN, OUT, DRIVE, THRESHOLD, GAIN, MIX
}; };
class Drive : public Plugin<Drive> { class Drive : public Plugin<Drive> {
const float *drive; const float *drive;
const float *threshold; const float *threshold;
const float *gain; const float *gain;
const float *mix;
const float *input; const float *input;
float *output; float *output;
public: public: