aboutsummaryrefslogtreecommitdiff
path: root/modules/abs~.c
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2006-05-25 16:40:19 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2006-05-25 16:40:19 +0000
commitd962ed33f6b5fe3040cfbd798f63ab9aa36d1f9e (patch)
treef700234efa8d57c28ce9be56e0db5f6526921fbe /modules/abs~.c
parent2994949cca515f63fb82fa1d114ce07eb213220d (diff)
renamed files to match their class names
svn path=/trunk/externals/creb/; revision=5127
Diffstat (limited to 'modules/abs~.c')
-rw-r--r--modules/abs~.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/modules/abs~.c b/modules/abs~.c
new file mode 100644
index 0000000..0cb3d4d
--- /dev/null
+++ b/modules/abs~.c
@@ -0,0 +1,51 @@
+
+// since this is present in a lot of libs, it is conditionally compiled
+#ifdef HAVE_ABS_TILDE
+
+#include "m_pd.h"
+#include <math.h>
+
+/* ------------------------- abs~ -------------------------- */
+static t_class *abs_class;
+
+typedef struct _abs
+{
+ t_object x_obj;
+} t_abs;
+
+static t_int *abs_perform(t_int *w)
+{
+ t_abs *x = (t_abs *)(w[1]);
+ t_float *in = (t_float *)(w[2]);
+ t_float *out = (t_float *)(w[3]);
+ int n = (int)(w[4]);
+ while (n--)
+ {
+ float f = *in++;
+ if (f < 0) f = -f;
+ *out++ = f;
+ }
+ return (w+5);
+}
+
+static void abs_dsp(t_abs *x, t_signal **sp)
+{
+ dsp_add(abs_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
+}
+
+static void *abs_new(void)
+{
+ t_abs *x = (t_abs *)pd_new(abs_class);
+ outlet_new(&x->x_obj, &s_signal);
+ return (x);
+}
+
+void abs_tilde_setup(void)
+{
+ abs_class = class_new(gensym("abs~"), (t_newmethod)abs_new, 0,
+ sizeof(t_abs), 0, A_NULL);
+ class_addmethod(abs_class, (t_method)nullfn, &s_signal, A_NULL);
+ class_addmethod(abs_class, (t_method)abs_dsp, gensym("dsp"), A_NULL);
+}
+
+#endif