Add FS #10214. Initial commit of the original PDa code for the GSoC Pure Data plugin...
[kugel-rb.git] / apps / plugins / pdbox / PDa / intern / dbtorms~.c
blob9d45a076ebc962e04311c706d889eb955e6efe54
1 #include <m_pd.h>
2 #include <m_fixed.h>
5 #define LOGTEN 2.302585092994
7 typedef struct dbtorms_tilde
9 t_object x_obj;
10 float x_f;
11 } t_dbtorms_tilde;
13 t_class *dbtorms_tilde_class;
15 static void *dbtorms_tilde_new(void)
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);
23 static t_int *dbtorms_tilde_perform(t_int *w)
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++)
29 float f = *in;
30 if (f <= 0) *out = 0;
31 else
33 if (f > 485)
34 f = 485;
35 *out = exp((LOGTEN * 0.05) * (f-100.));
38 return (w + 4);
41 static void dbtorms_tilde_dsp(t_dbtorms_tilde *x, t_signal **sp)
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);
47 void dbtorms_tilde_setup(void)
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);
54 #include <m_pd.h>
55 #include <m_fixed.h>
58 #define LOGTEN 2.302585092994
60 typedef struct dbtorms_tilde
62 t_object x_obj;
63 float x_f;
64 } t_dbtorms_tilde;
66 t_class *dbtorms_tilde_class;
68 static void *dbtorms_tilde_new(void)
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);
76 static t_int *dbtorms_tilde_perform(t_int *w)
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++)
82 float f = *in;
83 if (f <= 0) *out = 0;
84 else
86 if (f > 485)
87 f = 485;
88 *out = exp((LOGTEN * 0.05) * (f-100.));
91 return (w + 4);
94 static void dbtorms_tilde_dsp(t_dbtorms_tilde *x, t_signal **sp)
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);
100 void dbtorms_tilde_setup(void)
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);