diff options
author | Peter D'Hoye <peter.dhoye@gmail.com> | 2009-05-22 21:58:48 +0000 |
---|---|---|
committer | Peter D'Hoye <peter.dhoye@gmail.com> | 2009-05-22 21:58:48 +0000 |
commit | 513389b4c1bc8afe4b2dc9947c534bfeb105e3da (patch) | |
tree | 10e673b35651ac567fed2eda0c679c7ade64cbc6 /apps/plugins/pdbox/PDa/extra/zerox~.c | |
parent | 95fa7f6a2ef466444fbe3fe87efc6d5db6b77b36 (diff) | |
download | rockbox-513389b4c1bc8afe4b2dc9947c534bfeb105e3da.tar.gz rockbox-513389b4c1bc8afe4b2dc9947c534bfeb105e3da.zip |
Add FS #10214. Initial commit of the original PDa code for the GSoC Pure Data plugin project of Wincent Balin. Stripped some non-sourcefiles and added a rockbox readme that needs a bit more info from Wincent. Is added to CATEGORIES and viewers, but not yet to SUBDIRS (ie doesn't build yet)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21044 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/pdbox/PDa/extra/zerox~.c')
-rw-r--r-- | apps/plugins/pdbox/PDa/extra/zerox~.c | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/apps/plugins/pdbox/PDa/extra/zerox~.c b/apps/plugins/pdbox/PDa/extra/zerox~.c new file mode 100644 index 0000000000..f97f412308 --- /dev/null +++ b/apps/plugins/pdbox/PDa/extra/zerox~.c | |||
@@ -0,0 +1,114 @@ | |||
1 | #include "m_pd.h" | ||
2 | |||
3 | static t_class *zerox_class; | ||
4 | |||
5 | typedef struct _zerox | ||
6 | { | ||
7 | t_object x_obj; | ||
8 | t_sample x_f; | ||
9 | t_int x_zeros; | ||
10 | } t_zerox; | ||
11 | |||
12 | |||
13 | static t_int *zerox_perform(t_int *w) | ||
14 | { | ||
15 | t_zerox* x = (t_zerox*)w[1]; | ||
16 | t_sample *in = (t_sample *)(w[2]); | ||
17 | int n = (int)(w[3]) ; | ||
18 | |||
19 | if (*in * x->x_f < 0) x->x_zeros++; | ||
20 | n--; | ||
21 | while (n--) | ||
22 | { | ||
23 | float f = *(in++); | ||
24 | x->x_zeros += f * *in < 0; | ||
25 | } | ||
26 | return (w+4); | ||
27 | } | ||
28 | |||
29 | static void zerox_dsp(t_zerox *x, t_signal **sp) | ||
30 | { | ||
31 | dsp_add(zerox_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); | ||
32 | } | ||
33 | |||
34 | |||
35 | static void zerox_bang(t_zerox* x) | ||
36 | { | ||
37 | outlet_float(x->x_obj.ob_outlet,x->x_zeros); | ||
38 | x->x_zeros=0; | ||
39 | } | ||
40 | |||
41 | static void *zerox_new(void) | ||
42 | { | ||
43 | t_zerox *x = (t_zerox *)pd_new(zerox_class); | ||
44 | outlet_new(&x->x_obj, gensym("float")); | ||
45 | x->x_f = 0; | ||
46 | x->x_zeros=0; | ||
47 | return (x); | ||
48 | } | ||
49 | |||
50 | void zerox_tilde_setup(void) | ||
51 | { | ||
52 | zerox_class = class_new(gensym("zerox~"), (t_newmethod)zerox_new, 0, | ||
53 | sizeof(t_zerox), 0, A_DEFFLOAT, 0); | ||
54 | CLASS_MAINSIGNALIN(zerox_class, t_zerox, x_f); | ||
55 | class_addmethod(zerox_class, (t_method)zerox_dsp, gensym("dsp"), 0); | ||
56 | class_addbang(zerox_class, (t_method)zerox_bang); | ||
57 | } | ||
58 | #include "m_pd.h" | ||
59 | |||
60 | static t_class *zerox_class; | ||
61 | |||
62 | typedef struct _zerox | ||
63 | { | ||
64 | t_object x_obj; | ||
65 | t_sample x_f; | ||
66 | t_int x_zeros; | ||
67 | } t_zerox; | ||
68 | |||
69 | |||
70 | static t_int *zerox_perform(t_int *w) | ||
71 | { | ||
72 | t_zerox* x = (t_zerox*)w[1]; | ||
73 | t_sample *in = (t_sample *)(w[2]); | ||
74 | int n = (int)(w[3]) ; | ||
75 | |||
76 | if (*in * x->x_f < 0) x->x_zeros++; | ||
77 | n--; | ||
78 | while (n--) | ||
79 | { | ||
80 | float f = *(in++); | ||
81 | x->x_zeros += f * *in < 0; | ||
82 | } | ||
83 | return (w+4); | ||
84 | } | ||
85 | |||
86 | static void zerox_dsp(t_zerox *x, t_signal **sp) | ||
87 | { | ||
88 | dsp_add(zerox_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); | ||
89 | } | ||
90 | |||
91 | |||
92 | static void zerox_bang(t_zerox* x) | ||
93 | { | ||
94 | outlet_float(x->x_obj.ob_outlet,x->x_zeros); | ||
95 | x->x_zeros=0; | ||
96 | } | ||
97 | |||
98 | static void *zerox_new(void) | ||
99 | { | ||
100 | t_zerox *x = (t_zerox *)pd_new(zerox_class); | ||
101 | outlet_new(&x->x_obj, gensym("float")); | ||
102 | x->x_f = 0; | ||
103 | x->x_zeros=0; | ||
104 | return (x); | ||
105 | } | ||
106 | |||
107 | void zerox_tilde_setup(void) | ||
108 | { | ||
109 | zerox_class = class_new(gensym("zerox~"), (t_newmethod)zerox_new, 0, | ||
110 | sizeof(t_zerox), 0, A_DEFFLOAT, 0); | ||
111 | CLASS_MAINSIGNALIN(zerox_class, t_zerox, x_f); | ||
112 | class_addmethod(zerox_class, (t_method)zerox_dsp, gensym("dsp"), 0); | ||
113 | class_addbang(zerox_class, (t_method)zerox_bang); | ||
114 | } | ||