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