aboutsummaryrefslogtreecommitdiff
path: root/externals/vanilla/dac~.c
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2010-12-13 02:32:29 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2010-12-13 02:32:29 +0000
commit26a43627098f14a8d0d2291bd9b27121b5c6a9cb (patch)
treee2b3c9e96fbfa3067f25a7a494ae91304d0bb477 /externals/vanilla/dac~.c
parenta71366075fadcdb720b8fa02663bb19200fed5e5 (diff)
refactored d_dac.c into adc~.c and dac~.c
svn path=/trunk/; revision=14610
Diffstat (limited to 'externals/vanilla/dac~.c')
-rw-r--r--externals/vanilla/dac~.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/externals/vanilla/dac~.c b/externals/vanilla/dac~.c
new file mode 100644
index 00000000..4e59e23f
--- /dev/null
+++ b/externals/vanilla/dac~.c
@@ -0,0 +1,71 @@
+/* Copyright (c) 1997-1999 Miller Puckette.
+* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+/* The dac~ and adc~ routines.
+*/
+
+#include "m_pd.h"
+#include "s_stuff.h"
+
+/* ----------------------------- dac~ --------------------------- */
+static t_class *dac_class;
+
+typedef struct _dac
+{
+ t_object x_obj;
+ t_int x_n;
+ t_int *x_vec;
+ t_float x_f;
+} t_dac;
+
+static void *dac_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_dac *x = (t_dac *)pd_new(dac_class);
+ t_atom defarg[2], *ap;
+ int i;
+ if (!argc)
+ {
+ argv = defarg;
+ argc = 2;
+ SETFLOAT(&defarg[0], 1);
+ SETFLOAT(&defarg[1], 2);
+ }
+ x->x_n = argc;
+ x->x_vec = (t_int *)getbytes(argc * sizeof(*x->x_vec));
+ for (i = 0; i < argc; i++)
+ x->x_vec[i] = atom_getintarg(i, argc, argv);
+ for (i = 1; i < argc; i++)
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+ x->x_f = 0;
+ return (x);
+}
+
+static void dac_dsp(t_dac *x, t_signal **sp)
+{
+ t_int i, *ip;
+ t_signal **sp2;
+ for (i = x->x_n, ip = x->x_vec, sp2 = sp; i--; ip++, sp2++)
+ {
+ int ch = *ip - 1;
+ if ((*sp2)->s_n != DEFDACBLKSIZE)
+ error("dac~: bad vector size");
+ else if (ch >= 0 && ch < sys_get_outchannels())
+ dsp_add(plus_perform, 4, sys_soundout + DEFDACBLKSIZE*ch,
+ (*sp2)->s_vec, sys_soundout + DEFDACBLKSIZE*ch, DEFDACBLKSIZE);
+ }
+}
+
+static void dac_free(t_dac *x)
+{
+ freebytes(x->x_vec, x->x_n * sizeof(*x->x_vec));
+}
+
+void dac_tilde_setup(void)
+{
+ dac_class = class_new(gensym("dac~"), (t_newmethod)dac_new,
+ (t_method)dac_free, sizeof(t_dac), 0, A_GIMME, 0);
+ CLASS_MAINSIGNALIN(dac_class, t_dac, x_f);
+ class_addmethod(dac_class, (t_method)dac_dsp, gensym("dsp"), A_CANT, 0);
+ class_sethelpsymbol(dac_class, gensym("adc~_dac~"));
+}