[SCM] calf/master: Merge branch 'filterclavier' of ssh://repo.or.cz/srv/git/calf
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:38:54 UTC 2013
+ Filter: make Inertia a RT-context port again (it couldn't work properly the way it was implemented anyway)
+ Phaser: add live frequency response graph
+ AutoHell: add missing headers to Makefile.am in header directory
+ LED widget, Keyboard widget: fix warnings
+ Benchmark: remove unnecessary glib header from benchmark.cpp
+ DSSI: move OSC server code into separate file, remove dependency of OSC client code on Glib, include OSC code in non-GUI libraries
+ ChangeLog: updated
+ JACK host: manpage update
+ JACK host: replace broken option -p with new syntax (pluginname:preset instead of -p preset pluginname)
+ LADSPA: make the hint guessing logic compatible with logarithmic ports (makes default values for Reverb sane again)
* experimental version of filter plugin refactored into three base classes
*typos
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: d6a3c1a63a147948535a50da009275278ad5e6a3
X-Git-Newrev: 34569260c452f0fa4c543155ebba174a42a343dc
The following commit has been merged in the master branch:
commit 76f6c9b226d8a040c9e751165a7222b7c95ac9cd
Merge: fb179d0e9d2eeb453215438cebb7cb48344dac7f c0e9a72650de0726c0de5005ba2879f6d1ebd321
Author: Krzysztof Foltman <wdev at foltman.com>
Date: Tue Jan 20 01:07:59 2009 +0000
Merge branch 'filterclavier' of ssh://repo.or.cz/srv/git/calf
diff --combined AUTHORS
index e93f248,e93f248..81a8e0a
--- a/AUTHORS
+++ b/AUTHORS
@@@ -2,3 -2,3 +2,4 @@@ Krzysztof Foltman <wdev at foltman.com
Hermann Meyer <brummer- at web.de>
Thor Harald Johansen <thj at thj.no>
Thorsten Wilms <t_w_ at freenet.de>
++Hans Baier <hansfbaier at googlemail.com>
diff --combined src/calf/modules.h
index d82d1ad,bde4886..7a2edbc
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@@ -242,145 -242,6 +242,6 @@@ public
void deactivate();
};
- class filter_audio_module: public audio_module<filter_metadata>, public line_graph_iface
- {
- public:
- float *ins[in_count];
- float *outs[out_count];
- float *params[param_count];
- dsp::biquad_d1<float> left[3], right[3];
- uint32_t srate;
- int order;
- inertia<exponential_ramp> inertia_cutoff, inertia_resonance;
- once_per_n timer;
- bool is_active;
-
- filter_audio_module()
- : inertia_cutoff(exponential_ramp(128), 20)
- , inertia_resonance(exponential_ramp(128), 20)
- , timer(128)
- {
- order = 0;
- is_active = false;
- }
-
- void calculate_filter()
- {
- float freq = inertia_cutoff.get_last();
- // printf("freq=%g inr.cnt=%d timer.left=%d\n", freq, inertia_cutoff.count, timer.left);
- // XXXKF this is resonance of a single stage, obviously for three stages, resonant gain will be different
- float q = inertia_resonance.get_last();
- // XXXKF this is highly inefficient and should be replaced as soon as I have fast f2i in primitives.h
- int mode = (int)*params[par_mode];
- // printf("freq = %f q = %f mode = %d\n", freq, q, mode);
- if (mode < 3) {
- order = mode + 1;
- left[0].set_lp_rbj(freq, pow(q, 1.0 / order), srate);
- } else {
- order = mode - 2;
- left[0].set_hp_rbj(freq, pow(q, 1.0 / order), srate);
- }
- // XXXKF this is highly inefficient and should be replaced as soon as I have fast f2i in primitives.h
- int inertia = dsp::fastf2i_drm(*params[par_inertia]);
- if (inertia != inertia_cutoff.ramp.length()) {
- inertia_cutoff.ramp.set_length(inertia);
- inertia_resonance.ramp.set_length(inertia);
- }
-
- right[0].copy_coeffs(left[0]);
- for (int i = 1; i < order; i++) {
- left[i].copy_coeffs(left[0]);
- right[i].copy_coeffs(left[0]);
- }
- }
- void params_changed()
- {
- inertia_cutoff.set_inertia(*params[par_cutoff]);
- inertia_resonance.set_inertia(*params[par_resonance]);
- calculate_filter();
- }
- void on_timer()
- {
- inertia_cutoff.step();
- inertia_resonance.step();
- calculate_filter();
- }
- void activate();
- void set_sample_rate(uint32_t sr);
- void deactivate();
- inline int process_channel(dsp::biquad_d1<float> *filter, float *in, float *out, uint32_t numsamples, int inmask) {
- if (inmask) {
- switch(order) {
- case 1:
- for (uint32_t i = 0; i < numsamples; i++)
- out[i] = filter[0].process(in[i]);
- break;
- case 2:
- for (uint32_t i = 0; i < numsamples; i++)
- out[i] = filter[1].process(filter[0].process(in[i]));
- break;
- case 3:
- for (uint32_t i = 0; i < numsamples; i++)
- out[i] = filter[2].process(filter[1].process(filter[0].process(in[i])));
- break;
- }
- } else {
- if (filter[order - 1].empty())
- return 0;
- switch(order) {
- case 1:
- for (uint32_t i = 0; i < numsamples; i++)
- out[i] = filter[0].process_zeroin();
- break;
- case 2:
- if (filter[0].empty())
- for (uint32_t i = 0; i < numsamples; i++)
- out[i] = filter[1].process_zeroin();
- else
- for (uint32_t i = 0; i < numsamples; i++)
- out[i] = filter[1].process(filter[0].process_zeroin());
- break;
- case 3:
- if (filter[1].empty())
- for (uint32_t i = 0; i < numsamples; i++)
- out[i] = filter[2].process_zeroin();
- else
- for (uint32_t i = 0; i < numsamples; i++)
- out[i] = filter[2].process(filter[1].process(filter[0].process_zeroin()));
- break;
- }
- }
- for (int i = 0; i < order; i++)
- filter[i].sanitize();
- return filter[order - 1].empty() ? 0 : inmask;
- }
- uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask) {
- // printf("sr=%d cutoff=%f res=%f mode=%f\n", srate, *params[par_cutoff], *params[par_resonance], *params[par_mode]);
- uint32_t ostate = 0;
- numsamples += offset;
- while(offset < numsamples) {
- uint32_t numnow = numsamples - offset;
- // if inertia's inactive, we can calculate the whole buffer at once
- if (inertia_cutoff.active() || inertia_resonance.active())
- numnow = timer.get(numnow);
- if (outputs_mask & 1) {
- ostate |= process_channel(left, ins[0] + offset, outs[0] + offset, numnow, inputs_mask & 1);
- }
- if (outputs_mask & 2) {
- ostate |= process_channel(right, ins[1] + offset, outs[1] + offset, numnow, inputs_mask & 2);
- }
- if (timer.elapsed()) {
- on_timer();
- }
- offset += numnow;
- }
- return ostate;
- }
- bool get_graph(int index, int subindex, float *data, int points, cairo_iface *context);
- float freq_gain(int subindex, float freq, float srate);
- bool get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context);
- };
-
class vintage_delay_audio_module: public audio_module<vintage_delay_metadata>
{
public:
@@@ -714,6 -575,138 +575,138 @@@ public
}
};
+ template<typename FilterClass, typename Metadata>
+ class filter_module_with_inertia: public FilterClass
+ {
+ public:
+ typedef filter_module_with_inertia inertia_filter_module;
+
+ float *ins[Metadata::in_count];
+ float *outs[Metadata::out_count];
+ float *params[Metadata::param_count];
+
+ inertia<exponential_ramp> inertia_cutoff, inertia_resonance;
+ once_per_n timer;
+ bool is_active;
+
+ filter_module_with_inertia()
+ : inertia_cutoff(exponential_ramp(128), 20)
+ , inertia_resonance(exponential_ramp(128), 20)
+ , timer(128)
+ {
+ is_active = false;
+ }
+
+ void calculate_filter()
+ {
+ float freq = inertia_cutoff.get_last();
+ // printf("freq=%g inr.cnt=%d timer.left=%d\n", freq, inertia_cutoff.count, timer.left);
+ // XXXKF this is resonance of a single stage, obviously for three stages, resonant gain will be different
+ float q = inertia_resonance.get_last();
+ int mode = dsp::fastf2i_drm(*params[Metadata::par_mode]);
+ // printf("freq = %f q = %f mode = %d\n", freq, q, mode);
+
+ int inertia = dsp::fastf2i_drm(*params[Metadata::par_inertia]);
+ if (inertia != inertia_cutoff.ramp.length()) {
+ inertia_cutoff.ramp.set_length(inertia);
+ inertia_resonance.ramp.set_length(inertia);
+ }
+
+ FilterClass::calculate_filter(freq, q, mode);
+ }
+
+ void params_changed()
+ {
+ inertia_cutoff.set_inertia(*params[Metadata::par_cutoff]);
+ inertia_resonance.set_inertia(*params[Metadata::par_resonance]);
+ calculate_filter();
+ }
+
+ void on_timer()
+ {
+ inertia_cutoff.step();
+ inertia_resonance.step();
+ calculate_filter();
+ }
+
+ void activate()
+ {
+ params_changed();
+ FilterClass::filter_activate();
+ timer = once_per_n(FilterClass::srate / 1000);
+ timer.start();
+ is_active = true;
+ }
+
+ void set_sample_rate(uint32_t sr)
+ {
+ FilterClass::srate = sr;
+ }
+
+
+ void deactivate()
+ {
+ is_active = false;
+ }
+
+ uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask) {
+ // printf("sr=%d cutoff=%f res=%f mode=%f\n", FilterClass::srate, *params[Metadata::par_cutoff], *params[Metadata::par_resonance], *params[Metadata::par_mode]);
+ uint32_t ostate = 0;
+ numsamples += offset;
+ while(offset < numsamples) {
+ uint32_t numnow = numsamples - offset;
+ // if inertia's inactive, we can calculate the whole buffer at once
+ if (inertia_cutoff.active() || inertia_resonance.active())
+ numnow = timer.get(numnow);
+
+ if (outputs_mask & 1) {
+ ostate |= FilterClass::process_channel(0, ins[0] + offset, outs[0] + offset, numnow, inputs_mask & 1);
+ }
+ if (outputs_mask & 2) {
+ ostate |= FilterClass::process_channel(1, ins[1] + offset, outs[1] + offset, numnow, inputs_mask & 2);
+ }
+
+ if (timer.elapsed()) {
+ on_timer();
+ }
+ offset += numnow;
+ }
+ return ostate;
+ }
+ };
+
+ class filter_audio_module:
+ public audio_module<filter_metadata>,
+ public filter_module_with_inertia<biquad_filter_module, filter_metadata>,
+ public line_graph_iface
+ {
+ public:
+ void params_changed()
+ {
+ inertia_filter_module::params_changed();
+ }
+
+ void activate()
+ {
+ inertia_filter_module::activate();
+ }
+
+ void set_sample_rate(uint32_t sr)
+ {
+ inertia_filter_module::set_sample_rate(sr);
+ }
+
+
+ void deactivate()
+ {
+ inertia_filter_module::deactivate();
+ }
+
+
+ bool get_graph(int index, int subindex, float *data, int points, cairo_iface *context);
+ bool get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context);
+ };
+
/// A multitap stereo chorus thing - processing
class multichorus_audio_module: public audio_module<multichorus_metadata>, public line_graph_iface
{
@@@ -789,7 -782,115 +782,7 @@@ public
compressor_audio_module();
void activate();
void deactivate();
- uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask) {
- bool bypass = *params[param_bypass] > 0.5f;
-
- if(bypass) {
- int count = numsamples * sizeof(float);
- memcpy(outs[0], ins[0], count);
- memcpy(outs[1], ins[1], count);
-
- if(params[param_compression] != NULL) {
- *params[param_compression] = 1.f;
- }
-
- if(params[param_clip] != NULL) {
- *params[param_clip] = 0.f;
- }
-
- if(params[param_peak] != NULL) {
- *params[param_peak] = 0.f;
- }
-
- return inputs_mask;
- }
-
- bool rms = *params[param_detection] == 0;
- bool average = *params[param_stereo_link] == 0;
- bool aweighting = *params[param_aweighting] > 0.5f;
- float linThreshold = *params[param_threshold];
- ratio = *params[param_ratio];
- float attack = *params[param_attack];
- float attack_coeff = std::min(1.f, 1.f / (attack * srate / 4000.f));
- float release = *params[param_release];
- float release_coeff = std::min(1.f, 1.f / (release * srate / 4000.f));
- makeup = *params[param_makeup];
- knee = *params[param_knee];
-
- float linKneeSqrt = sqrt(knee);
- linKneeStart = linThreshold / linKneeSqrt;
- adjKneeStart = linKneeStart*linKneeStart;
- float linKneeStop = linThreshold * linKneeSqrt;
-
- threshold = log(linThreshold);
- kneeStart = log(linKneeStart);
- kneeStop = log(linKneeStop);
- compressedKneeStop = (kneeStop - threshold) / ratio + threshold;
-
- numsamples += offset;
-
- float compression = 1.f;
-
- peak -= peak * 5.f * numsamples / srate;
-
- clip -= std::min(clip, numsamples);
-
- while(offset < numsamples) {
- float left = ins[0][offset];
- float right = ins[1][offset];
-
- if(aweighting) {
- left = awL.process(left);
- right = awR.process(right);
- }
-
- float absample = average ? (fabs(left) + fabs(right)) * 0.5f : std::max(fabs(left), fabs(right));
- if(rms) absample *= absample;
-
- linSlope += (absample - linSlope) * (absample > linSlope ? attack_coeff : release_coeff);
-
- float gain = 1.f;
-
- if(linSlope > 0.f) {
- gain = output_gain(linSlope, rms);
- }
-
- compression = gain;
- gain *= makeup;
-
- float outL = ins[0][offset] * gain;
- float outR = ins[1][offset] * gain;
-
- outs[0][offset] = outL;
- outs[1][offset] = outR;
-
- ++offset;
-
- float maxLR = std::max(fabs(outL), fabs(outR));
-
- if(maxLR > 1.f) clip = srate >> 3; /* blink clip LED for 125 ms */
-
- if(maxLR > peak) {
- peak = maxLR;
- }
- }
-
- detected = rms ? sqrt(linSlope) : linSlope;
-
- if(params[param_compression] != NULL) {
- *params[param_compression] = compression;
- }
-
- if(params[param_clip] != NULL) {
- *params[param_clip] = clip;
- }
-
- if(params[param_peak] != NULL) {
- *params[param_peak] = peak;
- }
-
- return inputs_mask;
- }
+ uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask);
inline float output_level(float slope) {
return slope * output_gain(slope, false) * makeup;
diff --combined src/modules_dsp.cpp
index e818cc5,7c4c7a4..eec0056
--- a/src/modules_dsp.cpp
+++ b/src/modules_dsp.cpp
@@@ -26,6 -26,7 +26,7 @@@
#endif
#include <calf/giface.h>
#include <calf/modules.h>
+ #include <calf/modules_dev.h>
using namespace dsp;
using namespace calf_plugins;
@@@ -214,28 -215,6 +215,6 @@@ void reverb_audio_module::set_sample_ra
///////////////////////////////////////////////////////////////////////////////////////////////
- void filter_audio_module::activate()
- {
- params_changed();
- for (int i=0; i < order; i++) {
- left[i].reset();
- right[i].reset();
- }
- timer = once_per_n(srate / 1000);
- timer.start();
- is_active = true;
- }
-
- void filter_audio_module::deactivate()
- {
- is_active = false;
- }
-
- void filter_audio_module::set_sample_rate(uint32_t sr)
- {
- srate = sr;
- }
-
bool filter_audio_module::get_graph(int index, int subindex, float *data, int points, cairo_iface *context)
{
if (!is_active)
@@@ -247,14 -226,6 +226,6 @@@
return false;
}
- float filter_audio_module::freq_gain(int subindex, float freq, float srate)
- {
- float level = 1.0;
- for (int j = 0; j < order; j++)
- level *= left[j].freq_gain(freq, srate);
- return level;
- }
-
bool filter_audio_module::get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context)
{
if (index == par_cutoff)
@@@ -480,116 -451,3 +451,116 @@@ bool compressor_audio_module::get_gridl
}
return result;
}
+
+// In case of doubt: this function is written by Thor. I just moved it to this file, damaging
+// the output of "git annotate" in the process.
+uint32_t compressor_audio_module::process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask)
+{
+ bool bypass = *params[param_bypass] > 0.5f;
+
+ if(bypass) {
+ int count = numsamples * sizeof(float);
+ memcpy(outs[0], ins[0], count);
+ memcpy(outs[1], ins[1], count);
+
+ if(params[param_compression] != NULL) {
+ *params[param_compression] = 1.f;
+ }
+
+ if(params[param_clip] != NULL) {
+ *params[param_clip] = 0.f;
+ }
+
+ if(params[param_peak] != NULL) {
+ *params[param_peak] = 0.f;
+ }
+
+ return inputs_mask;
+ }
+
+ bool rms = *params[param_detection] == 0;
+ bool average = *params[param_stereo_link] == 0;
+ bool aweighting = *params[param_aweighting] > 0.5f;
+ float linThreshold = *params[param_threshold];
+ ratio = *params[param_ratio];
+ float attack = *params[param_attack];
+ float attack_coeff = std::min(1.f, 1.f / (attack * srate / 4000.f));
+ float release = *params[param_release];
+ float release_coeff = std::min(1.f, 1.f / (release * srate / 4000.f));
+ makeup = *params[param_makeup];
+ knee = *params[param_knee];
+
+ float linKneeSqrt = sqrt(knee);
+ linKneeStart = linThreshold / linKneeSqrt;
+ adjKneeStart = linKneeStart*linKneeStart;
+ float linKneeStop = linThreshold * linKneeSqrt;
+
+ threshold = log(linThreshold);
+ kneeStart = log(linKneeStart);
+ kneeStop = log(linKneeStop);
+ compressedKneeStop = (kneeStop - threshold) / ratio + threshold;
+
+ numsamples += offset;
+
+ float compression = 1.f;
+
+ peak -= peak * 5.f * numsamples / srate;
+
+ clip -= std::min(clip, numsamples);
+
+ while(offset < numsamples) {
+ float left = ins[0][offset];
+ float right = ins[1][offset];
+
+ if(aweighting) {
+ left = awL.process(left);
+ right = awR.process(right);
+ }
+
+ float absample = average ? (fabs(left) + fabs(right)) * 0.5f : std::max(fabs(left), fabs(right));
+ if(rms) absample *= absample;
+
+ linSlope += (absample - linSlope) * (absample > linSlope ? attack_coeff : release_coeff);
+
+ float gain = 1.f;
+
+ if(linSlope > 0.f) {
+ gain = output_gain(linSlope, rms);
+ }
+
+ compression = gain;
+ gain *= makeup;
+
+ float outL = ins[0][offset] * gain;
+ float outR = ins[1][offset] * gain;
+
+ outs[0][offset] = outL;
+ outs[1][offset] = outR;
+
+ ++offset;
+
+ float maxLR = std::max(fabs(outL), fabs(outR));
+
+ if(maxLR > 1.f) clip = srate >> 3; /* blink clip LED for 125 ms */
+
+ if(maxLR > peak) {
+ peak = maxLR;
+ }
+ }
+
+ detected = rms ? sqrt(linSlope) : linSlope;
+
+ if(params[param_compression] != NULL) {
+ *params[param_compression] = compression;
+ }
+
+ if(params[param_clip] != NULL) {
+ *params[param_clip] = clip;
+ }
+
+ if(params[param_peak] != NULL) {
+ *params[param_peak] = peak;
+ }
+
+ return inputs_mask;
+}
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list