[SCM] calf/master: Compressor working properly with threshold and ratio.
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:37:56 UTC 2013
The following commit has been merged in the master branch:
commit adc87f1a8453f58fee5979a9a0af0053a10594ae
Author: Thor Harald Johansen <thor at thor-pc.(none)>
Date: Thu Oct 30 19:13:25 2008 +0100
Compressor working properly with threshold and ratio.
diff --git a/src/calf/modules_dev.h b/src/calf/modules_dev.h
index 5b91780..55631a1 100644
--- a/src/calf/modules_dev.h
+++ b/src/calf/modules_dev.h
@@ -27,8 +27,8 @@ namespace synth {
class compressor_audio_module: public null_audio_module {
public:
- enum { in_count = 1, out_count = 1, support_midi = false, rt_capable = true };
- enum { dummy, param_count };
+ enum { in_count = 2, out_count = 2, support_midi = false, rt_capable = true };
+ enum { param_threshold, param_ratio, param_count };
static const char *port_names[in_count + out_count];
static synth::ladspa_plugin_info plugin_info;
@@ -37,14 +37,45 @@ public:
float *params[param_count];
uint32_t srate;
static parameter_properties param_props[];
+ void activate() {
+ target = 1;
+ aim = 1;
+ }
uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask) {
- return numsamples + offset;
+ numsamples += offset;
+ float threshold = *params[param_threshold];
+ float ratio = *params[param_ratio];
+ while(offset < numsamples) {
+ for(int channel = 0; channel < 2; channel++) {
+ float sample = ins[channel][offset];
+ float asample = fabs(sample);
+ if(asample > threshold) {
+ target = asample - threshold;
+ target /= ratio;
+ target += threshold;
+ target /= asample;
+ } else {
+ target = 1;
+ }
+
+ sample *= aim;
+
+ outs[channel][offset] = sample;
+ }
+
+ aim += (target - aim) * 0.0008;
+
+ ++offset;
+ }
+
+ return inputs_mask;
}
static const char *get_name() { return "compressor"; }
static const char *get_id() { return "compressor"; }
static const char *get_label() { return "Compressor"; }
-
+private:
+ float aim, target;
};
#endif
diff --git a/src/modules.cpp b/src/modules.cpp
index db3e745..954ca61 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -178,7 +178,8 @@ parameter_properties multichorus_audio_module::param_props[] = {
synth::ladspa_plugin_info multichorus_audio_module::plugin_info = { 0x8501, "MultiChorus", "Calf MultiChorus", "Krzysztof Foltman", synth::calf_copyright_info, "ChorusPlugin" };
parameter_properties compressor_audio_module::param_props[] = {
- { 1, 0, 1, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "threshold", "Threshold" }
+ { 1, 0, 1, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "threshold", "Threshold" },
+ { 1, 1, 100, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "ratio", "Ratio" },
};
synth::ladspa_plugin_info compressor_audio_module::plugin_info = { 0x8502, "Compressor", "Calf Compressor", "Thor Harald Johansen", synth::calf_copyright_info, "CompressorPlugin" };
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list