aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormusil <tmusil@users.sourceforge.net>2011-11-16 15:49:28 +0000
committermusil <tmusil@users.sourceforge.net>2011-11-16 15:49:28 +0000
commit4886f9b6c59a303f468cf7e9adddaf8e1bedc317 (patch)
tree2be838dd1529d5a1a807eee5e9389e545645dc14
parent515814ab052cb9dc25466db5ef5d18e2dd5baef3 (diff)
4 new objects
svn path=/trunk/externals/iem/iem_tab/; revision=15766
-rw-r--r--src/iem_tab.c14
-rw-r--r--src/tab_dbtopow.c185
-rw-r--r--src/tab_dbtorms.c185
-rw-r--r--src/tab_powtodb.c184
-rw-r--r--src/tab_rmstodb.c184
5 files changed, 748 insertions, 4 deletions
diff --git a/src/iem_tab.c b/src/iem_tab.c
index 9ea084b..479ed55 100644
--- a/src/iem_tab.c
+++ b/src/iem_tab.c
@@ -1,7 +1,7 @@
/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
-iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2009 */
+iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2011 */
#include "m_pd.h"
#include "iemlib.h"
@@ -56,6 +56,8 @@ void tab_conv_setup(void);
void tab_copy_setup(void);
void tab_counter_setup(void);
void tab_cross_corr_setup(void);
+void tab_dbtopow_setup(void);
+void tab_dbtorms_setup(void);
void tab_div_setup(void);
void tab_eq_setup(void);
void tab_eq_scalar_setup(void);
@@ -75,14 +77,15 @@ void tab_lt_scalar_setup(void);
void tab_max_index_setup(void);
void tab_min_index_setup(void);
void tab_min_max_setup(void);
-//void tab_mls_setup(void);
void tab_mul_setup(void);
void tab_mul_scalar_setup(void);
void tab_ne_setup(void);
void tab_ne_scalar_setup(void);
+void tab_powtodb_setup(void);
void tab_reverse_setup(void);
void tab_rfft_setup(void);
void tab_rifft_setup(void);
+void tab_rmstodb_setup(void);
void tab_sqrt_setup(void);
void tab_sub_setup(void);
void tab_sum_setup(void);
@@ -105,6 +108,8 @@ void iem_tab_setup(void)
tab_copy_setup();
tab_counter_setup();
tab_cross_corr_setup();
+ tab_dbtopow_setup();
+ tab_dbtorms_setup();
tab_div_setup();
tab_eq_setup();
tab_eq_scalar_setup();
@@ -124,19 +129,20 @@ void iem_tab_setup(void)
tab_max_index_setup();
tab_min_index_setup();
tab_min_max_setup();
- // tab_mls_setup();
tab_mul_setup();
tab_mul_scalar_setup();
tab_ne_setup();
tab_ne_scalar_setup();
+ tab_powtodb_setup();
tab_reverse_setup();
tab_rfft_setup();
tab_rifft_setup();
+ tab_rmstodb_setup();
tab_sqrt_setup();
tab_sub_setup();
tab_sum_setup();
- post("iem_tab (R-1.18) library loaded! (c) Thomas Musil 01.2009");
+ post("iem_tab (R-1.20) library loaded! (c) Thomas Musil 11.2011");
post(" musil%ciem.at iem KUG Graz Austria", '@');
}
diff --git a/src/tab_dbtopow.c b/src/tab_dbtopow.c
new file mode 100644
index 0000000..efcdbdb
--- /dev/null
+++ b/src/tab_dbtopow.c
@@ -0,0 +1,185 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2010 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include "iem_tab.h"
+#include <math.h>
+
+#define IEMTABLOGTEN 2.302585092994046
+
+/* -------------------------- tab_dbtopow ------------------------------ */
+
+
+typedef struct _tab_dbtopow
+{
+ t_object x_obj;
+ int x_size_src1;
+ int x_size_dst;
+ int x_offset_src1;
+ int x_offset_dst;
+ iemarray_t *x_beg_mem_src1;
+ iemarray_t *x_beg_mem_dst;
+ t_symbol *x_sym_scr1;
+ t_symbol *x_sym_dst;
+} t_tab_dbtopow;
+
+static t_class *tab_dbtopow_class;
+
+static void tab_dbtopow_src(t_tab_dbtopow *x, t_symbol *s)
+{
+ x->x_sym_scr1 = s;
+}
+
+static void tab_dbtopow_dst(t_tab_dbtopow *x, t_symbol *s)
+{
+ x->x_sym_dst = s;
+}
+
+static void tab_dbtopow_bang(t_tab_dbtopow *x)
+{
+ int i, n;
+ int ok_src, ok_dst;
+ iemarray_t *vec_src, *vec_dst;
+
+ ok_src = iem_tab_check_arrays(gensym("tab_dbtopow"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
+ ok_dst = iem_tab_check_arrays(gensym("tab_dbtopow"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
+
+ if(ok_src && ok_dst)
+ {
+ if(x->x_size_src1 < x->x_size_dst)
+ n = x->x_size_src1;
+ else
+ n = x->x_size_dst;
+ vec_src = x->x_beg_mem_src1;
+ vec_dst = x->x_beg_mem_dst;
+ if(n)
+ {
+ t_garray *a;
+
+ for(i=0; i<n; i++)
+ {
+ t_float f = iemarray_getfloat(vec_src, i);
+
+ if(f <= 0.0)
+ iemarray_setfloat(vec_dst, i, 0.0);
+ else
+ {
+ if(f > 870.0)
+ f = 870.0;
+ iemarray_setfloat(vec_dst, i, exp((IEMTABLOGTEN * 0.1) * (f-100.0)));
+ }
+ }
+ outlet_bang(x->x_obj.ob_outlet);
+ a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
+ garray_redraw(a);
+ }
+ }
+}
+
+static void tab_dbtopow_list(t_tab_dbtopow *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int beg_src, beg_dst;
+ int i, n;
+ int ok_src, ok_dst;
+ iemarray_t *vec_src, *vec_dst;
+
+ if((argc >= 3) &&
+ IS_A_FLOAT(argv,0) &&
+ IS_A_FLOAT(argv,1) &&
+ IS_A_FLOAT(argv,2))
+ {
+ beg_src = (int)atom_getintarg(0, argc, argv);
+ beg_dst = (int)atom_getintarg(1, argc, argv);
+ n = (int)atom_getintarg(2, argc, argv);
+ if(beg_src < 0)
+ beg_src = 0;
+ if(beg_dst < 0)
+ beg_dst = 0;
+ if(n < 0)
+ n = 0;
+
+ ok_src = iem_tab_check_arrays(gensym("tab_dbtopow"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+n);
+ ok_dst = iem_tab_check_arrays(gensym("tab_dbtopow"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
+
+ if(ok_src && ok_dst)
+ {
+ vec_src = x->x_beg_mem_src1 + beg_src;
+ vec_dst = x->x_beg_mem_dst + beg_dst;
+ if(n)
+ {
+ t_garray *a;
+
+ for(i=0; i<n; i++)
+ {
+ t_float f = iemarray_getfloat(vec_src, i);
+
+ if(f <= 0.0)
+ iemarray_setfloat(vec_dst, i, 0.0);
+ else
+ {
+ if(f > 870.0)
+ f = 870.0;
+ iemarray_setfloat(vec_dst, i, exp((IEMTABLOGTEN * 0.1) * (f-100.0)));
+ }
+ }
+ outlet_bang(x->x_obj.ob_outlet);
+ a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
+ garray_redraw(a);
+ }
+ }
+ }
+ else
+ {
+ post("tab_dbtopow-ERROR: list need 3 float arguments:");
+ post(" source_offset + destination_offset + number_of_samples_to_dbtopow");
+ }
+}
+
+static void tab_dbtopow_free(t_tab_dbtopow *x)
+{
+}
+
+static void *tab_dbtopow_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_tab_dbtopow *x = (t_tab_dbtopow *)pd_new(tab_dbtopow_class);
+ t_symbol *src, *dst;
+
+ if((argc >= 2) &&
+ IS_A_SYMBOL(argv,0) &&
+ IS_A_SYMBOL(argv,1))
+ {
+ src = (t_symbol *)atom_getsymbolarg(0, argc, argv);
+ dst = (t_symbol *)atom_getsymbolarg(1, argc, argv);
+ }
+ else if((argc >= 1) &&
+ IS_A_SYMBOL(argv,0))
+ {
+ src = (t_symbol *)atom_getsymbolarg(0, argc, argv);
+ dst = src;
+ }
+ else
+ {
+ post("tab_dbtopow-ERROR: need 2 symbols arguments:");
+ post(" source_array_name + destination_array_name");
+ return(0);
+ }
+
+ x->x_sym_scr1 = src;
+ x->x_sym_dst = dst;
+ outlet_new(&x->x_obj, &s_bang);
+ return(x);
+}
+
+void tab_dbtopow_setup(void)
+{
+ tab_dbtopow_class = class_new(gensym("tab_dbtopow"), (t_newmethod)tab_dbtopow_new, (t_method)tab_dbtopow_free,
+ sizeof(t_tab_dbtopow), 0, A_GIMME, 0);
+ class_addbang(tab_dbtopow_class, (t_method)tab_dbtopow_bang);
+ class_addlist(tab_dbtopow_class, (t_method)tab_dbtopow_list);
+ class_addmethod(tab_dbtopow_class, (t_method)tab_dbtopow_src, gensym("src"), A_DEFSYMBOL, 0);
+ class_addmethod(tab_dbtopow_class, (t_method)tab_dbtopow_src, gensym("src1"), A_DEFSYMBOL, 0);
+ class_addmethod(tab_dbtopow_class, (t_method)tab_dbtopow_dst, gensym("dst"), A_DEFSYMBOL, 0);
+}
diff --git a/src/tab_dbtorms.c b/src/tab_dbtorms.c
new file mode 100644
index 0000000..87d2194
--- /dev/null
+++ b/src/tab_dbtorms.c
@@ -0,0 +1,185 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2010 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include "iem_tab.h"
+#include <math.h>
+
+#define IEMTABLOGTEN 2.302585092994046
+
+/* -------------------------- tab_dbtorms ------------------------------ */
+/* x_beg_mem_dst[i] = sqrt(x_beg_mem_src1[i]) */
+
+typedef struct _tab_dbtorms
+{
+ t_object x_obj;
+ int x_size_src1;
+ int x_size_dst;
+ int x_offset_src1;
+ int x_offset_dst;
+ iemarray_t *x_beg_mem_src1;
+ iemarray_t *x_beg_mem_dst;
+ t_symbol *x_sym_scr1;
+ t_symbol *x_sym_dst;
+} t_tab_dbtorms;
+
+static t_class *tab_dbtorms_class;
+
+static void tab_dbtorms_src(t_tab_dbtorms *x, t_symbol *s)
+{
+ x->x_sym_scr1 = s;
+}
+
+static void tab_dbtorms_dst(t_tab_dbtorms *x, t_symbol *s)
+{
+ x->x_sym_dst = s;
+}
+
+static void tab_dbtorms_bang(t_tab_dbtorms *x)
+{
+ int i, n;
+ int ok_src, ok_dst;
+ iemarray_t *vec_src, *vec_dst;
+
+ ok_src = iem_tab_check_arrays(gensym("tab_dbtorms"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
+ ok_dst = iem_tab_check_arrays(gensym("tab_dbtorms"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
+
+ if(ok_src && ok_dst)
+ {
+ if(x->x_size_src1 < x->x_size_dst)
+ n = x->x_size_src1;
+ else
+ n = x->x_size_dst;
+ vec_src = x->x_beg_mem_src1;
+ vec_dst = x->x_beg_mem_dst;
+ if(n)
+ {
+ t_garray *a;
+
+ for(i=0; i<n; i++)
+ {
+ t_float f = iemarray_getfloat(vec_src, i);
+
+ if(f <= 0.0)
+ iemarray_setfloat(vec_dst, i, 0.0);
+ else
+ {
+ if(f > 485.0)
+ f = 485.0;
+ iemarray_setfloat(vec_dst, i, exp((IEMTABLOGTEN * 0.05) * (f-100.0)));
+ }
+ }
+ outlet_bang(x->x_obj.ob_outlet);
+ a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
+ garray_redraw(a);
+ }
+ }
+}
+
+static void tab_dbtorms_list(t_tab_dbtorms *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int beg_src, beg_dst;
+ int i, n;
+ int ok_src, ok_dst;
+ iemarray_t *vec_src, *vec_dst;
+
+ if((argc >= 3) &&
+ IS_A_FLOAT(argv,0) &&
+ IS_A_FLOAT(argv,1) &&
+ IS_A_FLOAT(argv,2))
+ {
+ beg_src = (int)atom_getintarg(0, argc, argv);
+ beg_dst = (int)atom_getintarg(1, argc, argv);
+ n = (int)atom_getintarg(2, argc, argv);
+ if(beg_src < 0)
+ beg_src = 0;
+ if(beg_dst < 0)
+ beg_dst = 0;
+ if(n < 0)
+ n = 0;
+
+ ok_src = iem_tab_check_arrays(gensym("tab_dbtorms"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+n);
+ ok_dst = iem_tab_check_arrays(gensym("tab_dbtorms"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
+
+ if(ok_src && ok_dst)
+ {
+ vec_src = x->x_beg_mem_src1 + beg_src;
+ vec_dst = x->x_beg_mem_dst + beg_dst;
+ if(n)
+ {
+ t_garray *a;
+
+ for(i=0; i<n; i++)
+ {
+ t_float f = iemarray_getfloat(vec_src, i);
+
+ if(f <= 0.0)
+ iemarray_setfloat(vec_dst, i, 0.0);
+ else
+ {
+ if(f > 485.0)
+ f = 485.0;
+ iemarray_setfloat(vec_dst, i, exp((IEMTABLOGTEN * 0.05) * (f-100.0)));
+ }
+ }
+ outlet_bang(x->x_obj.ob_outlet);
+ a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
+ garray_redraw(a);
+ }
+ }
+ }
+ else
+ {
+ post("tab_dbtorms-ERROR: list need 3 float arguments:");
+ post(" source_offset + destination_offset + number_of_samples_to_dbtorms");
+ }
+}
+
+static void tab_dbtorms_free(t_tab_dbtorms *x)
+{
+}
+
+static void *tab_dbtorms_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_tab_dbtorms *x = (t_tab_dbtorms *)pd_new(tab_dbtorms_class);
+ t_symbol *src, *dst;
+
+ if((argc >= 2) &&
+ IS_A_SYMBOL(argv,0) &&
+ IS_A_SYMBOL(argv,1))
+ {
+ src = (t_symbol *)atom_getsymbolarg(0, argc, argv);
+ dst = (t_symbol *)atom_getsymbolarg(1, argc, argv);
+ }
+ else if((argc >= 1) &&
+ IS_A_SYMBOL(argv,0))
+ {
+ src = (t_symbol *)atom_getsymbolarg(0, argc, argv);
+ dst = src;
+ }
+ else
+ {
+ post("tab_dbtorms-ERROR: need 2 symbols arguments:");
+ post(" source_array_name + destination_array_name");
+ return(0);
+ }
+
+ x->x_sym_scr1 = src;
+ x->x_sym_dst = dst;
+ outlet_new(&x->x_obj, &s_bang);
+ return(x);
+}
+
+void tab_dbtorms_setup(void)
+{
+ tab_dbtorms_class = class_new(gensym("tab_dbtorms"), (t_newmethod)tab_dbtorms_new, (t_method)tab_dbtorms_free,
+ sizeof(t_tab_dbtorms), 0, A_GIMME, 0);
+ class_addbang(tab_dbtorms_class, (t_method)tab_dbtorms_bang);
+ class_addlist(tab_dbtorms_class, (t_method)tab_dbtorms_list);
+ class_addmethod(tab_dbtorms_class, (t_method)tab_dbtorms_src, gensym("src"), A_DEFSYMBOL, 0);
+ class_addmethod(tab_dbtorms_class, (t_method)tab_dbtorms_src, gensym("src1"), A_DEFSYMBOL, 0);
+ class_addmethod(tab_dbtorms_class, (t_method)tab_dbtorms_dst, gensym("dst"), A_DEFSYMBOL, 0);
+}
diff --git a/src/tab_powtodb.c b/src/tab_powtodb.c
new file mode 100644
index 0000000..a8fd638
--- /dev/null
+++ b/src/tab_powtodb.c
@@ -0,0 +1,184 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2010 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include "iem_tab.h"
+#include <math.h>
+
+#define IEMTABLOGTEN 2.302585092994046
+
+/* -------------------------- tab_powtodb ------------------------------ */
+/* x_beg_mem_dst[i] = sqrt(x_beg_mem_src1[i]) */
+
+typedef struct _tab_powtodb
+{
+ t_object x_obj;
+ int x_size_src1;
+ int x_size_dst;
+ int x_offset_src1;
+ int x_offset_dst;
+ iemarray_t *x_beg_mem_src1;
+ iemarray_t *x_beg_mem_dst;
+ t_symbol *x_sym_scr1;
+ t_symbol *x_sym_dst;
+} t_tab_powtodb;
+
+static t_class *tab_powtodb_class;
+
+static void tab_powtodb_src(t_tab_powtodb *x, t_symbol *s)
+{
+ x->x_sym_scr1 = s;
+}
+
+static void tab_powtodb_dst(t_tab_powtodb *x, t_symbol *s)
+{
+ x->x_sym_dst = s;
+}
+
+static void tab_powtodb_bang(t_tab_powtodb *x)
+{
+ int i, n;
+ int ok_src, ok_dst;
+ iemarray_t *vec_src, *vec_dst;
+
+ ok_src = iem_tab_check_arrays(gensym("tab_powtodb"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
+ ok_dst = iem_tab_check_arrays(gensym("tab_powtodb"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
+
+ if(ok_src && ok_dst)
+ {
+ if(x->x_size_src1 < x->x_size_dst)
+ n = x->x_size_src1;
+ else
+ n = x->x_size_dst;
+ vec_src = x->x_beg_mem_src1;
+ vec_dst = x->x_beg_mem_dst;
+ if(n)
+ {
+ t_garray *a;
+
+ for(i=0; i<n; i++)
+ {
+ t_float f = iemarray_getfloat(vec_src, i);
+
+ if(f <= 0.0)
+ iemarray_setfloat(vec_dst, i, 0.0);
+ else
+ {
+ t_float g = 100.0 + 10.0/IEMTABLOGTEN * log(f);
+
+ iemarray_setfloat(vec_dst, i, g < 0.0 ? 0.0 : g);
+ }
+ }
+ outlet_bang(x->x_obj.ob_outlet);
+ a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
+ garray_redraw(a);
+ }
+ }
+}
+
+static void tab_powtodb_list(t_tab_powtodb *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int beg_src, beg_dst;
+ int i, n;
+ int ok_src, ok_dst;
+ iemarray_t *vec_src, *vec_dst;
+
+ if((argc >= 3) &&
+ IS_A_FLOAT(argv,0) &&
+ IS_A_FLOAT(argv,1) &&
+ IS_A_FLOAT(argv,2))
+ {
+ beg_src = (int)atom_getintarg(0, argc, argv);
+ beg_dst = (int)atom_getintarg(1, argc, argv);
+ n = (int)atom_getintarg(2, argc, argv);
+ if(beg_src < 0)
+ beg_src = 0;
+ if(beg_dst < 0)
+ beg_dst = 0;
+ if(n < 0)
+ n = 0;
+
+ ok_src = iem_tab_check_arrays(gensym("tab_powtodb"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+n);
+ ok_dst = iem_tab_check_arrays(gensym("tab_powtodb"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
+
+ if(ok_src && ok_dst)
+ {
+ vec_src = x->x_beg_mem_src1 + beg_src;
+ vec_dst = x->x_beg_mem_dst + beg_dst;
+ if(n)
+ {
+ t_garray *a;
+
+ for(i=0; i<n; i++)
+ {
+ t_float f = iemarray_getfloat(vec_src, i);
+
+ if(f <= 0.0)
+ iemarray_setfloat(vec_dst, i, 0.0);
+ else
+ {
+ t_float g = 100.0 + 10.0/IEMTABLOGTEN * log(f);
+
+ iemarray_setfloat(vec_dst, i, g < 0.0 ? 0.0 : g);
+ }
+ } outlet_bang(x->x_obj.ob_outlet);
+ a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
+ garray_redraw(a);
+ }
+ }
+ }
+ else
+ {
+ post("tab_powtodb-ERROR: list need 3 float arguments:");
+ post(" source_offset + destination_offset + number_of_samples_to_sqrt");
+ }
+}
+
+static void tab_powtodb_free(t_tab_powtodb *x)
+{
+}
+
+static void *tab_powtodb_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_tab_powtodb *x = (t_tab_powtodb *)pd_new(tab_powtodb_class);
+ t_symbol *src, *dst;
+
+ if((argc >= 2) &&
+ IS_A_SYMBOL(argv,0) &&
+ IS_A_SYMBOL(argv,1))
+ {
+ src = (t_symbol *)atom_getsymbolarg(0, argc, argv);
+ dst = (t_symbol *)atom_getsymbolarg(1, argc, argv);
+ }
+ else if((argc >= 1) &&
+ IS_A_SYMBOL(argv,0))
+ {
+ src = (t_symbol *)atom_getsymbolarg(0, argc, argv);
+ dst = src;
+ }
+ else
+ {
+ post("tab_powtodb-ERROR: need 2 symbols arguments:");
+ post(" source_array_name + destination_array_name");
+ return(0);
+ }
+
+ x->x_sym_scr1 = src;
+ x->x_sym_dst = dst;
+ outlet_new(&x->x_obj, &s_bang);
+ return(x);
+}
+
+void tab_powtodb_setup(void)
+{
+ tab_powtodb_class = class_new(gensym("tab_powtodb"), (t_newmethod)tab_powtodb_new, (t_method)tab_powtodb_free,
+ sizeof(t_tab_powtodb), 0, A_GIMME, 0);
+ class_addbang(tab_powtodb_class, (t_method)tab_powtodb_bang);
+ class_addlist(tab_powtodb_class, (t_method)tab_powtodb_list);
+ class_addmethod(tab_powtodb_class, (t_method)tab_powtodb_src, gensym("src"), A_DEFSYMBOL, 0);
+ class_addmethod(tab_powtodb_class, (t_method)tab_powtodb_src, gensym("src1"), A_DEFSYMBOL, 0);
+ class_addmethod(tab_powtodb_class, (t_method)tab_powtodb_dst, gensym("dst"), A_DEFSYMBOL, 0);
+}
diff --git a/src/tab_rmstodb.c b/src/tab_rmstodb.c
new file mode 100644
index 0000000..ae45901
--- /dev/null
+++ b/src/tab_rmstodb.c
@@ -0,0 +1,184 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2010 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include "iem_tab.h"
+#include <math.h>
+
+#define IEMTABLOGTEN 2.302585092994046
+
+/* -------------------------- tab_rmstodb ------------------------------ */
+
+typedef struct _tab_rmstodb
+{
+ t_object x_obj;
+ int x_size_src1;
+ int x_size_dst;
+ int x_offset_src1;
+ int x_offset_dst;
+ iemarray_t *x_beg_mem_src1;
+ iemarray_t *x_beg_mem_dst;
+ t_symbol *x_sym_scr1;
+ t_symbol *x_sym_dst;
+} t_tab_rmstodb;
+
+static t_class *tab_rmstodb_class;
+
+static void tab_rmstodb_src(t_tab_rmstodb *x, t_symbol *s)
+{
+ x->x_sym_scr1 = s;
+}
+
+static void tab_rmstodb_dst(t_tab_rmstodb *x, t_symbol *s)
+{
+ x->x_sym_dst = s;
+}
+
+static void tab_rmstodb_bang(t_tab_rmstodb *x)
+{
+ int i, n;
+ int ok_src, ok_dst;
+ iemarray_t *vec_src, *vec_dst;
+
+ ok_src = iem_tab_check_arrays(gensym("tab_rmstodb"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
+ ok_dst = iem_tab_check_arrays(gensym("tab_rmstodb"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
+
+ if(ok_src && ok_dst)
+ {
+ if(x->x_size_src1 < x->x_size_dst)
+ n = x->x_size_src1;
+ else
+ n = x->x_size_dst;
+ vec_src = x->x_beg_mem_src1;
+ vec_dst = x->x_beg_mem_dst;
+ if(n)
+ {
+ t_garray *a;
+
+ for(i=0; i<n; i++)
+ {
+ t_float f = iemarray_getfloat(vec_src, i);
+
+ if(f <= 0.0)
+ iemarray_setfloat(vec_dst, i, 0.0);
+ else
+ {
+ t_float g = 100.0 + 20.0/IEMTABLOGTEN * log(f);
+
+ iemarray_setfloat(vec_dst, i, g < 0.0 ? 0.0 : g);
+ }
+ }
+ outlet_bang(x->x_obj.ob_outlet);
+ a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
+ garray_redraw(a);
+ }
+ }
+}
+
+static void tab_rmstodb_list(t_tab_rmstodb *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int beg_src, beg_dst;
+ int i, n;
+ int ok_src, ok_dst;
+ iemarray_t *vec_src, *vec_dst;
+
+ if((argc >= 3) &&
+ IS_A_FLOAT(argv,0) &&
+ IS_A_FLOAT(argv,1) &&
+ IS_A_FLOAT(argv,2))
+ {
+ beg_src = (int)atom_getintarg(0, argc, argv);
+ beg_dst = (int)atom_getintarg(1, argc, argv);
+ n = (int)atom_getintarg(2, argc, argv);
+ if(beg_src < 0)
+ beg_src = 0;
+ if(beg_dst < 0)
+ beg_dst = 0;
+ if(n < 0)
+ n = 0;
+
+ ok_src = iem_tab_check_arrays(gensym("tab_rmstodb"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+n);
+ ok_dst = iem_tab_check_arrays(gensym("tab_rmstodb"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
+
+ if(ok_src && ok_dst)
+ {
+ vec_src = x->x_beg_mem_src1 + beg_src;
+ vec_dst = x->x_beg_mem_dst + beg_dst;
+ if(n)
+ {
+ t_garray *a;
+
+ for(i=0; i<n; i++)
+ {
+ t_float f = iemarray_getfloat(vec_src, i);
+
+ if(f <= 0.0)
+ iemarray_setfloat(vec_dst, i, 0.0);
+ else
+ {
+ t_float g = 100.0 + 20.0/IEMTABLOGTEN * log(f);
+
+ iemarray_setfloat(vec_dst, i, g < 0.0 ? 0.0 : g);
+ }
+ }
+ outlet_bang(x->x_obj.ob_outlet);
+ a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
+ garray_redraw(a);
+ }
+ }
+ }
+ else
+ {
+ post("tab_rmstodb-ERROR: list need 3 float arguments:");
+ post(" source_offset + destination_offset + number_of_samples_to_rmstodb");
+ }
+}
+
+static void tab_rmstodb_free(t_tab_rmstodb *x)
+{
+}
+
+static void *tab_rmstodb_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_tab_rmstodb *x = (t_tab_rmstodb *)pd_new(tab_rmstodb_class);
+ t_symbol *src, *dst;
+
+ if((argc >= 2) &&
+ IS_A_SYMBOL(argv,0) &&
+ IS_A_SYMBOL(argv,1))
+ {
+ src = (t_symbol *)atom_getsymbolarg(0, argc, argv);
+ dst = (t_symbol *)atom_getsymbolarg(1, argc, argv);
+ }
+ else if((argc >= 1) &&
+ IS_A_SYMBOL(argv,0))
+ {
+ src = (t_symbol *)atom_getsymbolarg(0, argc, argv);
+ dst = src;
+ }
+ else
+ {
+ post("tab_rmstodb-ERROR: need 2 symbols arguments:");
+ post(" source_array_name + destination_array_name");
+ return(0);
+ }
+
+ x->x_sym_scr1 = src;
+ x->x_sym_dst = dst;
+ outlet_new(&x->x_obj, &s_bang);
+ return(x);
+}
+
+void tab_rmstodb_setup(void)
+{
+ tab_rmstodb_class = class_new(gensym("tab_rmstodb"), (t_newmethod)tab_rmstodb_new, (t_method)tab_rmstodb_free,
+ sizeof(t_tab_rmstodb), 0, A_GIMME, 0);
+ class_addbang(tab_rmstodb_class, (t_method)tab_rmstodb_bang);
+ class_addlist(tab_rmstodb_class, (t_method)tab_rmstodb_list);
+ class_addmethod(tab_rmstodb_class, (t_method)tab_rmstodb_src, gensym("src"), A_DEFSYMBOL, 0);
+ class_addmethod(tab_rmstodb_class, (t_method)tab_rmstodb_src, gensym("src1"), A_DEFSYMBOL, 0);
+ class_addmethod(tab_rmstodb_class, (t_method)tab_rmstodb_dst, gensym("dst"), A_DEFSYMBOL, 0);
+}