1
/******************************************************
3
* zexy - implementation file
5
* copyleft (c) IOhannes m zm-b�lnig-A
7
* 1999:forum::f-b�r::uml�ute:2007-A
9
* institute of electronic music and acoustics (iem)
11
******************************************************
13
* license: GNU General Public License v.2
15
******************************************************/
17
/* based on tabread4~ which is part of pd */
21
/******************** tabread4~~ ***********************/
24
static t_class *tabread4_tilde_class;
26
typedef struct _tabread4_tilde
31
t_symbol *x_arrayname;
35
static void *tabread4_tilde_new(t_symbol *s)
37
t_tabread4_tilde *x = (t_tabread4_tilde *)pd_new(tabread4_tilde_class);
42
inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
43
outlet_new(&x->x_obj, &s_signal);
48
static t_int *tabread4_tilde_perform(t_int *w)
50
t_tabread4_tilde *x = (t_tabread4_tilde *)(w[1]);
51
t_sample *in = (t_sample *)(w[2]);
52
t_sample *in1 = (t_sample *)(w[3]);
53
t_sample *out = (t_sample *)(w[4]);
56
zarray_t *buf = x->x_vec, *wp;
59
maxindex = x->x_npoints - 3;
61
while (n--) *out++ = 0;
64
for (i = 0; i < n; i++)
67
t_sample in1_s=*in1++;
68
double findex = (double)in0_s + (double)in1_s;
69
long int index = findex;
71
t_sample a, b, c, d, cminusb;
74
else if (index > maxindex)
75
index = maxindex, frac = 1;
76
else frac = findex - index;
80
a = zarray_getfloat(wp,-1);
81
b = zarray_getfloat(wp, 0);
82
c = zarray_getfloat(wp, 1);
83
d = zarray_getfloat(wp, 2);
87
cminusb - 0.1666667f * (1.-frac) * (
88
(d - a - 3.0f * cminusb) * frac + (d + 2.0f*a - 3.0f*b)
95
static void tabread4_tilde_set(t_tabread4_tilde *x, t_symbol *s)
100
if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
103
pd_error(x, "tabread4~~: %s: no such array", x->x_arrayname->s_name);
106
else if (!zarray_getarray(a, &x->x_npoints, &x->x_vec))
108
pd_error(x, "%s: bad template for tabread4~~", x->x_arrayname->s_name);
111
else garray_usedindsp(a);
114
static void tabread4_tilde_dsp(t_tabread4_tilde *x, t_signal **sp)
116
tabread4_tilde_set(x, x->x_arrayname);
118
dsp_add(tabread4_tilde_perform, 5, x,
119
sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n);
123
static void tabread4_tilde_free(t_tabread4_tilde *x)
127
void tabread4_tilde_tilde_setup(void)
129
tabread4_tilde_class = class_new(gensym("tabread4~~"),
130
(t_newmethod)tabread4_tilde_new, (t_method)tabread4_tilde_free,
131
sizeof(t_tabread4_tilde), 0, A_DEFSYM, 0);
132
CLASS_MAINSIGNALIN(tabread4_tilde_class, t_tabread4_tilde, x_f);
133
class_addmethod(tabread4_tilde_class, (t_method)tabread4_tilde_dsp,
135
class_addmethod(tabread4_tilde_class, (t_method)tabread4_tilde_set,
136
gensym("set"), A_SYMBOL, 0);
138
zexy_register("tabread4~~");
141
void setup_tabread40x7e_tilde(void)
143
tabread4_tilde_tilde_setup();
146
void setup_tabread40x7e0x7e(void)
148
tabread4_tilde_tilde_setup();