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/intern/wrap~.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/intern/wrap~.c')
-rw-r--r-- | apps/plugins/pdbox/PDa/intern/wrap~.c | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/apps/plugins/pdbox/PDa/intern/wrap~.c b/apps/plugins/pdbox/PDa/intern/wrap~.c new file mode 100644 index 0000000000..dda79f2fcd --- /dev/null +++ b/apps/plugins/pdbox/PDa/intern/wrap~.c | |||
@@ -0,0 +1,104 @@ | |||
1 | |||
2 | #include <m_pd.h> | ||
3 | #include <m_fixed.h> | ||
4 | |||
5 | typedef struct wrap | ||
6 | { | ||
7 | t_object x_obj; | ||
8 | float x_f; | ||
9 | } t_sigwrap; | ||
10 | |||
11 | t_class *sigwrap_class; | ||
12 | |||
13 | static void *sigwrap_new(void) | ||
14 | { | ||
15 | t_sigwrap *x = (t_sigwrap *)pd_new(sigwrap_class); | ||
16 | outlet_new(&x->x_obj, gensym("signal")); | ||
17 | x->x_f = 0; | ||
18 | return (x); | ||
19 | } | ||
20 | |||
21 | static t_int *sigwrap_perform(t_int *w) | ||
22 | { | ||
23 | t_sample *in = *(t_sample **)(w+1), *out = *(t_sample **)(w+2); | ||
24 | t_int n = *(t_int *)(w+3); | ||
25 | while (n--) | ||
26 | { | ||
27 | t_sample f = *in++; | ||
28 | |||
29 | #ifndef FIXEDPOINT | ||
30 | int k = f; | ||
31 | if (f > 0) *out++ = f-k; | ||
32 | else *out++ = f - (k-1); | ||
33 | #else | ||
34 | int k = ftofix(1.) - 1; | ||
35 | *out = f&k; | ||
36 | #endif | ||
37 | } | ||
38 | return (w + 4); | ||
39 | } | ||
40 | |||
41 | static void sigwrap_dsp(t_sigwrap *x, t_signal **sp) | ||
42 | { | ||
43 | dsp_add(sigwrap_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); | ||
44 | } | ||
45 | |||
46 | void wrap_tilde_setup(void) | ||
47 | { | ||
48 | sigwrap_class = class_new(gensym("wrap~"), (t_newmethod)sigwrap_new, 0, | ||
49 | sizeof(t_sigwrap), 0, 0); | ||
50 | CLASS_MAINSIGNALIN(sigwrap_class, t_sigwrap, x_f); | ||
51 | class_addmethod(sigwrap_class, (t_method)sigwrap_dsp, gensym("dsp"), 0); | ||
52 | } | ||
53 | |||
54 | #include <m_pd.h> | ||
55 | #include <m_fixed.h> | ||
56 | |||
57 | typedef struct wrap | ||
58 | { | ||
59 | t_object x_obj; | ||
60 | float x_f; | ||
61 | } t_sigwrap; | ||
62 | |||
63 | t_class *sigwrap_class; | ||
64 | |||
65 | static void *sigwrap_new(void) | ||
66 | { | ||
67 | t_sigwrap *x = (t_sigwrap *)pd_new(sigwrap_class); | ||
68 | outlet_new(&x->x_obj, gensym("signal")); | ||
69 | x->x_f = 0; | ||
70 | return (x); | ||
71 | } | ||
72 | |||
73 | static t_int *sigwrap_perform(t_int *w) | ||
74 | { | ||
75 | t_sample *in = *(t_sample **)(w+1), *out = *(t_sample **)(w+2); | ||
76 | t_int n = *(t_int *)(w+3); | ||
77 | while (n--) | ||
78 | { | ||
79 | t_sample f = *in++; | ||
80 | |||
81 | #ifndef FIXEDPOINT | ||
82 | int k = f; | ||
83 | if (f > 0) *out++ = f-k; | ||
84 | else *out++ = f - (k-1); | ||
85 | #else | ||
86 | int k = ftofix(1.) - 1; | ||
87 | *out = f&k; | ||
88 | #endif | ||
89 | } | ||
90 | return (w + 4); | ||
91 | } | ||
92 | |||
93 | static void sigwrap_dsp(t_sigwrap *x, t_signal **sp) | ||
94 | { | ||
95 | dsp_add(sigwrap_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); | ||
96 | } | ||
97 | |||
98 | void wrap_tilde_setup(void) | ||
99 | { | ||
100 | sigwrap_class = class_new(gensym("wrap~"), (t_newmethod)sigwrap_new, 0, | ||
101 | sizeof(t_sigwrap), 0, 0); | ||
102 | CLASS_MAINSIGNALIN(sigwrap_class, t_sigwrap, x_f); | ||
103 | class_addmethod(sigwrap_class, (t_method)sigwrap_dsp, gensym("dsp"), 0); | ||
104 | } | ||