[SCM] calf/master: Added adjustable knee support.
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:38:03 UTC 2013
The following commit has been merged in the master branch:
commit 2e2261ff154975d3bafc731158e14e6747915219
Author: Thor Harald Johansen <thj at thj.no>
Date: Fri Oct 31 21:35:30 2008 +0100
Added adjustable knee support.
diff --git a/src/calf/modules_dev.h b/src/calf/modules_dev.h
index b785886..ecb026b 100644
--- a/src/calf/modules_dev.h
+++ b/src/calf/modules_dev.h
@@ -38,17 +38,17 @@ public:
uint32_t srate;
static parameter_properties param_props[];
void activate() {
- target = 1;
- aim = 1;
+ target = 1.f;
+ aim = 1.f;
}
uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask) {
numsamples += offset;
float threshold = *params[param_threshold];
float ratio = *params[param_ratio];
- float attack_coeff = 1 / (*params[param_attack] * srate / 4000);
- float release_coeff = 1 / (*params[param_release] * srate / 4000);
+ float attack_coeff = 1.f / (*params[param_attack] * srate / 4000.f);
+ float release_coeff = 1.f / (*params[param_release] * srate / 4000.f);
float makeup = *params[param_makeup];
- bool knee = *params[param_knee] > 0.5;
+ float knee = *params[param_knee];
if(params[param_compression] != NULL) {
*params[param_compression] = aim;
@@ -57,21 +57,17 @@ public:
while(offset < numsamples) {
float asample = std::max(fabs(ins[0][offset]), fabs(ins[1][offset]));
for(int channel = 0; channel < in_count; channel++) {
- if(asample > threshold) {
+ if(asample > 0 && (asample > threshold || knee < 1)) {
target = asample - threshold;
target /= ratio;
target += threshold;
- target /= asample;
- } else if(asample > 0 && knee) {
- target = asample - threshold;
- target /= ratio;
- target += threshold;
- float knee1 = pow(asample / threshold, 3);
- float knee2 = 1 - knee1;
- target = target * knee1 + asample * knee2;
+ if(knee < 1) {
+ float t = std::min(1.f, std::max(0.f, asample - knee) / (1.f - knee) / threshold);
+ target = (target - asample) * t + asample;
+ }
target /= asample;
} else {
- target = 1;
+ target = 1.f;
}
outs[channel][offset] = ins[channel][offset] * aim * makeup;
diff --git a/src/modules.cpp b/src/modules.cpp
index c80441c..a91b158 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -179,7 +179,7 @@ parameter_properties compressor_audio_module::param_props[] = {
{ 10, 1, 2000, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "attack", "Attack" },
{ 100, 1, 2000, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL, "release", "Release" },
{ 1, 1, 12, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "makeup", "Makeup Gain" },
- { 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "knee", "Knee" },
+ { 1, 0, 1, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "knee", "Knee" },
{ 0, 0.03125, 1, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_CTLO_REVERSE | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "compression", "Compression" }
};
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list