[SCM] calf/master: + New filter types + Support for combo box control in calfjackhost
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:36:41 UTC 2013
The following commit has been merged in the master branch:
commit 78c784d854c4a605eb2747d3f4ca058d5a7a04b9
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date: Sat Dec 1 15:45:26 2007 +0000
+ New filter types
+ Support for combo box control in calfjackhost
git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@3 78b06b96-2940-0410-b7fc-879d825d01d8
diff --git a/configure.in b/configure.in
index cbfedbe..9cad532 100644
--- a/configure.in
+++ b/configure.in
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
-AC_INIT([calf],[0.0.2],[wdev at foltman.com])
+AC_INIT([calf],[0.0.3],[wdev at foltman.com])
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADER([config.h])
diff --git a/src/calf/biquad.h b/src/calf/biquad.h
index d78e60a..b597583 100644
--- a/src/calf/biquad.h
+++ b/src/calf/biquad.h
@@ -172,6 +172,16 @@ public:
b1 = 2*(ab0-ab2)*q;
b2 = (ab0-ab1+ab2)*q;
}
+
+ template<class U>
+ inline void copy_coeffs(const biquad<U> &src)
+ {
+ a0 = src.a0;
+ a1 = src.a1;
+ a2 = src.a2;
+ b1 = src.b1;
+ b2 = src.b2;
+ }
// direct I form with four state variables
inline T process_d1(T in)
diff --git a/src/calf/modules.h b/src/calf/modules.h
index dc2b7e9..fe12ba1 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -161,26 +161,35 @@ public:
float *outs[out_count];
float *params[param_count];
static const char *param_names[];
- dsp::biquad<float> left, right;
+ dsp::biquad<float> left[3], right[3];
uint32_t srate;
static parameter_properties param_props[];
+ int order;
void params_changed() {
float freq = *params[par_cutoff];
+ // XXXKF this is resonance of a single stage, obviously for three stages, resonant gain will be different
float q = *params[par_resonance];
- int mode = (*params[par_mode] <= 0.5 ? 0 : 1);
+ // XXXKF this is highly inefficient
+ int mode = (int)*params[par_mode];
+ order = (mode < 3) ? mode + 1 : mode - 2;
// printf("freq = %f q = %f mode = %d\n", freq, q, mode);
- if (mode == 0) {
- left.set_lp_rbj(freq, q, srate);
- right.set_lp_rbj(freq, q, srate);
+ if (mode < 3) {
+ left[0].set_lp_rbj(freq, q, srate);
} else {
- left.set_hp_rbj(freq, q, srate);
- right.set_hp_rbj(freq, q, srate);
+ left[0].set_hp_rbj(freq, q, srate);
+ }
+ 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 activate() {
- left.reset();
- right.reset();
+ for (int i=0; i < order; i++) {
+ left[i].reset();
+ right[i].reset();
+ }
}
void deactivate() {
}
@@ -192,16 +201,51 @@ public:
srate = sr;
params_changed();
}
- inline int process_channel(dsp::biquad<float> &filter, float *in, float *out, uint32_t numsamples, int inmask) {
+ inline int process_channel(dsp::biquad<float> *filter, float *in, float *out, uint32_t numsamples, int inmask) {
if (inmask) {
- for (uint32_t i = 0; i < numsamples; i++)
- out[i] = filter.process_d1(in[i]);
+ switch(order) {
+ case 1:
+ for (uint32_t i = 0; i < numsamples; i++)
+ out[i] = filter[0].process_d1(in[i]);
+ break;
+ case 2:
+ for (uint32_t i = 0; i < numsamples; i++)
+ out[i] = filter[1].process_d1(filter[0].process_d1(in[i]));
+ break;
+ case 3:
+ for (uint32_t i = 0; i < numsamples; i++)
+ out[i] = filter[2].process_d1(filter[1].process_d1(filter[0].process_d1(in[i])));
+ break;
+ }
} else {
- for (uint32_t i = 0; i < numsamples; i++)
- out[i] = filter.process_d1_zeroin();
+ if (filter[order - 1].empty_d1())
+ return 0;
+ switch(order) {
+ case 1:
+ for (uint32_t i = 0; i < numsamples; i++)
+ out[i] = filter[0].process_d1_zeroin();
+ break;
+ case 2:
+ if (filter[0].empty_d1())
+ for (uint32_t i = 0; i < numsamples; i++)
+ out[i] = filter[1].process_d1_zeroin();
+ else
+ for (uint32_t i = 0; i < numsamples; i++)
+ out[i] = filter[1].process_d1(filter[0].process_d1_zeroin());
+ break;
+ case 3:
+ if (filter[1].empty_d1())
+ for (uint32_t i = 0; i < numsamples; i++)
+ out[i] = filter[2].process_d1_zeroin();
+ else
+ for (uint32_t i = 0; i < numsamples; i++)
+ out[i] = filter[2].process_d1(filter[1].process_d1(filter[0].process_d1_zeroin()));
+ break;
+ }
}
- filter.sanitize_d1();
- return filter.empty_d1() ? 0 : inmask;
+ for (int i = 0; i < order; i++)
+ filter[i].sanitize_d1();
+ return filter[order - 1].empty_d1() ? 0 : inmask;
}
uint32_t process(uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask) {
if (outputs_mask & 1) {
diff --git a/src/jackhost.cpp b/src/jackhost.cpp
index 65060d2..fc48978 100644
--- a/src/jackhost.cpp
+++ b/src/jackhost.cpp
@@ -49,7 +49,8 @@ public:
jack_host_gui(GtkWidget *_toplevel);
void create(synth::jack_host_base *_host);
- static void value_changed(PhatKnob *widget, gpointer value);
+ static void knob_value_changed(PhatKnob *widget, gpointer value);
+ static void combo_value_changed(GtkComboBox *widget, gpointer value);
};
jack_host_gui::jack_host_gui(GtkWidget *_toplevel)
@@ -58,7 +59,7 @@ jack_host_gui::jack_host_gui(GtkWidget *_toplevel)
}
-void jack_host_gui::value_changed(PhatKnob *widget, gpointer value)
+void jack_host_gui::knob_value_changed(PhatKnob *widget, gpointer value)
{
jack_host_param *jhp = (jack_host_param *)value;
jack_host_base &jh = *jhp->gui->host;
@@ -69,6 +70,15 @@ void jack_host_gui::value_changed(PhatKnob *widget, gpointer value)
jh.set_params();
}
+void jack_host_gui::combo_value_changed(GtkComboBox *widget, gpointer value)
+{
+ jack_host_param *jhp = (jack_host_param *)value;
+ jack_host_base &jh = *jhp->gui->host;
+ int nparam = jhp->param_no;
+ jh.get_params()[nparam] = gtk_combo_box_get_active (widget) + jh.get_param_props()[jhp->param_no].min;
+ jh.set_params();
+}
+
void jack_host_gui::create(synth::jack_host_base *_host)
{
host = _host;
@@ -86,9 +96,25 @@ void jack_host_gui::create(synth::jack_host_base *_host)
GtkWidget *label = gtk_label_new (host->get_param_names()[host->get_input_count() + host->get_output_count() + i]);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, i, i + 1, GTK_EXPAND, GTK_EXPAND, 2, 2);
- GtkWidget *slider = phat_knob_new_with_range (host->get_param_props()[i].to_01 (host->get_params()[i]), 0, 1, 0.01);
- gtk_signal_connect (GTK_OBJECT (slider), "value-changed", G_CALLBACK (value_changed), (gpointer)¶ms[i]);
- gtk_table_attach (GTK_TABLE (table), slider, 1, 2, i, i + 1, GTK_EXPAND, GTK_EXPAND, 0, 0);
+ parameter_properties &props = host->get_param_props()[i];
+
+ GtkWidget *widget;
+
+ if ((props.flags & PF_TYPEMASK) == PF_ENUM &&
+ (props.flags & PF_CTLMASK) == PF_CTL_COMBO)
+ {
+ widget = gtk_combo_box_new_text ();
+ for (int j = (int)props.min; j <= (int)props.max; j++)
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), props.choices[j]);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), (int)host->get_params()[i] - (int)props.min);
+ gtk_signal_connect (GTK_OBJECT (widget), "changed", G_CALLBACK (combo_value_changed), (gpointer)¶ms[i]);
+ }
+ else
+ {
+ widget = phat_knob_new_with_range (host->get_param_props()[i].to_01 (host->get_params()[i]), 0, 1, 0.01);
+ gtk_signal_connect (GTK_OBJECT (widget), "value-changed", G_CALLBACK (knob_value_changed), (gpointer)¶ms[i]);
+ }
+ gtk_table_attach (GTK_TABLE (table), widget, 1, 2, i, i + 1, GTK_EXPAND, GTK_EXPAND, 0, 0);
}
gtk_container_add (GTK_CONTAINER (toplevel), table);
diff --git a/src/modules.cpp b/src/modules.cpp
index 8192099..d1ef7a5 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -71,14 +71,18 @@ synth::ladspa_wrapper<reverb_audio_module> reverb(reverb_info);
const char *filter_audio_module::param_names[] = {"In L", "In R", "Out L", "Out R", "Cutoff", "Resonance", "Mode"};
const char *filter_choices[] = {
- "Lowpass",
- "Highpass"
+ "12dB/oct Lowpass",
+ "24dB/oct Lowpass",
+ "36dB/oct Lowpass",
+ "12dB/oct Highpass",
+ "24dB/oct Highpass",
+ "36dB/oct Highpass",
};
parameter_properties filter_audio_module::param_props[] = {
- { 2000, 20,20000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL },
+ { 2000, 10,20000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL },
{ 0.707, 0.707, 20, 1.1, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL },
- { 0, 0, 1, 1, PF_ENUM | PF_CTL_COMBO, filter_choices },
+ { 0, 0, 5, 1, PF_ENUM | PF_CTL_COMBO, filter_choices },
};
static synth::ladspa_info filter_info = { 0x847f, "Filter", "Calf Filter", "Krzysztof Foltman", copyright, "FilterPlugin" };
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list