diff options
Diffstat (limited to 'apps/plugins/pdbox/PDa/intern/mtof~.c')
-rw-r--r-- | apps/plugins/pdbox/PDa/intern/mtof~.c | 98 |
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 | |||
4 | typedef struct mtof_tilde | ||
5 | { | ||
6 | t_object x_obj; | ||
7 | float x_f; | ||
8 | } t_mtof_tilde; | ||
9 | |||
10 | t_class *mtof_tilde_class; | ||
11 | |||
12 | static 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 | |||
20 | static 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 | |||
37 | static 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 | |||
43 | void 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 | |||
53 | typedef struct mtof_tilde | ||
54 | { | ||
55 | t_object x_obj; | ||
56 | float x_f; | ||
57 | } t_mtof_tilde; | ||
58 | |||
59 | t_class *mtof_tilde_class; | ||
60 | |||
61 | static 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 | |||
69 | static 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 | |||
86 | static 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 | |||
92 | void 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 | } | ||