summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/intern/mtof~.c
diff options
context:
space:
mode:
authorPeter D'Hoye <peter.dhoye@gmail.com>2009-05-22 21:58:48 +0000
committerPeter D'Hoye <peter.dhoye@gmail.com>2009-05-22 21:58:48 +0000
commit513389b4c1bc8afe4b2dc9947c534bfeb105e3da (patch)
tree10e673b35651ac567fed2eda0c679c7ade64cbc6 /apps/plugins/pdbox/PDa/intern/mtof~.c
parent95fa7f6a2ef466444fbe3fe87efc6d5db6b77b36 (diff)
downloadrockbox-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/mtof~.c')
-rw-r--r--apps/plugins/pdbox/PDa/intern/mtof~.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/apps/plugins/pdbox/PDa/intern/mtof~.c b/apps/plugins/pdbox/PDa/intern/mtof~.c
new file mode 100644
index 0000000000..1db7dc52a7
--- /dev/null
+++ b/apps/plugins/pdbox/PDa/intern/mtof~.c
@@ -0,0 +1,98 @@
1#include <m_pd.h>
2#include <m_fixed.h>
3
4typedef struct mtof_tilde
5{
6 t_object x_obj;
7 float x_f;
8} t_mtof_tilde;
9
10t_class *mtof_tilde_class;
11
12static void *mtof_tilde_new(void)
13{
14 t_mtof_tilde *x = (t_mtof_tilde *)pd_new(mtof_tilde_class);
15 outlet_new(&x->x_obj, gensym("signal"));
16 x->x_f = 0;
17 return (x);
18}
19
20static t_int *mtof_tilde_perform(t_int *w)
21{
22 t_sample *in = *(t_sample **)(w+1), *out = *(t_sample **)(w+2);
23 t_int n = *(t_int *)(w+3);
24 for (; n--; in++, out++)
25 {
26 t_sample f = *in;
27 if (f <= ftofix(-1500.)) *out = 0;
28 else
29 {
30 if (f > ftofix(1499.)) f = ftofix(1499.);
31 *out = ftofix(8.17579891564 * exp(.0577622650 * fixtof(f)));
32 }
33 }
34 return (w + 4);
35}
36
37static void mtof_tilde_dsp(t_mtof_tilde *x, t_signal **sp)
38{
39 post("warning: %s not usable yet",__FUNCTION__);
40 dsp_add(mtof_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
41}
42
43void mtof_tilde_setup(void)
44{
45 mtof_tilde_class = class_new(gensym("mtof~"), (t_newmethod)mtof_tilde_new, 0,
46 sizeof(t_mtof_tilde), 0, 0);
47 CLASS_MAINSIGNALIN(mtof_tilde_class, t_mtof_tilde, x_f);
48 class_addmethod(mtof_tilde_class, (t_method)mtof_tilde_dsp, gensym("dsp"), 0);
49}
50#include <m_pd.h>
51#include <m_fixed.h>
52
53typedef struct mtof_tilde
54{
55 t_object x_obj;
56 float x_f;
57} t_mtof_tilde;
58
59t_class *mtof_tilde_class;
60
61static void *mtof_tilde_new(void)
62{
63 t_mtof_tilde *x = (t_mtof_tilde *)pd_new(mtof_tilde_class);
64 outlet_new(&x->x_obj, gensym("signal"));
65 x->x_f = 0;
66 return (x);
67}
68
69static t_int *mtof_tilde_perform(t_int *w)
70{
71 t_sample *in = *(t_sample **)(w+1), *out = *(t_sample **)(w+2);
72 t_int n = *(t_int *)(w+3);
73 for (; n--; in++, out++)
74 {
75 t_sample f = *in;
76 if (f <= ftofix(-1500.)) *out = 0;
77 else
78 {
79 if (f > ftofix(1499.)) f = ftofix(1499.);
80 *out = ftofix(8.17579891564 * exp(.0577622650 * fixtof(f)));
81 }
82 }
83 return (w + 4);
84}
85
86static void mtof_tilde_dsp(t_mtof_tilde *x, t_signal **sp)
87{
88 post("warning: %s not usable yet",__FUNCTION__);
89 dsp_add(mtof_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
90}
91
92void mtof_tilde_setup(void)
93{
94 mtof_tilde_class = class_new(gensym("mtof~"), (t_newmethod)mtof_tilde_new, 0,
95 sizeof(t_mtof_tilde), 0, 0);
96 CLASS_MAINSIGNALIN(mtof_tilde_class, t_mtof_tilde, x_f);
97 class_addmethod(mtof_tilde_class, (t_method)mtof_tilde_dsp, gensym("dsp"), 0);
98}