aboutsummaryrefslogtreecommitdiff
path: root/modules++
diff options
context:
space:
mode:
Diffstat (limited to 'modules++')
-rw-r--r--modules++/Makefile10
-rw-r--r--modules++/biquadseries.cc128
-rw-r--r--modules++/filterortho.cc131
3 files changed, 269 insertions, 0 deletions
diff --git a/modules++/Makefile b/modules++/Makefile
new file mode 100644
index 0000000..1329f4b
--- /dev/null
+++ b/modules++/Makefile
@@ -0,0 +1,10 @@
+include ../Makefile.config
+current: all
+
+all: biquadseries.o filterortho.o
+
+
+clean:
+ rm -f *~
+ rm -f *.o
+
diff --git a/modules++/biquadseries.cc b/modules++/biquadseries.cc
new file mode 100644
index 0000000..40b3aef
--- /dev/null
+++ b/modules++/biquadseries.cc
@@ -0,0 +1,128 @@
+/*
+ * biquadseries.cc - second order section filter pd interface
+ * Copyright (c) 2000-2003 by Tom Schouten
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#include "m_pd.h"
+#include <math.h>
+
+#include "DSPIcomplex.h"
+#include "DSPIfilters.h"
+
+
+
+typedef struct biquadseries_struct
+{
+ t_object x_obj;
+ t_float x_f;
+ DSPIfilterSeries* biquadseries;
+} t_biquadseries;
+
+void biquadseries_bang(t_biquadseries *x)
+{
+
+}
+
+void biquadseries_butterLP(t_biquadseries *x, t_floatarg f)
+{
+ x->biquadseries->setButterLP(f / sys_getsr());
+}
+
+void biquadseries_butterHP(t_biquadseries *x, t_floatarg f)
+{
+ x->biquadseries->setButterHP(f / sys_getsr());
+}
+
+
+
+static t_int *biquadseries_perform(t_int *w)
+{
+
+
+ t_float *in = (float *)(w[3]);
+ t_float *out = (float *)(w[4]);
+ DSPIfilterSeries* biquadseries = (DSPIfilterSeries *)(w[1]);
+ t_int n = (t_int)(w[2]);
+ t_int i;
+ t_float x;
+
+ // dit kan beter
+ float smooth = .01;
+ //1.0f - pow(.9f,1.0f/(float)(n));
+
+ for (i = 0; i < n; i++)
+ {
+ x = *in++;
+ biquadseries->BangSmooth(x, x, smooth);
+ *out++ = x;
+ }
+
+ return (w+5);
+}
+
+static void biquadseries_dsp(t_biquadseries *x, t_signal **sp)
+{
+ dsp_add(biquadseries_perform, 4, x->biquadseries, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec);
+
+}
+void biquadseries_free(void)
+{
+
+}
+
+t_class *biquadseries_class;
+
+void *biquadseries_new(t_floatarg fsections)
+{
+ t_biquadseries *x = (t_biquadseries *)pd_new(biquadseries_class);
+
+ int sections = (int)fsections;
+ if (sections < 1) sections = 1;
+ // post("biquadseries~: %d sections", sections);
+ x->biquadseries = new DSPIfilterSeries(sections);
+
+ // inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("freq"));
+ outlet_new(&x->x_obj, gensym("signal"));
+
+ biquadseries_butterLP(x, 10000);
+
+ return (void *)x;
+}
+
+
+extern "C" {
+
+void biquadseries_tilde_setup(void)
+{
+ //post("biquadseries~ v0.1");
+
+ biquadseries_class = class_new(gensym("biquadseries~"), (t_newmethod)biquadseries_new,
+ (t_method)biquadseries_free, sizeof(t_biquadseries), 0, A_DEFFLOAT, 0);
+
+ CLASS_MAINSIGNALIN(biquadseries_class, t_biquadseries, x_f);
+
+ class_addmethod(biquadseries_class, (t_method)biquadseries_bang, gensym("bang"), (t_atomtype)0);
+
+ class_addmethod(biquadseries_class, (t_method)biquadseries_dsp, gensym("dsp"), (t_atomtype)0);
+
+ class_addmethod(biquadseries_class, (t_method)biquadseries_butterLP, gensym("butterLP"), A_FLOAT, A_NULL);
+ class_addmethod(biquadseries_class, (t_method)biquadseries_butterHP, gensym("butterHP"), A_FLOAT, A_NULL);
+
+}
+
+}
diff --git a/modules++/filterortho.cc b/modules++/filterortho.cc
new file mode 100644
index 0000000..11c6aac
--- /dev/null
+++ b/modules++/filterortho.cc
@@ -0,0 +1,131 @@
+/*
+ * filterortho.cc - orthogonal biquad filter pd interface
+ * Copyright (c) 2000-2003 by Tom Schouten
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#include "m_pd.h"
+#include <math.h>
+
+#include "DSPIcomplex.h"
+#include "DSPIfilters.h"
+
+
+
+typedef struct filterortho_struct
+{
+ t_object x_obj;
+ t_float x_f;
+ DSPIfilterOrtho filterortho;
+} t_filterortho;
+
+void filterortho_bang(t_filterortho *x)
+{
+
+}
+
+
+static t_int *filterortho_perform(t_int *w)
+{
+
+
+ t_float *in = (float *)(w[3]);
+ t_float *out = (float *)(w[4]);
+ DSPIfilterOrtho* filterortho = (DSPIfilterOrtho *)(w[1]);
+ t_int n = (t_int)(w[2]);
+ t_int i;
+ t_float x;
+
+
+ // dit kan beter
+ float smooth = 1.0f - pow(.05f,1.0f/(float)(n));
+
+ for (i = 0; i < n; i++)
+ {
+ x = *in++;
+ filterortho->BangSmooth(x, x, smooth);
+ *out++ = x;
+ }
+
+ filterortho->killDenormals();
+
+ return (w+5);
+}
+
+static void filterortho_dsp(t_filterortho *x, t_signal **sp)
+{
+ dsp_add(filterortho_perform, 4, &(x->filterortho), sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec);
+
+}
+void filterortho_free(void)
+{
+
+}
+
+t_class *filterortho_class;
+
+
+
+void setLP(t_filterortho *x, t_floatarg f, t_floatarg Q) {x->filterortho.setLP(f / sys_getsr(), Q);}
+void setHP(t_filterortho *x, t_floatarg f, t_floatarg Q) {x->filterortho.setHP(f / sys_getsr(), Q);}
+void setBP(t_filterortho *x, t_floatarg f, t_floatarg Q) {x->filterortho.setBP(f / sys_getsr(), Q);}
+void setBR(t_filterortho *x, t_floatarg f, t_floatarg Q) {x->filterortho.setBR(f / sys_getsr(), Q);}
+void setAP(t_filterortho *x, t_floatarg f, t_floatarg Q) {x->filterortho.setAP(f / sys_getsr(), Q);}
+
+void setLS(t_filterortho *x, t_floatarg f, t_floatarg A) {x->filterortho.setLS(f / sys_getsr(), A);}
+void setHS(t_filterortho *x, t_floatarg f, t_floatarg A) {x->filterortho.setHS(f / sys_getsr(), A);}
+
+void setEQ(t_filterortho *x, t_floatarg f, t_floatarg Q, t_floatarg A) {x->filterortho.setEQ(f / sys_getsr(), Q, A);}
+
+
+void *filterortho_new()
+{
+ t_filterortho *x = (t_filterortho *)pd_new(filterortho_class);
+ outlet_new(&x->x_obj, gensym("signal"));
+ setLP(x, 10000, 2);
+ return (void *)x;
+}
+
+
+
+extern "C" {
+
+void filterortho_tilde_setup(void)
+{
+ //post("filterortho~ v0.1");
+
+ filterortho_class = class_new(gensym("filterortho~"), (t_newmethod)filterortho_new,
+ (t_method)filterortho_free, sizeof(t_filterortho), 0, A_NULL);
+
+ CLASS_MAINSIGNALIN(filterortho_class, t_filterortho, x_f);
+
+ class_addmethod(filterortho_class, (t_method)filterortho_bang, gensym("bang"), A_NULL);
+
+ class_addmethod(filterortho_class, (t_method)filterortho_dsp, gensym("dsp"), A_NULL);
+
+ class_addmethod(filterortho_class, (t_method)setLP, gensym("setLP"), A_FLOAT, A_FLOAT, A_NULL);
+ class_addmethod(filterortho_class, (t_method)setHP, gensym("setHP"), A_FLOAT, A_FLOAT, A_NULL);
+ class_addmethod(filterortho_class, (t_method)setBP, gensym("setBP"), A_FLOAT, A_FLOAT, A_NULL);
+ class_addmethod(filterortho_class, (t_method)setBR, gensym("setBR"), A_FLOAT, A_FLOAT, A_NULL);
+ class_addmethod(filterortho_class, (t_method)setAP, gensym("setAP"), A_FLOAT, A_FLOAT, A_NULL);
+ class_addmethod(filterortho_class, (t_method)setLS, gensym("setLS"), A_FLOAT, A_FLOAT, A_NULL);
+ class_addmethod(filterortho_class, (t_method)setHS, gensym("setHS"), A_FLOAT, A_FLOAT, A_NULL);
+ class_addmethod(filterortho_class, (t_method)setEQ, gensym("setEQ"), A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
+
+}
+
+}