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/snapshot~.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/snapshot~.c')
-rw-r--r-- | apps/plugins/pdbox/PDa/intern/snapshot~.c | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/apps/plugins/pdbox/PDa/intern/snapshot~.c b/apps/plugins/pdbox/PDa/intern/snapshot~.c new file mode 100644 index 0000000000..f63aeb76cd --- /dev/null +++ b/apps/plugins/pdbox/PDa/intern/snapshot~.c | |||
@@ -0,0 +1,114 @@ | |||
1 | #include <m_pd.h> | ||
2 | #include <m_fixed.h> | ||
3 | |||
4 | |||
5 | static t_class *snapshot_tilde_class; | ||
6 | |||
7 | typedef struct _snapshot | ||
8 | { | ||
9 | t_object x_obj; | ||
10 | t_sample x_value; | ||
11 | float x_f; | ||
12 | } t_snapshot; | ||
13 | |||
14 | static void *snapshot_tilde_new(void) | ||
15 | { | ||
16 | t_snapshot *x = (t_snapshot *)pd_new(snapshot_tilde_class); | ||
17 | x->x_value = 0; | ||
18 | outlet_new(&x->x_obj, &s_float); | ||
19 | x->x_f = 0; | ||
20 | return (x); | ||
21 | } | ||
22 | |||
23 | static t_int *snapshot_tilde_perform(t_int *w) | ||
24 | { | ||
25 | t_sample *in = (t_sample *)(w[1]); | ||
26 | t_sample *out = (t_sample *)(w[2]); | ||
27 | *out = *in; | ||
28 | return (w+3); | ||
29 | } | ||
30 | |||
31 | static void snapshot_tilde_dsp(t_snapshot *x, t_signal **sp) | ||
32 | { | ||
33 | dsp_add(snapshot_tilde_perform, 2, sp[0]->s_vec + (sp[0]->s_n-1), | ||
34 | &x->x_value); | ||
35 | } | ||
36 | |||
37 | static void snapshot_tilde_bang(t_snapshot *x) | ||
38 | { | ||
39 | outlet_float(x->x_obj.ob_outlet, fixtof(x->x_value)); | ||
40 | } | ||
41 | |||
42 | static void snapshot_tilde_set(t_snapshot *x, t_floatarg f) | ||
43 | { | ||
44 | x->x_value = ftofix(f); | ||
45 | } | ||
46 | |||
47 | void snapshot_tilde_setup(void) | ||
48 | { | ||
49 | snapshot_tilde_class = class_new(gensym("snapshot~"), snapshot_tilde_new, 0, | ||
50 | sizeof(t_snapshot), 0, 0); | ||
51 | CLASS_MAINSIGNALIN(snapshot_tilde_class, t_snapshot, x_f); | ||
52 | class_addmethod(snapshot_tilde_class, (t_method)snapshot_tilde_dsp, | ||
53 | gensym("dsp"), 0); | ||
54 | class_addmethod(snapshot_tilde_class, (t_method)snapshot_tilde_set, | ||
55 | gensym("set"), A_DEFFLOAT, 0); | ||
56 | class_addbang(snapshot_tilde_class, snapshot_tilde_bang); | ||
57 | } | ||
58 | #include <m_pd.h> | ||
59 | #include <m_fixed.h> | ||
60 | |||
61 | |||
62 | static t_class *snapshot_tilde_class; | ||
63 | |||
64 | typedef struct _snapshot | ||
65 | { | ||
66 | t_object x_obj; | ||
67 | t_sample x_value; | ||
68 | float x_f; | ||
69 | } t_snapshot; | ||
70 | |||
71 | static void *snapshot_tilde_new(void) | ||
72 | { | ||
73 | t_snapshot *x = (t_snapshot *)pd_new(snapshot_tilde_class); | ||
74 | x->x_value = 0; | ||
75 | outlet_new(&x->x_obj, &s_float); | ||
76 | x->x_f = 0; | ||
77 | return (x); | ||
78 | } | ||
79 | |||
80 | static t_int *snapshot_tilde_perform(t_int *w) | ||
81 | { | ||
82 | t_sample *in = (t_sample *)(w[1]); | ||
83 | t_sample *out = (t_sample *)(w[2]); | ||
84 | *out = *in; | ||
85 | return (w+3); | ||
86 | } | ||
87 | |||
88 | static void snapshot_tilde_dsp(t_snapshot *x, t_signal **sp) | ||
89 | { | ||
90 | dsp_add(snapshot_tilde_perform, 2, sp[0]->s_vec + (sp[0]->s_n-1), | ||
91 | &x->x_value); | ||
92 | } | ||
93 | |||
94 | static void snapshot_tilde_bang(t_snapshot *x) | ||
95 | { | ||
96 | outlet_float(x->x_obj.ob_outlet, fixtof(x->x_value)); | ||
97 | } | ||
98 | |||
99 | static void snapshot_tilde_set(t_snapshot *x, t_floatarg f) | ||
100 | { | ||
101 | x->x_value = ftofix(f); | ||
102 | } | ||
103 | |||
104 | void snapshot_tilde_setup(void) | ||
105 | { | ||
106 | snapshot_tilde_class = class_new(gensym("snapshot~"), snapshot_tilde_new, 0, | ||
107 | sizeof(t_snapshot), 0, 0); | ||
108 | CLASS_MAINSIGNALIN(snapshot_tilde_class, t_snapshot, x_f); | ||
109 | class_addmethod(snapshot_tilde_class, (t_method)snapshot_tilde_dsp, | ||
110 | gensym("dsp"), 0); | ||
111 | class_addmethod(snapshot_tilde_class, (t_method)snapshot_tilde_set, | ||
112 | gensym("set"), A_DEFFLOAT, 0); | ||
113 | class_addbang(snapshot_tilde_class, snapshot_tilde_bang); | ||
114 | } | ||