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