diff --git a/externals/iem/iem_tab/src/iemlib.h b/externals/iem/iem_tab/src/iemlib.h index 97b088bab37b67d9eb7487855d98c74ae29e6305..ac1ffced384955b34e5156eb8d45b9c18352bafe 100644 --- a/externals/iem/iem_tab/src/iemlib.h +++ b/externals/iem/iem_tab/src/iemlib.h @@ -1,12 +1,13 @@ /* For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. -iemlib written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2009 */ +iemlib written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2012 */ #ifndef __IEMLIB_H__ #define __IEMLIB_H__ +#define IS_A_NULL(atom,index) ((atom+index)->a_type == A_NULL) #define IS_A_POINTER(atom,index) ((atom+index)->a_type == A_POINTER) #define IS_A_FLOAT(atom,index) ((atom+index)->a_type == A_FLOAT) #define IS_A_SYMBOL(atom,index) ((atom+index)->a_type == A_SYMBOL) @@ -15,6 +16,8 @@ iemlib written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2009 * #define IS_A_SEMI(atom,index) ((atom+index)->a_type == A_SEMI) #define IS_A_COMMA(atom,index) ((atom+index)->a_type == A_COMMA) +#define SETNULL(atom) ((atom)->a_type = A_NULL) + /* now miller's code starts : for 4 point interpolation for lookup tables @@ -53,11 +56,11 @@ extern int sys_noloadbang; #define int32 long #endif /* MSW */ -#if defined(__FreeBSD__) || defined(__APPLE__) +#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__FreeBSD_kernel__) #include <machine/endian.h> #endif -#ifdef __linux__ +#if defined(__linux__) || defined(__CYGWIN__) || defined(__GNU__) || defined(ANDROID) #include <endian.h> #endif @@ -100,7 +103,7 @@ union tabfudge_f #endif /* on 64bit systems we cannot use garray_getfloatarray... */ -#if (defined __x86_64__) +#if ((defined PD_MAJOR_VERSION && defined PD_MINOR_VERSION) && (PD_MAJOR_VERSION > 0 || PD_MINOR_VERSION > 40)) # define iemarray_t t_word # define iemarray_getarray garray_getfloatwords # define iemarray_getfloat(pointer, index) (pointer[index].w_float) @@ -112,5 +115,4 @@ union tabfudge_f # define iemarray_setfloat(pointer, index, fvalue) (pointer[index] = fvalue) #endif - #endif diff --git a/externals/iem/iem_tab/src/makefile_d_ppc b/externals/iem/iem_tab/src/makefile_d_ppc index 22ef78baed35277ab6b3bad6414783f3d4c47b79..5579fb88ae75076753796016222257b0a4e9c0d8 100644 --- a/externals/iem/iem_tab/src/makefile_d_ppc +++ b/externals/iem/iem_tab/src/makefile_d_ppc @@ -24,6 +24,8 @@ SRC = tab_abs.c \ tab_copy.c \ tab_counter.c \ tab_cross_corr.c \ + tab_dbtopow.c \ + tab_dbtorms.c \ tab_div.c \ tab_eq.c \ tab_eq_scalar.c \ @@ -47,9 +49,11 @@ SRC = tab_abs.c \ tab_mul_scalar.c \ tab_ne.c \ tab_ne_scalar.c \ + tab_powtodb.c \ tab_reverse.c \ tab_rfft.c \ tab_rifft.c \ + tab_rmstodb.c \ tab_sqrt.c \ tab_sub.c \ tab_sum.c \ diff --git a/externals/iem/iem_tab/src/makefile_darwin b/externals/iem/iem_tab/src/makefile_darwin index 8ab9bebc2356ed361dbaf5ee3fd596e4dfdf3606..79dc3412880c5588c20fcab20394ba2dd7613517 100644 --- a/externals/iem/iem_tab/src/makefile_darwin +++ b/externals/iem/iem_tab/src/makefile_darwin @@ -29,6 +29,8 @@ SRC = tab_abs.c \ tab_copy.c \ tab_counter.c \ tab_cross_corr.c \ + tab_dbtopow.c \ + tab_dbtorms.c \ tab_div.c \ tab_eq.c \ tab_eq_scalar.c \ @@ -52,9 +54,11 @@ SRC = tab_abs.c \ tab_mul_scalar.c \ tab_ne.c \ tab_ne_scalar.c \ + tab_powtodb.c \ tab_reverse.c \ tab_rfft.c \ tab_rifft.c \ + tab_rmstodb.c \ tab_sqrt.c \ tab_sub.c \ tab_sum.c \ diff --git a/externals/iem/iem_tab/src/makefile_linux b/externals/iem/iem_tab/src/makefile_linux index 9a91e2947347f1e7c37e606b14efeccd38b2f2e7..61c7a11e2ff47d327b44f1db60d3c8b8fd467979 100644 --- a/externals/iem/iem_tab/src/makefile_linux +++ b/externals/iem/iem_tab/src/makefile_linux @@ -78,14 +78,14 @@ OBJ = $(SRC:.c=.o) # clean: - rm ../$(TARGET) - rm *.o + -rm ../$(TARGET) $(TARGET) + -rm *.o all: $(OBJ) @echo :: $(OBJ) $(LD) $(LDFLAGS) -o $(TARGET) *.o $(LIB) strip --strip-unneeded $(TARGET) - mv $(TARGET) .. + cp $(TARGET) .. $(OBJ) : %.o : %.c $(CC) $(CFLAGS) $(INCLUDE) -c -o $*.o $*.c diff --git a/externals/iem/iem_tab/src/makefile_vc9proj b/externals/iem/iem_tab/src/makefile_vc9proj index 2c44a2c5ad9b4f368ed028ceedc3fdf7861b6fa8..b12fc13b4507cca0afa780a895182e6a83760483 100644 --- a/externals/iem/iem_tab/src/makefile_vc9proj +++ b/externals/iem/iem_tab/src/makefile_vc9proj @@ -2,11 +2,11 @@ TARGET = iem_tab all: ..\$(TARGET).dll -VIS_CPP_PATH = "C:\Program Files\Microsoft Visual Studio 9.0\VC" -VIS_SDK_PATH = "C:\Program Files\Microsoft SDKs\Windows\v6.0A" -PD_INST_PATH = "C:\Program Files\pd-0.43.0" -PD_WIN_INCLUDE_PATH = /I. /I$(PD_INST_PATH)\src /I$(VIS_CPP_PATH)\include -PD_WIN_C_FLAGS = /nologo /W3 /WX /DMSW /DNT /DPD /DWIN32 /DWINDOWS /Ox -D_CRT_SECURE_NO_WARNINGS +VIS_CPP_PATH = "$(PROGRAMFILES)\Microsoft Visual Studio 9.0\VC" +VIS_SDK_PATH = "$(PROGRAMFILES)\Microsoft SDKs\Windows\v6.0A" +PD_INST_PATH = "$(PROGRAMFILES)\pd" +PD_WIN_INCLUDE_PATH = /I. /I..\..\include /I$(PD_INST_PATH)\src /I$(VIS_CPP_PATH)\include +PD_WIN_C_FLAGS = /nologo /W3 /WX /DMSW /DNT /DPD /DWIN32 /DWINDOWS /DHAVE_G_CANVAS_H /Ox -D_CRT_SECURE_NO_WARNINGS PD_WIN_L_FLAGS = /nologo PD_WIN_LIB = /NODEFAULTLIB:libcmt /NODEFAULTLIB:oldnames /NODEFAULTLIB:kernel32 \ @@ -26,6 +26,8 @@ SRC = tab_abs.c \ tab_copy.c \ tab_counter.c \ tab_cross_corr.c \ + tab_dbtorms.c \ + tab_dbtopow.c \ tab_div.c \ tab_eq.c \ tab_eq_scalar.c \ @@ -49,13 +51,16 @@ SRC = tab_abs.c \ tab_mul_scalar.c \ tab_ne.c \ tab_ne_scalar.c \ + tab_powtodb.c \ tab_reverse.c \ + tab_rmstodb.c \ tab_rfft.c \ tab_rifft.c \ tab_sqrt.c \ tab_sub.c \ tab_sum.c \ - iem_tab.c + $(TARGET).c + OBJ = $(SRC:.c=.obj) diff --git a/externals/iem/iem_tab/src/makefile_win b/externals/iem/iem_tab/src/makefile_win index 97fb9cdbb92b211cac9cb554609583bd2157e904..9686ad11c488a9be716c19f3b6fe15b171fdc156 100644 --- a/externals/iem/iem_tab/src/makefile_win +++ b/externals/iem/iem_tab/src/makefile_win @@ -31,6 +31,8 @@ SRC = tab_abs.c \ tab_copy.c \ tab_counter.c \ tab_cross_corr.c \ + tab_dbtopow.c \ + tab_dbtorms.c \ tab_div.c \ tab_eq.c \ tab_eq_scalar.c \ @@ -54,9 +56,11 @@ SRC = tab_abs.c \ tab_mul_scalar.c \ tab_ne.c \ tab_ne_scalar.c \ + tab_powtodb.c \ tab_reverse.c \ tab_rfft.c \ tab_rifft.c \ + tab_rmstodb.c \ tab_sqrt.c \ tab_sub.c \ tab_sum.c \ diff --git a/externals/iem/iem_tab/src/tab_carth2polar.c b/externals/iem/iem_tab/src/tab_carth2polar.c index 9dccd6863405579065db57d087fdbe2418527844..bc450fff30e914bb298d9f03292d5d7a64e98fb2 100644 --- a/externals/iem/iem_tab/src/tab_carth2polar.c +++ b/externals/iem/iem_tab/src/tab_carth2polar.c @@ -86,7 +86,7 @@ static void tab_carth2polar_bang(t_tab_carth2polar *x) if(n) { t_garray *a; - t_float rcp_two_pi=0.125f/atan(1.0); + t_float rcp_two_pi=0.125/atan(1.0); for(i=0; i<n; i++) { @@ -156,7 +156,7 @@ static void tab_carth2polar_list(t_tab_carth2polar *x, t_symbol *s, int argc, t_ if(n) { t_garray *a; - t_float rcp_two_pi=0.125f/atan(1.0); + t_float rcp_two_pi=0.125/atan(1.0); for(i=0; i<n; i++) { @@ -231,5 +231,4 @@ void tab_carth2polar_setup(void) class_addmethod(tab_carth2polar_class, (t_method)tab_carth2polar_src_im, gensym("src1_im"), A_DEFSYMBOL, 0); class_addmethod(tab_carth2polar_class, (t_method)tab_carth2polar_dst_mag, gensym("dst_mag"), A_DEFSYMBOL, 0); class_addmethod(tab_carth2polar_class, (t_method)tab_carth2polar_dst_arg, gensym("dst_arg"), A_DEFSYMBOL, 0); -// class_sethelpsymbol(tab_carth2polar_class, gensym("iemhelp2/help-tab_carth2polar")); } diff --git a/externals/iem/iem_tab/src/tab_complex_inv.c b/externals/iem/iem_tab/src/tab_complex_inv.c index 3b14af6214826de955d59a9836d8cfe9466e6696..f363d054d3637a60180095c5f3fb316794ab6b81 100644 --- a/externals/iem/iem_tab/src/tab_complex_inv.c +++ b/externals/iem/iem_tab/src/tab_complex_inv.c @@ -92,7 +92,7 @@ static void tab_complex_inv_bang(t_tab_complex_inv *x) re = iemarray_getfloat(vec_src1_re, i); im = iemarray_getfloat(vec_src1_im, i); - abs = 1.0f / (re*re + im*im); + abs = 1.0 / (re*re + im*im); iemarray_setfloat(vec_dst_re, i, re*abs); iemarray_setfloat(vec_dst_im, i, -im*abs); } @@ -160,7 +160,7 @@ static void tab_complex_inv_list(t_tab_complex_inv *x, t_symbol *s, int argc, t_ re = iemarray_getfloat(vec_src1_re, i); im = iemarray_getfloat(vec_src1_im, i); - abs = 1.0f / (re*re + im*im); + abs = 1.0 / (re*re + im*im); iemarray_setfloat(vec_dst_re, i, re*abs); iemarray_setfloat(vec_dst_im, i, -im*abs); } @@ -235,5 +235,4 @@ void tab_complex_inv_setup(void) class_addmethod(tab_complex_inv_class, (t_method)tab_complex_inv_src1_im, gensym("src1_im"), A_DEFSYMBOL, 0); class_addmethod(tab_complex_inv_class, (t_method)tab_complex_inv_src1_im, gensym("src_im"), A_DEFSYMBOL, 0); class_addmethod(tab_complex_inv_class, (t_method)tab_complex_inv_dst_im, gensym("dst_im"), A_DEFSYMBOL, 0); -// class_sethelpsymbol(tab_complex_inv_class, gensym("iemhelp2/tab_complex_inv-help")); } diff --git a/externals/iem/iem_tab/src/tab_const.c b/externals/iem/iem_tab/src/tab_const.c index 461f950ed8dba7b7aac95738963996e19b7b603a..7d846a328ee62bd29b41a0f782d8219a0b21b411 100644 --- a/externals/iem/iem_tab/src/tab_const.c +++ b/externals/iem/iem_tab/src/tab_const.c @@ -44,7 +44,7 @@ static void tab_const_bang(t_tab_const *x) t_garray *a; for(i=0; i<n; i++) - iemarray_setfloat(vec_dst, i, 0.0f); + iemarray_setfloat(vec_dst, i, 0.0); outlet_bang(x->x_obj.ob_outlet); a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class); garray_redraw(a); @@ -156,5 +156,4 @@ void tab_const_setup(void) class_addfloat(tab_const_class, (t_method)tab_const_float); class_addlist(tab_const_class, (t_method)tab_const_list); class_addmethod(tab_const_class, (t_method)tab_const_dst, gensym("dst"), A_DEFSYMBOL, 0); -// class_sethelpsymbol(tab_const_class, gensym("iemhelp2/tab_const-help")); } diff --git a/externals/iem/iem_tab/src/tab_conv.c b/externals/iem/iem_tab/src/tab_conv.c index 8352faa3d326ba5b729f52b8e0f61dac59852d55..164b766fed166eb2d5e128c122a5ac5be3ebc3f8 100644 --- a/externals/iem/iem_tab/src/tab_conv.c +++ b/externals/iem/iem_tab/src/tab_conv.c @@ -203,7 +203,7 @@ static void tab_conv_list(t_tab_conv *x, t_symbol *s, int argc, t_atom *argv) int i, j, k, l, m, n, p; int ok_src1, ok_src2, ok_dst; iemarray_t *vec_sig, *vec_ir, *vec_dst; - t_float sum=0.0f; + t_float sum=0.0; if((argc >= 5) && IS_A_FLOAT(argv,0) && @@ -257,7 +257,7 @@ static void tab_conv_list(t_tab_conv *x, t_symbol *s, int argc, t_atom *argv) l = m - 1; for(i=0; i<l; i++) { - sum = 0.0f; + sum = 0.0; for(j=0, k=i-1; j<i; j++, k--) sum += iemarray_getfloat(vec_sig, j) * iemarray_getfloat(vec_ir, k); iemarray_setfloat(vec_dst, 0, sum); @@ -268,7 +268,7 @@ static void tab_conv_list(t_tab_conv *x, t_symbol *s, int argc, t_atom *argv) l = n - m + 1; for(i=0; i<l; i++) { - sum = 0.0f; + sum = 0.0; for(j=0, k=m-1; j<m; j++, k--) sum += iemarray_getfloat(vec_sig, j) * iemarray_getfloat(vec_ir, k); iemarray_setfloat(vec_dst, 0, sum); @@ -279,7 +279,7 @@ static void tab_conv_list(t_tab_conv *x, t_symbol *s, int argc, t_atom *argv) l = m - 1; for(i=l-1; i>=0; i--) { - sum = 0.0f; + sum = 0.0; for(j=0, k=i-1; j<i; j++, k--) sum += iemarray_getfloat(vec_sig, j) * iemarray_getfloat(vec_ir, k); iemarray_setfloat(vec_dst, 0, sum); @@ -310,7 +310,7 @@ static void tab_conv_list(t_tab_conv *x, t_symbol *s, int argc, t_atom *argv) l = m - 1; for(i=0; i<l; i++) { - sum = 0.0f; + sum = 0.0; for(j=0, k=i-1; j<i; j++, k--) sum += iemarray_getfloat(vec_sig, j) * iemarray_getfloat(vec_ir, k); iemarray_setfloat(vec_dst, 0, sum); @@ -324,7 +324,7 @@ static void tab_conv_list(t_tab_conv *x, t_symbol *s, int argc, t_atom *argv) l = n - m + 1; for(i=0; i<l; i++) { - sum = 0.0f; + sum = 0.0; for(j=0, k=m-1; j<m; j++, k--) sum += iemarray_getfloat(vec_sig, j) * iemarray_getfloat(vec_ir, k); iemarray_setfloat(vec_dst, 0, sum); @@ -338,7 +338,7 @@ static void tab_conv_list(t_tab_conv *x, t_symbol *s, int argc, t_atom *argv) l = m - 1; for(i=l-1; i>=0; i--) { - sum = 0.0f; + sum = 0.0; for(j=0, k=i-1; j<i; j++, k--) sum += iemarray_getfloat(vec_sig, j) * iemarray_getfloat(vec_ir, k); iemarray_setfloat(vec_dst, 0, sum); @@ -411,5 +411,4 @@ void tab_conv_setup(void) class_addmethod(tab_conv_class, (t_method)tab_conv_src1, gensym("src1"), A_DEFSYMBOL, 0); class_addmethod(tab_conv_class, (t_method)tab_conv_src2, gensym("src2"), A_DEFSYMBOL, 0); class_addmethod(tab_conv_class, (t_method)tab_conv_dst, gensym("dst"), A_DEFSYMBOL, 0); -// class_sethelpsymbol(tab_conv_class, gensym("iemhelp2/tab_conv-help")); } diff --git a/externals/iem/iem_tab/src/tab_sqrt.c b/externals/iem/iem_tab/src/tab_sqrt.c index 29f888914baad4288405c7c9504437e2e37a3adc..fca72635ef0ff4c94a9b87c26e3d5a9f3e412dbe 100644 --- a/externals/iem/iem_tab/src/tab_sqrt.c +++ b/externals/iem/iem_tab/src/tab_sqrt.c @@ -8,8 +8,7 @@ iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2009 #include "iem_tab.h" #include <math.h> -#define TABDUMTAB1SIZE 256 -#define TABDUMTAB2SIZE 1024 + /* -------------------------- tab_sqrt ------------------------------ */ /* x_beg_mem_dst[i] = sqrt(x_beg_mem_src1[i]) */ @@ -28,28 +27,6 @@ typedef struct _tab_sqrt } t_tab_sqrt; static t_class *tab_sqrt_class; -static t_float tab_rsqrt_exptab[TABDUMTAB1SIZE], tab_rsqrt_mantissatab[TABDUMTAB2SIZE]; - -static void init_tab_rsqrt(void) -{ - int i; - - for (i=0; i<TABDUMTAB1SIZE; i++) - { - t_float f; - long l = (i ? (i == TABDUMTAB1SIZE-1 ? TABDUMTAB1SIZE-2 : i) : 1)<< 23; - - *(long *)(&f) = l; - tab_rsqrt_exptab[i] = 1.0f/sqrt(f); - } - - for (i=0; i<TABDUMTAB2SIZE; i++) - { - t_float f = 1.0f + (1.0f / (t_float)TABDUMTAB2SIZE) * (t_float)i; - - tab_rsqrt_mantissatab[i] = 1.0f / sqrt(f); - } -} static void tab_sqrt_src(t_tab_sqrt *x, t_symbol *s) { @@ -81,19 +58,22 @@ static void tab_sqrt_bang(t_tab_sqrt *x) if(n) { t_garray *a; - - for(i=0; i<n; i++) + + for(i=0; i<n; i++) { t_float f = iemarray_getfloat(vec_src, i); - long l = *(long *)(&f); if(f < 0.0f) iemarray_setfloat(vec_dst, i, 0.0f); else { - t_float g = tab_rsqrt_exptab[(l >> 23) & 0xff] * tab_rsqrt_mantissatab[(l >> 13) & 0x3ff]; - - iemarray_setfloat(vec_dst, i, f*g*(1.5f - 0.5f * g * g * f)); +#if ((defined PD_MAJOR_VERSION && defined PD_MINOR_VERSION) && (PD_MAJOR_VERSION > 0 || PD_MINOR_VERSION > 43)) + t_float g = q8_rsqrt(f); + + iemarray_setfloat(vec_dst, i, f*g*(1.5f - 0.5f * g * g * f)); +#else + iemarray_setfloat(vec_dst, i, sqrt(f)); +#endif } } outlet_bang(x->x_obj.ob_outlet); @@ -135,19 +115,22 @@ static void tab_sqrt_list(t_tab_sqrt *x, t_symbol *s, int argc, t_atom *argv) if(n) { t_garray *a; - - for(i=0; i<n; i++) + + for(i=0; i<n; i++) { t_float f = iemarray_getfloat(vec_src, i); - long l = *(long *)(&f); if(f < 0.0f) iemarray_setfloat(vec_dst, i, 0.0f); else { - t_float g = tab_rsqrt_exptab[(l >> 23) & 0xff] * tab_rsqrt_mantissatab[(l >> 13) & 0x3ff]; +#if ((defined PD_MAJOR_VERSION && defined PD_MINOR_VERSION) && (PD_MAJOR_VERSION > 0 || PD_MINOR_VERSION > 43)) + t_float g = q8_rsqrt(f); iemarray_setfloat(vec_dst, i, f*g*(1.5f - 0.5f * g * g * f)); +#else + iemarray_setfloat(vec_dst, i, sqrt(f)); +#endif } } outlet_bang(x->x_obj.ob_outlet); @@ -200,7 +183,6 @@ static void *tab_sqrt_new(t_symbol *s, int argc, t_atom *argv) void tab_sqrt_setup(void) { - init_tab_rsqrt(); tab_sqrt_class = class_new(gensym("tab_sqrt"), (t_newmethod)tab_sqrt_new, (t_method)tab_sqrt_free, sizeof(t_tab_sqrt), 0, A_GIMME, 0); class_addbang(tab_sqrt_class, (t_method)tab_sqrt_bang); @@ -208,5 +190,4 @@ void tab_sqrt_setup(void) class_addmethod(tab_sqrt_class, (t_method)tab_sqrt_src, gensym("src"), A_DEFSYMBOL, 0); class_addmethod(tab_sqrt_class, (t_method)tab_sqrt_src, gensym("src1"), A_DEFSYMBOL, 0); class_addmethod(tab_sqrt_class, (t_method)tab_sqrt_dst, gensym("dst"), A_DEFSYMBOL, 0); -// class_sethelpsymbol(tab_sqrt_class, gensym("iemhelp2/tab_sqrt-help")); } diff --git a/externals/iem/iem_tab/tab_rifft-help.pd b/externals/iem/iem_tab/tab_rifft-help.pd index 16ad4c3fee7999b7d0179fe59f3a835630e8942d..6bed246b30f8618a1c1016959064b671fa976d6c 100644 --- a/externals/iem/iem_tab/tab_rifft-help.pd +++ b/externals/iem/iem_tab/tab_rifft-help.pd @@ -1,4 +1,4 @@ -#N canvas 24 39 983 666 10; +#N canvas 24 39 991 674 10; #N canvas 0 22 450 300 (subpatch) 0; #X array src_re 100 float 0; #X coords 0 1 99 -1 199 100 1; @@ -238,6 +238,9 @@ of complex src-arrays to a real dst-array; #X text 124 452 iem.at; #X text 85 474 Graz \, Austria; #X text 37 441 (c) Thomas Musil 2000 - 2009; +#X text 521 17 1.); +#X text 469 236 2.); +#X text 44 25 3.); #X connect 2 0 13 0; #X connect 6 0 12 0; #X connect 12 0 4 0;