summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/intern/osc~.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/osc~.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/osc~.c')
-rw-r--r--apps/plugins/pdbox/PDa/intern/osc~.c88
1 files changed, 0 insertions, 88 deletions
diff --git a/apps/plugins/pdbox/PDa/intern/osc~.c b/apps/plugins/pdbox/PDa/intern/osc~.c
index f8e89970e9..b2cc843b55 100644
--- a/apps/plugins/pdbox/PDa/intern/osc~.c
+++ b/apps/plugins/pdbox/PDa/intern/osc~.c
@@ -84,91 +84,3 @@ void osc_tilde_setup(void)
84 class_addmethod(osc_class, (t_method)osc_ft1, gensym("ft1"), A_FLOAT, 0); 84 class_addmethod(osc_class, (t_method)osc_ft1, gensym("ft1"), A_FLOAT, 0);
85} 85}
86 86
87
88
89
90#include <m_pd.h>
91#include <m_fixed.h>
92#include "cos_table.h"
93
94/* ------------------------ osc~ ----------------------------- */
95
96static t_class *osc_class, *scalarosc_class;
97
98typedef struct _osc
99{
100 t_object x_obj;
101 unsigned int x_phase;
102 t_sample x_conv;
103 t_sample x_f; /* frequency if scalar */
104} t_osc;
105
106static void *osc_new(t_floatarg f)
107{
108 t_osc *x = (t_osc *)pd_new(osc_class);
109 x->x_f = ftofix(f);
110 outlet_new(&x->x_obj, gensym("signal"));
111 inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1"));
112 x->x_phase = 0;
113 x->x_conv = 0;
114 return (x);
115}
116
117
118static t_int *osc_perform(t_int *w)
119{
120 t_osc *x = (t_osc *)(w[1]);
121 t_sample *in = (t_sample *)(w[2]);
122 t_sample *out = (t_sample *)(w[3]);
123 int n = (int)(w[4]);
124 t_sample *tab = cos_table;
125 unsigned int phase = x->x_phase;
126 int conv = x->x_conv;
127 int off;
128 int frac;
129 while (n--) {
130 phase+= mult(conv ,(*in++));
131 phase &= (itofix(1) -1);
132 off = fixtoi((long long)phase<<ILOGCOSTABSIZE);
133
134#ifdef NO_INTERPOLATION
135 *out = *(tab+off);
136#else
137// frac = phase & (itofix(1)-1);
138 frac = phase & ((1<<ILOGCOSTABSIZE)-1);
139 frac <<= (fix1-ILOGCOSTABSIZE);
140 *out = mult(*(tab + off),(itofix(1) - frac)) +
141 mult(*(tab + off + 1),frac);
142#endif
143 out++;
144 }
145 x->x_phase = phase;
146
147 return (w+5);
148}
149
150static void osc_dsp(t_osc *x, t_signal **sp)
151{
152 post("samplerate %f",sp[0]->s_sr);
153 x->x_conv = ftofix(1000.)/sp[0]->s_sr;
154 post("conf %d",x->x_conv);
155 x->x_conv = mult(x->x_conv + 500,ftofix(0.001));
156 post("conf %d",x->x_conv);
157 dsp_add(osc_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
158}
159
160static void osc_ft1(t_osc *x, t_float f)
161{
162 x->x_phase = ftofix(f); /* *2 ??? */
163}
164
165void osc_tilde_setup(void)
166{
167 osc_class = class_new(gensym("osc~"), (t_newmethod)osc_new, 0,
168 sizeof(t_osc), 0, A_DEFFLOAT, 0);
169 CLASS_MAINSIGNALIN(osc_class, t_osc, x_f);
170 class_addmethod(osc_class, (t_method)osc_dsp, gensym("dsp"), 0);
171 class_addmethod(osc_class, (t_method)osc_ft1, gensym("ft1"), A_FLOAT, 0);
172}
173
174