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