Commit 344ffd71 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

update iem_tab to current Sourceforge svn

parent b4c7ff20
/* 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
......@@ -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 \
......
......@@ -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 \
......
......@@ -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
......
......@@ -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)
......
......@@ -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 \
......
......@@ -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"));
}
......@@ -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"));
}
......@@ -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"));
}
......@@ -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"));
}
......@@ -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"));
}
#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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment