summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/intern/cos~.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/pdbox/PDa/intern/cos~.c')
-rw-r--r--apps/plugins/pdbox/PDa/intern/cos~.c60
1 files changed, 0 insertions, 60 deletions
diff --git a/apps/plugins/pdbox/PDa/intern/cos~.c b/apps/plugins/pdbox/PDa/intern/cos~.c
index 30ec4e49a7..38625d7419 100644
--- a/apps/plugins/pdbox/PDa/intern/cos~.c
+++ b/apps/plugins/pdbox/PDa/intern/cos~.c
@@ -60,63 +60,3 @@ void cos_tilde_setup(void)
60 class_sethelpsymbol(cos_class, gensym("osc~-help.pd")); 60 class_sethelpsymbol(cos_class, gensym("osc~-help.pd"));
61} 61}
62 62
63#include <m_pd.h>
64#include <m_fixed.h>
65#include "cos_table.h"
66
67/* ------------------------ cos~ ----------------------------- */
68#define FRAC ((1<<(fix1-ILOGCOSTABSIZE))-1)
69
70static t_class *cos_class;
71
72typedef struct _cos
73{
74 t_object x_obj;
75 float x_f;
76} t_cos;
77
78static void *cos_new(void)
79{
80 t_cos *x = (t_cos *)pd_new(cos_class);
81 outlet_new(&x->x_obj, gensym("signal"));
82 x->x_f = 0;
83 return (x);
84}
85
86static t_int *cos_perform(t_int *w)
87{
88 t_sample *in = (t_sample *)(w[1]);
89 t_sample *out = (t_sample *)(w[2]);
90 int n = (int)(w[3]);
91 t_sample *tab = cos_table;
92 int off;
93 int frac;
94 unsigned int phase;
95
96 while (n--) {
97 phase = *in++;
98 phase &= ((1<<fix1)-1);
99 off = fixtoi((long long)phase<<ILOGCOSTABSIZE);
100
101 frac = phase&(itofix(1)-1);
102 *out = mult(*(tab + off),itofix(1) - frac) +
103 mult(*(tab + off + 1),frac);
104 out++;
105 }
106 return (w+4);
107}
108
109static void cos_dsp(t_cos *x, t_signal **sp)
110{
111 dsp_add(cos_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
112}
113
114
115void cos_tilde_setup(void)
116{
117 cos_class = class_new(gensym("cos~"), (t_newmethod)cos_new, 0,
118 sizeof(t_cos), 0, A_DEFFLOAT, 0);
119 CLASS_MAINSIGNALIN(cos_class, t_cos, x_f);
120 class_addmethod(cos_class, (t_method)cos_dsp, gensym("dsp"), 0);
121 class_sethelpsymbol(cos_class, gensym("osc~-help.pd"));
122}