Fix pdbox makefile to actually take part in dependency generation
[kugel-rb.git] / apps / plugins / pdbox / PDa / intern / cos~.c
blob9e2d61f848316986f3a049ea0f36c8581eeec17d
2 #include "../src/m_pd.h"
3 #include <../src/m_fixed.h>
4 #include "cos_table.h"
6 /* ------------------------ cos~ ----------------------------- */
7 #define FRAC ((1<<(fix1-ILOGCOSTABSIZE))-1)
9 static t_class *cos_class;
11 typedef struct _cos
13 t_object x_obj;
14 float x_f;
15 } t_cos;
17 static void *cos_new(void)
19 t_cos *x = (t_cos *)pd_new(cos_class);
20 outlet_new(&x->x_obj, gensym("signal"));
21 x->x_f = 0;
22 return (x);
25 static t_int *cos_perform(t_int *w)
27 t_sample *in = (t_sample *)(w[1]);
28 t_sample *out = (t_sample *)(w[2]);
29 int n = (int)(w[3]);
30 t_sample *tab = cos_table;
31 int off;
32 int frac;
33 unsigned int phase;
35 while (n--) {
36 phase = *in++;
37 phase &= ((1<<fix1)-1);
38 off = fixtoi((long long)phase<<ILOGCOSTABSIZE);
40 frac = phase&(itofix(1)-1);
41 *out = mult(*(tab + off),itofix(1) - frac) +
42 mult(*(tab + off + 1),frac);
43 out++;
45 return (w+4);
48 static void cos_dsp(t_cos *x, t_signal **sp)
50 #ifdef ROCKBOX
51 (void) x;
52 #endif
53 dsp_add(cos_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
57 void cos_tilde_setup(void)
59 cos_class = class_new(gensym("cos~"), (t_newmethod)cos_new, 0,
60 sizeof(t_cos), 0, A_DEFFLOAT, 0);
61 CLASS_MAINSIGNALIN(cos_class, t_cos, x_f);
62 class_addmethod(cos_class, (t_method)cos_dsp, gensym("dsp"), 0);
63 class_sethelpsymbol(cos_class, gensym("osc~-help.pd"));