More sensible range for threshold, add post gain

This commit is contained in:
Aleks Rutins 2023-04-14 13:30:21 -04:00
parent a32ece06df
commit a4f63da955
3 changed files with 22 additions and 7 deletions

View file

@ -45,6 +45,15 @@
lv2:symbol "threshold" ; lv2:symbol "threshold" ;
lv2:name "Threshold" ; lv2:name "Threshold" ;
lv2:default 10.0 ; lv2:default 10.0 ;
lv2:minimum 0.0 ; lv2:minimum -60.0 ;
lv2:maximum 1.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 ;
]. ].

View file

@ -16,19 +16,24 @@ namespace Dynamite {
case THRESHOLD: case THRESHOLD:
threshold = (const float *)data; threshold = (const float *)data;
break; break;
case GAIN:
gain = (const float *)data;
} }
} }
void Drive::run(uint32_t n_samples) { void Drive::run(uint32_t n_samples) {
const float coeff = dbCo(*drive); const float coeff = dbCo(*drive);
const float threshCoeff = dbCo(*threshold);
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; output[pos] = input[pos] * coeff;
if(output[pos] > *threshold) { if(output[pos] > threshCoeff) {
output[pos] = *threshold; output[pos] = threshCoeff;
} else if (output[pos] < -*threshold) { } else if (output[pos] < -threshCoeff) {
output[pos] = -*threshold; output[pos] = -threshCoeff;
} }
output[pos] = output[pos] * gainCoeff;
} }
} }
} }

View file

@ -6,12 +6,13 @@ using namespace LV2;
namespace Dynamite { namespace Dynamite {
enum PluginPort { enum PluginPort {
IN, OUT, DRIVE, THRESHOLD IN, OUT, DRIVE, THRESHOLD, GAIN
}; };
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 *input; const float *input;
float *output; float *output;
public: public: