1 #include "../src/m_pd.h"
2 #include <../src/m_fixed.h>
5 static t_class
*noise_class
;
13 static void *noise_new(void)
15 t_noise
*x
= (t_noise
*)pd_new(noise_class
);
16 static int init
= 307;
17 x
->x_val
= (init
*= 1319);
18 outlet_new(&x
->x_obj
, gensym("signal"));
22 static t_int
*noise_perform(t_int
*w
)
24 t_sample
*out
= (t_sample
*)(w
[1]);
25 int *vp
= (int *)(w
[2]);
31 *out
++ = ((t_sample
)((val
& 0x7fffffff) - 0x40000000)) *
32 (t_sample
)(1.0 / 0x40000000);
34 *out
++=val
>>(32-fix1
);
36 val
= val
* 435898247 + 382842987;
43 static void noise_dsp(t_noise
*x
, t_signal
**sp
)
45 dsp_add(noise_perform
, 3, sp
[0]->s_vec
, &x
->x_val
, sp
[0]->s_n
);
48 void noise_tilde_setup(void)
50 noise_class
= class_new(gensym("noise~"), (t_newmethod
)noise_new
, 0,
51 sizeof(t_noise
), 0, 0);
52 class_addmethod(noise_class
, (t_method
)noise_dsp
, gensym("dsp"), 0);