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