diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2010-12-13 02:32:29 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2010-12-13 02:32:29 +0000 |
commit | 26a43627098f14a8d0d2291bd9b27121b5c6a9cb (patch) | |
tree | e2b3c9e96fbfa3067f25a7a494ae91304d0bb477 /externals/vanilla | |
parent | a71366075fadcdb720b8fa02663bb19200fed5e5 (diff) |
refactored d_dac.c into adc~.c and dac~.c
svn path=/trunk/; revision=14610
Diffstat (limited to 'externals/vanilla')
-rw-r--r-- | externals/vanilla/Makefile | 2 | ||||
-rw-r--r-- | externals/vanilla/adc~.c | 114 | ||||
-rw-r--r-- | externals/vanilla/adc~_dac~-help.pd | 16 | ||||
-rw-r--r-- | externals/vanilla/dac~.c | 71 | ||||
-rw-r--r-- | externals/vanilla/lib_d_dac.c | 5 |
5 files changed, 202 insertions, 6 deletions
diff --git a/externals/vanilla/Makefile b/externals/vanilla/Makefile index 9576a30e..df04f386 100644 --- a/externals/vanilla/Makefile +++ b/externals/vanilla/Makefile @@ -5,7 +5,7 @@ LIBRARY_NAME = vanilla # add your .c source files, one object per file, to the SOURCES # variable, help files will be included automatically -SOURCES = abs~.c bng.c clip~.c cnv.c dbtopow~.c dbtorms~.c del.c delay.c exp~.c ftom~.c hdl.c hradio.c hsl.c hslider.c key.c keyname.c keyup.c line.c list.c log~.c metro.c mtof~.c my_canvas.c my_numbox.c nbx.c netsend.c netreceive.c openpanel.c pipe.c powtodb~.c pow~.c print.c qlist.c radiobut.c radiobutton.c rdb.c rmstodb~.c rsqrt~.c savepanel.c sqrt~.c textfile.c tgl.c timer.c toggle.c vdl.c vradio.c vsl.c vslider.c vu.c wrap~.c random.c loadbang.c namecanvas.c cputime.c realtime.c bang~.c print~.c +SOURCES = abs~.c bng.c clip~.c cnv.c dbtopow~.c dbtorms~.c del.c delay.c exp~.c ftom~.c hdl.c hradio.c hsl.c hslider.c key.c keyname.c keyup.c line.c list.c log~.c metro.c mtof~.c my_canvas.c my_numbox.c nbx.c netsend.c netreceive.c openpanel.c pipe.c powtodb~.c pow~.c print.c qlist.c radiobut.c radiobutton.c rdb.c rmstodb~.c rsqrt~.c savepanel.c sqrt~.c textfile.c tgl.c timer.c toggle.c vdl.c vradio.c vsl.c vslider.c vu.c wrap~.c random.c loadbang.c namecanvas.c cputime.c realtime.c bang~.c print~.c adc~.c dac~.c # list all pd objects (i.e. myobject.pd) files here, and their helpfiles will # be included automatically diff --git a/externals/vanilla/adc~.c b/externals/vanilla/adc~.c new file mode 100644 index 00000000..831a122c --- /dev/null +++ b/externals/vanilla/adc~.c @@ -0,0 +1,114 @@ +/* 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" + +static t_class *adc_class; + +typedef struct _adc +{ + t_object x_obj; + t_int x_n; + t_int *x_vec; +} t_adc; + +static void *adc_new(t_symbol *s, int argc, t_atom *argv) +{ + t_adc *x = (t_adc *)pd_new(adc_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 = 0; i < argc; i++) + outlet_new(&x->x_obj, &s_signal); + return (x); +} + +t_int *copy_perform(t_int *w) +{ + t_sample *in1 = (t_sample *)(w[1]); + t_sample *out = (t_sample *)(w[2]); + int n = (int)(w[3]); + while (n--) *out++ = *in1++; + return (w+4); +} + +t_int *copy_perf8(t_int *w) +{ + t_sample *in1 = (t_sample *)(w[1]); + t_sample *out = (t_sample *)(w[2]); + int n = (int)(w[3]); + + for (; n; n -= 8, in1 += 8, out += 8) + { + t_sample f0 = in1[0]; + t_sample f1 = in1[1]; + t_sample f2 = in1[2]; + t_sample f3 = in1[3]; + t_sample f4 = in1[4]; + t_sample f5 = in1[5]; + t_sample f6 = in1[6]; + t_sample f7 = in1[7]; + + out[0] = f0; + out[1] = f1; + out[2] = f2; + out[3] = f3; + out[4] = f4; + out[5] = f5; + out[6] = f6; + out[7] = f7; + } + return (w+4); +} + +void dsp_add_copy(t_sample *in, t_sample *out, int n) +{ + if (n&7) + dsp_add(copy_perform, 3, in, out, n); + else + dsp_add(copy_perf8, 3, in, out, n); +} + +static void adc_dsp(t_adc *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("adc~: bad vector size"); + else if (ch >= 0 && ch < sys_get_inchannels()) + dsp_add_copy(sys_soundin + DEFDACBLKSIZE*ch, + (*sp2)->s_vec, DEFDACBLKSIZE); + else dsp_add_zero((*sp2)->s_vec, DEFDACBLKSIZE); + } +} + +static void adc_free(t_adc *x) +{ + freebytes(x->x_vec, x->x_n * sizeof(*x->x_vec)); +} + +void adc_tilde_setup(void) +{ + adc_class = class_new(gensym("adc~"), (t_newmethod)adc_new, + (t_method)adc_free, sizeof(t_adc), 0, A_GIMME, 0); + class_addmethod(adc_class, (t_method)adc_dsp, gensym("dsp"), A_CANT, 0); + class_sethelpsymbol(adc_class, gensym("adc~_dac~")); +} diff --git a/externals/vanilla/adc~_dac~-help.pd b/externals/vanilla/adc~_dac~-help.pd new file mode 100644 index 00000000..7538d8ff --- /dev/null +++ b/externals/vanilla/adc~_dac~-help.pd @@ -0,0 +1,16 @@ +#N canvas 195 155 575 293 12; +#X obj 8 11 adc~; +#X obj 72 11 dac~; +#X obj 63 121 adc~ 5; +#X text 143 121 (input from channel 5 only); +#X obj 61 145 dac~ 1 2 5 23; +#X text 184 145 (output to channels 1 \, 2 \, 5 \, and 23); +#X text 16 173 The actual number of channels Pd inputs and outputs +are set on Pd's command line. You can open patches that want to use +more channels \, and channel numbers out of rance will be dropped (dac~) +or appear as zero (adc~).; +#X text 308 254 updated for Pd version 0.33; +#X text 122 9 - audio I/O; +#X text 8 46 Adc~ and dac~ provide real-time audio input and output +for Pd \, respectively \, whether analog or digital. By default they +are stereo but you can specify channel numbers as in:; 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~")); +} diff --git a/externals/vanilla/lib_d_dac.c b/externals/vanilla/lib_d_dac.c deleted file mode 100644 index a77ddf0c..00000000 --- a/externals/vanilla/lib_d_dac.c +++ /dev/null @@ -1,5 +0,0 @@ -#include "../../pd/src/d_dac.c" -void lib_d_dac_setup(void) -{ - d_dac_setup(); -} |