3 #include "../../pdbox.h"
6 #include "../src/m_pd.h"
7 #include <../src/m_fixed.h>
9 #define LOGTEN 2.302585092994
12 typedef struct powtodb_tilde
18 t_class
*powtodb_tilde_class
;
20 static void *powtodb_tilde_new(void)
22 t_powtodb_tilde
*x
= (t_powtodb_tilde
*)pd_new(powtodb_tilde_class
);
23 outlet_new(&x
->x_obj
, gensym("signal"));
28 static t_int
*powtodb_tilde_perform(t_int
*w
)
30 t_sample
*in
= *(t_sample
**)(w
+1), *out
= *(t_sample
**)(w
+2);
31 t_int n
= *(t_int
*)(w
+3);
32 for (; n
--; in
++, out
++)
38 float g
= 100 + 10./LOGTEN
* log(f
);
39 *out
= (g
< 0 ? 0 : g
);
45 static void powtodb_tilde_dsp(t_powtodb_tilde
*x
, t_signal
**sp
)
50 post("warning: %s not usable yet",__FUNCTION__
);
51 dsp_add(powtodb_tilde_perform
, 3, sp
[0]->s_vec
, sp
[1]->s_vec
, sp
[0]->s_n
);
54 void powtodb_tilde_setup(void)
56 powtodb_tilde_class
= class_new(gensym("powtodb~"), (t_newmethod
)powtodb_tilde_new
, 0,
57 sizeof(t_powtodb_tilde
), 0, 0);
58 CLASS_MAINSIGNALIN(powtodb_tilde_class
, t_powtodb_tilde
, x_f
);
59 class_addmethod(powtodb_tilde_class
, (t_method
)powtodb_tilde_dsp
, gensym("dsp"), 0);