From 843409ecc7baf287962cbe34e967380302f35509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Fri, 1 Jun 2007 09:15:09 +0000 Subject: new filelayout (one c-file per object) svn path=/trunk/externals/iem16/; revision=7739 --- src/tab16receive~.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/tab16receive~.c (limited to 'src/tab16receive~.c') diff --git a/src/tab16receive~.c b/src/tab16receive~.c new file mode 100644 index 0000000..f946dce --- /dev/null +++ b/src/tab16receive~.c @@ -0,0 +1,68 @@ +/* copyleft (c) 2003 forum::für::umläute -- IOhannes m zmölnig @ IEM + * based on d_array.c from pd: + * Copyright (c) 1997-1999 Miller Puckette and others. + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ + +/* tab16write~, tab16play~, tab16read~, tab16read4~, tab16send~, tab16receive~ */ + +#include "iem16_table.h" + +/* ------------------------ tab16receive~ ------------------------- */ + +static t_class *tab16receive_class; + +typedef struct _tab16receive{ + t_object x_obj; + t_iem16_16bit *x_vec; + t_symbol *x_arrayname; +} t_tab16receive; + +static t_int *tab16receive_perform(t_int *w){ + t_tab16receive *x = (t_tab16receive *)(w[1]); + t_float *out = (t_float *)(w[2]); + int n = w[3]; + t_iem16_16bit *from = x->x_vec; + if (from) while (n--) *out++ = *from++*IEM16_SCALE_DOWN; + else while (n--) *out++ = 0; + return (w+4); +} + +static void tab16receive_dsp(t_tab16receive *x, t_signal **sp){ + t_table16 *a; + int vecsize; + + if (!(a = (t_table16 *)pd_findbyclass(x->x_arrayname, table16_class))) { + if (*x->x_arrayname->s_name) + error("tab16send~: %s: no such array", x->x_arrayname->s_name); + } + else if (!table16_getarray16(a, &vecsize, &x->x_vec)) + error("%s: bad template for tab16receive~", x->x_arrayname->s_name); + else { + int n = sp[0]->s_n; + if (n < vecsize) vecsize = n; + table16_usedindsp(a); + dsp_add(tab16receive_perform, 3, x, sp[0]->s_vec, vecsize); + } +} + +static void *tab16receive_new(t_symbol *s){ + t_tab16receive *x = (t_tab16receive *)pd_new(tab16receive_class); + x->x_arrayname = s; + outlet_new(&x->x_obj, gensym("signal")); + return (x); +} + +static void tab16receive_setup(void){ + tab16receive_class = class_new(gensym("tab16receive~"), + (t_newmethod)tab16receive_new, 0, + sizeof(t_tab16receive), 0, A_DEFSYM, 0); + class_addmethod(tab16receive_class, (t_method)tab16receive_dsp, + gensym("dsp"), 0); +} + +// G.Holzmann: for PD-extended build system +void tab16receive_tilde_setup(void) +{ + tab16receive_setup(); +} -- cgit v1.2.1