summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/intern/phasor~.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/pdbox/PDa/intern/phasor~.c')
-rw-r--r--apps/plugins/pdbox/PDa/intern/phasor~.c69
1 files changed, 0 insertions, 69 deletions
diff --git a/apps/plugins/pdbox/PDa/intern/phasor~.c b/apps/plugins/pdbox/PDa/intern/phasor~.c
index b823286b89..551d7b08f9 100644
--- a/apps/plugins/pdbox/PDa/intern/phasor~.c
+++ b/apps/plugins/pdbox/PDa/intern/phasor~.c
@@ -67,72 +67,3 @@ void phasor_tilde_setup(void)
67 class_sethelpsymbol(phasor_class, gensym("osc~-help.pd")); 67 class_sethelpsymbol(phasor_class, gensym("osc~-help.pd"));
68} 68}
69 69
70
71#include <m_pd.h>
72#include <m_fixed.h>
73
74/* -------------------------- phasor~ ------------------------------ */
75static t_class *phasor_class;
76
77typedef struct _phasor
78{
79 t_object x_obj;
80 unsigned int x_phase;
81 t_sample x_conv;
82 t_sample x_f; /* scalar frequency */
83} t_phasor;
84
85static void *phasor_new(t_floatarg f)
86{
87 t_phasor *x = (t_phasor *)pd_new(phasor_class);
88 x->x_f = ftofix(f);
89 inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1"));
90 x->x_phase = 0;
91 x->x_conv = 0;
92 outlet_new(&x->x_obj, gensym("signal"));
93 return (x);
94}
95
96static t_int *phasor_perform(t_int *w)
97{
98 t_phasor *x = (t_phasor *)(w[1]);
99 t_sample *in = (t_sample *)(w[2]);
100 t_sample *out = (t_sample *)(w[3]);
101 int n = (int)(w[4]);
102 unsigned int phase = x->x_phase;
103 int conv = x->x_conv;
104
105 while (n--) {
106 phase+= mult(conv , (*in++));
107 phase &= (itofix(1) - 1);
108 *out++ = phase;
109 }
110 x->x_phase = phase;
111
112 return (w+5);
113}
114
115static void phasor_dsp(t_phasor *x, t_signal **sp)
116{
117 x->x_conv = ftofix(1000.)/sp[0]->s_sr;
118 x->x_conv = mult(x->x_conv + 500,ftofix(0.001));
119 dsp_add(phasor_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
120}
121
122
123static void phasor_ft1(t_phasor *x, t_float f)
124{
125 x->x_phase = ftofix(f);
126}
127
128void phasor_tilde_setup(void)
129{
130 phasor_class = class_new(gensym("phasor~"), (t_newmethod)phasor_new, 0,
131 sizeof(t_phasor), 0, A_DEFFLOAT, 0);
132 CLASS_MAINSIGNALIN(phasor_class, t_phasor, x_f);
133 class_addmethod(phasor_class, (t_method)phasor_dsp, gensym("dsp"), 0);
134 class_addmethod(phasor_class, (t_method)phasor_ft1,
135 gensym("ft1"), A_FLOAT, 0);
136 class_sethelpsymbol(phasor_class, gensym("osc~-help.pd"));
137}
138