More sensible range for threshold, add post gain
This commit is contained in:
parent
a32ece06df
commit
a4f63da955
3 changed files with 22 additions and 7 deletions
13
dynamite.ttl
13
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 ;
|
||||
].
|
15
plugin.cc
15
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,12 +6,13 @@ using namespace LV2;
|
|||
|
||||
namespace Dynamite {
|
||||
enum PluginPort {
|
||||
IN, OUT, DRIVE, THRESHOLD
|
||||
IN, OUT, DRIVE, THRESHOLD, GAIN
|
||||
};
|
||||
|
||||
class Drive : public Plugin<Drive> {
|
||||
const float *drive;
|
||||
const float *threshold;
|
||||
const float *gain;
|
||||
const float *input;
|
||||
float *output;
|
||||
public:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue