aboutsummaryrefslogtreecommitdiff
path: root/vrmstodb.c
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2010-02-10 00:34:05 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2010-02-10 00:34:05 +0000
commit086e6b358ad45bda0e6a948cfb7ea2d33ab7da5a (patch)
treeb87b0adfbfd8f9b9439d8bf528b63b64f23dce03 /vrmstodb.c
parent98e3e1214cf71a62b2de938c9c7e07f6bdd0090c (diff)
re-arranged into libdir and setup with the template Makefile+debian stuff. renabled vv+ and vv- as vvplus and vvminus
svn path=/trunk/externals/smlib/; revision=13158
Diffstat (limited to 'vrmstodb.c')
-rw-r--r--vrmstodb.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/vrmstodb.c b/vrmstodb.c
new file mode 100644
index 0000000..d375bf9
--- /dev/null
+++ b/vrmstodb.c
@@ -0,0 +1,54 @@
+#include "defines.h"
+
+/*--------------- vrmstodb ----------------*/
+
+static t_class *vrmstodb_class;
+
+typedef struct _vrmstodb
+{
+ t_object x_obj;
+} t_vrmstodb;
+
+float rmstodb(float f)
+{
+ if (f <= 0) return (0);
+ else
+ {
+ float val = (float)(100 + 20./LOGTEN * log(f));
+ return (val < 0 ? 0 : val);
+ }
+}
+
+static void vrmstodb_perform(t_vrmstodb *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i;
+ t_atom *ap,*app;
+ ap = (t_atom *)getbytes(sizeof(t_atom)*argc);
+ app=ap;
+
+ for (i = 0; i < argc; i++)
+ {
+ SETFLOAT(app, rmstodb(atom_getfloat(argv++)));
+ app++;
+ }
+ outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap);
+ freebytes(ap,argc);
+}
+
+static void *vrmstodb_new()
+{
+ t_vrmstodb *x=(t_vrmstodb *)pd_new(vrmstodb_class);
+ outlet_new(&x->x_obj, gensym("list"));
+ return (void *)x;
+}
+
+void vrmstodb_setup(void)
+{
+ vrmstodb_class = class_new(gensym("vrmstodb"),
+ (t_newmethod)vrmstodb_new, 0,
+ sizeof(t_vrmstodb),
+ CLASS_DEFAULT,
+ 0);
+ class_addlist(vrmstodb_class, (t_method)vrmstodb_perform);
+}
+