summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/intern/delread~.c
diff options
context:
space:
mode:
authorPeter D'Hoye <peter.dhoye@gmail.com>2009-05-24 21:28:16 +0000
committerPeter D'Hoye <peter.dhoye@gmail.com>2009-05-24 21:28:16 +0000
commit526b5580dabbfed7cfe5439dc3a90ec727f563c2 (patch)
tree22b1af92348785daad16714ee5e2b633017e0e48 /apps/plugins/pdbox/PDa/intern/delread~.c
parent4f2dfcc01b260d946044ef2b6af5fe36cb772c8d (diff)
downloadrockbox-526b5580dabbfed7cfe5439dc3a90ec727f563c2.tar.gz
rockbox-526b5580dabbfed7cfe5439dc3a90ec727f563c2.zip
Cut the files in half and it might work better (note to self: check your tree is really clean before patching)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21070 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/pdbox/PDa/intern/delread~.c')
-rw-r--r--apps/plugins/pdbox/PDa/intern/delread~.c99
1 files changed, 0 insertions, 99 deletions
diff --git a/apps/plugins/pdbox/PDa/intern/delread~.c b/apps/plugins/pdbox/PDa/intern/delread~.c
index b0a58393be..ed7d2f2d80 100644
--- a/apps/plugins/pdbox/PDa/intern/delread~.c
+++ b/apps/plugins/pdbox/PDa/intern/delread~.c
@@ -98,103 +98,4 @@ void delread_tilde_setup(void)
98 gensym("dsp"), 0); 98 gensym("dsp"), 0);
99 class_addfloat(sigdelread_class, (t_method)sigdelread_float); 99 class_addfloat(sigdelread_class, (t_method)sigdelread_float);
100} 100}
101#include <m_pd.h>
102#include <m_fixed.h>
103#include "delay.h"
104
105extern int ugen_getsortno(void);
106
107#define DEFDELVS 64 /* LATER get this from canvas at DSP time */
108static int delread_zero = 0; /* four bytes of zero for delread~, vd~ */
109
110static t_class *sigdelread_class;
111
112typedef struct _sigdelread
113{
114 t_object x_obj;
115 t_symbol *x_sym;
116 t_float x_deltime; /* delay in msec */
117 int x_delsamps; /* delay in samples */
118 t_float x_sr; /* samples per msec */
119 t_float x_n; /* vector size */
120 int x_zerodel; /* 0 or vecsize depending on read/write order */
121} t_sigdelread;
122
123static void sigdelread_float(t_sigdelread *x, t_float f);
124
125static void *sigdelread_new(t_symbol *s, t_floatarg f)
126{
127 t_sigdelread *x = (t_sigdelread *)pd_new(sigdelread_class);
128 x->x_sym = s;
129 x->x_sr = 1;
130 x->x_n = 1;
131 x->x_zerodel = 0;
132 sigdelread_float(x, f);
133 outlet_new(&x->x_obj, &s_signal);
134 return (x);
135}
136 101
137static void sigdelread_float(t_sigdelread *x, t_float f)
138{
139 int samps;
140 t_sigdelwrite *delwriter =
141 (t_sigdelwrite *)pd_findbyclass(x->x_sym, sigdelwrite_class);
142 x->x_deltime = f;
143 if (delwriter)
144 {
145 int delsize = delwriter->x_cspace.c_n;
146 x->x_delsamps = (int)(0.5 + x->x_sr * x->x_deltime)
147 + x->x_n - x->x_zerodel;
148 if (x->x_delsamps < x->x_n) x->x_delsamps = x->x_n;
149 else if (x->x_delsamps > delwriter->x_cspace.c_n - DEFDELVS)
150 x->x_delsamps = delwriter->x_cspace.c_n - DEFDELVS;
151 }
152}
153
154static t_int *sigdelread_perform(t_int *w)
155{
156 t_sample *out = (t_sample *)(w[1]);
157 t_delwritectl *c = (t_delwritectl *)(w[2]);
158 int delsamps = *(int *)(w[3]);
159 int n = (int)(w[4]);
160 int phase = c->c_phase - delsamps, nsamps = c->c_n;
161 t_sample *vp = c->c_vec, *bp, *ep = vp + (c->c_n + XTRASAMPS);
162
163 if (phase < 0) phase += nsamps;
164 bp = vp + phase;
165 while (n--)
166 {
167 *out++ = *bp++;
168 if (bp == ep) bp -= nsamps;
169 }
170 return (w+5);
171}
172
173static void sigdelread_dsp(t_sigdelread *x, t_signal **sp)
174{
175 t_sigdelwrite *delwriter =
176 (t_sigdelwrite *)pd_findbyclass(x->x_sym, sigdelwrite_class);
177 x->x_sr = sp[0]->s_sr * 0.001;
178 x->x_n = sp[0]->s_n;
179 if (delwriter)
180 {
181 sigdelwrite_checkvecsize(delwriter, sp[0]->s_n);
182 x->x_zerodel = (delwriter->x_sortno == ugen_getsortno() ?
183 0 : delwriter->x_vecsize);
184 sigdelread_float(x, x->x_deltime);
185 dsp_add(sigdelread_perform, 4,
186 sp[0]->s_vec, &delwriter->x_cspace, &x->x_delsamps, sp[0]->s_n);
187 }
188 else if (*x->x_sym->s_name)
189 error("delread~: %s: no such delwrite~",x->x_sym->s_name);
190}
191
192void delread_tilde_setup(void)
193{
194 sigdelread_class = class_new(gensym("delread~"),
195 (t_newmethod)sigdelread_new, 0,
196 sizeof(t_sigdelread), 0, A_DEFSYM, A_DEFFLOAT, 0);
197 class_addmethod(sigdelread_class, (t_method)sigdelread_dsp,
198 gensym("dsp"), 0);
199 class_addfloat(sigdelread_class, (t_method)sigdelread_float);
200}