Update of /cvsroot/pure-data/externals/iem/iem_tab/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1435/iem/iem_tab/src
Modified Files:
iem_tab.c makefile makefile_win tab_abs.c tab_add.c
tab_add_scalar.c tab_complex_inv.c tab_complex_mul.c
tab_const.c tab_conv.c tab_copy.c tab_counter.c
tab_cross_corr.c tab_div.c tab_eq.c tab_eq_scalar.c tab_fft.c
tab_find_peaks.c tab_ge.c tab_ge_scalar.c tab_gt.c
tab_gt_scalar.c tab_ifft.c tab_le.c tab_le_scalar.c tab_lt.c
tab_lt_scalar.c tab_max_index.c tab_min_index.c tab_min_max.c
tab_mls.c tab_mul.c tab_mul_scalar.c tab_ne.c tab_ne_scalar.c
tab_reverse.c tab_rfft.c tab_rifft.c tab_sqrt.c tab_sub.c
tab_sum.c
Added Files:
makefile_linux tab_carth2polar.c tab_find_exact_peaks.c
Log Message:
makefiles -fno-strict-aliasing flag
some new objects
float to t_float
no #pragma
--- NEW FILE: tab_carth2polar.c ---
/* 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 - 2005 */
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
#include <math.h>
/* -------------------------- tab_carth2polar ------------------------------ */
typedef struct _tab_carth2polar
{
t_object x_obj;
int x_size_src_re;
int x_size_dst_mag;
int x_size_src_im;
int x_size_dst_arg;
int x_offset_src_re;
int x_offset_dst_mag;
int x_offset_src_im;
int x_offset_dst_arg;
t_float *x_beg_mem_src_re;
t_float *x_beg_mem_dst_mag;
t_float *x_beg_mem_src_im;
t_float *x_beg_mem_dst_arg;
t_symbol *x_sym_src_re;
t_symbol *x_sym_dst_mag;
t_symbol *x_sym_src_im;
t_symbol *x_sym_dst_arg;
} t_tab_carth2polar;
static t_class *tab_carth2polar_class;
static void tab_carth2polar_src_re(t_tab_carth2polar *x, t_symbol *s)
{
x->x_sym_src_re = s;
}
static void tab_carth2polar_src_im(t_tab_carth2polar *x, t_symbol *s)
{
x->x_sym_src_im = s;
}
static void tab_carth2polar_dst_mag(t_tab_carth2polar *x, t_symbol *s)
{
x->x_sym_dst_mag = s;
}
static void tab_carth2polar_dst_arg(t_tab_carth2polar *x, t_symbol *s)
{
x->x_sym_dst_arg = s;
}
static void tab_carth2polar_bang(t_tab_carth2polar *x)
{
int i, n;
int ok_src_re, ok_dst_mag;
int ok_src_im, ok_dst_arg;
t_float *vec_src_re, *vec_dst_mag;
t_float *vec_src_im, *vec_dst_arg;
ok_src_re = iem_tab_check_arrays(gensym("tab_carth2polar"), x->x_sym_src_re, &x->x_beg_mem_src_re, &x->x_size_src_re, 0);
ok_dst_mag = iem_tab_check_arrays(gensym("tab_carth2polar"), x->x_sym_dst_mag, &x->x_beg_mem_dst_mag, &x->x_size_dst_mag, 0);
ok_src_im = iem_tab_check_arrays(gensym("tab_carth2polar"), x->x_sym_src_im, &x->x_beg_mem_src_im, &x->x_size_src_im, 0);
ok_dst_arg = iem_tab_check_arrays(gensym("tab_carth2polar"), x->x_sym_dst_arg, &x->x_beg_mem_dst_arg, &x->x_size_dst_arg, 0);
if(ok_src_re && ok_dst_mag && ok_src_im && ok_dst_arg)
{
if(x->x_size_src_re < x->x_size_dst_mag)
n = x->x_size_src_re;
else
n = x->x_size_dst_mag;
if(x->x_size_src_im < n)
n = x->x_size_src_im;
if(x->x_size_dst_arg < n)
n = x->x_size_dst_arg;
vec_src_re = x->x_beg_mem_src_re;
vec_dst_mag = x->x_beg_mem_dst_mag;
vec_src_im = x->x_beg_mem_src_im;
vec_dst_arg = x->x_beg_mem_dst_arg;
if(n)
{
t_garray *a;
t_float rcp_two_pi=0.125f/atan(1.0);
for(i=0; i<n; i++)
{
t_float re, im, mag, arg;
re = vec_src_re[i];
im = vec_src_im[i];
mag = sqrt(re*re + im*im);
arg = atan2(im, re) * rcp_two_pi;
vec_dst_mag[i] = mag;
vec_dst_arg[i] = arg;
}
outlet_bang(x->x_obj.ob_outlet);
a = (t_garray *)pd_findbyclass(x->x_sym_dst_mag, garray_class);
garray_redraw(a);
a = (t_garray *)pd_findbyclass(x->x_sym_dst_arg, garray_class);
garray_redraw(a);
}
}
}
static void tab_carth2polar_list(t_tab_carth2polar *x, t_symbol *s, int argc, t_atom *argv)
{
int i, n;
int beg_src_re, beg_dst_mag;
int beg_src_im, beg_dst_arg;
int ok_src_re, ok_dst_mag;
int ok_src_im, ok_dst_arg;
t_float *vec_src_re, *vec_dst_mag;
t_float *vec_src_im, *vec_dst_arg;
if((argc >= 5) &&
IS_A_FLOAT(argv,0) &&
IS_A_FLOAT(argv,1) &&
IS_A_FLOAT(argv,2) &&
IS_A_FLOAT(argv,3) &&
IS_A_FLOAT(argv,4))
{
beg_src_re = (int)atom_getintarg(0, argc, argv);
beg_src_im = (int)atom_getintarg(1, argc, argv);
beg_dst_mag = (int)atom_getintarg(2, argc, argv);
beg_dst_arg = (int)atom_getintarg(3, argc, argv);
n = (int)atom_getintarg(4, argc, argv);
if(beg_src_re < 0)
beg_src_re = 0;
if(beg_dst_mag < 0)
beg_dst_mag = 0;
if(beg_src_im < 0)
beg_src_im = 0;
if(beg_dst_arg < 0)
beg_dst_arg = 0;
if(n < 0)
n = 0;
ok_src_re = iem_tab_check_arrays(gensym("tab_carth2polar"), x->x_sym_src_re, &x->x_beg_mem_src_re, &x->x_size_src_re, beg_src_re+n);
ok_dst_mag = iem_tab_check_arrays(gensym("tab_carth2polar"), x->x_sym_dst_mag, &x->x_beg_mem_dst_mag, &x->x_size_dst_mag, beg_dst_mag+n);
ok_src_im = iem_tab_check_arrays(gensym("tab_carth2polar"), x->x_sym_src_im, &x->x_beg_mem_src_im, &x->x_size_src_im, beg_src_im+n);
ok_dst_arg = iem_tab_check_arrays(gensym("tab_carth2polar"), x->x_sym_dst_arg, &x->x_beg_mem_dst_arg, &x->x_size_dst_arg, beg_dst_arg+n);
if(ok_src_re && ok_dst_mag && ok_src_im && ok_dst_arg)
{
vec_src_re = x->x_beg_mem_src_re + beg_src_re;
vec_dst_mag = x->x_beg_mem_dst_mag + beg_dst_mag;
vec_src_im = x->x_beg_mem_src_im + beg_src_im;
vec_dst_arg = x->x_beg_mem_dst_arg + beg_dst_arg;
if(n)
{
t_garray *a;
t_float rcp_two_pi=0.125f/atan(1.0);
for(i=0; i<n; i++)
{
t_float re, im, mag, arg;
re = vec_src_re[i];
im = vec_src_im[i];
mag = sqrt(re*re + im*im);
arg = atan2(im, re) * rcp_two_pi;
vec_dst_mag[i] = mag;
vec_dst_arg[i] = arg;
}
outlet_bang(x->x_obj.ob_outlet);
a = (t_garray *)pd_findbyclass(x->x_sym_dst_mag, garray_class);
garray_redraw(a);
a = (t_garray *)pd_findbyclass(x->x_sym_dst_arg, garray_class);
garray_redraw(a);
}
}
}
else
{
post("tab_carth2polar-ERROR: list need 5 float arguments:");
post(" source_real_offset + source_imag_offset + destination_magnitude_offset + destination_phase_argument_offset + number_of_samples_to_convert");
}
}
static void tab_carth2polar_free(t_tab_carth2polar *x)
{
}
static void *tab_carth2polar_new(t_symbol *s, int argc, t_atom *argv)
{
t_tab_carth2polar *x = (t_tab_carth2polar *)pd_new(tab_carth2polar_class);
t_symbol *src_re, *dst_mag, *src_im, *dst_arg;
t_float time;
if((argc >= 4) &&
IS_A_SYMBOL(argv,0) &&
IS_A_SYMBOL(argv,1) &&
IS_A_SYMBOL(argv,2) &&
IS_A_SYMBOL(argv,3))
{
src_re = (t_symbol *)atom_getsymbolarg(0, argc, argv);
src_im = (t_symbol *)atom_getsymbolarg(1, argc, argv);
dst_mag = (t_symbol *)atom_getsymbolarg(2, argc, argv);
dst_arg = (t_symbol *)atom_getsymbolarg(3, argc, argv);
}
else
{
post("tab_carth2polar-ERROR: need 4 symbols arguments:");
post(" source_real_array_name + source_imag_array_name + destination_magnitude_array_name + destination_phase_argument_array_name");
return(0);
}
x->x_sym_src_re = src_re;
x->x_sym_src_im = src_im;
x->x_sym_dst_mag = dst_mag;
x->x_sym_dst_arg = dst_arg;
outlet_new(&x->x_obj, &s_bang);
return(x);
}
void tab_carth2polar_setup(void)
{
tab_carth2polar_class = class_new(gensym("tab_carth2polar"), (t_newmethod)tab_carth2polar_new, (t_method)tab_carth2polar_free,
sizeof(t_tab_carth2polar), 0, A_GIMME, 0);
class_addbang(tab_carth2polar_class, (t_method)tab_carth2polar_bang);
class_addlist(tab_carth2polar_class, (t_method)tab_carth2polar_list);
class_addmethod(tab_carth2polar_class, (t_method)tab_carth2polar_src_re, gensym("src_re"), A_DEFSYMBOL, 0);
class_addmethod(tab_carth2polar_class, (t_method)tab_carth2polar_src_im, gensym("src_im"), A_DEFSYMBOL, 0);
class_addmethod(tab_carth2polar_class, (t_method)tab_carth2polar_src_re, gensym("src1_re"), A_DEFSYMBOL, 0);
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"));
}
--- NEW FILE: makefile_linux ---
current: all
.SUFFIXES: .pd_linux
INCLUDE = -I. -I/usr/local/src/pd/src
LDFLAGS = -export-dynamic -shared
LIB = -ldl -lm
#select either the DBG and OPT compiler flags below:
CFLAGS = -DPD -DUNIX -W -Werror -Wno-unused \
-Wno-parentheses -Wno-switch -O6 -funroll-loops -fomit-frame-pointer -fno-strict-aliasing \
-DDL_OPEN -fPIC
SYSTEM = $(shell uname -m)
# the sources
SRC = tab_abs.c \
tab_add.c \
tab_add_scalar.c \
tab_carth2polar.c \
tab_complex_inv.c \
tab_complex_mul.c \
tab_const.c \
tab_conv.c \
tab_copy.c \
tab_counter.c \
tab_cross_corr.c \
tab_div.c \
tab_eq.c \
tab_eq_scalar.c \
tab_fft.c \
tab_find_exact_peaks.c \
tab_find_peaks.c \
tab_ge.c \
tab_ge_scalar.c \
tab_gt.c \
tab_gt_scalar.c \
tab_ifft.c \
tab_le.c \
tab_le_scalar.c \
tab_lt.c \
tab_lt_scalar.c \
tab_max_index.c \
tab_min_index.c \
tab_min_max.c \
tab_mul.c \
tab_mul_scalar.c \
tab_ne.c \
tab_ne_scalar.c \
tab_reverse.c \
tab_rfft.c \
tab_rifft.c \
tab_sqrt.c \
tab_sub.c \
tab_sum.c \
iem_tab.c
TARGET = iem_tab.pd_linux
OBJ = $(SRC:.c=.o)
#
# ------------------ targets ------------------------------------
#
clean:
rm $(TARGET)
rm *.o
all: $(OBJ)
@echo :: $(OBJ)
$(LD) $(LDFLAGS) -o $(TARGET) *.o $(LIB)
strip --strip-unneeded $(TARGET)
$(OBJ) : %.o : %.c
$(CC) $(CFLAGS) $(INCLUDE) -c -o $*.o $*.c
Index: tab_min_max.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_min_max.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_min_max.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_min_max.c 10 Nov 2006 17:15:48 -0000 1.2
***************
*** 4,19 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
--- 4,11 ----
***************
*** 22,33 ****
typedef struct _tab_min_max
{
! t_object x_obj;
! int x_size_src1;
! int x_offset_src1;
! float *x_beg_mem_src1;
! t_symbol *x_sym_scr1;
! void *x_bang_out;
! void *x_min_out;
! void *x_max_out;
} t_tab_min_max;
--- 14,25 ----
typedef struct _tab_min_max
{
! t_object x_obj;
! int x_size_src1;
! int x_offset_src1;
! t_float *x_beg_mem_src1;
! t_symbol *x_sym_scr1;
! void *x_bang_out;
! void *x_min_out;
! void *x_max_out;
} t_tab_min_max;
***************
*** 36,115 ****
static void tab_min_max_src(t_tab_min_max *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_min_max_bang(t_tab_min_max *x)
{
! int i, n;
! int ok_src;
! t_float *vec_src;
! t_float min=1.0e37, max=-1.0e37;
!
! ok_src = iem_tab_check_arrays(gensym("tab_min_max"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
!
! if(ok_src)
! {
! n = x->x_size_src1;
! vec_src = x->x_beg_mem_src1;
! if(n)
! {
! for(i=0; i<n; i++)
! {
! if(vec_src[i] > max)
! max = vec_src[i];
! if(vec_src[i] < min)
! min = vec_src[i];
! }
! outlet_float(x->x_max_out, max);
! outlet_float(x->x_min_out, min);
! outlet_bang(x->x_bang_out);
! }
! }
}
static void tab_min_max_list(t_tab_min_max *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src;
! int i, n;
! int ok_src;
! t_float *vec_src;
! t_float min=1.0e37, max=-1.0e37;
!
! if((argc >= 2) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1))
! {
! beg_src = (int)atom_getintarg(0, argc, argv);
! n = (int)atom_getintarg(1, argc, argv);
! if(beg_src < 0)
! beg_src = 0;
! if(n < 0)
! n = 0;
!
! ok_src = iem_tab_check_arrays(gensym("tab_min_max"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+n);
!
! if(ok_src)
! {
! vec_src = x->x_beg_mem_src1 + beg_src;
! if(n)
! {
! for(i=0; i<n; i++)
! {
! if(vec_src[i] > max)
! max = vec_src[i];
! if(vec_src[i] < min)
! min = vec_src[i];
! }
! outlet_float(x->x_max_out, max);
! outlet_float(x->x_min_out, min);
! outlet_bang(x->x_bang_out);
! }
! }
! }
! else
! {
! post("tab_min_max-ERROR: list need 2 float arguments:");
! post(" source_offset + number_of_samples_to_calc_min_max");
! }
}
--- 28,107 ----
static void tab_min_max_src(t_tab_min_max *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_min_max_bang(t_tab_min_max *x)
{
! int i, n;
! int ok_src;
! t_float *vec_src;
! t_float min=1.0e37, max=-1.0e37;
!
! ok_src = iem_tab_check_arrays(gensym("tab_min_max"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
!
! if(ok_src)
! {
! n = x->x_size_src1;
! vec_src = x->x_beg_mem_src1;
! if(n)
! {
! for(i=0; i<n; i++)
! {
! if(vec_src[i] > max)
! max = vec_src[i];
! if(vec_src[i] < min)
! min = vec_src[i];
! }
! outlet_float(x->x_max_out, max);
! outlet_float(x->x_min_out, min);
! outlet_bang(x->x_bang_out);
! }
! }
}
static void tab_min_max_list(t_tab_min_max *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src;
! int i, n;
! int ok_src;
! t_float *vec_src;
! t_float min=1.0e37, max=-1.0e37;
!
! if((argc >= 2) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1))
! {
! beg_src = (int)atom_getintarg(0, argc, argv);
! n = (int)atom_getintarg(1, argc, argv);
! if(beg_src < 0)
! beg_src = 0;
! if(n < 0)
! n = 0;
!
! ok_src = iem_tab_check_arrays(gensym("tab_min_max"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+n);
!
! if(ok_src)
! {
! vec_src = x->x_beg_mem_src1 + beg_src;
! if(n)
! {
! for(i=0; i<n; i++)
! {
! if(vec_src[i] > max)
! max = vec_src[i];
! if(vec_src[i] < min)
! min = vec_src[i];
! }
! outlet_float(x->x_max_out, max);
! outlet_float(x->x_min_out, min);
! outlet_bang(x->x_bang_out);
! }
! }
! }
! else
! {
! post("tab_min_max-ERROR: list need 2 float arguments:");
! post(" source_offset + number_of_samples_to_calc_min_max");
! }
}
***************
*** 120,153 ****
static void *tab_min_max_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_min_max *x = (t_tab_min_max *)pd_new(tab_min_max_class);
! t_symbol *src;
!
! if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! }
! else
! {
! post("tab_min_max-ERROR: need 1 symbol argument:");
! post(" source_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src;
! x->x_bang_out = outlet_new(&x->x_obj, &s_bang);
! x->x_min_out = outlet_new(&x->x_obj, &s_float);
! x->x_max_out = outlet_new(&x->x_obj, &s_float);
! return(x);
}
void tab_min_max_setup(void)
{
! tab_min_max_class = class_new(gensym("tab_min_max"), (t_newmethod)tab_min_max_new, (t_method)tab_min_max_free,
! sizeof(t_tab_min_max), 0, A_GIMME, 0);
! class_addbang(tab_min_max_class, (t_method)tab_min_max_bang);
! class_addlist(tab_min_max_class, (t_method)tab_min_max_list);
! class_addmethod(tab_min_max_class, (t_method)tab_min_max_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_min_max_class, (t_method)tab_min_max_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_min_max_class, gensym("iemhelp2/tab_min_max-help"));
}
--- 112,145 ----
static void *tab_min_max_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_min_max *x = (t_tab_min_max *)pd_new(tab_min_max_class);
! t_symbol *src;
!
! if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! }
! else
! {
! post("tab_min_max-ERROR: need 1 symbol argument:");
! post(" source_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src;
! x->x_bang_out = outlet_new(&x->x_obj, &s_bang);
! x->x_min_out = outlet_new(&x->x_obj, &s_float);
! x->x_max_out = outlet_new(&x->x_obj, &s_float);
! return(x);
}
void tab_min_max_setup(void)
{
! tab_min_max_class = class_new(gensym("tab_min_max"), (t_newmethod)tab_min_max_new, (t_method)tab_min_max_free,
! sizeof(t_tab_min_max), 0, A_GIMME, 0);
! class_addbang(tab_min_max_class, (t_method)tab_min_max_bang);
! class_addlist(tab_min_max_class, (t_method)tab_min_max_list);
! class_addmethod(tab_min_max_class, (t_method)tab_min_max_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_min_max_class, (t_method)tab_min_max_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_min_max_class, gensym("iemhelp2/tab_min_max-help"));
}
Index: makefile
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/makefile,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** makefile 10 Nov 2006 14:53:19 -0000 1.3
--- makefile 10 Nov 2006 17:15:47 -0000 1.4
***************
*** 18,58 ****
# the sources
! SRC = tab_copy.c \
! tab_reverse.c \
! tab_min_max.c \
! tab_min_index.c \
! tab_max_index.c \
! tab_find_peaks.c \
! tab_abs.c \
! tab_sqrt.c \
! tab_sum.c \
tab_add.c \
- tab_sub.c \
- tab_mul.c \
- tab_div.c \
- tab_complex_mul.c \
- tab_complex_inv.c \
tab_add_scalar.c \
! tab_mul_scalar.c \
tab_const.c \
- tab_fft.c \
- tab_ifft.c \
- tab_rfft.c \
- tab_rifft.c \
- tab_cross_corr.c \
tab_conv.c \
! tab_gt_scalar.c \
! tab_ge_scalar.c \
! tab_lt_scalar.c \
! tab_le_scalar.c \
! tab_ne_scalar.c \
tab_eq_scalar.c \
! tab_gt.c \
tab_ge.c \
! tab_lt.c \
tab_le.c \
tab_ne.c \
! tab_eq.c \
! tab_counter.c \
iem_tab.c
--- 18,60 ----
# the sources
! SRC = tab_abs.c \
tab_add.c \
tab_add_scalar.c \
! tab_carth2polar.c \
! tab_complex_inv.c \
! tab_complex_mul.c \
tab_const.c \
tab_conv.c \
! tab_copy.c \
! tab_counter.c \
! tab_cross_corr.c \
! tab_div.c \
! tab_eq.c \
tab_eq_scalar.c \
! tab_fft.c \
! tab_find_exact_peaks.c \
! tab_find_peaks.c \
tab_ge.c \
! tab_ge_scalar.c \
! tab_gt.c \
! tab_gt_scalar.c \
! tab_ifft.c \
tab_le.c \
+ tab_le_scalar.c \
+ tab_lt.c \
+ tab_lt_scalar.c \
+ tab_max_index.c \
+ tab_min_index.c \
+ tab_min_max.c \
+ tab_mul.c \
+ tab_mul_scalar.c \
tab_ne.c \
! tab_ne_scalar.c \
! tab_reverse.c \
! tab_rfft.c \
! tab_rifft.c \
! tab_sqrt.c \
! tab_sub.c \
! tab_sum.c \
iem_tab.c
Index: tab_mul.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_mul.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_mul.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_mul.c 10 Nov 2006 17:15:48 -0000 1.2
***************
*** 4,19 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
--- 4,10 ----
***************
*** 22,38 ****
typedef struct _tab_mul
{
! t_object x_obj;
! int x_size_src1;
! int x_size_src2;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_src2;
! int x_offset_dst;
! float *x_beg_mem_src1;
! float *x_beg_mem_src2;
! float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_scr2;
! t_symbol *x_sym_dst;
} t_tab_mul;
--- 13,29 ----
typedef struct _tab_mul
{
! t_object x_obj;
! int x_size_src1;
! int x_size_src2;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_src2;
! int x_offset_dst;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_src2;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_scr2;
! t_symbol *x_sym_dst;
} t_tab_mul;
***************
*** 41,144 ****
static void tab_mul_src1(t_tab_mul *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_mul_src2(t_tab_mul *x, t_symbol *s)
{
! x->x_sym_scr2 = s;
}
static void tab_mul_dst(t_tab_mul *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_mul_bang(t_tab_mul *x)
{
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_mul"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_src2 = iem_tab_check_arrays(gensym("tab_mul"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_mul"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
! if(x->x_size_src2 < n)
! n = x->x_size_src2;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = vec_src1[i]*vec_src2[i];
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_mul_list(t_tab_mul *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_src2, beg_dst;
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_src2 = (int)atom_getintarg(1, argc, argv);
! beg_dst = (int)atom_getintarg(2, argc, argv);
! n = (int)atom_getintarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_src2 < 0)
! beg_src2 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_mul"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_src2 = iem_tab_check_arrays(gensym("tab_mul"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, beg_src2+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_mul"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_src2 = x->x_beg_mem_src2 + beg_src2;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = vec_src1[i]*vec_src2[i];
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_mul-ERROR: list need 4 float arguments:");
! post(" source1_offset + source2_offset + destination_offset + number_of_samples_to_mul");
! }
}
--- 32,135 ----
static void tab_mul_src1(t_tab_mul *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_mul_src2(t_tab_mul *x, t_symbol *s)
{
! x->x_sym_scr2 = s;
}
static void tab_mul_dst(t_tab_mul *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_mul_bang(t_tab_mul *x)
{
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_mul"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_src2 = iem_tab_check_arrays(gensym("tab_mul"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_mul"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
! if(x->x_size_src2 < n)
! n = x->x_size_src2;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = vec_src1[i]*vec_src2[i];
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_mul_list(t_tab_mul *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_src2, beg_dst;
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_src2 = (int)atom_getintarg(1, argc, argv);
! beg_dst = (int)atom_getintarg(2, argc, argv);
! n = (int)atom_getintarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_src2 < 0)
! beg_src2 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_mul"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_src2 = iem_tab_check_arrays(gensym("tab_mul"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, beg_src2+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_mul"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_src2 = x->x_beg_mem_src2 + beg_src2;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = vec_src1[i]*vec_src2[i];
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_mul-ERROR: list need 4 float arguments:");
! post(" source1_offset + source2_offset + destination_offset + number_of_samples_to_mul");
! }
}
***************
*** 149,196 ****
static void *tab_mul_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_mul *x = (t_tab_mul *)pd_new(tab_mul_class);
! t_symbol *src1, *src2, *dst;
! t_float time;
!
! if((argc >= 3) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! }
! else if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else
! {
! post("tab_mul-ERROR: need 3 symbols arguments:");
! post(" source1_array_name + source2_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_scr2 = src2;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_mul_setup(void)
{
! tab_mul_class = class_new(gensym("tab_mul"), (t_newmethod)tab_mul_new, (t_method)tab_mul_free,
! sizeof(t_tab_mul), 0, A_GIMME, 0);
! class_addbang(tab_mul_class, (t_method)tab_mul_bang);
! class_addlist(tab_mul_class, (t_method)tab_mul_list);
! class_addmethod(tab_mul_class, (t_method)tab_mul_src1, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_mul_class, (t_method)tab_mul_src2, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_mul_class, (t_method)tab_mul_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_mul_class, gensym("iemhelp2/tab_mul-help"));
}
--- 140,187 ----
static void *tab_mul_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_mul *x = (t_tab_mul *)pd_new(tab_mul_class);
! t_symbol *src1, *src2, *dst;
! t_float time;
!
! if((argc >= 3) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! }
! else if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else
! {
! post("tab_mul-ERROR: need 3 symbols arguments:");
! post(" source1_array_name + source2_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_scr2 = src2;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_mul_setup(void)
{
! tab_mul_class = class_new(gensym("tab_mul"), (t_newmethod)tab_mul_new, (t_method)tab_mul_free,
! sizeof(t_tab_mul), 0, A_GIMME, 0);
! class_addbang(tab_mul_class, (t_method)tab_mul_bang);
! class_addlist(tab_mul_class, (t_method)tab_mul_list);
! class_addmethod(tab_mul_class, (t_method)tab_mul_src1, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_mul_class, (t_method)tab_mul_src2, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_mul_class, (t_method)tab_mul_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_mul_class, gensym("iemhelp2/tab_mul-help"));
}
Index: makefile_win
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/makefile_win,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** makefile_win 10 Mar 2006 03:05:55 -0000 1.1
--- makefile_win 10 Nov 2006 17:15:47 -0000 1.2
***************
*** 21,61 ****
! SRC = tab_copy.c \
! tab_reverse.c \
! tab_min_max.c \
! tab_min_index.c \
! tab_max_index.c \
! tab_find_peaks.c \
! tab_abs.c \
! tab_sqrt.c \
! tab_sum.c \
tab_add.c \
- tab_sub.c \
- tab_mul.c \
- tab_div.c \
- tab_complex_mul.c \
- tab_complex_inv.c \
tab_add_scalar.c \
! tab_mul_scalar.c \
tab_const.c \
- tab_fft.c \
- tab_ifft.c \
- tab_rfft.c \
- tab_rifft.c \
- tab_cross_corr.c \
tab_conv.c \
! tab_gt_scalar.c \
! tab_ge_scalar.c \
! tab_lt_scalar.c \
! tab_le_scalar.c \
! tab_ne_scalar.c \
tab_eq_scalar.c \
! tab_gt.c \
tab_ge.c \
! tab_lt.c \
tab_le.c \
tab_ne.c \
! tab_eq.c \
! tab_counter.c \
iem_tab.c
--- 21,63 ----
! SRC = tab_abs.c \
tab_add.c \
tab_add_scalar.c \
! tab_carth2polar.c \
! tab_complex_inv.c \
! tab_complex_mul.c \
tab_const.c \
tab_conv.c \
! tab_copy.c \
! tab_counter.c \
! tab_cross_corr.c \
! tab_div.c \
! tab_eq.c \
tab_eq_scalar.c \
! tab_fft.c \
! tab_find_exact_peaks.c \
! tab_find_peaks.c \
tab_ge.c \
! tab_ge_scalar.c \
! tab_gt.c \
! tab_gt_scalar.c \
! tab_ifft.c \
tab_le.c \
+ tab_le_scalar.c \
+ tab_lt.c \
+ tab_lt_scalar.c \
+ tab_max_index.c \
+ tab_min_index.c \
+ tab_min_max.c \
+ tab_mul.c \
+ tab_mul_scalar.c \
tab_ne.c \
! tab_ne_scalar.c \
! tab_reverse.c \
! tab_rfft.c \
! tab_rifft.c \
! tab_sqrt.c \
! tab_sub.c \
! tab_sum.c \
iem_tab.c
Index: tab_gt.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_gt.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_gt.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_gt.c 10 Nov 2006 17:15:47 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_gt ------------------------------ */
--- 4,10 ----
***************
*** 22,38 ****
typedef struct _tab_gt
{
! t_object x_obj;
! int x_size_src1;
! int x_size_src2;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_src2;
! int x_offset_dst;
! float *x_beg_mem_src1;
! float *x_beg_mem_src2;
! float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_scr2;
! t_symbol *x_sym_dst;
} t_tab_gt;
--- 12,28 ----
typedef struct _tab_gt
{
! t_object x_obj;
! int x_size_src1;
! int x_size_src2;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_src2;
! int x_offset_dst;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_src2;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_scr2;
! t_symbol *x_sym_dst;
} t_tab_gt;
***************
*** 41,154 ****
static void tab_gt_src1(t_tab_gt *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_gt_src2(t_tab_gt *x, t_symbol *s)
{
! x->x_sym_scr2 = s;
}
static void tab_gt_dst(t_tab_gt *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_gt_bang(t_tab_gt *x)
{
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_gt"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_src2 = iem_tab_check_arrays(gensym("tab_gt"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_gt"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
! if(x->x_size_src2 < n)
! n = x->x_size_src2;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] > vec_src2[i])
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_gt_list(t_tab_gt *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_src2, beg_dst;
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_src2 = (int)atom_getintarg(1, argc, argv);
! beg_dst = (int)atom_getintarg(2, argc, argv);
! n = (int)atom_getintarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_src2 < 0)
! beg_src2 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_gt"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_src2 = iem_tab_check_arrays(gensym("tab_gt"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, beg_src2+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_gt"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_src2 = x->x_beg_mem_src2 + beg_src2;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] > vec_src2[i])
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_gt-ERROR: list need 4 float arguments:");
! post(" source1_offset + source2_offset + destination_offset + number_of_samples_to_compare");
! }
}
--- 31,144 ----
static void tab_gt_src1(t_tab_gt *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_gt_src2(t_tab_gt *x, t_symbol *s)
{
! x->x_sym_scr2 = s;
}
static void tab_gt_dst(t_tab_gt *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_gt_bang(t_tab_gt *x)
{
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_gt"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_src2 = iem_tab_check_arrays(gensym("tab_gt"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_gt"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
! if(x->x_size_src2 < n)
! n = x->x_size_src2;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] > vec_src2[i])
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_gt_list(t_tab_gt *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_src2, beg_dst;
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_src2 = (int)atom_getintarg(1, argc, argv);
! beg_dst = (int)atom_getintarg(2, argc, argv);
! n = (int)atom_getintarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_src2 < 0)
! beg_src2 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_gt"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_src2 = iem_tab_check_arrays(gensym("tab_gt"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, beg_src2+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_gt"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_src2 = x->x_beg_mem_src2 + beg_src2;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] > vec_src2[i])
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_gt-ERROR: list need 4 float arguments:");
! post(" source1_offset + source2_offset + destination_offset + number_of_samples_to_compare");
! }
}
***************
*** 159,206 ****
static void *tab_gt_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_gt *x = (t_tab_gt *)pd_new(tab_gt_class);
! t_symbol *src1, *src2, *dst;
! t_float time;
!
! if((argc >= 3) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! }
! else if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else
! {
! post("tab_gt-ERROR: need 3 symbols arguments:");
! post(" source1_array_name + source2_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_scr2 = src2;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_gt_setup(void)
{
! tab_gt_class = class_new(gensym("tab_gt"), (t_newmethod)tab_gt_new, (t_method)tab_gt_free,
! sizeof(t_tab_gt), 0, A_GIMME, 0);
! class_addbang(tab_gt_class, (t_method)tab_gt_bang);
! class_addlist(tab_gt_class, (t_method)tab_gt_list);
! class_addmethod(tab_gt_class, (t_method)tab_gt_src1, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_gt_class, (t_method)tab_gt_src2, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_gt_class, (t_method)tab_gt_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_gt_class, gensym("iemhelp2/tab_gt-help"));
}
--- 149,196 ----
static void *tab_gt_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_gt *x = (t_tab_gt *)pd_new(tab_gt_class);
! t_symbol *src1, *src2, *dst;
! t_float time;
!
! if((argc >= 3) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! }
! else if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else
! {
! post("tab_gt-ERROR: need 3 symbols arguments:");
! post(" source1_array_name + source2_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_scr2 = src2;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_gt_setup(void)
{
! tab_gt_class = class_new(gensym("tab_gt"), (t_newmethod)tab_gt_new, (t_method)tab_gt_free,
! sizeof(t_tab_gt), 0, A_GIMME, 0);
! class_addbang(tab_gt_class, (t_method)tab_gt_bang);
! class_addlist(tab_gt_class, (t_method)tab_gt_list);
! class_addmethod(tab_gt_class, (t_method)tab_gt_src1, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_gt_class, (t_method)tab_gt_src2, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_gt_class, (t_method)tab_gt_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_gt_class, gensym("iemhelp2/tab_gt-help"));
}
Index: tab_copy.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_copy.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_copy.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_copy.c 10 Nov 2006 17:15:47 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_copy ------------------------------ */
--- 4,10 ----
***************
*** 22,34 ****
typedef struct _tab_copy
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! float *x_beg_mem_src1;
! float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_copy;
--- 12,24 ----
typedef struct _tab_copy
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_copy;
***************
*** 37,124 ****
static void tab_copy_src(t_tab_copy *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_copy_dst(t_tab_copy *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_copy_bang(t_tab_copy *x)
{
! int i, n;
! int ok_src, ok_dst;
! t_float *vec_src, *vec_dst;
!
! ok_src = iem_tab_check_arrays(gensym("tab_copy"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_copy"), 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++)
! vec_dst[i] = vec_src[i];
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_copy_list(t_tab_copy *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src, beg_dst;
! int i, n;
! int ok_src, ok_dst;
! t_float *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_copy"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_copy"), 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++)
! vec_dst[i] = vec_src[i];
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_copy-ERROR: list need 3 float arguments:");
! post(" source_offset + destination_offset + number_of_samples_to_copy");
! }
}
--- 27,114 ----
static void tab_copy_src(t_tab_copy *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_copy_dst(t_tab_copy *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_copy_bang(t_tab_copy *x)
{
! int i, n;
! int ok_src, ok_dst;
! t_float *vec_src, *vec_dst;
!
! ok_src = iem_tab_check_arrays(gensym("tab_copy"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_copy"), 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++)
! vec_dst[i] = vec_src[i];
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_copy_list(t_tab_copy *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src, beg_dst;
! int i, n;
! int ok_src, ok_dst;
! t_float *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_copy"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_copy"), 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++)
! vec_dst[i] = vec_src[i];
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_copy-ERROR: list need 3 float arguments:");
! post(" source_offset + destination_offset + number_of_samples_to_copy");
! }
}
***************
*** 129,170 ****
static void *tab_copy_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_copy *x = (t_tab_copy *)pd_new(tab_copy_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_copy-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_copy_setup(void)
{
! tab_copy_class = class_new(gensym("tab_copy"), (t_newmethod)tab_copy_new, (t_method)tab_copy_free,
! sizeof(t_tab_copy), 0, A_GIMME, 0);
! class_addbang(tab_copy_class, (t_method)tab_copy_bang);
! class_addlist(tab_copy_class, (t_method)tab_copy_list);
! class_addmethod(tab_copy_class, (t_method)tab_copy_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_copy_class, (t_method)tab_copy_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_copy_class, (t_method)tab_copy_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_copy_class, gensym("iemhelp2/tab_copy-help"));
}
--- 119,160 ----
static void *tab_copy_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_copy *x = (t_tab_copy *)pd_new(tab_copy_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_copy-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_copy_setup(void)
{
! tab_copy_class = class_new(gensym("tab_copy"), (t_newmethod)tab_copy_new, (t_method)tab_copy_free,
! sizeof(t_tab_copy), 0, A_GIMME, 0);
! class_addbang(tab_copy_class, (t_method)tab_copy_bang);
! class_addlist(tab_copy_class, (t_method)tab_copy_list);
! class_addmethod(tab_copy_class, (t_method)tab_copy_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_copy_class, (t_method)tab_copy_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_copy_class, (t_method)tab_copy_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_copy_class, gensym("iemhelp2/tab_copy-help"));
}
Index: iem_tab.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/iem_tab.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** iem_tab.c 10 Mar 2006 03:05:55 -0000 1.1
--- iem_tab.c 10 Nov 2006 17:15:47 -0000 1.2
***************
*** 4,13 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
--- 4,7 ----
***************
*** 17,86 ****
int iem_tab_check_arrays(t_symbol *obj_name, t_symbol *array_name, t_float **beg_mem, int *array_size, int max_index)
{
! int ok=1;
! t_garray *a;
!
! if(!(a = (t_garray *)pd_findbyclass(array_name, garray_class)))
! {
! error("%s: no such array", array_name->s_name);
! ok = 0;
! }
! else if(!garray_getfloatarray(a, array_size, beg_mem))
! {
! error("%s: bad template for %s", array_name->s_name, obj_name->s_name);
! ok = 0;
! }
! else if(*array_size < max_index)
! {
! error("%s: bad array-size: %d", array_name->s_name, *array_size);
! ok = 0;
! }
! return(ok);
}
static void *iem_tab_new(void)
{
! t_object *x = (t_object *)pd_new(iem_tab_class);
!
! return (x);
}
- void tab_copy_setup(void);
- void tab_reverse_setup(void);
- void tab_min_max_setup(void);
- void tab_min_index_setup(void);
- void tab_max_index_setup(void);
- void tab_find_peaks_setup(void);
void tab_abs_setup(void);
- void tab_sqrt_setup(void);
- void tab_sum_setup(void);
void tab_add_setup(void);
- void tab_sub_setup(void);
- void tab_mul_setup(void);
- void tab_div_setup(void);
- void tab_complex_mul_setup(void);
- void tab_complex_inv_setup(void);
- void tab_mul_scalar_setup(void);
void tab_add_scalar_setup(void);
void tab_const_setup(void);
- void tab_fft_setup(void);
- void tab_ifft_setup(void);
- void tab_rfft_setup(void);
- void tab_rifft_setup(void);
- void tab_cross_corr_setup(void);
void tab_conv_setup(void);
! void tab_gt_scalar_setup(void);
! void tab_ge_scalar_setup(void);
! void tab_lt_scalar_setup(void);
! void tab_le_scalar_setup(void);
! void tab_ne_scalar_setup(void);
void tab_eq_scalar_setup(void);
! void tab_gt_setup(void);
void tab_ge_setup(void);
! void tab_lt_setup(void);
void tab_le_setup(void);
! void tab_ne_setup(void);
! void tab_eq_setup(void);
! void tab_counter_setup(void);
//void tab_mls_setup(void);
/* ------------------------ setup routine ------------------------- */
--- 11,82 ----
int iem_tab_check_arrays(t_symbol *obj_name, t_symbol *array_name, t_float **beg_mem, int *array_size, int max_index)
{
! int ok=1;
! t_garray *a;
!
! if(!(a = (t_garray *)pd_findbyclass(array_name, garray_class)))
! {
! error("%s: no such array", array_name->s_name);
! ok = 0;
! }
! else if(!garray_getfloatarray(a, array_size, beg_mem))
! {
! error("%s: bad template for %s", array_name->s_name, obj_name->s_name);
! ok = 0;
! }
! else if(*array_size < max_index)
! {
! error("%s: bad array-size: %d", array_name->s_name, *array_size);
! ok = 0;
! }
! return(ok);
}
static void *iem_tab_new(void)
{
! t_object *x = (t_object *)pd_new(iem_tab_class);
!
! return (x);
}
void tab_abs_setup(void);
void tab_add_setup(void);
void tab_add_scalar_setup(void);
+ void tab_carth2polar_setup(void);
+ void tab_complex_inv_setup(void);
+ void tab_complex_mul_setup(void);
void tab_const_setup(void);
void tab_conv_setup(void);
! void tab_copy_setup(void);
! void tab_counter_setup(void);
! void tab_cross_corr_setup(void);
! void tab_div_setup(void);
! void tab_eq_setup(void);
void tab_eq_scalar_setup(void);
! void tab_fft_setup(void);
! void tab_find_exact_peaks_setup(void);
! void tab_find_peaks_setup(void);
void tab_ge_setup(void);
! void tab_ge_scalar_setup(void);
! void tab_gt_setup(void);
! void tab_gt_scalar_setup(void);
! void tab_ifft_setup(void);
void tab_le_setup(void);
! void tab_le_scalar_setup(void);
! void tab_lt_setup(void);
! 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_reverse_setup(void);
+ void tab_rfft_setup(void);
+ void tab_rifft_setup(void);
+ void tab_sqrt_setup(void);
+ void tab_sub_setup(void);
+ void tab_sum_setup(void);
/* ------------------------ setup routine ------------------------- */
***************
*** 88,134 ****
void iem_tab_setup(void)
{
! iem_tab_class = class_new(gensym("iem_tab"), iem_tab_new, 0,
! sizeof(t_object), CLASS_NOINLET, 0);
!
! tab_copy_setup();
! tab_reverse_setup();
! tab_min_max_setup();
! tab_min_index_setup();
! tab_max_index_setup();
! tab_find_peaks_setup();
! tab_abs_setup();
! tab_sqrt_setup();
! tab_sum_setup();
! tab_add_setup();
! tab_sub_setup();
! tab_mul_setup();
! tab_div_setup();
! tab_complex_mul_setup();
! tab_complex_inv_setup();
! tab_mul_scalar_setup();
! tab_add_scalar_setup();
! tab_const_setup();
! tab_fft_setup();
! tab_ifft_setup();
! tab_rfft_setup();
! tab_rifft_setup();
! tab_cross_corr_setup();
! tab_conv_setup();
! tab_gt_scalar_setup();
! tab_ge_scalar_setup();
! tab_lt_scalar_setup();
! tab_le_scalar_setup();
! tab_ne_scalar_setup();
! tab_eq_scalar_setup();
! tab_gt_setup();
! tab_ge_setup();
! tab_lt_setup();
! tab_le_setup();
! tab_ne_setup();
! tab_eq_setup();
! tab_counter_setup();
! // tab_mls_setup();
!
! post("iem_tab (R-1.16) library loaded! (c) Thomas Musil 05.2005");
! post(" musil%ciem.at iem KUG Graz Austria", '@');
}
--- 84,132 ----
void iem_tab_setup(void)
{
! iem_tab_class = class_new(gensym("iem_tab"), iem_tab_new, 0,
! sizeof(t_object), CLASS_NOINLET, 0);
!
! tab_abs_setup();
! tab_add_setup();
! tab_add_scalar_setup();
! tab_carth2polar_setup();
! tab_complex_inv_setup();
! tab_complex_mul_setup();
! tab_const_setup();
! tab_conv_setup();
! tab_copy_setup();
! tab_counter_setup();
! tab_cross_corr_setup();
! tab_div_setup();
! tab_eq_setup();
! tab_eq_scalar_setup();
! tab_fft_setup();
! tab_find_exact_peaks_setup();
! tab_find_peaks_setup();
! tab_ge_setup();
! tab_ge_scalar_setup();
! tab_gt_setup();
! tab_gt_scalar_setup();
! tab_ifft_setup();
! tab_le_setup();
! tab_le_scalar_setup();
! tab_lt_setup();
! tab_lt_scalar_setup();
! 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_reverse_setup();
! tab_rfft_setup();
! tab_rifft_setup();
! tab_sqrt_setup();
! tab_sub_setup();
! tab_sum_setup();
!
! post("iem_tab (R-1.16) library loaded! (c) Thomas Musil 05.2005");
! post(" musil%ciem.at iem KUG Graz Austria", '@');
}
Index: tab_reverse.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_reverse.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_reverse.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_reverse.c 10 Nov 2006 17:15:48 -0000 1.2
***************
*** 4,19 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
--- 4,11 ----
***************
*** 22,34 ****
typedef struct _tab_reverse
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! float *x_beg_mem_src1;
! float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_reverse;
--- 14,26 ----
typedef struct _tab_reverse
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_reverse;
***************
*** 37,124 ****
static void tab_reverse_src(t_tab_reverse *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_reverse_dst(t_tab_reverse *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_reverse_bang(t_tab_reverse *x)
{
! int i, j, n;
! int ok_src, ok_dst;
! t_float *vec_src, *vec_dst;
!
! ok_src = iem_tab_check_arrays(gensym("tab_reverse"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_reverse"), 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, j=n-1; i<n; i++, j--)
! vec_dst[i] = vec_src[j];
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_reverse_list(t_tab_reverse *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src, beg_dst;
! int i, j, n;
! int ok_src, ok_dst;
! t_float *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_reverse"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_reverse"), 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, j=n-1; i<n; i++, j--)
! vec_dst[i] = vec_src[j];
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_reverse-ERROR: list need 3 float arguments:");
! post(" source_offset + destination_offset + number_of_samples_to_copy");
! }
}
--- 29,116 ----
static void tab_reverse_src(t_tab_reverse *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_reverse_dst(t_tab_reverse *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_reverse_bang(t_tab_reverse *x)
{
! int i, j, n;
! int ok_src, ok_dst;
! t_float *vec_src, *vec_dst;
!
! ok_src = iem_tab_check_arrays(gensym("tab_reverse"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_reverse"), 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, j=n-1; i<n; i++, j--)
! vec_dst[i] = vec_src[j];
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_reverse_list(t_tab_reverse *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src, beg_dst;
! int i, j, n;
! int ok_src, ok_dst;
! t_float *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_reverse"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_reverse"), 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, j=n-1; i<n; i++, j--)
! vec_dst[i] = vec_src[j];
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_reverse-ERROR: list need 3 float arguments:");
! post(" source_offset + destination_offset + number_of_samples_to_copy");
! }
}
***************
*** 129,170 ****
static void *tab_reverse_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_reverse *x = (t_tab_reverse *)pd_new(tab_reverse_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_reverse-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_reverse_setup(void)
{
! tab_reverse_class = class_new(gensym("tab_reverse"), (t_newmethod)tab_reverse_new, (t_method)tab_reverse_free,
! sizeof(t_tab_reverse), 0, A_GIMME, 0);
! class_addbang(tab_reverse_class, (t_method)tab_reverse_bang);
! class_addlist(tab_reverse_class, (t_method)tab_reverse_list);
! class_addmethod(tab_reverse_class, (t_method)tab_reverse_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_reverse_class, (t_method)tab_reverse_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_reverse_class, (t_method)tab_reverse_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_reverse_class, gensym("iemhelp2/tab_reverse-help"));
}
--- 121,162 ----
static void *tab_reverse_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_reverse *x = (t_tab_reverse *)pd_new(tab_reverse_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_reverse-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_reverse_setup(void)
{
! tab_reverse_class = class_new(gensym("tab_reverse"), (t_newmethod)tab_reverse_new, (t_method)tab_reverse_free,
! sizeof(t_tab_reverse), 0, A_GIMME, 0);
! class_addbang(tab_reverse_class, (t_method)tab_reverse_bang);
! class_addlist(tab_reverse_class, (t_method)tab_reverse_list);
! class_addmethod(tab_reverse_class, (t_method)tab_reverse_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_reverse_class, (t_method)tab_reverse_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_reverse_class, (t_method)tab_reverse_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_reverse_class, gensym("iemhelp2/tab_reverse-help"));
}
Index: tab_min_index.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_min_index.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_min_index.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_min_index.c 10 Nov 2006 17:15:48 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_min_index ------------------------------ */
--- 4,11 ----
***************
*** 22,33 ****
typedef struct _tab_min_index
{
! t_object x_obj;
! int x_size_src1;
! int x_offset_src1;
! float *x_beg_mem_src1;
! t_symbol *x_sym_scr1;
! void *x_bang_out;
! void *x_min_out;
! void *x_min_index_out;
} t_tab_min_index;
--- 13,24 ----
typedef struct _tab_min_index
{
! t_object x_obj;
! int x_size_src1;
! int x_offset_src1;
! t_float *x_beg_mem_src1;
! t_symbol *x_sym_scr1;
! void *x_bang_out;
! void *x_min_out;
! void *x_min_index_out;
} t_tab_min_index;
***************
*** 36,117 ****
static void tab_min_index_src(t_tab_min_index *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_min_index_bang(t_tab_min_index *x)
{
! int i, n;
! int ok_src, min_index=0;
! t_float *vec_src;
! t_float min=1.0e37;
!
! ok_src = iem_tab_check_arrays(gensym("tab_min_index"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
!
! if(ok_src)
! {
! n = x->x_size_src1;
! vec_src = x->x_beg_mem_src1;
! if(n)
! {
! for(i=0; i<n; i++)
! {
! if(vec_src[i] < min)
! {
! min = vec_src[i];
! min_index = i;
! }
! }
! outlet_float(x->x_min_out, min);
! outlet_float(x->x_min_index_out, (float)min_index);
! outlet_bang(x->x_bang_out);
! }
! }
}
static void tab_min_index_list(t_tab_min_index *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src;
! int i, n;
! int ok_src, min_index=0;
! t_float *vec_src;
! t_float min=1.0e37;
!
! if((argc >= 2) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1))
! {
! beg_src = (int)atom_getintarg(0, argc, argv);
! n = (int)atom_getintarg(1, argc, argv);
! if(beg_src < 0)
! beg_src = 0;
! if(n < 0)
! n = 0;
!
! ok_src = iem_tab_check_arrays(gensym("tab_min_index"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+n);
!
! if(ok_src)
! {
! vec_src = x->x_beg_mem_src1 + beg_src;
! if(n)
! {
! for(i=0; i<n; i++)
! {
! if(vec_src[i] < min)
! {
! min = vec_src[i];
! min_index = i + beg_src;
! }
! }
! outlet_float(x->x_min_out, min);
! outlet_float(x->x_min_index_out, (float)min_index);
! outlet_bang(x->x_bang_out);
! }
! }
! }
! else
! {
! post("tab_min_index-ERROR: list need 2 float arguments:");
! post(" source_offset + number_of_samples_to_calc_min_index");
! }
}
--- 27,108 ----
static void tab_min_index_src(t_tab_min_index *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_min_index_bang(t_tab_min_index *x)
{
! int i, n;
! int ok_src, min_index=0;
! t_float *vec_src;
! t_float min=1.0e37;
!
! ok_src = iem_tab_check_arrays(gensym("tab_min_index"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
!
! if(ok_src)
! {
! n = x->x_size_src1;
! vec_src = x->x_beg_mem_src1;
! if(n)
! {
! for(i=0; i<n; i++)
! {
! if(vec_src[i] < min)
! {
! min = vec_src[i];
! min_index = i;
! }
! }
! outlet_float(x->x_min_out, min);
! outlet_float(x->x_min_index_out, (t_float)min_index);
! outlet_bang(x->x_bang_out);
! }
! }
}
static void tab_min_index_list(t_tab_min_index *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src;
! int i, n;
! int ok_src, min_index=0;
! t_float *vec_src;
! t_float min=1.0e37;
!
! if((argc >= 2) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1))
! {
! beg_src = (int)atom_getintarg(0, argc, argv);
! n = (int)atom_getintarg(1, argc, argv);
! if(beg_src < 0)
! beg_src = 0;
! if(n < 0)
! n = 0;
!
! ok_src = iem_tab_check_arrays(gensym("tab_min_index"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+n);
!
! if(ok_src)
! {
! vec_src = x->x_beg_mem_src1 + beg_src;
! if(n)
! {
! for(i=0; i<n; i++)
! {
! if(vec_src[i] < min)
! {
! min = vec_src[i];
! min_index = i + beg_src;
! }
! }
! outlet_float(x->x_min_out, min);
! outlet_float(x->x_min_index_out, (t_float)min_index);
! outlet_bang(x->x_bang_out);
! }
! }
! }
! else
! {
! post("tab_min_index-ERROR: list need 2 float arguments:");
! post(" source_offset + number_of_samples_to_calc_min_index");
! }
}
***************
*** 122,155 ****
static void *tab_min_index_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_min_index *x = (t_tab_min_index *)pd_new(tab_min_index_class);
! t_symbol *src;
!
! if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! }
! else
! {
! post("tab_min_index-ERROR: need 1 symbol argument:");
! post(" source_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src;
! x->x_bang_out = outlet_new(&x->x_obj, &s_bang);
! x->x_min_index_out = outlet_new(&x->x_obj, &s_float);
! x->x_min_out = outlet_new(&x->x_obj, &s_float);
! return(x);
}
void tab_min_index_setup(void)
{
! tab_min_index_class = class_new(gensym("tab_min_index"), (t_newmethod)tab_min_index_new, (t_method)tab_min_index_free,
! sizeof(t_tab_min_index), 0, A_GIMME, 0);
! class_addbang(tab_min_index_class, (t_method)tab_min_index_bang);
! class_addlist(tab_min_index_class, (t_method)tab_min_index_list);
! class_addmethod(tab_min_index_class, (t_method)tab_min_index_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_min_index_class, (t_method)tab_min_index_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_min_index_class, gensym("iemhelp2/tab_min_index-help"));
}
--- 113,146 ----
static void *tab_min_index_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_min_index *x = (t_tab_min_index *)pd_new(tab_min_index_class);
! t_symbol *src;
!
! if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! }
! else
! {
! post("tab_min_index-ERROR: need 1 symbol argument:");
! post(" source_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src;
! x->x_bang_out = outlet_new(&x->x_obj, &s_bang);
! x->x_min_index_out = outlet_new(&x->x_obj, &s_float);
! x->x_min_out = outlet_new(&x->x_obj, &s_float);
! return(x);
}
void tab_min_index_setup(void)
{
! tab_min_index_class = class_new(gensym("tab_min_index"), (t_newmethod)tab_min_index_new, (t_method)tab_min_index_free,
! sizeof(t_tab_min_index), 0, A_GIMME, 0);
! class_addbang(tab_min_index_class, (t_method)tab_min_index_bang);
! class_addlist(tab_min_index_class, (t_method)tab_min_index_list);
! class_addmethod(tab_min_index_class, (t_method)tab_min_index_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_min_index_class, (t_method)tab_min_index_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_min_index_class, gensym("iemhelp2/tab_min_index-help"));
}
Index: tab_ne_scalar.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_ne_scalar.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_ne_scalar.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_ne_scalar.c 10 Nov 2006 17:15:48 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_ne_scalar ------------------------------ */
--- 4,10 ----
***************
*** 22,34 ****
typedef struct _tab_ne_scalar
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! float *x_beg_mem_src1;
! float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_ne_scalar;
--- 12,24 ----
typedef struct _tab_ne_scalar
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_ne_scalar;
***************
*** 37,136 ****
static void tab_ne_scalar_src(t_tab_ne_scalar *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_ne_scalar_float(t_tab_ne_scalar *x, t_floatarg compare)
{
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_ne_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_ne_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] != compare)
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_ne_scalar_dst(t_tab_ne_scalar *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_ne_scalar_list(t_tab_ne_scalar *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_dst;
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst, compare;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_dst = (int)atom_getintarg(1, argc, argv);
! n = (int)atom_getintarg(2, argc, argv);
! compare = (t_float)atom_getfloatarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_ne_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_ne_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] != compare)
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_ne_scalar-ERROR: list need 4 float arguments:");
! post(" source1_offset + destination_offset + number_of_samples_to_compare + compare_scalar");
}
}
--- 27,126 ----
static void tab_ne_scalar_src(t_tab_ne_scalar *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_ne_scalar_float(t_tab_ne_scalar *x, t_floatarg compare)
{
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_ne_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_ne_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] != compare)
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_ne_scalar_dst(t_tab_ne_scalar *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_ne_scalar_list(t_tab_ne_scalar *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_dst;
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst, compare;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_dst = (int)atom_getintarg(1, argc, argv);
! n = (int)atom_getintarg(2, argc, argv);
! compare = (t_float)atom_getfloatarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_ne_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_ne_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] != compare)
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_ne_scalar-ERROR: list need 4 float arguments:");
! post(" source1_offset + destination_offset + number_of_samples_to_compare + compare_scalar");
}
}
***************
*** 142,183 ****
static void *tab_ne_scalar_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_ne_scalar *x = (t_tab_ne_scalar *)pd_new(tab_ne_scalar_class);
! t_symbol *src1, *dst;
!
! if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! }
! else
! {
! post("tab_ne_scalar-ERROR: need 2 symbol arguments:");
! post(" source_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_ne_scalar_setup(void)
{
! tab_ne_scalar_class = class_new(gensym("tab_ne_scalar"), (t_newmethod)tab_ne_scalar_new, (t_method)tab_ne_scalar_free,
! sizeof(t_tab_ne_scalar), 0, A_GIMME, 0);
! class_addfloat(tab_ne_scalar_class, (t_method)tab_ne_scalar_float);
! class_addlist(tab_ne_scalar_class, (t_method)tab_ne_scalar_list);
! class_addmethod(tab_ne_scalar_class, (t_method)tab_ne_scalar_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ne_scalar_class, (t_method)tab_ne_scalar_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ne_scalar_class, (t_method)tab_ne_scalar_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_ne_scalar_class, gensym("iemhelp2/tab_ne_scalar-help"));
}
--- 132,173 ----
static void *tab_ne_scalar_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_ne_scalar *x = (t_tab_ne_scalar *)pd_new(tab_ne_scalar_class);
! t_symbol *src1, *dst;
!
! if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! }
! else
! {
! post("tab_ne_scalar-ERROR: need 2 symbol arguments:");
! post(" source_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_ne_scalar_setup(void)
{
! tab_ne_scalar_class = class_new(gensym("tab_ne_scalar"), (t_newmethod)tab_ne_scalar_new, (t_method)tab_ne_scalar_free,
! sizeof(t_tab_ne_scalar), 0, A_GIMME, 0);
! class_addfloat(tab_ne_scalar_class, (t_method)tab_ne_scalar_float);
! class_addlist(tab_ne_scalar_class, (t_method)tab_ne_scalar_list);
! class_addmethod(tab_ne_scalar_class, (t_method)tab_ne_scalar_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ne_scalar_class, (t_method)tab_ne_scalar_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ne_scalar_class, (t_method)tab_ne_scalar_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_ne_scalar_class, gensym("iemhelp2/tab_ne_scalar-help"));
}
Index: tab_gt_scalar.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_gt_scalar.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_gt_scalar.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_gt_scalar.c 10 Nov 2006 17:15:47 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_gt_scalar ------------------------------ */
--- 4,10 ----
***************
*** 22,34 ****
typedef struct _tab_gt_scalar
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! float *x_beg_mem_src1;
! float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_gt_scalar;
--- 12,24 ----
typedef struct _tab_gt_scalar
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_gt_scalar;
***************
*** 37,137 ****
static void tab_gt_scalar_src(t_tab_gt_scalar *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_gt_scalar_float(t_tab_gt_scalar *x, t_floatarg compare)
{
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_gt_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_gt_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] > compare)
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_gt_scalar_dst(t_tab_gt_scalar *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_gt_scalar_list(t_tab_gt_scalar *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_dst;
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst, compare;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_dst = (int)atom_getintarg(1, argc, argv);
! n = (int)atom_getintarg(2, argc, argv);
! compare = (t_float)atom_getfloatarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_gt_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_gt_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] > compare)
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_gt_scalar-ERROR: list need 4 float arguments:");
! post(" source1_offset + destination_offset + number_of_samples_to_compare + compare_scalar");
! }
}
--- 27,127 ----
static void tab_gt_scalar_src(t_tab_gt_scalar *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_gt_scalar_float(t_tab_gt_scalar *x, t_floatarg compare)
{
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_gt_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_gt_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] > compare)
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_gt_scalar_dst(t_tab_gt_scalar *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_gt_scalar_list(t_tab_gt_scalar *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_dst;
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst, compare;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_dst = (int)atom_getintarg(1, argc, argv);
! n = (int)atom_getintarg(2, argc, argv);
! compare = (t_float)atom_getfloatarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_gt_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_gt_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] > compare)
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_gt_scalar-ERROR: list need 4 float arguments:");
! post(" source1_offset + destination_offset + number_of_samples_to_compare + compare_scalar");
! }
}
***************
*** 142,183 ****
static void *tab_gt_scalar_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_gt_scalar *x = (t_tab_gt_scalar *)pd_new(tab_gt_scalar_class);
! t_symbol *src1, *dst;
!
! if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! }
! else
! {
! post("tab_gt_scalar-ERROR: need 2 symbol arguments:");
! post(" source_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_gt_scalar_setup(void)
{
! tab_gt_scalar_class = class_new(gensym("tab_gt_scalar"), (t_newmethod)tab_gt_scalar_new, (t_method)tab_gt_scalar_free,
! sizeof(t_tab_gt_scalar), 0, A_GIMME, 0);
! class_addfloat(tab_gt_scalar_class, (t_method)tab_gt_scalar_float);
! class_addlist(tab_gt_scalar_class, (t_method)tab_gt_scalar_list);
! class_addmethod(tab_gt_scalar_class, (t_method)tab_gt_scalar_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_gt_scalar_class, (t_method)tab_gt_scalar_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_gt_scalar_class, (t_method)tab_gt_scalar_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_gt_scalar_class, gensym("iemhelp2/tab_gt_scalar-help"));
}
--- 132,173 ----
static void *tab_gt_scalar_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_gt_scalar *x = (t_tab_gt_scalar *)pd_new(tab_gt_scalar_class);
! t_symbol *src1, *dst;
!
! if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! }
! else
! {
! post("tab_gt_scalar-ERROR: need 2 symbol arguments:");
! post(" source_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_gt_scalar_setup(void)
{
! tab_gt_scalar_class = class_new(gensym("tab_gt_scalar"), (t_newmethod)tab_gt_scalar_new, (t_method)tab_gt_scalar_free,
! sizeof(t_tab_gt_scalar), 0, A_GIMME, 0);
! class_addfloat(tab_gt_scalar_class, (t_method)tab_gt_scalar_float);
! class_addlist(tab_gt_scalar_class, (t_method)tab_gt_scalar_list);
! class_addmethod(tab_gt_scalar_class, (t_method)tab_gt_scalar_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_gt_scalar_class, (t_method)tab_gt_scalar_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_gt_scalar_class, (t_method)tab_gt_scalar_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_gt_scalar_class, gensym("iemhelp2/tab_gt_scalar-help"));
}
Index: tab_rifft.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_rifft.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_rifft.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_rifft.c 10 Nov 2006 17:15:48 -0000 1.2
***************
*** 4,19 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
#include <math.h>
- #include <stdio.h>
- #include <string.h>
--- 4,11 ----
***************
*** 22,41 ****
typedef struct _tab_rifft
{
! t_object x_obj;
! int x_size_src_re;
! int x_size_src_im;
! int x_size_dst;
! int x_offset_src_re;
! int x_offset_src_im;
! int x_offset_dst;
! int x_fftsize;
! float *x_beg_mem_src_re;
! float *x_beg_mem_src_im;
! float *x_beg_mem_dst_re;
! float *x_beg_mem_dst_im;
! TAB_COMPLEX *x_sin_cos;
! t_symbol *x_sym_src_re;
! t_symbol *x_sym_src_im;
! t_symbol *x_sym_dst;
} t_tab_rifft;
--- 14,33 ----
typedef struct _tab_rifft
{
! t_object x_obj;
! int x_size_src_re;
! int x_size_src_im;
! int x_size_dst;
! int x_offset_src_re;
! int x_offset_src_im;
! int x_offset_dst;
! int x_fftsize;
! t_float *x_beg_mem_src_re;
! t_float *x_beg_mem_src_im;
! t_float *x_beg_mem_dst_re;
! t_float *x_beg_mem_dst_im;
! TAB_COMPLEX *x_sin_cos;
! t_symbol *x_sym_src_re;
! t_symbol *x_sym_src_im;
! t_symbol *x_sym_dst;
} t_tab_rifft;
***************
*** 44,406 ****
static void tab_rifft_init(t_tab_rifft *x)
{
! int i, fftsize = x->x_fftsize;
! float f, g;
! TAB_COMPLEX *sincos = x->x_sin_cos;
!
! g = 2.0f * 3.1415926538f / (float)fftsize;
! for(i=0; i<fftsize; i++)
! {
! f = g * (float)i;
! (*sincos).real = cos(f);
! (*sincos).imag = sin(f);/*IFFT*/
! sincos++;
! }
}
static void tab_rifft_ifftsize(t_tab_rifft *x, t_floatarg f)
{
! int i=1, fftsize = (int)f;
!
! if(fftsize < 8)
! fftsize = 8;
!
! while(i <= fftsize)
! i *= 2;
! i /= 2;
!
! if(i != x->x_fftsize)
! {
! x->x_sin_cos = (TAB_COMPLEX *)resizebytes(x->x_sin_cos, x->x_fftsize*sizeof(TAB_COMPLEX), i*sizeof(TAB_COMPLEX));
! x->x_beg_mem_dst_im = (float *)resizebytes(x->x_beg_mem_dst_im, x->x_fftsize*sizeof(float), i*sizeof(float));
! x->x_fftsize = i;
! }
! tab_rifft_init(x);
}
static void tab_rifft_dst(t_tab_rifft *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_rifft_src_re(t_tab_rifft *x, t_symbol *s)
{
! x->x_sym_src_re = s;
}
static void tab_rifft_src_im(t_tab_rifft *x, t_symbol *s)
{
! x->x_sym_src_im = s;
}
static void tab_rifft_bang(t_tab_rifft *x)
{
! int i, j, k;
! int ok_src_re, ok_src_im, ok_dst;
! int w_index, w_inc, i_inc, v_index;
! int fftsize = x->x_fftsize;
! int fs1 = fftsize - 1;
! int fs2 = fftsize / 2;
! TAB_COMPLEX w;
! TAB_COMPLEX *sincos = x->x_sin_cos;
! t_float *vec_src_re, *vec_src_im, *vec_dst_re, *vec_dst_im;
! t_float old1_re, old1_im, old2_re, old2_im, g;
!
! ok_src_re = iem_tab_check_arrays(gensym("tab_rifft"), x->x_sym_src_re, &x->x_beg_mem_src_re, &x->x_size_src_re, fftsize);
! ok_src_im = iem_tab_check_arrays(gensym("tab_rifft"), x->x_sym_src_im, &x->x_beg_mem_src_im, &x->x_size_src_im, fftsize);
! ok_dst = iem_tab_check_arrays(gensym("tab_rifft"), x->x_sym_dst, &x->x_beg_mem_dst_re, &x->x_size_dst, fftsize);
!
! if(ok_src_re && ok_src_im && ok_dst)
! {
! t_garray *a;
!
! vec_src_re=x->x_beg_mem_src_re;
! vec_src_im=x->x_beg_mem_src_im;
! vec_dst_re=x->x_beg_mem_dst_re;
! vec_dst_im=x->x_beg_mem_dst_im;
!
! for(j=0; j<fs2; j++)
! {
! vec_dst_re[j] = vec_src_re[j];
! vec_dst_im[j] = vec_src_im[j];
! }
! vec_dst_re[fs2] = vec_src_re[fs2];
! vec_dst_im[fs2] = 0.0f;
! for(k=1, j=fftsize-1; k<fs2; k++, j--)
! {
! vec_dst_re[j] = vec_src_re[k];
! vec_dst_im[j] = -vec_src_im[k];
! }
!
! i_inc = fs2;
! w_inc = 1;
! for(i=1; i<fftsize; i<<=1)
! {
! v_index = 0;
! for(j=0; j<i; j++)
! {
! w_index = 0;
! for(k=0; k<i_inc; k++)
! {
! old1_re = vec_dst_re[v_index];
! old1_im = vec_dst_im[v_index];
! old2_re = vec_dst_re[v_index+i_inc];
! old2_im = vec_dst_im[v_index+i_inc];
! w = sincos[w_index];
! vec_dst_re[v_index+i_inc] = (old1_re - old2_re)*w.real - (old1_im - old2_im)*w.imag;
! vec_dst_im[v_index+i_inc] = (old1_im - old2_im)*w.real + (old1_re - old2_re)*w.imag;
! vec_dst_re[v_index] = old1_re + old2_re;
! vec_dst_im[v_index] = old1_im + old2_im;
! w_index += w_inc;
! v_index++;
! }
! v_index += i_inc;
! }
! w_inc <<= 1;
! i_inc >>= 1;
! }
!
! j = 0;
! for(i=1;i<fs1;i++)
! {
! k = fs2;
! while(k <= j)
! {
! j = j - k;
! k >>= 1;
! }
! j = j + k;
! if(i < j)
! {
! old1_re = vec_dst_re[j];
! old1_im = vec_dst_im[j];
! vec_dst_re[j] = vec_dst_re[i];
! vec_dst_im[j] = vec_dst_im[i];
! vec_dst_re[i] = old1_re;
! vec_dst_im[i] = old1_im;
! }
! }
!
! // g = 2.0f / (float)fftsize;
! /*
! ein fehler tritt auf beim 0.sample, hier sollte nur mal 1.0 multipliziert werden
! wenn gelten soll : Energie im zeitfenster == Energie im Frequenz-dichte-fenster
!
! g = 1.0f;
! for(i = 0; i < fs2; i++)
! {
! vec_dst_re[i] *= g;
! vec_dst_im[i] *= g;
! }
! */
!
! g = 1.0f / (float)fftsize;
! for(i = 0; i < fftsize; i++)
! {
! vec_dst_re[i] *= 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_rifft_list(t_tab_rifft *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src_re, beg_src_im, beg_dst;
! int i, j, k;
! int ok_src_re, ok_src_im, ok_dst;
! int w_index, w_inc, i_inc, v_index;
! int fftsize = x->x_fftsize;
! int fs1 = fftsize - 1;
! int fs2 = fftsize / 2;
! TAB_COMPLEX w;
! TAB_COMPLEX *sincos = x->x_sin_cos;
! t_float *vec_src_re, *vec_src_im, *vec_dst_re, *vec_dst_im;
! t_float old1_re, old1_im, old2_re, old2_im, g;
!
! if((argc >= 3) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2))
! {
! beg_src_re = (int)atom_getintarg(0, argc, argv);
! beg_src_im = (int)atom_getintarg(1, argc, argv);
! beg_dst = (int)atom_getintarg(2, argc, argv);
! if(beg_src_re < 0)
! beg_src_re = 0;
! if(beg_src_im < 0)
! beg_src_im = 0;
! if(beg_dst < 0)
! beg_dst = 0;
!
! ok_src_re = iem_tab_check_arrays(gensym("tab_rifft"), x->x_sym_src_re, &x->x_beg_mem_src_re, &x->x_size_src_re, beg_src_re+fftsize);
! ok_src_im = iem_tab_check_arrays(gensym("tab_rifft"), x->x_sym_src_im, &x->x_beg_mem_src_im, &x->x_size_src_im, beg_src_im+fftsize);
! ok_dst = iem_tab_check_arrays(gensym("tab_rifft"), x->x_sym_dst, &x->x_beg_mem_dst_re, &x->x_size_dst, beg_dst+fftsize);
!
! if(ok_src_re && ok_src_im && ok_dst)
! {
! t_garray *a;
!
! vec_src_re=x->x_beg_mem_src_re + beg_src_re;
! vec_src_im=x->x_beg_mem_src_im + beg_src_im;
! vec_dst_re=x->x_beg_mem_dst_re + beg_dst;
! vec_dst_im=x->x_beg_mem_dst_im;
!
! for(j=0; j<fs2; j++)
! {
! vec_dst_re[j] = vec_src_re[j];
! vec_dst_im[j] = vec_src_im[j];
! }
! vec_dst_re[fs2] = vec_src_re[fs2];
! vec_dst_im[fs2] = 0.0f;
! for(k=1, j=fftsize-1; k<fs2; k++, j--)
! {
! vec_dst_re[j] = vec_src_re[k];
! vec_dst_im[j] = -vec_src_im[k];
! }
!
! i_inc = fs2;
! w_inc = 1;
! for(i=1; i<fftsize; i<<=1)
! {
! v_index = 0;
! for(j=0; j<i; j++)
! {
! w_index = 0;
! for(k=0; k<i_inc; k++)
! {
! old1_re = vec_dst_re[v_index];
! old1_im = vec_dst_im[v_index];
! old2_re = vec_dst_re[v_index+i_inc];
! old2_im = vec_dst_im[v_index+i_inc];
! w = sincos[w_index];
! vec_dst_re[v_index+i_inc] = (old1_re - old2_re)*w.real - (old1_im - old2_im)*w.imag;
! vec_dst_im[v_index+i_inc] = (old1_im - old2_im)*w.real + (old1_re - old2_re)*w.imag;
! vec_dst_re[v_index] = old1_re + old2_re;
! vec_dst_im[v_index] = old1_im + old2_im;
! w_index += w_inc;
! v_index++;
! }
! v_index += i_inc;
! }
! w_inc <<= 1;
! i_inc >>= 1;
! }
!
! j = 0;
! for(i=1;i<fs1;i++)
! {
! k = fs2;
! while(k <= j)
! {
! j = j - k;
! k >>= 1;
! }
! j = j + k;
! if(i < j)
! {
! old1_re = vec_dst_re[j];
! old1_im = vec_dst_im[j];
! vec_dst_re[j] = vec_dst_re[i];
! vec_dst_im[j] = vec_dst_im[i];
! vec_dst_re[i] = old1_re;
! vec_dst_im[i] = old1_im;
! }
! }
!
! // g = 2.0f / (float)fftsize;
! /*
! ein fehler tritt auf beim 0.sample, hier sollte nur mal 1.0 multipliziert werden
! wenn gelten soll : Energie im zeitfenster == Energie im Frequenz-dichte-fenster
!
! g = 1.0f;
! for(i = 0; i < fs2; i++)
! {
! vec_src_re[i] *= g;
! vec_src_im[i] *= g;
! }
! */
!
! g = 1.0f / (float)fftsize;
! for(i = 0; i < fftsize; i++)
! {
! vec_dst_re[i] *= 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_rifft-ERROR: list need 3 float arguments:");
! post(" source_real_offset + source_imag_offset + destination_offset");
! }
}
static void tab_rifft_free(t_tab_rifft *x)
{
! freebytes(x->x_sin_cos, x->x_fftsize * sizeof(TAB_COMPLEX));
! freebytes(x->x_beg_mem_dst_im, x->x_fftsize * sizeof(float));
}
static void *tab_rifft_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_rifft *x = (t_tab_rifft *)pd_new(tab_rifft_class);
! t_symbol *src_re, *src_im, *dst;
! int fftsize, i=1;
!
! if((argc >= 4) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! src_re = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src_im = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! fftsize = (int)atom_getintarg(3, argc, argv);
! }
! else
! {
! post("tab_rifft-ERROR: need 3 symbols + 1 float arguments:");
! post(" source_real_array_name + source_imag_array_name + destination_array_name + IFFT-size");
! return(0);
! }
!
! if(fftsize < 8)
! fftsize = 8;
!
! while(i <= fftsize)
! i *= 2;
! i /= 2;
! fftsize = i;
!
! x->x_fftsize = fftsize;
! x->x_sym_src_re = src_re;
! x->x_sym_src_im = src_im;
! x->x_sym_dst = dst;
! x->x_sin_cos = (TAB_COMPLEX *)getbytes(x->x_fftsize * sizeof(TAB_COMPLEX));
! x->x_beg_mem_dst_im = (float *)getbytes(x->x_fftsize * sizeof(float));
! tab_rifft_init(x);
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_rifft_setup(void)
{
! tab_rifft_class = class_new(gensym("tab_rifft"), (t_newmethod)tab_rifft_new, (t_method)tab_rifft_free,
! sizeof(t_tab_rifft), 0, A_GIMME, 0);
! class_addbang(tab_rifft_class, (t_method)tab_rifft_bang);
! class_addlist(tab_rifft_class, (t_method)tab_rifft_list);
! class_addmethod(tab_rifft_class, (t_method)tab_rifft_ifftsize, gensym("ifftsize"), A_DEFFLOAT, 0);
! class_addmethod(tab_rifft_class, (t_method)tab_rifft_src_re, gensym("src_re"), A_DEFSYMBOL, 0);
! class_addmethod(tab_rifft_class, (t_method)tab_rifft_src_im, gensym("src_im"), A_DEFSYMBOL, 0);
! class_addmethod(tab_rifft_class, (t_method)tab_rifft_src_re, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_rifft_class, (t_method)tab_rifft_src_im, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_rifft_class, (t_method)tab_rifft_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_addmethod(tab_rifft_class, (t_method)tab_rifft_dst, gensym("dst1"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_rifft_class, gensym("iemhelp2/tab_rifft-help"));
}
--- 36,398 ----
static void tab_rifft_init(t_tab_rifft *x)
{
! int i, fftsize = x->x_fftsize;
! t_float f, g;
! TAB_COMPLEX *sincos = x->x_sin_cos;
!
! g = 2.0f * 3.1415926538f / (t_float)fftsize;
! for(i=0; i<fftsize; i++)
! {
! f = g * (t_float)i;
! (*sincos).real = cos(f);
! (*sincos).imag = sin(f);/*IFFT*/
! sincos++;
! }
}
static void tab_rifft_ifftsize(t_tab_rifft *x, t_floatarg f)
{
! int i=1, fftsize = (int)f;
!
! if(fftsize < 8)
! fftsize = 8;
!
! while(i <= fftsize)
! i *= 2;
! i /= 2;
!
! if(i != x->x_fftsize)
! {
! x->x_sin_cos = (TAB_COMPLEX *)resizebytes(x->x_sin_cos, x->x_fftsize*sizeof(TAB_COMPLEX), i*sizeof(TAB_COMPLEX));
! x->x_beg_mem_dst_im = (t_float *)resizebytes(x->x_beg_mem_dst_im, x->x_fftsize*sizeof(t_float), i*sizeof(t_float));
! x->x_fftsize = i;
! }
! tab_rifft_init(x);
}
static void tab_rifft_dst(t_tab_rifft *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_rifft_src_re(t_tab_rifft *x, t_symbol *s)
{
! x->x_sym_src_re = s;
}
static void tab_rifft_src_im(t_tab_rifft *x, t_symbol *s)
{
! x->x_sym_src_im = s;
}
static void tab_rifft_bang(t_tab_rifft *x)
{
! int i, j, k;
! int ok_src_re, ok_src_im, ok_dst;
! int w_index, w_inc, i_inc, v_index;
! int fftsize = x->x_fftsize;
! int fs1 = fftsize - 1;
! int fs2 = fftsize / 2;
! TAB_COMPLEX w;
! TAB_COMPLEX *sincos = x->x_sin_cos;
! t_float *vec_src_re, *vec_src_im, *vec_dst_re, *vec_dst_im;
! t_float old1_re, old1_im, old2_re, old2_im, g;
!
! ok_src_re = iem_tab_check_arrays(gensym("tab_rifft"), x->x_sym_src_re, &x->x_beg_mem_src_re, &x->x_size_src_re, fftsize);
! ok_src_im = iem_tab_check_arrays(gensym("tab_rifft"), x->x_sym_src_im, &x->x_beg_mem_src_im, &x->x_size_src_im, fftsize);
! ok_dst = iem_tab_check_arrays(gensym("tab_rifft"), x->x_sym_dst, &x->x_beg_mem_dst_re, &x->x_size_dst, fftsize);
!
! if(ok_src_re && ok_src_im && ok_dst)
! {
! t_garray *a;
!
! vec_src_re=x->x_beg_mem_src_re;
! vec_src_im=x->x_beg_mem_src_im;
! vec_dst_re=x->x_beg_mem_dst_re;
! vec_dst_im=x->x_beg_mem_dst_im;
!
! for(j=0; j<fs2; j++)
! {
! vec_dst_re[j] = vec_src_re[j];
! vec_dst_im[j] = vec_src_im[j];
! }
! vec_dst_re[fs2] = vec_src_re[fs2];
! vec_dst_im[fs2] = 0.0f;
! for(k=1, j=fftsize-1; k<fs2; k++, j--)
! {
! vec_dst_re[j] = vec_src_re[k];
! vec_dst_im[j] = -vec_src_im[k];
! }
!
! i_inc = fs2;
! w_inc = 1;
! for(i=1; i<fftsize; i<<=1)
! {
! v_index = 0;
! for(j=0; j<i; j++)
! {
! w_index = 0;
! for(k=0; k<i_inc; k++)
! {
! old1_re = vec_dst_re[v_index];
! old1_im = vec_dst_im[v_index];
! old2_re = vec_dst_re[v_index+i_inc];
! old2_im = vec_dst_im[v_index+i_inc];
! w = sincos[w_index];
! vec_dst_re[v_index+i_inc] = (old1_re - old2_re)*w.real - (old1_im - old2_im)*w.imag;
! vec_dst_im[v_index+i_inc] = (old1_im - old2_im)*w.real + (old1_re - old2_re)*w.imag;
! vec_dst_re[v_index] = old1_re + old2_re;
! vec_dst_im[v_index] = old1_im + old2_im;
! w_index += w_inc;
! v_index++;
! }
! v_index += i_inc;
! }
! w_inc <<= 1;
! i_inc >>= 1;
! }
!
! j = 0;
! for(i=1;i<fs1;i++)
! {
! k = fs2;
! while(k <= j)
! {
! j = j - k;
! k >>= 1;
! }
! j = j + k;
! if(i < j)
! {
! old1_re = vec_dst_re[j];
! old1_im = vec_dst_im[j];
! vec_dst_re[j] = vec_dst_re[i];
! vec_dst_im[j] = vec_dst_im[i];
! vec_dst_re[i] = old1_re;
! vec_dst_im[i] = old1_im;
! }
! }
!
! // g = 2.0f / (t_float)fftsize;
! /*
! ein fehler tritt auf beim 0.sample, hier sollte nur mal 1.0 multipliziert werden
! wenn gelten soll : Energie im zeitfenster == Energie im Frequenz-dichte-fenster
!
! g = 1.0f;
! for(i = 0; i < fs2; i++)
! {
! vec_dst_re[i] *= g;
! vec_dst_im[i] *= g;
! }
! */
!
! g = 1.0f / (t_float)fftsize;
! for(i = 0; i < fftsize; i++)
! {
! vec_dst_re[i] *= 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_rifft_list(t_tab_rifft *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src_re, beg_src_im, beg_dst;
! int i, j, k;
! int ok_src_re, ok_src_im, ok_dst;
! int w_index, w_inc, i_inc, v_index;
! int fftsize = x->x_fftsize;
! int fs1 = fftsize - 1;
! int fs2 = fftsize / 2;
! TAB_COMPLEX w;
! TAB_COMPLEX *sincos = x->x_sin_cos;
! t_float *vec_src_re, *vec_src_im, *vec_dst_re, *vec_dst_im;
! t_float old1_re, old1_im, old2_re, old2_im, g;
!
! if((argc >= 3) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2))
! {
! beg_src_re = (int)atom_getintarg(0, argc, argv);
! beg_src_im = (int)atom_getintarg(1, argc, argv);
! beg_dst = (int)atom_getintarg(2, argc, argv);
! if(beg_src_re < 0)
! beg_src_re = 0;
! if(beg_src_im < 0)
! beg_src_im = 0;
! if(beg_dst < 0)
! beg_dst = 0;
!
! ok_src_re = iem_tab_check_arrays(gensym("tab_rifft"), x->x_sym_src_re, &x->x_beg_mem_src_re, &x->x_size_src_re, beg_src_re+fftsize);
! ok_src_im = iem_tab_check_arrays(gensym("tab_rifft"), x->x_sym_src_im, &x->x_beg_mem_src_im, &x->x_size_src_im, beg_src_im+fftsize);
! ok_dst = iem_tab_check_arrays(gensym("tab_rifft"), x->x_sym_dst, &x->x_beg_mem_dst_re, &x->x_size_dst, beg_dst+fftsize);
!
! if(ok_src_re && ok_src_im && ok_dst)
! {
! t_garray *a;
!
! vec_src_re=x->x_beg_mem_src_re + beg_src_re;
! vec_src_im=x->x_beg_mem_src_im + beg_src_im;
! vec_dst_re=x->x_beg_mem_dst_re + beg_dst;
! vec_dst_im=x->x_beg_mem_dst_im;
!
! for(j=0; j<fs2; j++)
! {
! vec_dst_re[j] = vec_src_re[j];
! vec_dst_im[j] = vec_src_im[j];
! }
! vec_dst_re[fs2] = vec_src_re[fs2];
! vec_dst_im[fs2] = 0.0f;
! for(k=1, j=fftsize-1; k<fs2; k++, j--)
! {
! vec_dst_re[j] = vec_src_re[k];
! vec_dst_im[j] = -vec_src_im[k];
! }
!
! i_inc = fs2;
! w_inc = 1;
! for(i=1; i<fftsize; i<<=1)
! {
! v_index = 0;
! for(j=0; j<i; j++)
! {
! w_index = 0;
! for(k=0; k<i_inc; k++)
! {
! old1_re = vec_dst_re[v_index];
! old1_im = vec_dst_im[v_index];
! old2_re = vec_dst_re[v_index+i_inc];
! old2_im = vec_dst_im[v_index+i_inc];
! w = sincos[w_index];
! vec_dst_re[v_index+i_inc] = (old1_re - old2_re)*w.real - (old1_im - old2_im)*w.imag;
! vec_dst_im[v_index+i_inc] = (old1_im - old2_im)*w.real + (old1_re - old2_re)*w.imag;
! vec_dst_re[v_index] = old1_re + old2_re;
! vec_dst_im[v_index] = old1_im + old2_im;
! w_index += w_inc;
! v_index++;
! }
! v_index += i_inc;
! }
! w_inc <<= 1;
! i_inc >>= 1;
! }
!
! j = 0;
! for(i=1;i<fs1;i++)
! {
! k = fs2;
! while(k <= j)
! {
! j = j - k;
! k >>= 1;
! }
! j = j + k;
! if(i < j)
! {
! old1_re = vec_dst_re[j];
! old1_im = vec_dst_im[j];
! vec_dst_re[j] = vec_dst_re[i];
! vec_dst_im[j] = vec_dst_im[i];
! vec_dst_re[i] = old1_re;
! vec_dst_im[i] = old1_im;
! }
! }
!
! // g = 2.0f / (t_float)fftsize;
! /*
! ein fehler tritt auf beim 0.sample, hier sollte nur mal 1.0 multipliziert werden
! wenn gelten soll : Energie im zeitfenster == Energie im Frequenz-dichte-fenster
!
! g = 1.0f;
! for(i = 0; i < fs2; i++)
! {
! vec_src_re[i] *= g;
! vec_src_im[i] *= g;
! }
! */
!
! g = 1.0f / (t_float)fftsize;
! for(i = 0; i < fftsize; i++)
! {
! vec_dst_re[i] *= 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_rifft-ERROR: list need 3 float arguments:");
! post(" source_real_offset + source_imag_offset + destination_offset");
! }
}
static void tab_rifft_free(t_tab_rifft *x)
{
! freebytes(x->x_sin_cos, x->x_fftsize * sizeof(TAB_COMPLEX));
! freebytes(x->x_beg_mem_dst_im, x->x_fftsize * sizeof(t_float));
}
static void *tab_rifft_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_rifft *x = (t_tab_rifft *)pd_new(tab_rifft_class);
! t_symbol *src_re, *src_im, *dst;
! int fftsize, i=1;
!
! if((argc >= 4) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! src_re = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src_im = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! fftsize = (int)atom_getintarg(3, argc, argv);
! }
! else
! {
! post("tab_rifft-ERROR: need 3 symbols + 1 float arguments:");
! post(" source_real_array_name + source_imag_array_name + destination_array_name + IFFT-size");
! return(0);
! }
!
! if(fftsize < 8)
! fftsize = 8;
!
! while(i <= fftsize)
! i *= 2;
! i /= 2;
! fftsize = i;
!
! x->x_fftsize = fftsize;
! x->x_sym_src_re = src_re;
! x->x_sym_src_im = src_im;
! x->x_sym_dst = dst;
! x->x_sin_cos = (TAB_COMPLEX *)getbytes(x->x_fftsize * sizeof(TAB_COMPLEX));
! x->x_beg_mem_dst_im = (t_float *)getbytes(x->x_fftsize * sizeof(t_float));
! tab_rifft_init(x);
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_rifft_setup(void)
{
! tab_rifft_class = class_new(gensym("tab_rifft"), (t_newmethod)tab_rifft_new, (t_method)tab_rifft_free,
! sizeof(t_tab_rifft), 0, A_GIMME, 0);
! class_addbang(tab_rifft_class, (t_method)tab_rifft_bang);
! class_addlist(tab_rifft_class, (t_method)tab_rifft_list);
! class_addmethod(tab_rifft_class, (t_method)tab_rifft_ifftsize, gensym("ifftsize"), A_DEFFLOAT, 0);
! class_addmethod(tab_rifft_class, (t_method)tab_rifft_src_re, gensym("src_re"), A_DEFSYMBOL, 0);
! class_addmethod(tab_rifft_class, (t_method)tab_rifft_src_im, gensym("src_im"), A_DEFSYMBOL, 0);
! class_addmethod(tab_rifft_class, (t_method)tab_rifft_src_re, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_rifft_class, (t_method)tab_rifft_src_im, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_rifft_class, (t_method)tab_rifft_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_addmethod(tab_rifft_class, (t_method)tab_rifft_dst, gensym("dst1"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_rifft_class, gensym("iemhelp2/tab_rifft-help"));
}
Index: tab_abs.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_abs.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_abs.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_abs.c 10 Nov 2006 17:15:47 -0000 1.2
***************
*** 4,12 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
#include "m_pd.h"
--- 4,7 ----
***************
*** 14,19 ****
#include "iem_tab.h"
#include <math.h>
- #include <stdio.h>
- #include <string.h>
--- 9,12 ----
***************
*** 22,34 ****
typedef struct _tab_abs
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! float *x_beg_mem_src1;
! float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_abs;
--- 15,27 ----
typedef struct _tab_abs
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_abs;
***************
*** 37,124 ****
static void tab_abs_src(t_tab_abs *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_abs_dst(t_tab_abs *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_abs_bang(t_tab_abs *x)
{
! int i, n;
! int ok_src, ok_dst;
! t_float *vec_src, *vec_dst;
!
! ok_src = iem_tab_check_arrays(gensym("tab_abs"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_abs"), 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++)
! vec_dst[i] = fabs(vec_src[i]);
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_abs_list(t_tab_abs *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src, beg_dst;
! int i, n;
! int ok_src, ok_dst;
! t_float *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_abs"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_abs"), 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++)
! vec_dst[i] = fabs(vec_src[i]);
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_abs-ERROR: list need 3 float arguments:");
! post(" source_offset + destination_offset + number_of_samples_to_abs");
! }
}
--- 30,117 ----
static void tab_abs_src(t_tab_abs *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_abs_dst(t_tab_abs *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_abs_bang(t_tab_abs *x)
{
! int i, n;
! int ok_src, ok_dst;
! t_float *vec_src, *vec_dst;
!
! ok_src = iem_tab_check_arrays(gensym("tab_abs"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_abs"), 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++)
! vec_dst[i] = fabs(vec_src[i]);
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_abs_list(t_tab_abs *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src, beg_dst;
! int i, n;
! int ok_src, ok_dst;
! t_float *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_abs"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_abs"), 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++)
! vec_dst[i] = fabs(vec_src[i]);
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_abs-ERROR: list need 3 float arguments:");
! post(" source_offset + destination_offset + number_of_samples_to_abs");
! }
}
***************
*** 129,170 ****
static void *tab_abs_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_abs *x = (t_tab_abs *)pd_new(tab_abs_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_abs-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_abs_setup(void)
{
! tab_abs_class = class_new(gensym("tab_abs"), (t_newmethod)tab_abs_new, (t_method)tab_abs_free,
! sizeof(t_tab_abs), 0, A_GIMME, 0);
! class_addbang(tab_abs_class, (t_method)tab_abs_bang);
! class_addlist(tab_abs_class, (t_method)tab_abs_list);
! class_addmethod(tab_abs_class, (t_method)tab_abs_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_abs_class, (t_method)tab_abs_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_abs_class, (t_method)tab_abs_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_abs_class, gensym("iemhelp2/tab_abs-help"));
}
--- 122,163 ----
static void *tab_abs_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_abs *x = (t_tab_abs *)pd_new(tab_abs_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_abs-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_abs_setup(void)
{
! tab_abs_class = class_new(gensym("tab_abs"), (t_newmethod)tab_abs_new, (t_method)tab_abs_free,
! sizeof(t_tab_abs), 0, A_GIMME, 0);
! class_addbang(tab_abs_class, (t_method)tab_abs_bang);
! class_addlist(tab_abs_class, (t_method)tab_abs_list);
! class_addmethod(tab_abs_class, (t_method)tab_abs_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_abs_class, (t_method)tab_abs_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_abs_class, (t_method)tab_abs_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_abs_class, gensym("iemhelp2/tab_abs-help"));
}
Index: tab_ne.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_ne.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_ne.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_ne.c 10 Nov 2006 17:15:48 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_ne ------------------------------ */
--- 4,11 ----
***************
*** 22,38 ****
typedef struct _tab_ne
{
! t_object x_obj;
! int x_size_src1;
! int x_size_src2;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_src2;
! int x_offset_dst;
! float *x_beg_mem_src1;
! float *x_beg_mem_src2;
! float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_scr2;
! t_symbol *x_sym_dst;
} t_tab_ne;
--- 13,29 ----
typedef struct _tab_ne
{
! t_object x_obj;
! int x_size_src1;
! int x_size_src2;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_src2;
! int x_offset_dst;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_src2;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_scr2;
! t_symbol *x_sym_dst;
} t_tab_ne;
***************
*** 41,154 ****
static void tab_ne_src1(t_tab_ne *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_ne_src2(t_tab_ne *x, t_symbol *s)
{
! x->x_sym_scr2 = s;
}
static void tab_ne_dst(t_tab_ne *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_ne_bang(t_tab_ne *x)
{
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_ne"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_src2 = iem_tab_check_arrays(gensym("tab_ne"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_ne"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
! if(x->x_size_src2 < n)
! n = x->x_size_src2;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] != vec_src2[i])
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_ne_list(t_tab_ne *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_src2, beg_dst;
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_src2 = (int)atom_getintarg(1, argc, argv);
! beg_dst = (int)atom_getintarg(2, argc, argv);
! n = (int)atom_getintarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_src2 < 0)
! beg_src2 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_ne"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_src2 = iem_tab_check_arrays(gensym("tab_ne"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, beg_src2+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_ne"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_src2 = x->x_beg_mem_src2 + beg_src2;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] != vec_src2[i])
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_ne-ERROR: list need 4 float arguments:");
! post(" source1_offset + source2_offset + destination_offset + number_of_samples_to_compare");
! }
}
--- 32,145 ----
static void tab_ne_src1(t_tab_ne *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_ne_src2(t_tab_ne *x, t_symbol *s)
{
! x->x_sym_scr2 = s;
}
static void tab_ne_dst(t_tab_ne *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_ne_bang(t_tab_ne *x)
{
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_ne"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_src2 = iem_tab_check_arrays(gensym("tab_ne"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_ne"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
! if(x->x_size_src2 < n)
! n = x->x_size_src2;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] != vec_src2[i])
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_ne_list(t_tab_ne *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_src2, beg_dst;
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_src2 = (int)atom_getintarg(1, argc, argv);
! beg_dst = (int)atom_getintarg(2, argc, argv);
! n = (int)atom_getintarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_src2 < 0)
! beg_src2 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_ne"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_src2 = iem_tab_check_arrays(gensym("tab_ne"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, beg_src2+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_ne"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_src2 = x->x_beg_mem_src2 + beg_src2;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] != vec_src2[i])
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_ne-ERROR: list need 4 float arguments:");
! post(" source1_offset + source2_offset + destination_offset + number_of_samples_to_compare");
! }
}
***************
*** 159,206 ****
static void *tab_ne_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_ne *x = (t_tab_ne *)pd_new(tab_ne_class);
! t_symbol *src1, *src2, *dst;
! t_float time;
!
! if((argc >= 3) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! }
! else if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else
! {
! post("tab_ne-ERROR: need 3 symbols arguments:");
! post(" source1_array_name + source2_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_scr2 = src2;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_ne_setup(void)
{
! tab_ne_class = class_new(gensym("tab_ne"), (t_newmethod)tab_ne_new, (t_method)tab_ne_free,
! sizeof(t_tab_ne), 0, A_GIMME, 0);
! class_addbang(tab_ne_class, (t_method)tab_ne_bang);
! class_addlist(tab_ne_class, (t_method)tab_ne_list);
! class_addmethod(tab_ne_class, (t_method)tab_ne_src1, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ne_class, (t_method)tab_ne_src2, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ne_class, (t_method)tab_ne_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_ne_class, gensym("iemhelp2/tab_ne-help"));
}
--- 150,197 ----
static void *tab_ne_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_ne *x = (t_tab_ne *)pd_new(tab_ne_class);
! t_symbol *src1, *src2, *dst;
! t_float time;
!
! if((argc >= 3) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! }
! else if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else
! {
! post("tab_ne-ERROR: need 3 symbols arguments:");
! post(" source1_array_name + source2_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_scr2 = src2;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_ne_setup(void)
{
! tab_ne_class = class_new(gensym("tab_ne"), (t_newmethod)tab_ne_new, (t_method)tab_ne_free,
! sizeof(t_tab_ne), 0, A_GIMME, 0);
! class_addbang(tab_ne_class, (t_method)tab_ne_bang);
! class_addlist(tab_ne_class, (t_method)tab_ne_list);
! class_addmethod(tab_ne_class, (t_method)tab_ne_src1, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ne_class, (t_method)tab_ne_src2, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ne_class, (t_method)tab_ne_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_ne_class, gensym("iemhelp2/tab_ne-help"));
}
Index: tab_eq_scalar.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_eq_scalar.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_eq_scalar.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_eq_scalar.c 10 Nov 2006 17:15:47 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_eq_scalar ------------------------------ */
--- 4,10 ----
***************
*** 22,34 ****
typedef struct _tab_eq_scalar
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! float *x_beg_mem_src1;
! float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_eq_scalar;
--- 12,24 ----
typedef struct _tab_eq_scalar
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_eq_scalar;
***************
*** 37,136 ****
static void tab_eq_scalar_src(t_tab_eq_scalar *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_eq_scalar_float(t_tab_eq_scalar *x, t_floatarg compare)
{
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_eq_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_eq_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] == compare)
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_eq_scalar_dst(t_tab_eq_scalar *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_eq_scalar_list(t_tab_eq_scalar *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_dst;
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst, compare;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_dst = (int)atom_getintarg(1, argc, argv);
! n = (int)atom_getintarg(2, argc, argv);
! compare = (t_float)atom_getfloatarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_eq_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_eq_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] == compare)
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_eq_scalar-ERROR: list need 4 float arguments:");
! post(" source1_offset + destination_offset + number_of_samples_to_compare + compare_scalar");
}
}
--- 27,126 ----
static void tab_eq_scalar_src(t_tab_eq_scalar *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_eq_scalar_float(t_tab_eq_scalar *x, t_floatarg compare)
{
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_eq_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_eq_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] == compare)
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_eq_scalar_dst(t_tab_eq_scalar *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_eq_scalar_list(t_tab_eq_scalar *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_dst;
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst, compare;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_dst = (int)atom_getintarg(1, argc, argv);
! n = (int)atom_getintarg(2, argc, argv);
! compare = (t_float)atom_getfloatarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_eq_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_eq_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] == compare)
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_eq_scalar-ERROR: list need 4 float arguments:");
! post(" source1_offset + destination_offset + number_of_samples_to_compare + compare_scalar");
}
}
***************
*** 142,183 ****
static void *tab_eq_scalar_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_eq_scalar *x = (t_tab_eq_scalar *)pd_new(tab_eq_scalar_class);
! t_symbol *src1, *dst;
!
! if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! }
! else
! {
! post("tab_eq_scalar-ERROR: need 2 symbol arguments:");
! post(" source_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_eq_scalar_setup(void)
{
! tab_eq_scalar_class = class_new(gensym("tab_eq_scalar"), (t_newmethod)tab_eq_scalar_new, (t_method)tab_eq_scalar_free,
! sizeof(t_tab_eq_scalar), 0, A_GIMME, 0);
! class_addfloat(tab_eq_scalar_class, (t_method)tab_eq_scalar_float);
! class_addlist(tab_eq_scalar_class, (t_method)tab_eq_scalar_list);
! class_addmethod(tab_eq_scalar_class, (t_method)tab_eq_scalar_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_eq_scalar_class, (t_method)tab_eq_scalar_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_eq_scalar_class, (t_method)tab_eq_scalar_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_eq_scalar_class, gensym("iemhelp2/tab_eq_scalar-help"));
}
--- 132,173 ----
static void *tab_eq_scalar_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_eq_scalar *x = (t_tab_eq_scalar *)pd_new(tab_eq_scalar_class);
! t_symbol *src1, *dst;
!
! if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! }
! else
! {
! post("tab_eq_scalar-ERROR: need 2 symbol arguments:");
! post(" source_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_eq_scalar_setup(void)
{
! tab_eq_scalar_class = class_new(gensym("tab_eq_scalar"), (t_newmethod)tab_eq_scalar_new, (t_method)tab_eq_scalar_free,
! sizeof(t_tab_eq_scalar), 0, A_GIMME, 0);
! class_addfloat(tab_eq_scalar_class, (t_method)tab_eq_scalar_float);
! class_addlist(tab_eq_scalar_class, (t_method)tab_eq_scalar_list);
! class_addmethod(tab_eq_scalar_class, (t_method)tab_eq_scalar_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_eq_scalar_class, (t_method)tab_eq_scalar_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_eq_scalar_class, (t_method)tab_eq_scalar_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_eq_scalar_class, gensym("iemhelp2/tab_eq_scalar-help"));
}
Index: tab_cross_corr.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_cross_corr.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_cross_corr.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_cross_corr.c 10 Nov 2006 17:15:47 -0000 1.2
***************
*** 4,19 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
--- 4,10 ----
***************
*** 22,40 ****
typedef struct _tab_cross_corr
{
! t_object x_obj;
! int x_size_src1;
! int x_size_src2;
! int x_size_dst;
! int x_n;
! float *x_beg_mem_src1;
! float *x_beg_mem_src2;
! float *x_beg_mem_dst;
! float x_factor;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_scr2;
! t_symbol *x_sym_dst;
! float x_delay;
! int x_counter;
! void *x_clock;
} t_tab_cross_corr;
--- 13,31 ----
typedef struct _tab_cross_corr
{
! t_object x_obj;
! int x_size_src1;
! int x_size_src2;
! int x_size_dst;
! int x_n;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_src2;
! t_float *x_beg_mem_dst;
! t_float x_factor;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_scr2;
! t_symbol *x_sym_dst;
! t_float x_delay;
! int x_counter;
! void *x_clock;
} t_tab_cross_corr;
***************
*** 43,222 ****
static void tab_cross_corr_tick(t_tab_cross_corr *x)
{
! x->x_counter++;
! if(x->x_counter < x->x_n)
! {
! t_float *vec_src1, *vec_src2, *vec_dst, sum;
! int j, m;
!
! vec_src1 = x->x_beg_mem_src1 + x->x_counter;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst + x->x_counter;
! m = x->x_size_src2;
! sum = 0.0f;
! for(j=0; j<m; j++)
! {
! sum += vec_src1[j]*vec_src2[j];
! }
! vec_dst[0] = sum*x->x_factor;
! clock_delay(x->x_clock, x->x_delay);
! }
! else
! {
! t_garray *a;
!
! clock_unset(x->x_clock);
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
}
static void tab_cross_corr_time(t_tab_cross_corr *x, t_floatarg time)
{
! if(time < 0.0f)
! time = 0.0f;
!
! x->x_delay = time;
}
static void tab_cross_corr_factor(t_tab_cross_corr *x, t_floatarg factor)
{
! x->x_factor = factor;
}
static void tab_cross_corr_src1(t_tab_cross_corr *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_cross_corr_src2(t_tab_cross_corr *x, t_symbol *s)
{
! x->x_sym_scr2 = s;
}
static void tab_cross_corr_dst(t_tab_cross_corr *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_cross_corr_bang(t_tab_cross_corr *x)
{
! int i, j, m, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
! t_float sum, f;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_cross_corr"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_src2 = iem_tab_check_arrays(gensym("tab_cross_corr"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_cross_corr"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! if(x->x_size_src1 > x->x_size_src2)
! n = x->x_size_src1 - x->x_size_src2;
! else
! n = 0;
! if(n > x->x_size_dst)
! x->x_n = x->x_size_dst;
! else
! x->x_n = n;
! f = x->x_factor;
! if(n)
! {
! if(x->x_delay == 0.0f)
! {
! t_garray *a;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst;
! m = x->x_size_src2;
! for(i=0; i<n; i++)
! {
! sum = 0.0f;
! for(j=0; j<m; j++)
! {
! sum += vec_src1[i+j]*vec_src2[j];
! }
! vec_dst[i] = sum*f;
! }
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! else
! {
! x->x_counter = 0;
! vec_src1 = x->x_beg_mem_src1 + x->x_counter;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst + x->x_counter;
! m = x->x_size_src2;
! sum = 0.0f;
! for(j=0; j<m; j++)
! {
! sum += vec_src1[j]*vec_src2[j];
! }
! vec_dst[0] = sum*f;
!
! clock_delay(x->x_clock, x->x_delay);
! }
! }
! }
}
static void tab_cross_corr_free(t_tab_cross_corr *x)
{
! clock_free(x->x_clock);
}
static void *tab_cross_corr_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_cross_corr *x = (t_tab_cross_corr *)pd_new(tab_cross_corr_class);
! t_symbol *src1, *src2, *dst;
! t_float time, factor;
!
! if((argc >= 3) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2) &&
! IS_A_FLOAT(argv,3) &&
! IS_A_FLOAT(argv,4))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! factor = (t_float)atom_getfloatarg(3, argc, argv);
! time = (t_float)atom_getfloatarg(4, argc, argv);
! }
! else
! {
! post("tab_cross_corr-ERROR: need 3 symbol + 2 float arguments:");
! post(" source_reference_array_name + source_measure_array_name + destination_array_name + norm_factor + calculation-time-per-sample_ms");
! return(0);
! }
!
! if(time < 0.0f)
! time = 0.0f;
!
! x->x_delay = time;
! x->x_factor = factor;
! x->x_sym_scr1 = src1;
! x->x_sym_scr2 = src2;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! x->x_clock = clock_new(x, (t_method)tab_cross_corr_tick);
! return(x);
}
void tab_cross_corr_setup(void)
{
! tab_cross_corr_class = class_new(gensym("tab_cross_corr"), (t_newmethod)tab_cross_corr_new, (t_method)tab_cross_corr_free,
! sizeof(t_tab_cross_corr), 0, A_GIMME, 0);
! class_addbang(tab_cross_corr_class, (t_method)tab_cross_corr_bang);
! class_addmethod(tab_cross_corr_class, (t_method)tab_cross_corr_time, gensym("time"), A_DEFFLOAT, 0);
! class_addmethod(tab_cross_corr_class, (t_method)tab_cross_corr_factor, gensym("factor"), A_DEFFLOAT, 0);
! class_addmethod(tab_cross_corr_class, (t_method)tab_cross_corr_src2, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_cross_corr_class, (t_method)tab_cross_corr_src1, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_cross_corr_class, (t_method)tab_cross_corr_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_cross_corr_class, gensym("iemhelp2/tab_cross_corr-help"));
}
--- 34,213 ----
static void tab_cross_corr_tick(t_tab_cross_corr *x)
{
! x->x_counter++;
! if(x->x_counter < x->x_n)
! {
! t_float *vec_src1, *vec_src2, *vec_dst, sum;
! int j, m;
!
! vec_src1 = x->x_beg_mem_src1 + x->x_counter;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst + x->x_counter;
! m = x->x_size_src2;
! sum = 0.0f;
! for(j=0; j<m; j++)
! {
! sum += vec_src1[j]*vec_src2[j];
! }
! vec_dst[0] = sum*x->x_factor;
! clock_delay(x->x_clock, x->x_delay);
! }
! else
! {
! t_garray *a;
!
! clock_unset(x->x_clock);
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
}
static void tab_cross_corr_time(t_tab_cross_corr *x, t_floatarg time)
{
! if(time < 0.0f)
! time = 0.0f;
!
! x->x_delay = time;
}
static void tab_cross_corr_factor(t_tab_cross_corr *x, t_floatarg factor)
{
! x->x_factor = factor;
}
static void tab_cross_corr_src1(t_tab_cross_corr *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_cross_corr_src2(t_tab_cross_corr *x, t_symbol *s)
{
! x->x_sym_scr2 = s;
}
static void tab_cross_corr_dst(t_tab_cross_corr *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_cross_corr_bang(t_tab_cross_corr *x)
{
! int i, j, m, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
! t_float sum, f;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_cross_corr"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_src2 = iem_tab_check_arrays(gensym("tab_cross_corr"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_cross_corr"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! if(x->x_size_src1 > x->x_size_src2)
! n = x->x_size_src1 - x->x_size_src2;
! else
! n = 0;
! if(n > x->x_size_dst)
! x->x_n = x->x_size_dst;
! else
! x->x_n = n;
! f = x->x_factor;
! if(n)
! {
! if(x->x_delay == 0.0f)
! {
! t_garray *a;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst;
! m = x->x_size_src2;
! for(i=0; i<n; i++)
! {
! sum = 0.0f;
! for(j=0; j<m; j++)
! {
! sum += vec_src1[i+j]*vec_src2[j];
! }
! vec_dst[i] = sum*f;
! }
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! else
! {
! x->x_counter = 0;
! vec_src1 = x->x_beg_mem_src1 + x->x_counter;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst + x->x_counter;
! m = x->x_size_src2;
! sum = 0.0f;
! for(j=0; j<m; j++)
! {
! sum += vec_src1[j]*vec_src2[j];
! }
! vec_dst[0] = sum*f;
!
! clock_delay(x->x_clock, x->x_delay);
! }
! }
! }
}
static void tab_cross_corr_free(t_tab_cross_corr *x)
{
! clock_free(x->x_clock);
}
static void *tab_cross_corr_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_cross_corr *x = (t_tab_cross_corr *)pd_new(tab_cross_corr_class);
! t_symbol *src1, *src2, *dst;
! t_float time, factor;
!
! if((argc >= 3) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2) &&
! IS_A_FLOAT(argv,3) &&
! IS_A_FLOAT(argv,4))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! factor = (t_float)atom_getfloatarg(3, argc, argv);
! time = (t_float)atom_getfloatarg(4, argc, argv);
! }
! else
! {
! post("tab_cross_corr-ERROR: need 3 symbol + 2 float arguments:");
! post(" source_reference_array_name + source_measure_array_name + destination_array_name + norm_factor + calculation-time-per-sample_ms");
! return(0);
! }
!
! if(time < 0.0f)
! time = 0.0f;
!
! x->x_delay = time;
! x->x_factor = factor;
! x->x_sym_scr1 = src1;
! x->x_sym_scr2 = src2;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! x->x_clock = clock_new(x, (t_method)tab_cross_corr_tick);
! return(x);
}
void tab_cross_corr_setup(void)
{
! tab_cross_corr_class = class_new(gensym("tab_cross_corr"), (t_newmethod)tab_cross_corr_new, (t_method)tab_cross_corr_free,
! sizeof(t_tab_cross_corr), 0, A_GIMME, 0);
! class_addbang(tab_cross_corr_class, (t_method)tab_cross_corr_bang);
! class_addmethod(tab_cross_corr_class, (t_method)tab_cross_corr_time, gensym("time"), A_DEFFLOAT, 0);
! class_addmethod(tab_cross_corr_class, (t_method)tab_cross_corr_factor, gensym("factor"), A_DEFFLOAT, 0);
! class_addmethod(tab_cross_corr_class, (t_method)tab_cross_corr_src2, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_cross_corr_class, (t_method)tab_cross_corr_src1, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_cross_corr_class, (t_method)tab_cross_corr_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_cross_corr_class, gensym("iemhelp2/tab_cross_corr-help"));
}
Index: tab_le.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_le.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_le.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_le.c 10 Nov 2006 17:15:47 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_le ------------------------------ */
--- 4,10 ----
***************
*** 22,38 ****
typedef struct _tab_le
{
! t_object x_obj;
! int x_size_src1;
! int x_size_src2;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_src2;
! int x_offset_dst;
! float *x_beg_mem_src1;
! float *x_beg_mem_src2;
! float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_scr2;
! t_symbol *x_sym_dst;
} t_tab_le;
--- 12,28 ----
typedef struct _tab_le
{
! t_object x_obj;
! int x_size_src1;
! int x_size_src2;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_src2;
! int x_offset_dst;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_src2;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_scr2;
! t_symbol *x_sym_dst;
} t_tab_le;
***************
*** 41,154 ****
static void tab_le_src1(t_tab_le *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_le_src2(t_tab_le *x, t_symbol *s)
{
! x->x_sym_scr2 = s;
}
static void tab_le_dst(t_tab_le *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_le_bang(t_tab_le *x)
{
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_le"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_src2 = iem_tab_check_arrays(gensym("tab_le"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_le"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
! if(x->x_size_src2 < n)
! n = x->x_size_src2;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] <= vec_src2[i])
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_le_list(t_tab_le *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_src2, beg_dst;
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_src2 = (int)atom_getintarg(1, argc, argv);
! beg_dst = (int)atom_getintarg(2, argc, argv);
! n = (int)atom_getintarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_src2 < 0)
! beg_src2 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_le"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_src2 = iem_tab_check_arrays(gensym("tab_le"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, beg_src2+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_le"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_src2 = x->x_beg_mem_src2 + beg_src2;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] <= vec_src2[i])
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_le-ERROR: list need 4 float arguments:");
! post(" source1_offset + source2_offset + destination_offset + number_of_samples_to_compare");
! }
}
--- 31,144 ----
static void tab_le_src1(t_tab_le *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_le_src2(t_tab_le *x, t_symbol *s)
{
! x->x_sym_scr2 = s;
}
static void tab_le_dst(t_tab_le *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_le_bang(t_tab_le *x)
{
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_le"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_src2 = iem_tab_check_arrays(gensym("tab_le"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_le"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
! if(x->x_size_src2 < n)
! n = x->x_size_src2;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] <= vec_src2[i])
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_le_list(t_tab_le *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_src2, beg_dst;
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_src2 = (int)atom_getintarg(1, argc, argv);
! beg_dst = (int)atom_getintarg(2, argc, argv);
! n = (int)atom_getintarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_src2 < 0)
! beg_src2 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_le"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_src2 = iem_tab_check_arrays(gensym("tab_le"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, beg_src2+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_le"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_src2 = x->x_beg_mem_src2 + beg_src2;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] <= vec_src2[i])
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_le-ERROR: list need 4 float arguments:");
! post(" source1_offset + source2_offset + destination_offset + number_of_samples_to_compare");
! }
}
***************
*** 159,206 ****
static void *tab_le_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_le *x = (t_tab_le *)pd_new(tab_le_class);
! t_symbol *src1, *src2, *dst;
! t_float time;
!
! if((argc >= 3) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! }
! else if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else
! {
! post("tab_le-ERROR: need 3 symbols arguments:");
! post(" source1_array_name + source2_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_scr2 = src2;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_le_setup(void)
{
! tab_le_class = class_new(gensym("tab_le"), (t_newmethod)tab_le_new, (t_method)tab_le_free,
! sizeof(t_tab_le), 0, A_GIMME, 0);
! class_addbang(tab_le_class, (t_method)tab_le_bang);
! class_addlist(tab_le_class, (t_method)tab_le_list);
! class_addmethod(tab_le_class, (t_method)tab_le_src1, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_le_class, (t_method)tab_le_src2, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_le_class, (t_method)tab_le_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_le_class, gensym("iemhelp2/tab_le-help"));
}
--- 149,196 ----
static void *tab_le_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_le *x = (t_tab_le *)pd_new(tab_le_class);
! t_symbol *src1, *src2, *dst;
! t_float time;
!
! if((argc >= 3) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! }
! else if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else
! {
! post("tab_le-ERROR: need 3 symbols arguments:");
! post(" source1_array_name + source2_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_scr2 = src2;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_le_setup(void)
{
! tab_le_class = class_new(gensym("tab_le"), (t_newmethod)tab_le_new, (t_method)tab_le_free,
! sizeof(t_tab_le), 0, A_GIMME, 0);
! class_addbang(tab_le_class, (t_method)tab_le_bang);
! class_addlist(tab_le_class, (t_method)tab_le_list);
! class_addmethod(tab_le_class, (t_method)tab_le_src1, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_le_class, (t_method)tab_le_src2, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_le_class, (t_method)tab_le_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_le_class, gensym("iemhelp2/tab_le-help"));
}
Index: tab_const.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_const.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_const.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_const.c 10 Nov 2006 17:15:47 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_const ------------------------------ */
--- 4,10 ----
***************
*** 22,31 ****
typedef struct _tab_const
{
! t_object x_obj;
! int x_size_dst;
! int x_offset_dst;
! t_float x_const;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_dst;
} t_tab_const;
--- 12,21 ----
typedef struct _tab_const
{
! t_object x_obj;
! int x_size_dst;
! int x_offset_dst;
! t_float x_const;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_dst;
} t_tab_const;
***************
*** 34,132 ****
static void tab_const_dst(t_tab_const *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_const_bang(t_tab_const *x)
{
! int i, n;
! int ok_dst;
! t_float *vec_dst;
!
! ok_dst = iem_tab_check_arrays(gensym("tab_const"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_dst)
! {
! n = x->x_size_dst;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = 0.0f;
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_const_float(t_tab_const *x, t_floatarg c)
{
! int i, n;
! int ok_dst;
! t_float *vec_dst;
!
! ok_dst = iem_tab_check_arrays(gensym("tab_const"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_dst)
! {
! n = x->x_size_dst;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = c;
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_const_list(t_tab_const *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_dst;
! int i, n;
! int ok_dst;
! t_float *vec_dst, c;
!
! if((argc >= 3) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2))
! {
! beg_dst = (int)atom_getintarg(0, argc, argv);
! n = (int)atom_getintarg(1, argc, argv);
! c = (t_float)atom_getfloatarg(2, argc, argv);
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_dst = iem_tab_check_arrays(gensym("tab_const"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_dst)
! {
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = c;
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_const-ERROR: list need 3 float arguments:");
! post(" destination_offset + number_of_samples_to_copy + constant-value");
! }
}
--- 24,122 ----
static void tab_const_dst(t_tab_const *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_const_bang(t_tab_const *x)
{
! int i, n;
! int ok_dst;
! t_float *vec_dst;
!
! ok_dst = iem_tab_check_arrays(gensym("tab_const"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_dst)
! {
! n = x->x_size_dst;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = 0.0f;
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_const_float(t_tab_const *x, t_floatarg c)
{
! int i, n;
! int ok_dst;
! t_float *vec_dst;
!
! ok_dst = iem_tab_check_arrays(gensym("tab_const"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_dst)
! {
! n = x->x_size_dst;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = c;
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_const_list(t_tab_const *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_dst;
! int i, n;
! int ok_dst;
! t_float *vec_dst, c;
!
! if((argc >= 3) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2))
! {
! beg_dst = (int)atom_getintarg(0, argc, argv);
! n = (int)atom_getintarg(1, argc, argv);
! c = (t_float)atom_getfloatarg(2, argc, argv);
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_dst = iem_tab_check_arrays(gensym("tab_const"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_dst)
! {
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = c;
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_const-ERROR: list need 3 float arguments:");
! post(" destination_offset + number_of_samples_to_copy + constant-value");
! }
}
***************
*** 137,169 ****
static void *tab_const_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_const *x = (t_tab_const *)pd_new(tab_const_class);
! t_symbol *dst;
! t_float time;
!
! if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! dst = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! }
! else
! {
! post("tab_const-ERROR: need 1 symbol argument:");
! post(" destination_array_name");
! return(0);
! }
!
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_const_setup(void)
{
! tab_const_class = class_new(gensym("tab_const"), (t_newmethod)tab_const_new, (t_method)tab_const_free,
! sizeof(t_tab_const), 0, A_GIMME, 0);
! class_addbang(tab_const_class, (t_method)tab_const_bang);
! 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"));
}
--- 127,159 ----
static void *tab_const_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_const *x = (t_tab_const *)pd_new(tab_const_class);
! t_symbol *dst;
! t_float time;
!
! if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! dst = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! }
! else
! {
! post("tab_const-ERROR: need 1 symbol argument:");
! post(" destination_array_name");
! return(0);
! }
!
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_const_setup(void)
{
! tab_const_class = class_new(gensym("tab_const"), (t_newmethod)tab_const_new, (t_method)tab_const_free,
! sizeof(t_tab_const), 0, A_GIMME, 0);
! class_addbang(tab_const_class, (t_method)tab_const_bang);
! 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"));
}
Index: tab_conv.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_conv.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_conv.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_conv.c 10 Nov 2006 17:15:47 -0000 1.2
***************
*** 4,19 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
--- 4,11 ----
***************
*** 22,38 ****
typedef struct _tab_conv
{
! t_object x_obj;
! int x_size_src1;
! int x_size_src2;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_src2;
! int x_offset_dst;
! float *x_beg_mem_src1;
! float *x_beg_mem_src2;
! float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_scr2;
! t_symbol *x_sym_dst;
} t_tab_conv;
--- 14,30 ----
typedef struct _tab_conv
{
! t_object x_obj;
! int x_size_src1;
! int x_size_src2;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_src2;
! int x_offset_dst;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_src2;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_scr2;
! t_symbol *x_sym_dst;
} t_tab_conv;
***************
*** 41,86 ****
static void tab_conv_src1(t_tab_conv *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_conv_src2(t_tab_conv *x, t_symbol *s)
{
! x->x_sym_scr2 = s;
}
static void tab_conv_dst(t_tab_conv *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_conv_bang(t_tab_conv *x)
{
! int i, j, k, l, min_s2, plu_s2, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
t_float sum=0.0f;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_conv"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_src2 = iem_tab_check_arrays(gensym("tab_conv"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_conv"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
! if(x->x_size_src2 < n)
{
vec_src1 = x->x_beg_mem_src1;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
min_s2 = -x->x_size_src2 / 2;
plu_s2 = min_s2 + x->x_size_src2;
! for(i=0; i<n; i++)
{
sum = 0.0f;
--- 33,78 ----
static void tab_conv_src1(t_tab_conv *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_conv_src2(t_tab_conv *x, t_symbol *s)
{
! x->x_sym_scr2 = s;
}
static void tab_conv_dst(t_tab_conv *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_conv_bang(t_tab_conv *x)
{
! int i, j, k, l, min_s2, plu_s2, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
t_float sum=0.0f;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_conv"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_src2 = iem_tab_check_arrays(gensym("tab_conv"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_conv"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
! if(x->x_size_src2 < n)
{
vec_src1 = x->x_beg_mem_src1;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
min_s2 = -x->x_size_src2 / 2;
plu_s2 = min_s2 + x->x_size_src2;
! for(i=0; i<n; i++)
{
sum = 0.0f;
***************
*** 89,102 ****
k = j + i;
if((k >= 0) && (k < n))
! sum += vec_src1[k] * vec_src2[l];
}
! vec_dst[i] = sum;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
}
! }
! }
}
--- 81,94 ----
k = j + i;
if((k >= 0) && (k < n))
! sum += vec_src1[k] * vec_src2[l];
}
! vec_dst[i] = sum;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
}
! }
! }
}
***************
*** 181,228 ****
static void *tab_conv_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_conv *x = (t_tab_conv *)pd_new(tab_conv_class);
! t_symbol *src1, *src2, *dst;
! t_float time;
!
! if((argc >= 3) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! }
! else if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else
! {
! post("tab_conv-ERROR: need 3 symbols arguments:");
! post(" source1_array_name + source2_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_scr2 = src2;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_conv_setup(void)
{
! tab_conv_class = class_new(gensym("tab_conv"), (t_newmethod)tab_conv_new, (t_method)tab_conv_free,
! sizeof(t_tab_conv), 0, A_GIMME, 0);
! class_addbang(tab_conv_class, (t_method)tab_conv_bang);
! class_addlist(tab_conv_class, (t_method)tab_conv_list);
! 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"));
}
--- 173,220 ----
static void *tab_conv_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_conv *x = (t_tab_conv *)pd_new(tab_conv_class);
! t_symbol *src1, *src2, *dst;
! t_float time;
!
! if((argc >= 3) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! }
! else if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else
! {
! post("tab_conv-ERROR: need 3 symbols arguments:");
! post(" source1_array_name + source2_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_scr2 = src2;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_conv_setup(void)
{
! tab_conv_class = class_new(gensym("tab_conv"), (t_newmethod)tab_conv_new, (t_method)tab_conv_free,
! sizeof(t_tab_conv), 0, A_GIMME, 0);
! class_addbang(tab_conv_class, (t_method)tab_conv_bang);
! class_addlist(tab_conv_class, (t_method)tab_conv_list);
! 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"));
}
Index: tab_sum.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_sum.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_sum.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_sum.c 10 Nov 2006 17:15:48 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_sum ------------------------------ */
--- 4,10 ----
***************
*** 22,32 ****
typedef struct _tab_sum
{
! t_object x_obj;
! int x_size_src1;
! int x_offset_src1;
! float *x_beg_mem_src1;
! t_symbol *x_sym_scr1;
! void *x_bang_out;
! void *x_sum_out;
} t_tab_sum;
--- 12,22 ----
typedef struct _tab_sum
{
! t_object x_obj;
! int x_size_src1;
! int x_offset_src1;
! t_float *x_beg_mem_src1;
! t_symbol *x_sym_scr1;
! void *x_bang_out;
! void *x_sum_out;
} t_tab_sum;
***************
*** 35,106 ****
static void tab_sum_src(t_tab_sum *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_sum_bang(t_tab_sum *x)
{
! int i, n;
! int ok_src;
! t_float *vec_src;
! t_float sum=0.0f;
!
! ok_src = iem_tab_check_arrays(gensym("tab_sum"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
!
! if(ok_src)
! {
! n = x->x_size_src1;
! vec_src = x->x_beg_mem_src1;
! if(n)
! {
! for(i=0; i<n; i++)
! {
! sum += vec_src[i];
! }
! outlet_float(x->x_sum_out, sum);
! outlet_bang(x->x_bang_out);
! }
! }
}
static void tab_sum_list(t_tab_sum *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src;
! int i, n;
! int ok_src;
! t_float *vec_src;
! t_float sum=0.0f;
!
! if((argc >= 2) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1))
! {
! beg_src = (int)atom_getintarg(0, argc, argv);
! n = (int)atom_getintarg(1, argc, argv);
! if(beg_src < 0)
! beg_src = 0;
! if(n < 0)
! n = 0;
!
! ok_src = iem_tab_check_arrays(gensym("tab_sum"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+n);
!
! if(ok_src)
! {
! vec_src = x->x_beg_mem_src1 + beg_src;
! if(n)
! {
! for(i=0; i<n; i++)
! {
! sum += vec_src[i];
! }
! outlet_float(x->x_sum_out, sum);
! outlet_bang(x->x_bang_out);
! }
! }
! }
! else
! {
! post("tab_sum-ERROR: list need 2 float arguments:");
! post(" source_offset + number_of_samples_to_calc_sum-value");
! }
}
--- 25,96 ----
static void tab_sum_src(t_tab_sum *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_sum_bang(t_tab_sum *x)
{
! int i, n;
! int ok_src;
! t_float *vec_src;
! t_float sum=0.0f;
!
! ok_src = iem_tab_check_arrays(gensym("tab_sum"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
!
! if(ok_src)
! {
! n = x->x_size_src1;
! vec_src = x->x_beg_mem_src1;
! if(n)
! {
! for(i=0; i<n; i++)
! {
! sum += vec_src[i];
! }
! outlet_float(x->x_sum_out, sum);
! outlet_bang(x->x_bang_out);
! }
! }
}
static void tab_sum_list(t_tab_sum *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src;
! int i, n;
! int ok_src;
! t_float *vec_src;
! t_float sum=0.0f;
!
! if((argc >= 2) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1))
! {
! beg_src = (int)atom_getintarg(0, argc, argv);
! n = (int)atom_getintarg(1, argc, argv);
! if(beg_src < 0)
! beg_src = 0;
! if(n < 0)
! n = 0;
!
! ok_src = iem_tab_check_arrays(gensym("tab_sum"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+n);
!
! if(ok_src)
! {
! vec_src = x->x_beg_mem_src1 + beg_src;
! if(n)
! {
! for(i=0; i<n; i++)
! {
! sum += vec_src[i];
! }
! outlet_float(x->x_sum_out, sum);
! outlet_bang(x->x_bang_out);
! }
! }
! }
! else
! {
! post("tab_sum-ERROR: list need 2 float arguments:");
! post(" source_offset + number_of_samples_to_calc_sum-value");
! }
}
***************
*** 111,143 ****
static void *tab_sum_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_sum *x = (t_tab_sum *)pd_new(tab_sum_class);
! t_symbol *src;
!
! if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! }
! else
! {
! post("tab_sum-ERROR: need 1 symbol argument:");
! post(" source_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src;
! x->x_bang_out = outlet_new(&x->x_obj, &s_bang);
! x->x_sum_out = outlet_new(&x->x_obj, &s_float);
! return(x);
}
void tab_sum_setup(void)
{
! tab_sum_class = class_new(gensym("tab_sum"), (t_newmethod)tab_sum_new, (t_method)tab_sum_free,
! sizeof(t_tab_sum), 0, A_GIMME, 0);
! class_addbang(tab_sum_class, (t_method)tab_sum_bang);
! class_addlist(tab_sum_class, (t_method)tab_sum_list);
! class_addmethod(tab_sum_class, (t_method)tab_sum_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_sum_class, (t_method)tab_sum_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_sum_class, gensym("iemhelp2/tab_sum-help"));
}
--- 101,133 ----
static void *tab_sum_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_sum *x = (t_tab_sum *)pd_new(tab_sum_class);
! t_symbol *src;
!
! if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! }
! else
! {
! post("tab_sum-ERROR: need 1 symbol argument:");
! post(" source_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src;
! x->x_bang_out = outlet_new(&x->x_obj, &s_bang);
! x->x_sum_out = outlet_new(&x->x_obj, &s_float);
! return(x);
}
void tab_sum_setup(void)
{
! tab_sum_class = class_new(gensym("tab_sum"), (t_newmethod)tab_sum_new, (t_method)tab_sum_free,
! sizeof(t_tab_sum), 0, A_GIMME, 0);
! class_addbang(tab_sum_class, (t_method)tab_sum_bang);
! class_addlist(tab_sum_class, (t_method)tab_sum_list);
! class_addmethod(tab_sum_class, (t_method)tab_sum_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_sum_class, (t_method)tab_sum_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_sum_class, gensym("iemhelp2/tab_sum-help"));
}
Index: tab_sqrt.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_sqrt.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_sqrt.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_sqrt.c 10 Nov 2006 17:15:48 -0000 1.2
***************
*** 4,19 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
#include <math.h>
- #include <stdio.h>
- #include <string.h>
#define TABDUMTAB1SIZE 256
--- 4,11 ----
***************
*** 24,44 ****
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);
! }
}
--- 16,36 ----
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);
! }
}
***************
*** 48,60 ****
typedef struct _tab_sqrt
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! float *x_beg_mem_src1;
! float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_sqrt;
--- 40,52 ----
typedef struct _tab_sqrt
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_sqrt;
***************
*** 63,174 ****
static void tab_sqrt_src(t_tab_sqrt *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_sqrt_dst(t_tab_sqrt *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_sqrt_bang(t_tab_sqrt *x)
{
! int i, n;
! int ok_src, ok_dst;
! t_float *vec_src, *vec_dst;
!
! ok_src = iem_tab_check_arrays(gensym("tab_sqrt"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_sqrt"), 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;
!
! while(n--)
! {
! t_float f = *vec_src;
! long l = *(long *)(vec_src++);
!
! if(f < 0.0f)
! *vec_dst++ = 0.0f;
! else
! {
! t_float g = tab_rsqrt_exptab[(l >> 23) & 0xff] * tab_rsqrt_mantissatab[(l >> 13) & 0x3ff];
!
! *vec_dst++ = f*g*(1.5f - 0.5f * g * g * f);
! }
! }
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_sqrt_list(t_tab_sqrt *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src, beg_dst;
! int i, n;
! int ok_src, ok_dst;
! t_float *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_sqrt"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_sqrt"), 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;
!
! while(n--)
! {
! t_float f = *vec_src;
! long l = *(long *)(vec_src++);
!
! if(f < 0.0f)
! *vec_dst++ = 0.0f;
! else
! {
! t_float g = tab_rsqrt_exptab[(l >> 23) & 0xff] * tab_rsqrt_mantissatab[(l >> 13) & 0x3ff];
!
! *vec_dst++ = f*g*(1.5f - 0.5f * g * g * f);
! }
! }
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_sqrt-ERROR: list need 3 float arguments:");
! post(" source_offset + destination_offset + number_of_samples_to_sqrt");
! }
}
--- 55,166 ----
static void tab_sqrt_src(t_tab_sqrt *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_sqrt_dst(t_tab_sqrt *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_sqrt_bang(t_tab_sqrt *x)
{
! int i, n;
! int ok_src, ok_dst;
! t_float *vec_src, *vec_dst;
!
! ok_src = iem_tab_check_arrays(gensym("tab_sqrt"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_sqrt"), 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;
!
! while(n--)
! {
! t_float f = *vec_src;
! long l = *(long *)(vec_src++);
!
! if(f < 0.0f)
! *vec_dst++ = 0.0f;
! else
! {
! t_float g = tab_rsqrt_exptab[(l >> 23) & 0xff] * tab_rsqrt_mantissatab[(l >> 13) & 0x3ff];
!
! *vec_dst++ = f*g*(1.5f - 0.5f * g * g * f);
! }
! }
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_sqrt_list(t_tab_sqrt *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src, beg_dst;
! int i, n;
! int ok_src, ok_dst;
! t_float *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_sqrt"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_sqrt"), 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;
!
! while(n--)
! {
! t_float f = *vec_src;
! long l = *(long *)(vec_src++);
!
! if(f < 0.0f)
! *vec_dst++ = 0.0f;
! else
! {
! t_float g = tab_rsqrt_exptab[(l >> 23) & 0xff] * tab_rsqrt_mantissatab[(l >> 13) & 0x3ff];
!
! *vec_dst++ = f*g*(1.5f - 0.5f * g * g * f);
! }
! }
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_sqrt-ERROR: list need 3 float arguments:");
! post(" source_offset + destination_offset + number_of_samples_to_sqrt");
! }
}
***************
*** 179,221 ****
static void *tab_sqrt_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_sqrt *x = (t_tab_sqrt *)pd_new(tab_sqrt_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_sqrt-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_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);
! class_addlist(tab_sqrt_class, (t_method)tab_sqrt_list);
! 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"));
}
--- 171,213 ----
static void *tab_sqrt_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_sqrt *x = (t_tab_sqrt *)pd_new(tab_sqrt_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_sqrt-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_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);
! class_addlist(tab_sqrt_class, (t_method)tab_sqrt_list);
! 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"));
}
Index: tab_complex_mul.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_complex_mul.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_complex_mul.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_complex_mul.c 10 Nov 2006 17:15:47 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_complex_mul ------------------------------ */
--- 4,10 ----
***************
*** 22,50 ****
typedef struct _tab_complex_mul
{
! t_object x_obj;
! int x_size_src1_re;
! int x_size_src2_re;
! int x_size_dst_re;
! int x_size_src1_im;
! int x_size_src2_im;
! int x_size_dst_im;
! int x_offset_src1_re;
! int x_offset_src2_re;
! int x_offset_dst_re;
! int x_offset_src1_im;
! int x_offset_src2_im;
! int x_offset_dst_im;
! float *x_beg_mem_src1_re;
! float *x_beg_mem_src2_re;
! float *x_beg_mem_dst_re;
! float *x_beg_mem_src1_im;
! float *x_beg_mem_src2_im;
! float *x_beg_mem_dst_im;
! t_symbol *x_sym_scr1_re;
! t_symbol *x_sym_scr2_re;
! t_symbol *x_sym_dst_re;
! t_symbol *x_sym_scr1_im;
! t_symbol *x_sym_scr2_im;
! t_symbol *x_sym_dst_im;
} t_tab_complex_mul;
--- 12,40 ----
typedef struct _tab_complex_mul
{
! t_object x_obj;
! int x_size_src1_re;
! int x_size_src2_re;
! int x_size_dst_re;
! int x_size_src1_im;
! int x_size_src2_im;
! int x_size_dst_im;
! int x_offset_src1_re;
! int x_offset_src2_re;
! int x_offset_dst_re;
! int x_offset_src1_im;
! int x_offset_src2_im;
! int x_offset_dst_im;
! t_float *x_beg_mem_src1_re;
! t_float *x_beg_mem_src2_re;
! t_float *x_beg_mem_dst_re;
! t_float *x_beg_mem_src1_im;
! t_float *x_beg_mem_src2_im;
! t_float *x_beg_mem_dst_im;
! t_symbol *x_sym_scr1_re;
! t_symbol *x_sym_scr2_re;
! t_symbol *x_sym_dst_re;
! t_symbol *x_sym_scr1_im;
! t_symbol *x_sym_scr2_im;
! t_symbol *x_sym_dst_im;
} t_tab_complex_mul;
***************
*** 53,229 ****
static void tab_complex_mul_src1_re(t_tab_complex_mul *x, t_symbol *s)
{
! x->x_sym_scr1_re = s;
}
static void tab_complex_mul_src1_im(t_tab_complex_mul *x, t_symbol *s)
{
! x->x_sym_scr1_im = s;
}
static void tab_complex_mul_src2_re(t_tab_complex_mul *x, t_symbol *s)
{
! x->x_sym_scr2_re = s;
}
static void tab_complex_mul_src2_im(t_tab_complex_mul *x, t_symbol *s)
{
! x->x_sym_scr2_im = s;
}
static void tab_complex_mul_dst_re(t_tab_complex_mul *x, t_symbol *s)
{
! x->x_sym_dst_re = s;
}
static void tab_complex_mul_dst_im(t_tab_complex_mul *x, t_symbol *s)
{
! x->x_sym_dst_im = s;
}
static void tab_complex_mul_bang(t_tab_complex_mul *x)
{
! int i, n;
! int ok_src1_re, ok_src2_re, ok_dst_re;
! int ok_src1_im, ok_src2_im, ok_dst_im;
! t_float *vec_src1_re, *vec_src2_re, *vec_dst_re;
! t_float *vec_src1_im, *vec_src2_im, *vec_dst_im;
!
! ok_src1_re = iem_tab_check_arrays(gensym("tab_complex_mul"), x->x_sym_scr1_re, &x->x_beg_mem_src1_re, &x->x_size_src1_re, 0);
! ok_src2_re = iem_tab_check_arrays(gensym("tab_complex_mul"), x->x_sym_scr2_re, &x->x_beg_mem_src2_re, &x->x_size_src2_re, 0);
! ok_dst_re = iem_tab_check_arrays(gensym("tab_complex_mul"), x->x_sym_dst_re, &x->x_beg_mem_dst_re, &x->x_size_dst_re, 0);
! ok_src1_im = iem_tab_check_arrays(gensym("tab_complex_mul"), x->x_sym_scr1_im, &x->x_beg_mem_src1_im, &x->x_size_src1_im, 0);
! ok_src2_im = iem_tab_check_arrays(gensym("tab_complex_mul"), x->x_sym_scr2_im, &x->x_beg_mem_src2_im, &x->x_size_src2_im, 0);
! ok_dst_im = iem_tab_check_arrays(gensym("tab_complex_mul"), x->x_sym_dst_im, &x->x_beg_mem_dst_im, &x->x_size_dst_im, 0);
!
! if(ok_src1_re && ok_src2_re && ok_dst_re && ok_src1_im && ok_src2_im && ok_dst_im)
! {
! if(x->x_size_src1_re < x->x_size_dst_re)
! n = x->x_size_src1_re;
! else
! n = x->x_size_dst_re;
! if(x->x_size_src2_re < n)
! n = x->x_size_src2_re;
! if(x->x_size_src1_im < n)
! n = x->x_size_src1_im;
! if(x->x_size_src2_im < n)
! n = x->x_size_src2_im;
! if(x->x_size_dst_im < n)
! n = x->x_size_dst_im;
!
! vec_src1_re = x->x_beg_mem_src1_re;
! vec_src2_re = x->x_beg_mem_src2_re;
! vec_dst_re = x->x_beg_mem_dst_re;
! vec_src1_im = x->x_beg_mem_src1_im;
! vec_src2_im = x->x_beg_mem_src2_im;
! vec_dst_im = x->x_beg_mem_dst_im;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! {
! t_float re1, re2, im1, im2;
!
! re1 = vec_src1_re[i];
! re2 = vec_src2_re[i];
! im1 = vec_src1_im[i];
! im2 = vec_src2_im[i];
! vec_dst_re[i] = re1*re2 - im1*im2;
! vec_dst_im[i] = re1*im2 + im1*re2;
! }
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_re, garray_class);
! garray_redraw(a);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_im, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_complex_mul_list(t_tab_complex_mul *x, t_symbol *s, int argc, t_atom *argv)
{
! int i, n;
! int beg_src1_re, beg_src2_re, beg_dst_re;
! int beg_src1_im, beg_src2_im, beg_dst_im;
! int ok_src1_re, ok_src2_re, ok_dst_re;
! int ok_src1_im, ok_src2_im, ok_dst_im;
! t_float *vec_src1_re, *vec_src2_re, *vec_dst_re;
! t_float *vec_src1_im, *vec_src2_im, *vec_dst_im;
!
! if((argc >= 7) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3) &&
! IS_A_FLOAT(argv,4) &&
! IS_A_FLOAT(argv,5) &&
! IS_A_FLOAT(argv,6))
! {
! beg_src1_re = (int)atom_getintarg(0, argc, argv);
! beg_src1_im = (int)atom_getintarg(1, argc, argv);
! beg_src2_re = (int)atom_getintarg(2, argc, argv);
! beg_src2_im = (int)atom_getintarg(3, argc, argv);
! beg_dst_re = (int)atom_getintarg(4, argc, argv);
! beg_dst_im = (int)atom_getintarg(5, argc, argv);
! n = (int)atom_getintarg(6, argc, argv);
! if(beg_src1_re < 0)
! beg_src1_re = 0;
! if(beg_src2_re < 0)
! beg_src2_re = 0;
! if(beg_dst_re < 0)
! beg_dst_re = 0;
! if(beg_src1_im < 0)
! beg_src1_im = 0;
! if(beg_src2_im < 0)
! beg_src2_im = 0;
! if(beg_dst_im < 0)
! beg_dst_im = 0;
! if(n < 0)
! n = 0;
!
! ok_src1_re = iem_tab_check_arrays(gensym("tab_complex_mul"), x->x_sym_scr1_re, &x->x_beg_mem_src1_re, &x->x_size_src1_re, beg_src1_re+n);
! ok_src2_re = iem_tab_check_arrays(gensym("tab_complex_mul"), x->x_sym_scr2_re, &x->x_beg_mem_src2_re, &x->x_size_src2_re, beg_src2_re+n);
! ok_dst_re = iem_tab_check_arrays(gensym("tab_complex_mul"), x->x_sym_dst_re, &x->x_beg_mem_dst_re, &x->x_size_dst_re, beg_dst_re+n);
! ok_src1_im = iem_tab_check_arrays(gensym("tab_complex_mul"), x->x_sym_scr1_im, &x->x_beg_mem_src1_im, &x->x_size_src1_im, beg_src1_im+n);
! ok_src2_im = iem_tab_check_arrays(gensym("tab_complex_mul"), x->x_sym_scr2_im, &x->x_beg_mem_src2_im, &x->x_size_src2_im, beg_src2_im+n);
! ok_dst_im = iem_tab_check_arrays(gensym("tab_complex_mul"), x->x_sym_dst_im, &x->x_beg_mem_dst_im, &x->x_size_dst_im, beg_dst_im+n);
!
! if(ok_src1_re && ok_src2_re && ok_dst_re && ok_src1_im && ok_src2_im && ok_dst_im)
! {
! vec_src1_re = x->x_beg_mem_src1_re + beg_src1_re;
! vec_src2_re = x->x_beg_mem_src2_re + beg_src2_re;
! vec_dst_re = x->x_beg_mem_dst_re + beg_dst_re;
! vec_src1_im = x->x_beg_mem_src1_im + beg_src1_im;
! vec_src2_im = x->x_beg_mem_src2_im + beg_src2_im;
! vec_dst_im = x->x_beg_mem_dst_im + beg_dst_im;
!
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! {
! t_float re1, re2, im1, im2;
!
! re1 = vec_src1_re[i];
! re2 = vec_src2_re[i];
! im1 = vec_src1_im[i];
! im2 = vec_src2_im[i];
! vec_dst_re[i] = re1*re2 - im1*im2;
! vec_dst_im[i] = re1*im2 + im1*re2;
! }
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_re, garray_class);
! garray_redraw(a);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_im, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_complex_mul-ERROR: list need 7 float arguments:");
! post(" source1_real_offset + source1_imag_offset + source2_real_offset + source2_imag_offset + destination_real_offset + destination_imag_offset + number_of_samples_to_complex_mul");
! }
}
--- 43,219 ----
static void tab_complex_mul_src1_re(t_tab_complex_mul *x, t_symbol *s)
{
! x->x_sym_scr1_re = s;
}
static void tab_complex_mul_src1_im(t_tab_complex_mul *x, t_symbol *s)
{
! x->x_sym_scr1_im = s;
}
static void tab_complex_mul_src2_re(t_tab_complex_mul *x, t_symbol *s)
{
! x->x_sym_scr2_re = s;
}
static void tab_complex_mul_src2_im(t_tab_complex_mul *x, t_symbol *s)
{
! x->x_sym_scr2_im = s;
}
static void tab_complex_mul_dst_re(t_tab_complex_mul *x, t_symbol *s)
{
! x->x_sym_dst_re = s;
}
static void tab_complex_mul_dst_im(t_tab_complex_mul *x, t_symbol *s)
{
! x->x_sym_dst_im = s;
}
static void tab_complex_mul_bang(t_tab_complex_mul *x)
{
! int i, n;
! int ok_src1_re, ok_src2_re, ok_dst_re;
! int ok_src1_im, ok_src2_im, ok_dst_im;
! t_float *vec_src1_re, *vec_src2_re, *vec_dst_re;
! t_float *vec_src1_im, *vec_src2_im, *vec_dst_im;
!
! ok_src1_re = iem_tab_check_arrays(gensym("tab_complex_mul"), x->x_sym_scr1_re, &x->x_beg_mem_src1_re, &x->x_size_src1_re, 0);
! ok_src2_re = iem_tab_check_arrays(gensym("tab_complex_mul"), x->x_sym_scr2_re, &x->x_beg_mem_src2_re, &x->x_size_src2_re, 0);
! ok_dst_re = iem_tab_check_arrays(gensym("tab_complex_mul"), x->x_sym_dst_re, &x->x_beg_mem_dst_re, &x->x_size_dst_re, 0);
! ok_src1_im = iem_tab_check_arrays(gensym("tab_complex_mul"), x->x_sym_scr1_im, &x->x_beg_mem_src1_im, &x->x_size_src1_im, 0);
! ok_src2_im = iem_tab_check_arrays(gensym("tab_complex_mul"), x->x_sym_scr2_im, &x->x_beg_mem_src2_im, &x->x_size_src2_im, 0);
! ok_dst_im = iem_tab_check_arrays(gensym("tab_complex_mul"), x->x_sym_dst_im, &x->x_beg_mem_dst_im, &x->x_size_dst_im, 0);
!
! if(ok_src1_re && ok_src2_re && ok_dst_re && ok_src1_im && ok_src2_im && ok_dst_im)
! {
! if(x->x_size_src1_re < x->x_size_dst_re)
! n = x->x_size_src1_re;
! else
! n = x->x_size_dst_re;
! if(x->x_size_src2_re < n)
! n = x->x_size_src2_re;
! if(x->x_size_src1_im < n)
! n = x->x_size_src1_im;
! if(x->x_size_src2_im < n)
! n = x->x_size_src2_im;
! if(x->x_size_dst_im < n)
! n = x->x_size_dst_im;
!
! vec_src1_re = x->x_beg_mem_src1_re;
! vec_src2_re = x->x_beg_mem_src2_re;
! vec_dst_re = x->x_beg_mem_dst_re;
! vec_src1_im = x->x_beg_mem_src1_im;
! vec_src2_im = x->x_beg_mem_src2_im;
! vec_dst_im = x->x_beg_mem_dst_im;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! {
! t_float re1, re2, im1, im2;
!
! re1 = vec_src1_re[i];
! re2 = vec_src2_re[i];
! im1 = vec_src1_im[i];
! im2 = vec_src2_im[i];
! vec_dst_re[i] = re1*re2 - im1*im2;
! vec_dst_im[i] = re1*im2 + im1*re2;
! }
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_re, garray_class);
! garray_redraw(a);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_im, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_complex_mul_list(t_tab_complex_mul *x, t_symbol *s, int argc, t_atom *argv)
{
! int i, n;
! int beg_src1_re, beg_src2_re, beg_dst_re;
! int beg_src1_im, beg_src2_im, beg_dst_im;
! int ok_src1_re, ok_src2_re, ok_dst_re;
! int ok_src1_im, ok_src2_im, ok_dst_im;
! t_float *vec_src1_re, *vec_src2_re, *vec_dst_re;
! t_float *vec_src1_im, *vec_src2_im, *vec_dst_im;
!
! if((argc >= 7) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3) &&
! IS_A_FLOAT(argv,4) &&
! IS_A_FLOAT(argv,5) &&
! IS_A_FLOAT(argv,6))
! {
! beg_src1_re = (int)atom_getintarg(0, argc, argv);
! beg_src1_im = (int)atom_getintarg(1, argc, argv);
! beg_src2_re = (int)atom_getintarg(2, argc, argv);
! beg_src2_im = (int)atom_getintarg(3, argc, argv);
! beg_dst_re = (int)atom_getintarg(4, argc, argv);
! beg_dst_im = (int)atom_getintarg(5, argc, argv);
! n = (int)atom_getintarg(6, argc, argv);
! if(beg_src1_re < 0)
! beg_src1_re = 0;
! if(beg_src2_re < 0)
! beg_src2_re = 0;
! if(beg_dst_re < 0)
! beg_dst_re = 0;
! if(beg_src1_im < 0)
! beg_src1_im = 0;
! if(beg_src2_im < 0)
! beg_src2_im = 0;
! if(beg_dst_im < 0)
! beg_dst_im = 0;
! if(n < 0)
! n = 0;
!
! ok_src1_re = iem_tab_check_arrays(gensym("tab_complex_mul"), x->x_sym_scr1_re, &x->x_beg_mem_src1_re, &x->x_size_src1_re, beg_src1_re+n);
! ok_src2_re = iem_tab_check_arrays(gensym("tab_complex_mul"), x->x_sym_scr2_re, &x->x_beg_mem_src2_re, &x->x_size_src2_re, beg_src2_re+n);
! ok_dst_re = iem_tab_check_arrays(gensym("tab_complex_mul"), x->x_sym_dst_re, &x->x_beg_mem_dst_re, &x->x_size_dst_re, beg_dst_re+n);
! ok_src1_im = iem_tab_check_arrays(gensym("tab_complex_mul"), x->x_sym_scr1_im, &x->x_beg_mem_src1_im, &x->x_size_src1_im, beg_src1_im+n);
! ok_src2_im = iem_tab_check_arrays(gensym("tab_complex_mul"), x->x_sym_scr2_im, &x->x_beg_mem_src2_im, &x->x_size_src2_im, beg_src2_im+n);
! ok_dst_im = iem_tab_check_arrays(gensym("tab_complex_mul"), x->x_sym_dst_im, &x->x_beg_mem_dst_im, &x->x_size_dst_im, beg_dst_im+n);
!
! if(ok_src1_re && ok_src2_re && ok_dst_re && ok_src1_im && ok_src2_im && ok_dst_im)
! {
! vec_src1_re = x->x_beg_mem_src1_re + beg_src1_re;
! vec_src2_re = x->x_beg_mem_src2_re + beg_src2_re;
! vec_dst_re = x->x_beg_mem_dst_re + beg_dst_re;
! vec_src1_im = x->x_beg_mem_src1_im + beg_src1_im;
! vec_src2_im = x->x_beg_mem_src2_im + beg_src2_im;
! vec_dst_im = x->x_beg_mem_dst_im + beg_dst_im;
!
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! {
! t_float re1, re2, im1, im2;
!
! re1 = vec_src1_re[i];
! re2 = vec_src2_re[i];
! im1 = vec_src1_im[i];
! im2 = vec_src2_im[i];
! vec_dst_re[i] = re1*re2 - im1*im2;
! vec_dst_im[i] = re1*im2 + im1*re2;
! }
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_re, garray_class);
! garray_redraw(a);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_im, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_complex_mul-ERROR: list need 7 float arguments:");
! post(" source1_real_offset + source1_imag_offset + source2_real_offset + source2_imag_offset + destination_real_offset + destination_imag_offset + number_of_samples_to_complex_mul");
! }
}
***************
*** 234,298 ****
static void *tab_complex_mul_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_complex_mul *x = (t_tab_complex_mul *)pd_new(tab_complex_mul_class);
! t_symbol *src1_re, *src2_re, *dst_re, *src1_im, *src2_im, *dst_im;
! t_float time;
!
! if((argc >= 6) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2) &&
! IS_A_SYMBOL(argv,3) &&
! IS_A_SYMBOL(argv,4) &&
! IS_A_SYMBOL(argv,5))
! {
! src1_re = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src1_im = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! src2_re = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! src2_im = (t_symbol *)atom_getsymbolarg(3, argc, argv);
! dst_re = (t_symbol *)atom_getsymbolarg(4, argc, argv);
! dst_im = (t_symbol *)atom_getsymbolarg(5, argc, argv);
! }
! else if((argc >= 4) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2) &&
! IS_A_SYMBOL(argv,4))
! {
! src1_re = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src1_im = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! src2_re = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! src2_im = (t_symbol *)atom_getsymbolarg(3, argc, argv);
! dst_re = src1_re;
! dst_im = src1_im;
! }
! else
! {
! post("tab_complex_mul-ERROR: need 6 symbols arguments:");
! post(" source1_real_array_name + source1_imag_array_name + source2_real_array_name + source2_imag_array_name + destination_real_array_name + destination_imag_array_name");
! return(0);
! }
!
! x->x_sym_scr1_re = src1_re;
! x->x_sym_scr1_im = src1_im;
! x->x_sym_scr2_re = src2_re;
! x->x_sym_scr2_im = src2_im;
! x->x_sym_dst_re = dst_re;
! x->x_sym_dst_im = dst_im;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_complex_mul_setup(void)
{
! tab_complex_mul_class = class_new(gensym("tab_complex_mul"), (t_newmethod)tab_complex_mul_new, (t_method)tab_complex_mul_free,
! sizeof(t_tab_complex_mul), 0, A_GIMME, 0);
! class_addbang(tab_complex_mul_class, (t_method)tab_complex_mul_bang);
! class_addlist(tab_complex_mul_class, (t_method)tab_complex_mul_list);
! class_addmethod(tab_complex_mul_class, (t_method)tab_complex_mul_src1_re, gensym("src1_re"), A_DEFSYMBOL, 0);
! class_addmethod(tab_complex_mul_class, (t_method)tab_complex_mul_src2_re, gensym("src2_re"), A_DEFSYMBOL, 0);
! class_addmethod(tab_complex_mul_class, (t_method)tab_complex_mul_dst_re, gensym("dst_re"), A_DEFSYMBOL, 0);
! class_addmethod(tab_complex_mul_class, (t_method)tab_complex_mul_src1_im, gensym("src1_im"), A_DEFSYMBOL, 0);
! class_addmethod(tab_complex_mul_class, (t_method)tab_complex_mul_src2_im, gensym("src2_im"), A_DEFSYMBOL, 0);
! class_addmethod(tab_complex_mul_class, (t_method)tab_complex_mul_dst_im, gensym("dst_im"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_complex_mul_class, gensym("iemhelp2/tab_complex_mul-help"));
}
--- 224,288 ----
static void *tab_complex_mul_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_complex_mul *x = (t_tab_complex_mul *)pd_new(tab_complex_mul_class);
! t_symbol *src1_re, *src2_re, *dst_re, *src1_im, *src2_im, *dst_im;
! t_float time;
!
! if((argc >= 6) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2) &&
! IS_A_SYMBOL(argv,3) &&
! IS_A_SYMBOL(argv,4) &&
! IS_A_SYMBOL(argv,5))
! {
! src1_re = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src1_im = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! src2_re = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! src2_im = (t_symbol *)atom_getsymbolarg(3, argc, argv);
! dst_re = (t_symbol *)atom_getsymbolarg(4, argc, argv);
! dst_im = (t_symbol *)atom_getsymbolarg(5, argc, argv);
! }
! else if((argc >= 4) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2) &&
! IS_A_SYMBOL(argv,4))
! {
! src1_re = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src1_im = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! src2_re = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! src2_im = (t_symbol *)atom_getsymbolarg(3, argc, argv);
! dst_re = src1_re;
! dst_im = src1_im;
! }
! else
! {
! post("tab_complex_mul-ERROR: need 6 symbols arguments:");
! post(" source1_real_array_name + source1_imag_array_name + source2_real_array_name + source2_imag_array_name + destination_real_array_name + destination_imag_array_name");
! return(0);
! }
!
! x->x_sym_scr1_re = src1_re;
! x->x_sym_scr1_im = src1_im;
! x->x_sym_scr2_re = src2_re;
! x->x_sym_scr2_im = src2_im;
! x->x_sym_dst_re = dst_re;
! x->x_sym_dst_im = dst_im;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_complex_mul_setup(void)
{
! tab_complex_mul_class = class_new(gensym("tab_complex_mul"), (t_newmethod)tab_complex_mul_new, (t_method)tab_complex_mul_free,
! sizeof(t_tab_complex_mul), 0, A_GIMME, 0);
! class_addbang(tab_complex_mul_class, (t_method)tab_complex_mul_bang);
! class_addlist(tab_complex_mul_class, (t_method)tab_complex_mul_list);
! class_addmethod(tab_complex_mul_class, (t_method)tab_complex_mul_src1_re, gensym("src1_re"), A_DEFSYMBOL, 0);
! class_addmethod(tab_complex_mul_class, (t_method)tab_complex_mul_src2_re, gensym("src2_re"), A_DEFSYMBOL, 0);
! class_addmethod(tab_complex_mul_class, (t_method)tab_complex_mul_dst_re, gensym("dst_re"), A_DEFSYMBOL, 0);
! class_addmethod(tab_complex_mul_class, (t_method)tab_complex_mul_src1_im, gensym("src1_im"), A_DEFSYMBOL, 0);
! class_addmethod(tab_complex_mul_class, (t_method)tab_complex_mul_src2_im, gensym("src2_im"), A_DEFSYMBOL, 0);
! class_addmethod(tab_complex_mul_class, (t_method)tab_complex_mul_dst_im, gensym("dst_im"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_complex_mul_class, gensym("iemhelp2/tab_complex_mul-help"));
}
Index: tab_div.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_div.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_div.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_div.c 10 Nov 2006 17:15:47 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_div ------------------------------ */
--- 4,10 ----
***************
*** 22,38 ****
typedef struct _tab_div
{
! t_object x_obj;
! int x_size_src1;
! int x_size_src2;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_src2;
! int x_offset_dst;
! float *x_beg_mem_src1;
! float *x_beg_mem_src2;
! float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_scr2;
! t_symbol *x_sym_dst;
} t_tab_div;
--- 12,28 ----
typedef struct _tab_div
{
! t_object x_obj;
! int x_size_src1;
! int x_size_src2;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_src2;
! int x_offset_dst;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_src2;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_scr2;
! t_symbol *x_sym_dst;
} t_tab_div;
***************
*** 41,154 ****
static void tab_div_src1(t_tab_div *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_div_src2(t_tab_div *x, t_symbol *s)
{
! x->x_sym_scr2 = s;
}
static void tab_div_dst(t_tab_div *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_div_bang(t_tab_div *x)
{
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_div"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_src2 = iem_tab_check_arrays(gensym("tab_div"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_div"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
! if(x->x_size_src2 < n)
! n = x->x_size_src2;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! {
! if(vec_src2[i] == 0.0f)
! vec_dst[i] = 0.0f;
! else
! vec_dst[i] = vec_src1[i] / vec_src2[i];
! }
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_div_list(t_tab_div *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_src2, beg_dst;
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_src2 = (int)atom_getintarg(1, argc, argv);
! beg_dst = (int)atom_getintarg(2, argc, argv);
! n = (int)atom_getintarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_src2 < 0)
! beg_src2 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_div"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_src2 = iem_tab_check_arrays(gensym("tab_div"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, beg_src2+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_div"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_src2 = x->x_beg_mem_src2 + beg_src2;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! {
! if(vec_src2[i] == 0.0f)
! vec_dst[i] = 0.0f;
! else
! vec_dst[i] = vec_src1[i] / vec_src2[i];
! }
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_div-ERROR: list need 4 float arguments:");
! post(" source1_offset + source2_offset + destination_offset + number_of_samples_to_div");
! }
}
--- 31,144 ----
static void tab_div_src1(t_tab_div *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_div_src2(t_tab_div *x, t_symbol *s)
{
! x->x_sym_scr2 = s;
}
static void tab_div_dst(t_tab_div *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_div_bang(t_tab_div *x)
{
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_div"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_src2 = iem_tab_check_arrays(gensym("tab_div"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_div"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
! if(x->x_size_src2 < n)
! n = x->x_size_src2;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! {
! if(vec_src2[i] == 0.0f)
! vec_dst[i] = 0.0f;
! else
! vec_dst[i] = vec_src1[i] / vec_src2[i];
! }
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_div_list(t_tab_div *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_src2, beg_dst;
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_src2 = (int)atom_getintarg(1, argc, argv);
! beg_dst = (int)atom_getintarg(2, argc, argv);
! n = (int)atom_getintarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_src2 < 0)
! beg_src2 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_div"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_src2 = iem_tab_check_arrays(gensym("tab_div"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, beg_src2+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_div"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_src2 = x->x_beg_mem_src2 + beg_src2;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! {
! if(vec_src2[i] == 0.0f)
! vec_dst[i] = 0.0f;
! else
! vec_dst[i] = vec_src1[i] / vec_src2[i];
! }
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_div-ERROR: list need 4 float arguments:");
! post(" source1_offset + source2_offset + destination_offset + number_of_samples_to_div");
! }
}
***************
*** 159,206 ****
static void *tab_div_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_div *x = (t_tab_div *)pd_new(tab_div_class);
! t_symbol *src1, *src2, *dst;
! t_float time;
!
! if((argc >= 3) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! }
! else if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else
! {
! post("tab_div-ERROR: need 3 symbols arguments:");
! post(" source1_array_name + source2_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_scr2 = src2;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_div_setup(void)
{
! tab_div_class = class_new(gensym("tab_div"), (t_newmethod)tab_div_new, (t_method)tab_div_free,
! sizeof(t_tab_div), 0, A_GIMME, 0);
! class_addbang(tab_div_class, (t_method)tab_div_bang);
! class_addlist(tab_div_class, (t_method)tab_div_list);
! class_addmethod(tab_div_class, (t_method)tab_div_src1, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_div_class, (t_method)tab_div_src2, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_div_class, (t_method)tab_div_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_div_class, gensym("iemhelp2/tab_div-help"));
}
--- 149,196 ----
static void *tab_div_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_div *x = (t_tab_div *)pd_new(tab_div_class);
! t_symbol *src1, *src2, *dst;
! t_float time;
!
! if((argc >= 3) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! }
! else if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else
! {
! post("tab_div-ERROR: need 3 symbols arguments:");
! post(" source1_array_name + source2_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_scr2 = src2;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_div_setup(void)
{
! tab_div_class = class_new(gensym("tab_div"), (t_newmethod)tab_div_new, (t_method)tab_div_free,
! sizeof(t_tab_div), 0, A_GIMME, 0);
! class_addbang(tab_div_class, (t_method)tab_div_bang);
! class_addlist(tab_div_class, (t_method)tab_div_list);
! class_addmethod(tab_div_class, (t_method)tab_div_src1, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_div_class, (t_method)tab_div_src2, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_div_class, (t_method)tab_div_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_div_class, gensym("iemhelp2/tab_div-help"));
}
Index: tab_lt_scalar.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_lt_scalar.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_lt_scalar.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_lt_scalar.c 10 Nov 2006 17:15:48 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_lt_scalar ------------------------------ */
--- 4,10 ----
***************
*** 22,34 ****
typedef struct _tab_lt_scalar
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! float *x_beg_mem_src1;
! float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_lt_scalar;
--- 12,24 ----
typedef struct _tab_lt_scalar
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_lt_scalar;
***************
*** 37,136 ****
static void tab_lt_scalar_src(t_tab_lt_scalar *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_lt_scalar_float(t_tab_lt_scalar *x, t_floatarg compare)
{
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_lt_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_lt_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] < compare)
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_lt_scalar_dst(t_tab_lt_scalar *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_lt_scalar_list(t_tab_lt_scalar *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_dst;
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst, compare;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_dst = (int)atom_getintarg(1, argc, argv);
! n = (int)atom_getintarg(2, argc, argv);
! compare = (t_float)atom_getfloatarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_lt_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_lt_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] < compare)
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_lt_scalar-ERROR: list need 4 float arguments:");
! post(" source1_offset + destination_offset + number_of_samples_to_compare + compare_scalar");
}
}
--- 27,126 ----
static void tab_lt_scalar_src(t_tab_lt_scalar *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_lt_scalar_float(t_tab_lt_scalar *x, t_floatarg compare)
{
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_lt_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_lt_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] < compare)
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_lt_scalar_dst(t_tab_lt_scalar *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_lt_scalar_list(t_tab_lt_scalar *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_dst;
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst, compare;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_dst = (int)atom_getintarg(1, argc, argv);
! n = (int)atom_getintarg(2, argc, argv);
! compare = (t_float)atom_getfloatarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_lt_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_lt_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] < compare)
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_lt_scalar-ERROR: list need 4 float arguments:");
! post(" source1_offset + destination_offset + number_of_samples_to_compare + compare_scalar");
}
}
***************
*** 142,183 ****
static void *tab_lt_scalar_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_lt_scalar *x = (t_tab_lt_scalar *)pd_new(tab_lt_scalar_class);
! t_symbol *src1, *dst;
!
! if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! }
! else
! {
! post("tab_lt_scalar-ERROR: need 2 symbol arguments:");
! post(" source_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_lt_scalar_setup(void)
{
! tab_lt_scalar_class = class_new(gensym("tab_lt_scalar"), (t_newmethod)tab_lt_scalar_new, (t_method)tab_lt_scalar_free,
! sizeof(t_tab_lt_scalar), 0, A_GIMME, 0);
! class_addfloat(tab_lt_scalar_class, (t_method)tab_lt_scalar_float);
! class_addlist(tab_lt_scalar_class, (t_method)tab_lt_scalar_list);
! class_addmethod(tab_lt_scalar_class, (t_method)tab_lt_scalar_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_lt_scalar_class, (t_method)tab_lt_scalar_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_lt_scalar_class, (t_method)tab_lt_scalar_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_lt_scalar_class, gensym("iemhelp2/tab_lt_scalar-help"));
}
--- 132,173 ----
static void *tab_lt_scalar_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_lt_scalar *x = (t_tab_lt_scalar *)pd_new(tab_lt_scalar_class);
! t_symbol *src1, *dst;
!
! if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! }
! else
! {
! post("tab_lt_scalar-ERROR: need 2 symbol arguments:");
! post(" source_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_lt_scalar_setup(void)
{
! tab_lt_scalar_class = class_new(gensym("tab_lt_scalar"), (t_newmethod)tab_lt_scalar_new, (t_method)tab_lt_scalar_free,
! sizeof(t_tab_lt_scalar), 0, A_GIMME, 0);
! class_addfloat(tab_lt_scalar_class, (t_method)tab_lt_scalar_float);
! class_addlist(tab_lt_scalar_class, (t_method)tab_lt_scalar_list);
! class_addmethod(tab_lt_scalar_class, (t_method)tab_lt_scalar_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_lt_scalar_class, (t_method)tab_lt_scalar_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_lt_scalar_class, (t_method)tab_lt_scalar_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_lt_scalar_class, gensym("iemhelp2/tab_lt_scalar-help"));
}
Index: tab_rfft.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_rfft.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_rfft.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_rfft.c 10 Nov 2006 17:15:48 -0000 1.2
***************
*** 4,19 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
#include <math.h>
- #include <stdio.h>
- #include <string.h>
--- 4,11 ----
***************
*** 22,40 ****
typedef struct _tab_rfft
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst_re;
! int x_size_dst_im;
! int x_offset_src1;
! int x_offset_dst_re;
! int x_offset_dst_im;
! int x_fftsize;
! float *x_beg_mem_src1;
! float *x_beg_mem_dst_re;
! float *x_beg_mem_dst_im;
! TAB_COMPLEX *x_sin_cos;
! t_symbol *x_sym_src1;
! t_symbol *x_sym_dst_re;
! t_symbol *x_sym_dst_im;
} t_tab_rfft;
--- 14,32 ----
typedef struct _tab_rfft
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst_re;
! int x_size_dst_im;
! int x_offset_src1;
! int x_offset_dst_re;
! int x_offset_dst_im;
! int x_fftsize;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_dst_re;
! t_float *x_beg_mem_dst_im;
! TAB_COMPLEX *x_sin_cos;
! t_symbol *x_sym_src1;
! t_symbol *x_sym_dst_re;
! t_symbol *x_sym_dst_im;
} t_tab_rfft;
***************
*** 43,391 ****
static void tab_rfft_init(t_tab_rfft *x)
{
! int i, fftsize = x->x_fftsize;
! float f, g;
! TAB_COMPLEX *sincos = x->x_sin_cos;
!
! g = 2.0f * 3.1415926538f / (float)fftsize;
! for(i=0; i<fftsize; i++)
! {
! f = g * (float)i;
! (*sincos).real = cos(f);
! (*sincos).imag = -sin(f);/*FFT*/
! sincos++;
! }
}
static void tab_rfft_fftsize(t_tab_rfft *x, t_floatarg f)
{
! int i=1, fftsize = (int)f;
!
! if(fftsize < 8)
! fftsize = 8;
!
! while(i <= fftsize)
! i *= 2;
! i /= 2;
!
! if(i != x->x_fftsize)
! {
! x->x_sin_cos = (TAB_COMPLEX *)resizebytes(x->x_sin_cos, x->x_fftsize*sizeof(TAB_COMPLEX), i*sizeof(TAB_COMPLEX));
! x->x_fftsize = i;
! }
! tab_rfft_init(x);
}
static void tab_rfft_src(t_tab_rfft *x, t_symbol *s)
{
! x->x_sym_src1 = s;
}
static void tab_rfft_dst_re(t_tab_rfft *x, t_symbol *s)
{
! x->x_sym_dst_re = s;
}
static void tab_rfft_dst_im(t_tab_rfft *x, t_symbol *s)
{
! x->x_sym_dst_im = s;
}
static void tab_rfft_bang(t_tab_rfft *x)
{
! int i, j, k;
! int ok_src, ok_dst_re, ok_dst_im;
! int w_index, w_inc, i_inc, v_index;
! int fftsize = x->x_fftsize;
! int fs1 = fftsize - 1;
! int fs2 = fftsize / 2;
! TAB_COMPLEX w;
! TAB_COMPLEX *sincos = x->x_sin_cos;
! t_float *vec_src, *vec_dst_re, *vec_dst_im;
! t_float old1_re, old1_im, old2_re, old2_im;
!
! ok_src = iem_tab_check_arrays(gensym("tab_rfft"), x->x_sym_src1, &x->x_beg_mem_src1, &x->x_size_src1, fftsize);
! ok_dst_re = iem_tab_check_arrays(gensym("tab_rfft"), x->x_sym_dst_re, &x->x_beg_mem_dst_re, &x->x_size_dst_re, fftsize);
! ok_dst_im = iem_tab_check_arrays(gensym("tab_rfft"), x->x_sym_dst_im, &x->x_beg_mem_dst_im, &x->x_size_dst_im, fftsize);
! if(ok_src && ok_dst_re && ok_dst_im)
! {
! t_garray *a;
!
! vec_src=x->x_beg_mem_src1;
! vec_dst_re=x->x_beg_mem_dst_re;
! vec_dst_im=x->x_beg_mem_dst_im;
!
! for(k=0; k<fftsize; k++)
! {
! vec_dst_re[k] = vec_src[k];
! vec_dst_im[k] = 0.0f;
! }
!
! i_inc = fs2;
! w_inc = 1;
! for(i=1; i<fftsize; i<<=1)
! {
! v_index = 0;
! for(j=0; j<i; j++)
! {
! w_index = 0;
! for(k=0; k<i_inc; k++)
! {
! old1_re = vec_dst_re[v_index];
! old1_im = vec_dst_im[v_index];
! old2_re = vec_dst_re[v_index+i_inc];
! old2_im = vec_dst_im[v_index+i_inc];
! w = sincos[w_index];
! vec_dst_re[v_index+i_inc] = (old1_re - old2_re)*w.real - (old1_im - old2_im)*w.imag;
! vec_dst_im[v_index+i_inc] = (old1_im - old2_im)*w.real + (old1_re - old2_re)*w.imag;
! vec_dst_re[v_index] = old1_re + old2_re;
! vec_dst_im[v_index] = old1_im + old2_im;
! w_index += w_inc;
! v_index++;
! }
! v_index += i_inc;
! }
! w_inc <<= 1;
! i_inc >>= 1;
! }
!
! j = 0;
! for(i=1;i<fs1;i++)
! {
! k = fs2;
! while(k <= j)
! {
! j = j - k;
! k >>= 1;
! }
! j = j + k;
! if(i < j)
! {
! old1_re = vec_dst_re[j];
! old1_im = vec_dst_im[j];
! vec_dst_re[j] = vec_dst_re[i];
! vec_dst_im[j] = vec_dst_im[i];
! vec_dst_re[i] = old1_re;
! vec_dst_im[i] = old1_im;
! }
! }
!
! // g = 2.0f / (float)fftsize;
! /*
! ein fehler tritt auf beim 0.sample, hier sollte nur mal 1.0 multipliziert werden
! wenn gelten soll : Energie im zeitfenster == Energie im Frequenz-dichte-fenster
!
! g = 1.0f;
! for(i = 0; i < fs2; i++)
! {
! vec_dst_re[i] *= g;
! vec_dst_im[i] *= g;
! }
! */
!
! vec_dst_im[fs2] = 0.0f;
! for(i = fs2+1; i < fftsize; i++)
! {
! vec_dst_re[i] = 0.0f;
! vec_dst_im[i] = 0.0f;
! }
!
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_re, garray_class);
! garray_redraw(a);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_im, garray_class);
! garray_redraw(a);
! }
}
static void tab_rfft_list(t_tab_rfft *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src, beg_dst_re, beg_dst_im;
! int i, j, k;
! int ok_src, ok_dst_re, ok_dst_im;
! int w_index, w_inc, i_inc, v_index;
! int fftsize = x->x_fftsize;
! int fs1 = fftsize - 1;
! int fs2 = fftsize / 2;
! TAB_COMPLEX w;
! TAB_COMPLEX *sincos = x->x_sin_cos;
! t_float *vec_src, *vec_dst_re, *vec_dst_im;
! t_float old1_re, old1_im, old2_re, old2_im;
!
! 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_re = (int)atom_getintarg(1, argc, argv);
! beg_dst_im = (int)atom_getintarg(2, argc, argv);
! if(beg_src < 0)
! beg_src = 0;
! if(beg_dst_re < 0)
! beg_dst_re = 0;
! if(beg_dst_im < 0)
! beg_dst_im = 0;
!
! ok_src = iem_tab_check_arrays(gensym("tab_rfft"), x->x_sym_src1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+fftsize);
! ok_dst_re = iem_tab_check_arrays(gensym("tab_rfft"), x->x_sym_dst_re, &x->x_beg_mem_dst_re, &x->x_size_dst_re, beg_dst_re+fftsize);
! ok_dst_im = iem_tab_check_arrays(gensym("tab_rfft"), x->x_sym_dst_im, &x->x_beg_mem_dst_im, &x->x_size_dst_im, beg_dst_im+fftsize);
!
! if(ok_src && ok_dst_re && ok_dst_im)
! {
! t_garray *a;
!
! vec_src=x->x_beg_mem_src1 + beg_src;
! vec_dst_re=x->x_beg_mem_dst_re + beg_dst_re;
! vec_dst_im=x->x_beg_mem_dst_im + beg_dst_im;
!
! for(k=0; k<fftsize; k++)
! {
! vec_dst_re[k] = vec_src[k];
! vec_dst_im[k] = 0.0f;
! }
!
! i_inc = fs2;
! w_inc = 1;
! for(i=1; i<fftsize; i<<=1)
! {
! v_index = 0;
! for(j=0; j<i; j++)
! {
! w_index = 0;
! for(k=0; k<i_inc; k++)
! {
! old1_re = vec_dst_re[v_index];
! old1_im = vec_dst_im[v_index];
! old2_re = vec_dst_re[v_index+i_inc];
! old2_im = vec_dst_im[v_index+i_inc];
! w = sincos[w_index];
! vec_dst_re[v_index+i_inc] = (old1_re - old2_re)*w.real - (old1_im - old2_im)*w.imag;
! vec_dst_im[v_index+i_inc] = (old1_im - old2_im)*w.real + (old1_re - old2_re)*w.imag;
! vec_dst_re[v_index] = old1_re + old2_re;
! vec_dst_im[v_index] = old1_im + old2_im;
! w_index += w_inc;
! v_index++;
! }
! v_index += i_inc;
! }
! w_inc <<= 1;
! i_inc >>= 1;
! }
!
! j = 0;
! for(i=1;i<fs1;i++)
! {
! k = fs2;
! while(k <= j)
! {
! j = j - k;
! k >>= 1;
! }
! j = j + k;
! if(i < j)
! {
! old1_re = vec_dst_re[j];
! old1_im = vec_dst_im[j];
! vec_dst_re[j] = vec_dst_re[i];
! vec_dst_im[j] = vec_dst_im[i];
! vec_dst_re[i] = old1_re;
! vec_dst_im[i] = old1_im;
! }
! }
!
! // g = 2.0f / (float)fftsize;
! /*
! ein fehler tritt auf beim 0.sample, hier sollte nur mal 1.0 multipliziert werden
! wenn gelten soll : Energie im zeitfenster == Energie im Frequenz-dichte-fenster
!
! g = 1.0f;
! for(i = 0; i < fs2; i++)
! {
! vec_dst_re[i] *= g;
! vec_dst_im[i] *= g;
! }
! */
!
! vec_dst_im[fs2] = 0.0f;
! for(i = fs2+1; i < fftsize; i++)
! {
! vec_dst_re[i] = 0.0f;
! vec_dst_im[i] = 0.0f;
! }
!
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_re, garray_class);
! garray_redraw(a);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_im, garray_class);
! garray_redraw(a);
! }
! }
! else
! {
! post("tab_rfft-ERROR: list need 3 float arguments:");
! post(" source_offset + destination_real_offset + destination_imag_offset");
! }
}
static void tab_rfft_free(t_tab_rfft *x)
{
! freebytes(x->x_sin_cos, x->x_fftsize * sizeof(TAB_COMPLEX));
}
static void *tab_rfft_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_rfft *x = (t_tab_rfft *)pd_new(tab_rfft_class);
! t_symbol *src, *dst_re, *dst_im;
! int fftsize, i=1;
!
! if((argc >= 4) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! src = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst_re = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst_im = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! fftsize = (int)atom_getintarg(3, argc, argv);
! }
! else
! {
! post("tab_rfft-ERROR: need 3 symbols + 1 float arguments:");
! post(" source_array_name + destination_real_array_name + destination_imag_array_name + FFT-size");
! return(0);
! }
!
! if(fftsize < 8)
! fftsize = 8;
!
! while(i <= fftsize)
! i *= 2;
! i /= 2;
! fftsize = i;
!
! x->x_fftsize = fftsize;
! x->x_sym_src1 = src;
! x->x_sym_dst_re = dst_re;
! x->x_sym_dst_im = dst_im;
! x->x_sin_cos = (TAB_COMPLEX *)getbytes(x->x_fftsize * sizeof(TAB_COMPLEX));
! tab_rfft_init(x);
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_rfft_setup(void)
{
! tab_rfft_class = class_new(gensym("tab_rfft"), (t_newmethod)tab_rfft_new, (t_method)tab_rfft_free,
! sizeof(t_tab_rfft), 0, A_GIMME, 0);
! class_addbang(tab_rfft_class, (t_method)tab_rfft_bang);
! class_addlist(tab_rfft_class, (t_method)tab_rfft_list);
! class_addmethod(tab_rfft_class, (t_method)tab_rfft_fftsize, gensym("fftsize"), A_DEFFLOAT, 0);
! class_addmethod(tab_rfft_class, (t_method)tab_rfft_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_rfft_class, (t_method)tab_rfft_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_rfft_class, (t_method)tab_rfft_dst_re, gensym("dst_re"), A_DEFSYMBOL, 0);
! class_addmethod(tab_rfft_class, (t_method)tab_rfft_dst_im, gensym("dst_im"), A_DEFSYMBOL, 0);
! class_addmethod(tab_rfft_class, (t_method)tab_rfft_dst_re, gensym("dst1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_rfft_class, (t_method)tab_rfft_dst_im, gensym("dst2"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_rfft_class, gensym("iemhelp2/tab_rfft-help"));
}
--- 35,383 ----
static void tab_rfft_init(t_tab_rfft *x)
{
! int i, fftsize = x->x_fftsize;
! t_float f, g;
! TAB_COMPLEX *sincos = x->x_sin_cos;
!
! g = 2.0f * 3.1415926538f / (t_float)fftsize;
! for(i=0; i<fftsize; i++)
! {
! f = g * (t_float)i;
! (*sincos).real = cos(f);
! (*sincos).imag = -sin(f);/*FFT*/
! sincos++;
! }
}
static void tab_rfft_fftsize(t_tab_rfft *x, t_floatarg f)
{
! int i=1, fftsize = (int)f;
!
! if(fftsize < 8)
! fftsize = 8;
!
! while(i <= fftsize)
! i *= 2;
! i /= 2;
!
! if(i != x->x_fftsize)
! {
! x->x_sin_cos = (TAB_COMPLEX *)resizebytes(x->x_sin_cos, x->x_fftsize*sizeof(TAB_COMPLEX), i*sizeof(TAB_COMPLEX));
! x->x_fftsize = i;
! }
! tab_rfft_init(x);
}
static void tab_rfft_src(t_tab_rfft *x, t_symbol *s)
{
! x->x_sym_src1 = s;
}
static void tab_rfft_dst_re(t_tab_rfft *x, t_symbol *s)
{
! x->x_sym_dst_re = s;
}
static void tab_rfft_dst_im(t_tab_rfft *x, t_symbol *s)
{
! x->x_sym_dst_im = s;
}
static void tab_rfft_bang(t_tab_rfft *x)
{
! int i, j, k;
! int ok_src, ok_dst_re, ok_dst_im;
! int w_index, w_inc, i_inc, v_index;
! int fftsize = x->x_fftsize;
! int fs1 = fftsize - 1;
! int fs2 = fftsize / 2;
! TAB_COMPLEX w;
! TAB_COMPLEX *sincos = x->x_sin_cos;
! t_float *vec_src, *vec_dst_re, *vec_dst_im;
! t_float old1_re, old1_im, old2_re, old2_im;
!
! ok_src = iem_tab_check_arrays(gensym("tab_rfft"), x->x_sym_src1, &x->x_beg_mem_src1, &x->x_size_src1, fftsize);
! ok_dst_re = iem_tab_check_arrays(gensym("tab_rfft"), x->x_sym_dst_re, &x->x_beg_mem_dst_re, &x->x_size_dst_re, fftsize);
! ok_dst_im = iem_tab_check_arrays(gensym("tab_rfft"), x->x_sym_dst_im, &x->x_beg_mem_dst_im, &x->x_size_dst_im, fftsize);
! if(ok_src && ok_dst_re && ok_dst_im)
! {
! t_garray *a;
!
! vec_src=x->x_beg_mem_src1;
! vec_dst_re=x->x_beg_mem_dst_re;
! vec_dst_im=x->x_beg_mem_dst_im;
!
! for(k=0; k<fftsize; k++)
! {
! vec_dst_re[k] = vec_src[k];
! vec_dst_im[k] = 0.0f;
! }
!
! i_inc = fs2;
! w_inc = 1;
! for(i=1; i<fftsize; i<<=1)
! {
! v_index = 0;
! for(j=0; j<i; j++)
! {
! w_index = 0;
! for(k=0; k<i_inc; k++)
! {
! old1_re = vec_dst_re[v_index];
! old1_im = vec_dst_im[v_index];
! old2_re = vec_dst_re[v_index+i_inc];
! old2_im = vec_dst_im[v_index+i_inc];
! w = sincos[w_index];
! vec_dst_re[v_index+i_inc] = (old1_re - old2_re)*w.real - (old1_im - old2_im)*w.imag;
! vec_dst_im[v_index+i_inc] = (old1_im - old2_im)*w.real + (old1_re - old2_re)*w.imag;
! vec_dst_re[v_index] = old1_re + old2_re;
! vec_dst_im[v_index] = old1_im + old2_im;
! w_index += w_inc;
! v_index++;
! }
! v_index += i_inc;
! }
! w_inc <<= 1;
! i_inc >>= 1;
! }
!
! j = 0;
! for(i=1;i<fs1;i++)
! {
! k = fs2;
! while(k <= j)
! {
! j = j - k;
! k >>= 1;
! }
! j = j + k;
! if(i < j)
! {
! old1_re = vec_dst_re[j];
! old1_im = vec_dst_im[j];
! vec_dst_re[j] = vec_dst_re[i];
! vec_dst_im[j] = vec_dst_im[i];
! vec_dst_re[i] = old1_re;
! vec_dst_im[i] = old1_im;
! }
! }
!
! // g = 2.0f / (t_float)fftsize;
! /*
! ein fehler tritt auf beim 0.sample, hier sollte nur mal 1.0 multipliziert werden
! wenn gelten soll : Energie im zeitfenster == Energie im Frequenz-dichte-fenster
!
! g = 1.0f;
! for(i = 0; i < fs2; i++)
! {
! vec_dst_re[i] *= g;
! vec_dst_im[i] *= g;
! }
! */
!
! vec_dst_im[fs2] = 0.0f;
! for(i = fs2+1; i < fftsize; i++)
! {
! vec_dst_re[i] = 0.0f;
! vec_dst_im[i] = 0.0f;
! }
!
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_re, garray_class);
! garray_redraw(a);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_im, garray_class);
! garray_redraw(a);
! }
}
static void tab_rfft_list(t_tab_rfft *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src, beg_dst_re, beg_dst_im;
! int i, j, k;
! int ok_src, ok_dst_re, ok_dst_im;
! int w_index, w_inc, i_inc, v_index;
! int fftsize = x->x_fftsize;
! int fs1 = fftsize - 1;
! int fs2 = fftsize / 2;
! TAB_COMPLEX w;
! TAB_COMPLEX *sincos = x->x_sin_cos;
! t_float *vec_src, *vec_dst_re, *vec_dst_im;
! t_float old1_re, old1_im, old2_re, old2_im;
!
! 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_re = (int)atom_getintarg(1, argc, argv);
! beg_dst_im = (int)atom_getintarg(2, argc, argv);
! if(beg_src < 0)
! beg_src = 0;
! if(beg_dst_re < 0)
! beg_dst_re = 0;
! if(beg_dst_im < 0)
! beg_dst_im = 0;
!
! ok_src = iem_tab_check_arrays(gensym("tab_rfft"), x->x_sym_src1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+fftsize);
! ok_dst_re = iem_tab_check_arrays(gensym("tab_rfft"), x->x_sym_dst_re, &x->x_beg_mem_dst_re, &x->x_size_dst_re, beg_dst_re+fftsize);
! ok_dst_im = iem_tab_check_arrays(gensym("tab_rfft"), x->x_sym_dst_im, &x->x_beg_mem_dst_im, &x->x_size_dst_im, beg_dst_im+fftsize);
!
! if(ok_src && ok_dst_re && ok_dst_im)
! {
! t_garray *a;
!
! vec_src=x->x_beg_mem_src1 + beg_src;
! vec_dst_re=x->x_beg_mem_dst_re + beg_dst_re;
! vec_dst_im=x->x_beg_mem_dst_im + beg_dst_im;
!
! for(k=0; k<fftsize; k++)
! {
! vec_dst_re[k] = vec_src[k];
! vec_dst_im[k] = 0.0f;
! }
!
! i_inc = fs2;
! w_inc = 1;
! for(i=1; i<fftsize; i<<=1)
! {
! v_index = 0;
! for(j=0; j<i; j++)
! {
! w_index = 0;
! for(k=0; k<i_inc; k++)
! {
! old1_re = vec_dst_re[v_index];
! old1_im = vec_dst_im[v_index];
! old2_re = vec_dst_re[v_index+i_inc];
! old2_im = vec_dst_im[v_index+i_inc];
! w = sincos[w_index];
! vec_dst_re[v_index+i_inc] = (old1_re - old2_re)*w.real - (old1_im - old2_im)*w.imag;
! vec_dst_im[v_index+i_inc] = (old1_im - old2_im)*w.real + (old1_re - old2_re)*w.imag;
! vec_dst_re[v_index] = old1_re + old2_re;
! vec_dst_im[v_index] = old1_im + old2_im;
! w_index += w_inc;
! v_index++;
! }
! v_index += i_inc;
! }
! w_inc <<= 1;
! i_inc >>= 1;
! }
!
! j = 0;
! for(i=1;i<fs1;i++)
! {
! k = fs2;
! while(k <= j)
! {
! j = j - k;
! k >>= 1;
! }
! j = j + k;
! if(i < j)
! {
! old1_re = vec_dst_re[j];
! old1_im = vec_dst_im[j];
! vec_dst_re[j] = vec_dst_re[i];
! vec_dst_im[j] = vec_dst_im[i];
! vec_dst_re[i] = old1_re;
! vec_dst_im[i] = old1_im;
! }
! }
!
! // g = 2.0f / (t_float)fftsize;
! /*
! ein fehler tritt auf beim 0.sample, hier sollte nur mal 1.0 multipliziert werden
! wenn gelten soll : Energie im zeitfenster == Energie im Frequenz-dichte-fenster
!
! g = 1.0f;
! for(i = 0; i < fs2; i++)
! {
! vec_dst_re[i] *= g;
! vec_dst_im[i] *= g;
! }
! */
!
! vec_dst_im[fs2] = 0.0f;
! for(i = fs2+1; i < fftsize; i++)
! {
! vec_dst_re[i] = 0.0f;
! vec_dst_im[i] = 0.0f;
! }
!
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_re, garray_class);
! garray_redraw(a);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_im, garray_class);
! garray_redraw(a);
! }
! }
! else
! {
! post("tab_rfft-ERROR: list need 3 float arguments:");
! post(" source_offset + destination_real_offset + destination_imag_offset");
! }
}
static void tab_rfft_free(t_tab_rfft *x)
{
! freebytes(x->x_sin_cos, x->x_fftsize * sizeof(TAB_COMPLEX));
}
static void *tab_rfft_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_rfft *x = (t_tab_rfft *)pd_new(tab_rfft_class);
! t_symbol *src, *dst_re, *dst_im;
! int fftsize, i=1;
!
! if((argc >= 4) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! src = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst_re = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst_im = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! fftsize = (int)atom_getintarg(3, argc, argv);
! }
! else
! {
! post("tab_rfft-ERROR: need 3 symbols + 1 float arguments:");
! post(" source_array_name + destination_real_array_name + destination_imag_array_name + FFT-size");
! return(0);
! }
!
! if(fftsize < 8)
! fftsize = 8;
!
! while(i <= fftsize)
! i *= 2;
! i /= 2;
! fftsize = i;
!
! x->x_fftsize = fftsize;
! x->x_sym_src1 = src;
! x->x_sym_dst_re = dst_re;
! x->x_sym_dst_im = dst_im;
! x->x_sin_cos = (TAB_COMPLEX *)getbytes(x->x_fftsize * sizeof(TAB_COMPLEX));
! tab_rfft_init(x);
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_rfft_setup(void)
{
! tab_rfft_class = class_new(gensym("tab_rfft"), (t_newmethod)tab_rfft_new, (t_method)tab_rfft_free,
! sizeof(t_tab_rfft), 0, A_GIMME, 0);
! class_addbang(tab_rfft_class, (t_method)tab_rfft_bang);
! class_addlist(tab_rfft_class, (t_method)tab_rfft_list);
! class_addmethod(tab_rfft_class, (t_method)tab_rfft_fftsize, gensym("fftsize"), A_DEFFLOAT, 0);
! class_addmethod(tab_rfft_class, (t_method)tab_rfft_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_rfft_class, (t_method)tab_rfft_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_rfft_class, (t_method)tab_rfft_dst_re, gensym("dst_re"), A_DEFSYMBOL, 0);
! class_addmethod(tab_rfft_class, (t_method)tab_rfft_dst_im, gensym("dst_im"), A_DEFSYMBOL, 0);
! class_addmethod(tab_rfft_class, (t_method)tab_rfft_dst_re, gensym("dst1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_rfft_class, (t_method)tab_rfft_dst_im, gensym("dst2"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_rfft_class, gensym("iemhelp2/tab_rfft-help"));
}
Index: tab_mul_scalar.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_mul_scalar.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_mul_scalar.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_mul_scalar.c 10 Nov 2006 17:15:48 -0000 1.2
***************
*** 4,19 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
--- 4,10 ----
***************
*** 22,34 ****
typedef struct _tab_mul_scalar
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! float *x_beg_mem_src1;
! float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_mul_scalar;
--- 13,25 ----
typedef struct _tab_mul_scalar
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_mul_scalar;
***************
*** 37,127 ****
static void tab_mul_scalar_src(t_tab_mul_scalar *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_mul_scalar_float(t_tab_mul_scalar *x, t_floatarg m)
{
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_mul_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_mul_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = vec_src1[i]*m;
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_mul_scalar_dst(t_tab_mul_scalar *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_mul_scalar_list(t_tab_mul_scalar *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_dst;
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst, m;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_dst = (int)atom_getintarg(1, argc, argv);
! n = (int)atom_getintarg(2, argc, argv);
! m = (t_float)atom_getfloatarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_mul_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_mul_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = vec_src1[i]*m;
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_mul_scalar-ERROR: list need 4 float arguments:");
! post(" source1_offset + destination_offset + number_of_samples_to_mul + mul_scalar");
! }
}
--- 28,118 ----
static void tab_mul_scalar_src(t_tab_mul_scalar *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_mul_scalar_float(t_tab_mul_scalar *x, t_floatarg m)
{
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_mul_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_mul_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = vec_src1[i]*m;
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_mul_scalar_dst(t_tab_mul_scalar *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_mul_scalar_list(t_tab_mul_scalar *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_dst;
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst, m;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_dst = (int)atom_getintarg(1, argc, argv);
! n = (int)atom_getintarg(2, argc, argv);
! m = (t_float)atom_getfloatarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_mul_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_mul_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = vec_src1[i]*m;
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_mul_scalar-ERROR: list need 4 float arguments:");
! post(" source1_offset + destination_offset + number_of_samples_to_mul + mul_scalar");
! }
}
***************
*** 132,173 ****
static void *tab_mul_scalar_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_mul_scalar *x = (t_tab_mul_scalar *)pd_new(tab_mul_scalar_class);
! t_symbol *src1, *dst;
!
! if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! }
! else
! {
! post("tab_mul_scalar-ERROR: need 2 symbol arguments:");
! post(" source_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_mul_scalar_setup(void)
{
! tab_mul_scalar_class = class_new(gensym("tab_mul_scalar"), (t_newmethod)tab_mul_scalar_new, (t_method)tab_mul_scalar_free,
! sizeof(t_tab_mul_scalar), 0, A_GIMME, 0);
! class_addfloat(tab_mul_scalar_class, (t_method)tab_mul_scalar_float);
! class_addlist(tab_mul_scalar_class, (t_method)tab_mul_scalar_list);
! class_addmethod(tab_mul_scalar_class, (t_method)tab_mul_scalar_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_mul_scalar_class, (t_method)tab_mul_scalar_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_mul_scalar_class, (t_method)tab_mul_scalar_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_mul_scalar_class, gensym("iemhelp2/tab_mul_scalar-help"));
}
--- 123,164 ----
static void *tab_mul_scalar_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_mul_scalar *x = (t_tab_mul_scalar *)pd_new(tab_mul_scalar_class);
! t_symbol *src1, *dst;
!
! if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! }
! else
! {
! post("tab_mul_scalar-ERROR: need 2 symbol arguments:");
! post(" source_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_mul_scalar_setup(void)
{
! tab_mul_scalar_class = class_new(gensym("tab_mul_scalar"), (t_newmethod)tab_mul_scalar_new, (t_method)tab_mul_scalar_free,
! sizeof(t_tab_mul_scalar), 0, A_GIMME, 0);
! class_addfloat(tab_mul_scalar_class, (t_method)tab_mul_scalar_float);
! class_addlist(tab_mul_scalar_class, (t_method)tab_mul_scalar_list);
! class_addmethod(tab_mul_scalar_class, (t_method)tab_mul_scalar_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_mul_scalar_class, (t_method)tab_mul_scalar_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_mul_scalar_class, (t_method)tab_mul_scalar_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_mul_scalar_class, gensym("iemhelp2/tab_mul_scalar-help"));
}
Index: tab_ge.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_ge.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_ge.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_ge.c 10 Nov 2006 17:15:47 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_ge ------------------------------ */
--- 4,10 ----
***************
*** 22,38 ****
typedef struct _tab_ge
{
! t_object x_obj;
! int x_size_src1;
! int x_size_src2;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_src2;
! int x_offset_dst;
! float *x_beg_mem_src1;
! float *x_beg_mem_src2;
! float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_scr2;
! t_symbol *x_sym_dst;
} t_tab_ge;
--- 12,28 ----
typedef struct _tab_ge
{
! t_object x_obj;
! int x_size_src1;
! int x_size_src2;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_src2;
! int x_offset_dst;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_src2;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_scr2;
! t_symbol *x_sym_dst;
} t_tab_ge;
***************
*** 41,154 ****
static void tab_ge_src1(t_tab_ge *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_ge_src2(t_tab_ge *x, t_symbol *s)
{
! x->x_sym_scr2 = s;
}
static void tab_ge_dst(t_tab_ge *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_ge_bang(t_tab_ge *x)
{
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_ge"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_src2 = iem_tab_check_arrays(gensym("tab_ge"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_ge"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
! if(x->x_size_src2 < n)
! n = x->x_size_src2;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] >= vec_src2[i])
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_ge_list(t_tab_ge *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_src2, beg_dst;
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_src2 = (int)atom_getintarg(1, argc, argv);
! beg_dst = (int)atom_getintarg(2, argc, argv);
! n = (int)atom_getintarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_src2 < 0)
! beg_src2 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_ge"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_src2 = iem_tab_check_arrays(gensym("tab_ge"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, beg_src2+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_ge"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_src2 = x->x_beg_mem_src2 + beg_src2;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] >= vec_src2[i])
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_ge-ERROR: list need 4 float arguments:");
! post(" source1_offset + source2_offset + destination_offset + number_of_samples_to_compare");
! }
}
--- 31,144 ----
static void tab_ge_src1(t_tab_ge *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_ge_src2(t_tab_ge *x, t_symbol *s)
{
! x->x_sym_scr2 = s;
}
static void tab_ge_dst(t_tab_ge *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_ge_bang(t_tab_ge *x)
{
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_ge"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_src2 = iem_tab_check_arrays(gensym("tab_ge"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_ge"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
! if(x->x_size_src2 < n)
! n = x->x_size_src2;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] >= vec_src2[i])
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_ge_list(t_tab_ge *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_src2, beg_dst;
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_src2 = (int)atom_getintarg(1, argc, argv);
! beg_dst = (int)atom_getintarg(2, argc, argv);
! n = (int)atom_getintarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_src2 < 0)
! beg_src2 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_ge"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_src2 = iem_tab_check_arrays(gensym("tab_ge"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, beg_src2+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_ge"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_src2 = x->x_beg_mem_src2 + beg_src2;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] >= vec_src2[i])
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_ge-ERROR: list need 4 float arguments:");
! post(" source1_offset + source2_offset + destination_offset + number_of_samples_to_compare");
! }
}
***************
*** 159,206 ****
static void *tab_ge_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_ge *x = (t_tab_ge *)pd_new(tab_ge_class);
! t_symbol *src1, *src2, *dst;
! t_float time;
!
! if((argc >= 3) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! }
! else if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else
! {
! post("tab_ge-ERROR: need 3 symbols arguments:");
! post(" source1_array_name + source2_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_scr2 = src2;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_ge_setup(void)
{
! tab_ge_class = class_new(gensym("tab_ge"), (t_newmethod)tab_ge_new, (t_method)tab_ge_free,
! sizeof(t_tab_ge), 0, A_GIMME, 0);
! class_addbang(tab_ge_class, (t_method)tab_ge_bang);
! class_addlist(tab_ge_class, (t_method)tab_ge_list);
! class_addmethod(tab_ge_class, (t_method)tab_ge_src1, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ge_class, (t_method)tab_ge_src2, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ge_class, (t_method)tab_ge_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_ge_class, gensym("iemhelp2/tab_ge-help"));
}
--- 149,196 ----
static void *tab_ge_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_ge *x = (t_tab_ge *)pd_new(tab_ge_class);
! t_symbol *src1, *src2, *dst;
! t_float time;
!
! if((argc >= 3) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! }
! else if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else
! {
! post("tab_ge-ERROR: need 3 symbols arguments:");
! post(" source1_array_name + source2_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_scr2 = src2;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_ge_setup(void)
{
! tab_ge_class = class_new(gensym("tab_ge"), (t_newmethod)tab_ge_new, (t_method)tab_ge_free,
! sizeof(t_tab_ge), 0, A_GIMME, 0);
! class_addbang(tab_ge_class, (t_method)tab_ge_bang);
! class_addlist(tab_ge_class, (t_method)tab_ge_list);
! class_addmethod(tab_ge_class, (t_method)tab_ge_src1, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ge_class, (t_method)tab_ge_src2, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ge_class, (t_method)tab_ge_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_ge_class, gensym("iemhelp2/tab_ge-help"));
}
Index: tab_eq.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_eq.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_eq.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_eq.c 10 Nov 2006 17:15:47 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_eq ------------------------------ */
--- 4,10 ----
***************
*** 22,38 ****
typedef struct _tab_eq
{
! t_object x_obj;
! int x_size_src1;
! int x_size_src2;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_src2;
! int x_offset_dst;
! float *x_beg_mem_src1;
! float *x_beg_mem_src2;
! float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_scr2;
! t_symbol *x_sym_dst;
} t_tab_eq;
--- 12,28 ----
typedef struct _tab_eq
{
! t_object x_obj;
! int x_size_src1;
! int x_size_src2;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_src2;
! int x_offset_dst;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_src2;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_scr2;
! t_symbol *x_sym_dst;
} t_tab_eq;
***************
*** 41,154 ****
static void tab_eq_src1(t_tab_eq *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_eq_src2(t_tab_eq *x, t_symbol *s)
{
! x->x_sym_scr2 = s;
}
static void tab_eq_dst(t_tab_eq *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_eq_bang(t_tab_eq *x)
{
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_eq"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_src2 = iem_tab_check_arrays(gensym("tab_eq"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_eq"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
! if(x->x_size_src2 < n)
! n = x->x_size_src2;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] == vec_src2[i])
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_eq_list(t_tab_eq *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_src2, beg_dst;
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_src2 = (int)atom_getintarg(1, argc, argv);
! beg_dst = (int)atom_getintarg(2, argc, argv);
! n = (int)atom_getintarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_src2 < 0)
! beg_src2 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_eq"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_src2 = iem_tab_check_arrays(gensym("tab_eq"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, beg_src2+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_eq"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_src2 = x->x_beg_mem_src2 + beg_src2;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] == vec_src2[i])
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_eq-ERROR: list need 4 float arguments:");
! post(" source1_offset + source2_offset + destination_offset + number_of_samples_to_compare");
! }
}
--- 31,144 ----
static void tab_eq_src1(t_tab_eq *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_eq_src2(t_tab_eq *x, t_symbol *s)
{
! x->x_sym_scr2 = s;
}
static void tab_eq_dst(t_tab_eq *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_eq_bang(t_tab_eq *x)
{
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_eq"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_src2 = iem_tab_check_arrays(gensym("tab_eq"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_eq"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
! if(x->x_size_src2 < n)
! n = x->x_size_src2;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] == vec_src2[i])
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_eq_list(t_tab_eq *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_src2, beg_dst;
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_src2 = (int)atom_getintarg(1, argc, argv);
! beg_dst = (int)atom_getintarg(2, argc, argv);
! n = (int)atom_getintarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_src2 < 0)
! beg_src2 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_eq"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_src2 = iem_tab_check_arrays(gensym("tab_eq"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, beg_src2+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_eq"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_src2 = x->x_beg_mem_src2 + beg_src2;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] == vec_src2[i])
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_eq-ERROR: list need 4 float arguments:");
! post(" source1_offset + source2_offset + destination_offset + number_of_samples_to_compare");
! }
}
***************
*** 159,206 ****
static void *tab_eq_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_eq *x = (t_tab_eq *)pd_new(tab_eq_class);
! t_symbol *src1, *src2, *dst;
! t_float time;
!
! if((argc >= 3) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! }
! else if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else
! {
! post("tab_eq-ERROR: need 3 symbols arguments:");
! post(" source1_array_name + source2_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_scr2 = src2;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_eq_setup(void)
{
! tab_eq_class = class_new(gensym("tab_eq"), (t_newmethod)tab_eq_new, (t_method)tab_eq_free,
! sizeof(t_tab_eq), 0, A_GIMME, 0);
! class_addbang(tab_eq_class, (t_method)tab_eq_bang);
! class_addlist(tab_eq_class, (t_method)tab_eq_list);
! class_addmethod(tab_eq_class, (t_method)tab_eq_src1, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_eq_class, (t_method)tab_eq_src2, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_eq_class, (t_method)tab_eq_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_eq_class, gensym("iemhelp2/tab_eq-help"));
}
--- 149,196 ----
static void *tab_eq_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_eq *x = (t_tab_eq *)pd_new(tab_eq_class);
! t_symbol *src1, *src2, *dst;
! t_float time;
!
! if((argc >= 3) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! }
! else if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else
! {
! post("tab_eq-ERROR: need 3 symbols arguments:");
! post(" source1_array_name + source2_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_scr2 = src2;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_eq_setup(void)
{
! tab_eq_class = class_new(gensym("tab_eq"), (t_newmethod)tab_eq_new, (t_method)tab_eq_free,
! sizeof(t_tab_eq), 0, A_GIMME, 0);
! class_addbang(tab_eq_class, (t_method)tab_eq_bang);
! class_addlist(tab_eq_class, (t_method)tab_eq_list);
! class_addmethod(tab_eq_class, (t_method)tab_eq_src1, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_eq_class, (t_method)tab_eq_src2, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_eq_class, (t_method)tab_eq_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_eq_class, gensym("iemhelp2/tab_eq-help"));
}
Index: tab_ifft.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_ifft.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_ifft.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_ifft.c 10 Nov 2006 17:15:47 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
#include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_ifft ------------------------------ */
--- 4,11 ----
***************
*** 22,44 ****
typedef struct _tab_ifft
{
! t_object x_obj;
! int x_size_src_re;
! int x_size_src_im;
! int x_size_dst_re;
! int x_size_dst_im;
! int x_offset_src_re;
! int x_offset_src_im;
! int x_offset_dst_re;
! int x_offset_dst_im;
! int x_fftsize;
! float *x_beg_mem_src_re;
! float *x_beg_mem_src_im;
! float *x_beg_mem_dst_re;
! float *x_beg_mem_dst_im;
! TAB_COMPLEX *x_sin_cos;
! t_symbol *x_sym_src_re;
! t_symbol *x_sym_src_im;
! t_symbol *x_sym_dst_re;
! t_symbol *x_sym_dst_im;
} t_tab_ifft;
--- 13,35 ----
typedef struct _tab_ifft
{
! t_object x_obj;
! int x_size_src_re;
! int x_size_src_im;
! int x_size_dst_re;
! int x_size_dst_im;
! int x_offset_src_re;
! int x_offset_src_im;
! int x_offset_dst_re;
! int x_offset_dst_im;
! int x_fftsize;
! t_float *x_beg_mem_src_re;
! t_float *x_beg_mem_src_im;
! t_float *x_beg_mem_dst_re;
! t_float *x_beg_mem_dst_im;
! TAB_COMPLEX *x_sin_cos;
! t_symbol *x_sym_src_re;
! t_symbol *x_sym_src_im;
! t_symbol *x_sym_dst_re;
! t_symbol *x_sym_dst_im;
} t_tab_ifft;
***************
*** 47,414 ****
static void tab_ifft_init(t_tab_ifft *x)
{
! int i, fftsize = x->x_fftsize;
! float f, g;
! TAB_COMPLEX *sincos = x->x_sin_cos;
!
! g = 2.0f * 3.1415926538f / (float)fftsize;
! for(i=0; i<fftsize; i++)
! {
! f = g * (float)i;
! (*sincos).real = cos(f);
! (*sincos).imag = sin(f);/*IFFT*/
! sincos++;
! }
}
static void tab_ifft_ifftsize(t_tab_ifft *x, t_floatarg f)
{
! int i=1, fftsize = (int)f;
!
! if(fftsize < 8)
! fftsize = 8;
!
! while(i <= fftsize)
! i *= 2;
! i /= 2;
!
! if(i != x->x_fftsize)
! {
! x->x_sin_cos = (TAB_COMPLEX *)resizebytes(x->x_sin_cos, x->x_fftsize*sizeof(TAB_COMPLEX), i*sizeof(TAB_COMPLEX));
! x->x_fftsize = i;
! }
! tab_ifft_init(x);
}
static void tab_ifft_dst_re(t_tab_ifft *x, t_symbol *s)
{
! x->x_sym_dst_re = s;
}
static void tab_ifft_dst_im(t_tab_ifft *x, t_symbol *s)
{
! x->x_sym_dst_im = s;
}
static void tab_ifft_src_re(t_tab_ifft *x, t_symbol *s)
{
! x->x_sym_src_re = s;
}
static void tab_ifft_src_im(t_tab_ifft *x, t_symbol *s)
{
! x->x_sym_src_im = s;
}
static void tab_ifft_bang(t_tab_ifft *x)
{
! int i, j, k;
! int ok_src_re, ok_src_im, ok_dst_re, ok_dst_im;
! int w_index, w_inc, i_inc, v_index;
! int fftsize = x->x_fftsize;
! int fs1 = fftsize - 1;
! int fs2 = fftsize / 2;
! TAB_COMPLEX w;
! TAB_COMPLEX *sincos = x->x_sin_cos;
! t_float *vec_src_re, *vec_src_im, *vec_dst_re, *vec_dst_im;
! t_float old1_re, old1_im, old2_re, old2_im, g;
!
! ok_src_re = iem_tab_check_arrays(gensym("tab_ifft"), x->x_sym_src_re, &x->x_beg_mem_src_re, &x->x_size_src_re, fftsize);
! ok_src_im = iem_tab_check_arrays(gensym("tab_ifft"), x->x_sym_src_im, &x->x_beg_mem_src_im, &x->x_size_src_im, fftsize);
! ok_dst_re = iem_tab_check_arrays(gensym("tab_ifft"), x->x_sym_dst_re, &x->x_beg_mem_dst_re, &x->x_size_dst_re, fftsize);
! ok_dst_im = iem_tab_check_arrays(gensym("tab_ifft"), x->x_sym_dst_im, &x->x_beg_mem_dst_im, &x->x_size_dst_im, fftsize);
!
! if(ok_src_re && ok_src_im && ok_dst_re && ok_dst_im)
! {
! t_garray *a;
!
! vec_src_re=x->x_beg_mem_src_re;
! vec_src_im=x->x_beg_mem_src_im;
! vec_dst_re=x->x_beg_mem_dst_re;
! vec_dst_im=x->x_beg_mem_dst_im;
!
! for(j=0; j<fftsize; j++)
! {
! vec_dst_re[j] = vec_src_re[j];
! vec_dst_im[j] = vec_src_im[j];
! }
!
! i_inc = fs2;
! w_inc = 1;
! for(i=1; i<fftsize; i<<=1)
! {
! v_index = 0;
! for(j=0; j<i; j++)
! {
! w_index = 0;
! for(k=0; k<i_inc; k++)
! {
! old1_re = vec_dst_re[v_index];
! old1_im = vec_dst_im[v_index];
! old2_re = vec_dst_re[v_index+i_inc];
! old2_im = vec_dst_im[v_index+i_inc];
! w = sincos[w_index];
! vec_dst_re[v_index+i_inc] = (old1_re - old2_re)*w.real - (old1_im - old2_im)*w.imag;
! vec_dst_im[v_index+i_inc] = (old1_im - old2_im)*w.real + (old1_re - old2_re)*w.imag;
! vec_dst_re[v_index] = old1_re + old2_re;
! vec_dst_im[v_index] = old1_im + old2_im;
! w_index += w_inc;
! v_index++;
! }
! v_index += i_inc;
! }
! w_inc <<= 1;
! i_inc >>= 1;
! }
!
! j = 0;
! for(i=1;i<fs1;i++)
! {
! k = fs2;
! while(k <= j)
! {
! j = j - k;
! k >>= 1;
! }
! j = j + k;
! if(i < j)
! {
! old1_re = vec_dst_re[j];
! old1_im = vec_dst_im[j];
! vec_dst_re[j] = vec_dst_re[i];
! vec_dst_im[j] = vec_dst_im[i];
! vec_dst_re[i] = old1_re;
! vec_dst_im[i] = old1_im;
! }
! }
!
! // g = 2.0f / (float)fftsize;
! /*
! ein fehler tritt auf beim 0.sample, hier sollte nur mal 1.0 multipliziert werden
! wenn gelten soll : Energie im zeitfenster == Energie im Frequenz-dichte-fenster
!
! g = 1.0f;
! for(i = 0; i < fs2; i++)
! {
! vec_dst_re[i] *= g;
! vec_dst_im[i] *= g;
! }
! */
!
! g = 1.0f / (float)fftsize;
! for(i = 0; i < fftsize; i++)
! {
! vec_dst_re[i] *= g;
! vec_dst_im[i] *= g;
! }
!
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_re, garray_class);
! garray_redraw(a);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_im, garray_class);
! garray_redraw(a);
! }
}
static void tab_ifft_list(t_tab_ifft *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src_re, beg_src_im, beg_dst_re, beg_dst_im;
! int i, j, k;
! int ok_src_re, ok_src_im, ok_dst_re, ok_dst_im;
! int w_index, w_inc, i_inc, v_index;
! int fftsize = x->x_fftsize;
! int fs1 = fftsize - 1;
! int fs2 = fftsize / 2;
! TAB_COMPLEX w;
! TAB_COMPLEX *sincos = x->x_sin_cos;
! t_float *vec_src_re, *vec_src_im, *vec_dst_re, *vec_dst_im;
! t_float old1_re, old1_im, old2_re, old2_im, g;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src_re = (int)atom_getintarg(0, argc, argv);
! beg_src_im = (int)atom_getintarg(1, argc, argv);
! beg_dst_re = (int)atom_getintarg(2, argc, argv);
! beg_dst_im = (int)atom_getintarg(3, argc, argv);
! if(beg_src_re < 0)
! beg_src_re = 0;
! if(beg_src_im < 0)
! beg_src_im = 0;
! if(beg_dst_re < 0)
! beg_dst_re = 0;
! if(beg_dst_im < 0)
! beg_dst_im = 0;
!
! ok_src_re = iem_tab_check_arrays(gensym("tab_ifft"), x->x_sym_src_re, &x->x_beg_mem_src_re, &x->x_size_src_re, fftsize);
! ok_src_im = iem_tab_check_arrays(gensym("tab_ifft"), x->x_sym_src_im, &x->x_beg_mem_src_im, &x->x_size_src_im, fftsize);
! ok_dst_re = iem_tab_check_arrays(gensym("tab_ifft"), x->x_sym_dst_re, &x->x_beg_mem_dst_re, &x->x_size_dst_re, fftsize);
! ok_dst_im = iem_tab_check_arrays(gensym("tab_ifft"), x->x_sym_dst_im, &x->x_beg_mem_dst_im, &x->x_size_dst_im, fftsize);
!
! if(ok_src_re && ok_src_im && ok_dst_re && ok_dst_im)
! {
! t_garray *a;
!
! vec_src_re=x->x_beg_mem_src_re + beg_src_re;
! vec_src_im=x->x_beg_mem_src_im + beg_src_im;
! vec_dst_re=x->x_beg_mem_dst_re + beg_dst_re;
! vec_dst_im=x->x_beg_mem_dst_im + beg_dst_im;
!
! for(j=0; j<fftsize; j++)
! {
! vec_dst_re[j] = vec_src_re[j];
! vec_dst_im[j] = vec_src_im[j];
! }
!
! i_inc = fs2;
! w_inc = 1;
! for(i=1; i<fftsize; i<<=1)
! {
! v_index = 0;
! for(j=0; j<i; j++)
! {
! w_index = 0;
! for(k=0; k<i_inc; k++)
! {
! old1_re = vec_dst_re[v_index];
! old1_im = vec_dst_im[v_index];
! old2_re = vec_dst_re[v_index+i_inc];
! old2_im = vec_dst_im[v_index+i_inc];
! w = sincos[w_index];
! vec_dst_re[v_index+i_inc] = (old1_re - old2_re)*w.real - (old1_im - old2_im)*w.imag;
! vec_dst_im[v_index+i_inc] = (old1_im - old2_im)*w.real + (old1_re - old2_re)*w.imag;
! vec_dst_re[v_index] = old1_re + old2_re;
! vec_dst_im[v_index] = old1_im + old2_im;
! w_index += w_inc;
! v_index++;
! }
! v_index += i_inc;
! }
! w_inc <<= 1;
! i_inc >>= 1;
! }
!
! j = 0;
! for(i=1;i<fs1;i++)
! {
! k = fs2;
! while(k <= j)
! {
! j = j - k;
! k >>= 1;
! }
! j = j + k;
! if(i < j)
! {
! old1_re = vec_dst_re[j];
! old1_im = vec_dst_im[j];
! vec_dst_re[j] = vec_dst_re[i];
! vec_dst_im[j] = vec_dst_im[i];
! vec_dst_re[i] = old1_re;
! vec_dst_im[i] = old1_im;
! }
! }
!
! // g = 2.0f / (float)fftsize;
! /*
! ein fehler tritt auf beim 0.sample, hier sollte nur mal 1.0 multipliziert werden
! wenn gelten soll : Energie im zeitfenster == Energie im Frequenz-dichte-fenster
!
! g = 1.0f;
! for(i = 0; i < fs2; i++)
! {
! vec_dst_re[i] *= g;
! vec_dst_im[i] *= g;
! }
! */
!
! g = 1.0f / (float)fftsize;
! for(i = 0; i < fftsize; i++)
! {
! vec_dst_re[i] *= g;
! vec_dst_im[i] *= g;
! }
!
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_re, garray_class);
! garray_redraw(a);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_im, garray_class);
! garray_redraw(a);
! }
! }
! else
! {
! post("tab_ifft-ERROR: list need 4 float arguments:");
! post(" source_real_offset + source_imag_offset + destination_real_offset + destination_imag_offset");
! }
}
static void tab_ifft_free(t_tab_ifft *x)
{
! freebytes(x->x_sin_cos, x->x_fftsize * sizeof(TAB_COMPLEX));
}
static void *tab_ifft_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_ifft *x = (t_tab_ifft *)pd_new(tab_ifft_class);
! t_symbol *src_re, *src_im, *dst_re, *dst_im;
! int fftsize, i=1;
!
! if((argc >= 5) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2) &&
! IS_A_SYMBOL(argv,3) &&
! IS_A_FLOAT(argv,4))
! {
! src_re = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src_im = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst_re = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! dst_im = (t_symbol *)atom_getsymbolarg(3, argc, argv);
! fftsize = (int)atom_getintarg(4, argc, argv);
! }
! else
! {
! post("tab_ifft-ERROR: need 4 symbols + 1 float arguments:");
! post(" source_real_array_name + source_imag_array_name + destination_real_array_name + destination_imag_array_name + IFFT-size");
! return(0);
! }
!
! if(fftsize < 8)
! fftsize = 8;
!
! while(i <= fftsize)
! i *= 2;
! i /= 2;
! fftsize = i;
!
! x->x_fftsize = fftsize;
! x->x_sym_src_re = src_re;
! x->x_sym_src_im = src_im;
! x->x_sym_dst_re = dst_re;
! x->x_sym_dst_im = dst_im;
! x->x_sin_cos = (TAB_COMPLEX *)getbytes(x->x_fftsize * sizeof(TAB_COMPLEX));
! tab_ifft_init(x);
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_ifft_setup(void)
{
! tab_ifft_class = class_new(gensym("tab_ifft"), (t_newmethod)tab_ifft_new, (t_method)tab_ifft_free,
! sizeof(t_tab_ifft), 0, A_GIMME, 0);
! class_addbang(tab_ifft_class, (t_method)tab_ifft_bang);
! class_addlist(tab_ifft_class, (t_method)tab_ifft_list);
! class_addmethod(tab_ifft_class, (t_method)tab_ifft_ifftsize, gensym("ifftsize"), A_DEFFLOAT, 0);
! class_addmethod(tab_ifft_class, (t_method)tab_ifft_src_re, gensym("src_re"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ifft_class, (t_method)tab_ifft_src_im, gensym("src_im"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ifft_class, (t_method)tab_ifft_src_re, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ifft_class, (t_method)tab_ifft_src_im, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ifft_class, (t_method)tab_ifft_dst_re, gensym("dst_re"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ifft_class, (t_method)tab_ifft_dst_im, gensym("dst_re"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ifft_class, (t_method)tab_ifft_dst_re, gensym("dst1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ifft_class, (t_method)tab_ifft_dst_im, gensym("dst2"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_ifft_class, gensym("iemhelp2/tab_ifft-help"));
}
--- 38,405 ----
static void tab_ifft_init(t_tab_ifft *x)
{
! int i, fftsize = x->x_fftsize;
! t_float f, g;
! TAB_COMPLEX *sincos = x->x_sin_cos;
!
! g = 2.0f * 3.1415926538f / (t_float)fftsize;
! for(i=0; i<fftsize; i++)
! {
! f = g * (t_float)i;
! (*sincos).real = cos(f);
! (*sincos).imag = sin(f);/*IFFT*/
! sincos++;
! }
}
static void tab_ifft_ifftsize(t_tab_ifft *x, t_floatarg f)
{
! int i=1, fftsize = (int)f;
!
! if(fftsize < 8)
! fftsize = 8;
!
! while(i <= fftsize)
! i *= 2;
! i /= 2;
!
! if(i != x->x_fftsize)
! {
! x->x_sin_cos = (TAB_COMPLEX *)resizebytes(x->x_sin_cos, x->x_fftsize*sizeof(TAB_COMPLEX), i*sizeof(TAB_COMPLEX));
! x->x_fftsize = i;
! }
! tab_ifft_init(x);
}
static void tab_ifft_dst_re(t_tab_ifft *x, t_symbol *s)
{
! x->x_sym_dst_re = s;
}
static void tab_ifft_dst_im(t_tab_ifft *x, t_symbol *s)
{
! x->x_sym_dst_im = s;
}
static void tab_ifft_src_re(t_tab_ifft *x, t_symbol *s)
{
! x->x_sym_src_re = s;
}
static void tab_ifft_src_im(t_tab_ifft *x, t_symbol *s)
{
! x->x_sym_src_im = s;
}
static void tab_ifft_bang(t_tab_ifft *x)
{
! int i, j, k;
! int ok_src_re, ok_src_im, ok_dst_re, ok_dst_im;
! int w_index, w_inc, i_inc, v_index;
! int fftsize = x->x_fftsize;
! int fs1 = fftsize - 1;
! int fs2 = fftsize / 2;
! TAB_COMPLEX w;
! TAB_COMPLEX *sincos = x->x_sin_cos;
! t_float *vec_src_re, *vec_src_im, *vec_dst_re, *vec_dst_im;
! t_float old1_re, old1_im, old2_re, old2_im, g;
!
! ok_src_re = iem_tab_check_arrays(gensym("tab_ifft"), x->x_sym_src_re, &x->x_beg_mem_src_re, &x->x_size_src_re, fftsize);
! ok_src_im = iem_tab_check_arrays(gensym("tab_ifft"), x->x_sym_src_im, &x->x_beg_mem_src_im, &x->x_size_src_im, fftsize);
! ok_dst_re = iem_tab_check_arrays(gensym("tab_ifft"), x->x_sym_dst_re, &x->x_beg_mem_dst_re, &x->x_size_dst_re, fftsize);
! ok_dst_im = iem_tab_check_arrays(gensym("tab_ifft"), x->x_sym_dst_im, &x->x_beg_mem_dst_im, &x->x_size_dst_im, fftsize);
!
! if(ok_src_re && ok_src_im && ok_dst_re && ok_dst_im)
! {
! t_garray *a;
!
! vec_src_re=x->x_beg_mem_src_re;
! vec_src_im=x->x_beg_mem_src_im;
! vec_dst_re=x->x_beg_mem_dst_re;
! vec_dst_im=x->x_beg_mem_dst_im;
!
! for(j=0; j<fftsize; j++)
! {
! vec_dst_re[j] = vec_src_re[j];
! vec_dst_im[j] = vec_src_im[j];
! }
!
! i_inc = fs2;
! w_inc = 1;
! for(i=1; i<fftsize; i<<=1)
! {
! v_index = 0;
! for(j=0; j<i; j++)
! {
! w_index = 0;
! for(k=0; k<i_inc; k++)
! {
! old1_re = vec_dst_re[v_index];
! old1_im = vec_dst_im[v_index];
! old2_re = vec_dst_re[v_index+i_inc];
! old2_im = vec_dst_im[v_index+i_inc];
! w = sincos[w_index];
! vec_dst_re[v_index+i_inc] = (old1_re - old2_re)*w.real - (old1_im - old2_im)*w.imag;
! vec_dst_im[v_index+i_inc] = (old1_im - old2_im)*w.real + (old1_re - old2_re)*w.imag;
! vec_dst_re[v_index] = old1_re + old2_re;
! vec_dst_im[v_index] = old1_im + old2_im;
! w_index += w_inc;
! v_index++;
! }
! v_index += i_inc;
! }
! w_inc <<= 1;
! i_inc >>= 1;
! }
!
! j = 0;
! for(i=1;i<fs1;i++)
! {
! k = fs2;
! while(k <= j)
! {
! j = j - k;
! k >>= 1;
! }
! j = j + k;
! if(i < j)
! {
! old1_re = vec_dst_re[j];
! old1_im = vec_dst_im[j];
! vec_dst_re[j] = vec_dst_re[i];
! vec_dst_im[j] = vec_dst_im[i];
! vec_dst_re[i] = old1_re;
! vec_dst_im[i] = old1_im;
! }
! }
!
! // g = 2.0f / (t_float)fftsize;
! /*
! ein fehler tritt auf beim 0.sample, hier sollte nur mal 1.0 multipliziert werden
! wenn gelten soll : Energie im zeitfenster == Energie im Frequenz-dichte-fenster
!
! g = 1.0f;
! for(i = 0; i < fs2; i++)
! {
! vec_dst_re[i] *= g;
! vec_dst_im[i] *= g;
! }
! */
!
! g = 1.0f / (t_float)fftsize;
! for(i = 0; i < fftsize; i++)
! {
! vec_dst_re[i] *= g;
! vec_dst_im[i] *= g;
! }
!
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_re, garray_class);
! garray_redraw(a);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_im, garray_class);
! garray_redraw(a);
! }
}
static void tab_ifft_list(t_tab_ifft *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src_re, beg_src_im, beg_dst_re, beg_dst_im;
! int i, j, k;
! int ok_src_re, ok_src_im, ok_dst_re, ok_dst_im;
! int w_index, w_inc, i_inc, v_index;
! int fftsize = x->x_fftsize;
! int fs1 = fftsize - 1;
! int fs2 = fftsize / 2;
! TAB_COMPLEX w;
! TAB_COMPLEX *sincos = x->x_sin_cos;
! t_float *vec_src_re, *vec_src_im, *vec_dst_re, *vec_dst_im;
! t_float old1_re, old1_im, old2_re, old2_im, g;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src_re = (int)atom_getintarg(0, argc, argv);
! beg_src_im = (int)atom_getintarg(1, argc, argv);
! beg_dst_re = (int)atom_getintarg(2, argc, argv);
! beg_dst_im = (int)atom_getintarg(3, argc, argv);
! if(beg_src_re < 0)
! beg_src_re = 0;
! if(beg_src_im < 0)
! beg_src_im = 0;
! if(beg_dst_re < 0)
! beg_dst_re = 0;
! if(beg_dst_im < 0)
! beg_dst_im = 0;
!
! ok_src_re = iem_tab_check_arrays(gensym("tab_ifft"), x->x_sym_src_re, &x->x_beg_mem_src_re, &x->x_size_src_re, fftsize);
! ok_src_im = iem_tab_check_arrays(gensym("tab_ifft"), x->x_sym_src_im, &x->x_beg_mem_src_im, &x->x_size_src_im, fftsize);
! ok_dst_re = iem_tab_check_arrays(gensym("tab_ifft"), x->x_sym_dst_re, &x->x_beg_mem_dst_re, &x->x_size_dst_re, fftsize);
! ok_dst_im = iem_tab_check_arrays(gensym("tab_ifft"), x->x_sym_dst_im, &x->x_beg_mem_dst_im, &x->x_size_dst_im, fftsize);
!
! if(ok_src_re && ok_src_im && ok_dst_re && ok_dst_im)
! {
! t_garray *a;
!
! vec_src_re=x->x_beg_mem_src_re + beg_src_re;
! vec_src_im=x->x_beg_mem_src_im + beg_src_im;
! vec_dst_re=x->x_beg_mem_dst_re + beg_dst_re;
! vec_dst_im=x->x_beg_mem_dst_im + beg_dst_im;
!
! for(j=0; j<fftsize; j++)
! {
! vec_dst_re[j] = vec_src_re[j];
! vec_dst_im[j] = vec_src_im[j];
! }
!
! i_inc = fs2;
! w_inc = 1;
! for(i=1; i<fftsize; i<<=1)
! {
! v_index = 0;
! for(j=0; j<i; j++)
! {
! w_index = 0;
! for(k=0; k<i_inc; k++)
! {
! old1_re = vec_dst_re[v_index];
! old1_im = vec_dst_im[v_index];
! old2_re = vec_dst_re[v_index+i_inc];
! old2_im = vec_dst_im[v_index+i_inc];
! w = sincos[w_index];
! vec_dst_re[v_index+i_inc] = (old1_re - old2_re)*w.real - (old1_im - old2_im)*w.imag;
! vec_dst_im[v_index+i_inc] = (old1_im - old2_im)*w.real + (old1_re - old2_re)*w.imag;
! vec_dst_re[v_index] = old1_re + old2_re;
! vec_dst_im[v_index] = old1_im + old2_im;
! w_index += w_inc;
! v_index++;
! }
! v_index += i_inc;
! }
! w_inc <<= 1;
! i_inc >>= 1;
! }
!
! j = 0;
! for(i=1;i<fs1;i++)
! {
! k = fs2;
! while(k <= j)
! {
! j = j - k;
! k >>= 1;
! }
! j = j + k;
! if(i < j)
! {
! old1_re = vec_dst_re[j];
! old1_im = vec_dst_im[j];
! vec_dst_re[j] = vec_dst_re[i];
! vec_dst_im[j] = vec_dst_im[i];
! vec_dst_re[i] = old1_re;
! vec_dst_im[i] = old1_im;
! }
! }
!
! // g = 2.0f / (t_float)fftsize;
! /*
! ein fehler tritt auf beim 0.sample, hier sollte nur mal 1.0 multipliziert werden
! wenn gelten soll : Energie im zeitfenster == Energie im Frequenz-dichte-fenster
!
! g = 1.0f;
! for(i = 0; i < fs2; i++)
! {
! vec_dst_re[i] *= g;
! vec_dst_im[i] *= g;
! }
! */
!
! g = 1.0f / (t_float)fftsize;
! for(i = 0; i < fftsize; i++)
! {
! vec_dst_re[i] *= g;
! vec_dst_im[i] *= g;
! }
!
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_re, garray_class);
! garray_redraw(a);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_im, garray_class);
! garray_redraw(a);
! }
! }
! else
! {
! post("tab_ifft-ERROR: list need 4 float arguments:");
! post(" source_real_offset + source_imag_offset + destination_real_offset + destination_imag_offset");
! }
}
static void tab_ifft_free(t_tab_ifft *x)
{
! freebytes(x->x_sin_cos, x->x_fftsize * sizeof(TAB_COMPLEX));
}
static void *tab_ifft_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_ifft *x = (t_tab_ifft *)pd_new(tab_ifft_class);
! t_symbol *src_re, *src_im, *dst_re, *dst_im;
! int fftsize, i=1;
!
! if((argc >= 5) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2) &&
! IS_A_SYMBOL(argv,3) &&
! IS_A_FLOAT(argv,4))
! {
! src_re = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src_im = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst_re = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! dst_im = (t_symbol *)atom_getsymbolarg(3, argc, argv);
! fftsize = (int)atom_getintarg(4, argc, argv);
! }
! else
! {
! post("tab_ifft-ERROR: need 4 symbols + 1 float arguments:");
! post(" source_real_array_name + source_imag_array_name + destination_real_array_name + destination_imag_array_name + IFFT-size");
! return(0);
! }
!
! if(fftsize < 8)
! fftsize = 8;
!
! while(i <= fftsize)
! i *= 2;
! i /= 2;
! fftsize = i;
!
! x->x_fftsize = fftsize;
! x->x_sym_src_re = src_re;
! x->x_sym_src_im = src_im;
! x->x_sym_dst_re = dst_re;
! x->x_sym_dst_im = dst_im;
! x->x_sin_cos = (TAB_COMPLEX *)getbytes(x->x_fftsize * sizeof(TAB_COMPLEX));
! tab_ifft_init(x);
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_ifft_setup(void)
{
! tab_ifft_class = class_new(gensym("tab_ifft"), (t_newmethod)tab_ifft_new, (t_method)tab_ifft_free,
! sizeof(t_tab_ifft), 0, A_GIMME, 0);
! class_addbang(tab_ifft_class, (t_method)tab_ifft_bang);
! class_addlist(tab_ifft_class, (t_method)tab_ifft_list);
! class_addmethod(tab_ifft_class, (t_method)tab_ifft_ifftsize, gensym("ifftsize"), A_DEFFLOAT, 0);
! class_addmethod(tab_ifft_class, (t_method)tab_ifft_src_re, gensym("src_re"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ifft_class, (t_method)tab_ifft_src_im, gensym("src_im"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ifft_class, (t_method)tab_ifft_src_re, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ifft_class, (t_method)tab_ifft_src_im, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ifft_class, (t_method)tab_ifft_dst_re, gensym("dst_re"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ifft_class, (t_method)tab_ifft_dst_im, gensym("dst_re"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ifft_class, (t_method)tab_ifft_dst_re, gensym("dst1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ifft_class, (t_method)tab_ifft_dst_im, gensym("dst2"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_ifft_class, gensym("iemhelp2/tab_ifft-help"));
}
Index: tab_find_peaks.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_find_peaks.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_find_peaks.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_find_peaks.c 10 Nov 2006 17:15:47 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_find_peaks ------------------------------ */
--- 4,10 ----
***************
*** 25,45 ****
typedef struct _tab_find_peaks
{
! t_object x_obj;
! int x_size_src1;
! int x_offset_src1;
! float *x_beg_mem_src1;
int x_work_alloc;
! int *x_beg_mem_work1;
! float *x_beg_mem_work2;
int x_sort_mode;
! float x_hdiff;
int x_min_width;
int x_max_width;
int x_n_peaks;
! t_symbol *x_sym_scr1;
! t_outlet *x_bang_out;
! t_outlet *x_sort_index_out;
! t_outlet *x_peak_value_out;
! t_outlet *x_peak_index_out;
} t_tab_find_peaks;
--- 15,35 ----
typedef struct _tab_find_peaks
{
! t_object x_obj;
! int x_size_src1;
! int x_offset_src1;
! t_float *x_beg_mem_src1;
int x_work_alloc;
! int *x_beg_mem_work1;
! t_float *x_beg_mem_work2;
int x_sort_mode;
! t_float x_hdiff;
int x_min_width;
int x_max_width;
int x_n_peaks;
! t_symbol *x_sym_scr1;
! t_outlet *x_bang_out;
! t_outlet *x_sort_index_out;
! t_outlet *x_peak_value_out;
! t_outlet *x_peak_index_out;
} t_tab_find_peaks;
***************
*** 49,69 ****
{
int max_peaks = (int)fmax_peaks;
!
if(max_peaks <= 0)
max_peaks = 1;
! x->x_n_peaks = max_peaks;
}
static void tab_find_peaks_width_range(t_tab_find_peaks *x, t_symbol *s, int argc, t_atom *argv)
{
! int minw, maxw, h;
!
! if((argc >= 2) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1))
! {
! minw = (int)atom_getintarg(0, argc, argv);
maxw = (int)atom_getintarg(1, argc, argv);
! if(minw <= 0)
minw = 1;
if(maxw <= 0)
--- 39,59 ----
{
int max_peaks = (int)fmax_peaks;
!
if(max_peaks <= 0)
max_peaks = 1;
! x->x_n_peaks = max_peaks;
}
static void tab_find_peaks_width_range(t_tab_find_peaks *x, t_symbol *s, int argc, t_atom *argv)
{
! int minw, maxw, h;
!
! if((argc >= 2) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1))
! {
! minw = (int)atom_getintarg(0, argc, argv);
maxw = (int)atom_getintarg(1, argc, argv);
! if(minw <= 0)
minw = 1;
if(maxw <= 0)
***************
*** 77,81 ****
x->x_min_width = minw;
x->x_max_width = maxw;
! }
}
--- 67,71 ----
x->x_min_width = minw;
x->x_max_width = maxw;
! }
}
***************
*** 84,103 ****
if(height_diff < 0.0f)
height_diff *= -1.0f;
! x->x_hdiff = height_diff;
}
static void tab_find_peaks_amp_sort(t_tab_find_peaks *x)
{
! x->x_sort_mode = IEMLIB_TAB_FIND_PEAKS_SORT_MODE_AMP;
}
static void tab_find_peaks_freq_sort(t_tab_find_peaks *x)
{
! x->x_sort_mode = IEMLIB_TAB_FIND_PEAKS_SORT_MODE_FREQ;
}
static void tab_find_peaks_src(t_tab_find_peaks *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
--- 74,93 ----
if(height_diff < 0.0f)
height_diff *= -1.0f;
! x->x_hdiff = height_diff;
}
static void tab_find_peaks_amp_sort(t_tab_find_peaks *x)
{
! x->x_sort_mode = IEMLIB_TAB_FIND_PEAKS_SORT_MODE_AMP;
}
static void tab_find_peaks_freq_sort(t_tab_find_peaks *x)
{
! x->x_sort_mode = IEMLIB_TAB_FIND_PEAKS_SORT_MODE_FREQ;
}
static void tab_find_peaks_src(t_tab_find_peaks *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
***************
*** 124,128 ****
{
x->x_beg_mem_work1 = (int *)getbytes(n * sizeof(int));
! x->x_beg_mem_work2 = (float *)getbytes(n * sizeof(float));
x->x_work_alloc = n;
}
--- 114,118 ----
{
x->x_beg_mem_work1 = (int *)getbytes(n * sizeof(int));
! x->x_beg_mem_work2 = (t_float *)getbytes(n * sizeof(t_float));
x->x_work_alloc = n;
}
***************
*** 130,134 ****
{
x->x_beg_mem_work1 = (int *)resizebytes(x->x_beg_mem_work1, x->x_work_alloc*sizeof(int), n*sizeof(int));
! x->x_beg_mem_work2 = (float *)resizebytes(x->x_beg_mem_work2, x->x_work_alloc*sizeof(float), n*sizeof(float));
x->x_work_alloc = n;
}
--- 120,124 ----
{
x->x_beg_mem_work1 = (int *)resizebytes(x->x_beg_mem_work1, x->x_work_alloc*sizeof(int), n*sizeof(int));
! x->x_beg_mem_work2 = (t_float *)resizebytes(x->x_beg_mem_work2, x->x_work_alloc*sizeof(t_float), n*sizeof(t_float));
x->x_work_alloc = n;
}
***************
*** 159,163 ****
diff_high = vec_src[i+high_bord] - abs_min_height_diff;
if((vec_src[i-low_bord-1] < diff_low) && !vec_work1[i-low_bord] &&
! (vec_src[i+high_bord+1] < diff_high) && !vec_work1[i+high_bord])
{
for(j=i-low_bord; j<=i+high_bord; j++)
--- 149,153 ----
diff_high = vec_src[i+high_bord] - abs_min_height_diff;
if((vec_src[i-low_bord-1] < diff_low) && !vec_work1[i-low_bord] &&
! (vec_src[i+high_bord+1] < diff_high) && !vec_work1[i+high_bord])
{
for(j=i-low_bord; j<=i+high_bord; j++)
***************
*** 186,190 ****
{
outlet_float(x->x_peak_value_out, vec_src[i]);
! outlet_float(x->x_peak_index_out, (float)peak_index);
outlet_float(x->x_sort_index_out, sort_index);
sort_index++;
--- 176,180 ----
{
outlet_float(x->x_peak_value_out, vec_src[i]);
! outlet_float(x->x_peak_index_out, (t_float)peak_index);
outlet_float(x->x_sort_index_out, sort_index);
sort_index++;
***************
*** 221,225 ****
diff_high = vec_src[i+high_bord] - abs_min_height_diff;
if((vec_src[i-low_bord-1] < diff_low) && !vec_work1[i-low_bord] &&
! (vec_src[i+high_bord+1] < diff_high) && !vec_work1[i+high_bord])
{
for(j=i-low_bord; j<=i+high_bord; j++)
--- 211,215 ----
diff_high = vec_src[i+high_bord] - abs_min_height_diff;
if((vec_src[i-low_bord-1] < diff_low) && !vec_work1[i-low_bord] &&
! (vec_src[i+high_bord+1] < diff_high) && !vec_work1[i+high_bord])
{
for(j=i-low_bord; j<=i+high_bord; j++)
***************
*** 253,257 ****
{
outlet_float(x->x_peak_value_out, max);
! outlet_float(x->x_peak_index_out, (float)peak_index);
outlet_float(x->x_sort_index_out, sort_index);
vec_work1[peak_index] = 0;
--- 243,247 ----
{
outlet_float(x->x_peak_value_out, max);
! outlet_float(x->x_peak_index_out, (t_float)peak_index);
outlet_float(x->x_sort_index_out, sort_index);
vec_work1[peak_index] = 0;
***************
*** 289,335 ****
/*static void tab_find_peaks_list(t_tab_find_peaks *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src;
! int i, n;
! int ok_src, max_index=0;
! t_float *vec_src;
! t_float max=-1.0e37;
!
! if((argc >= 2) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1))
! {
! beg_src = (int)atom_getintarg(0, argc, argv);
! n = (int)atom_getintarg(1, argc, argv);
! if(beg_src < 0)
! beg_src = 0;
! if(n < 0)
! n = 0;
!
! ok_src = iem_tab_check_arrays(gensym("tab_find_peaks"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+n);
! if(ok_src)
! {
! vec_src = x->x_beg_mem_src1 + beg_src;
! if(n)
! {
! for(i=0; i<n; i++)
! {
! if(vec_src[i] > max)
! {
! max = vec_src[i];
! max_index = i + beg_src;
! }
! }
! outlet_float(x->x_peak_value_out, max);
! outlet_float(x->x_peak_index_out, (float)max_index);
! outlet_bang(x->x_bang_out);
! }
! }
! }
! else
! {
! post("tab_find_peaks-ERROR: list need 2 float arguments:");
! post(" source_offset + number_of_samples_to_calc_max_index");
! }
}*/
--- 279,325 ----
/*static void tab_find_peaks_list(t_tab_find_peaks *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src;
! int i, n;
! int ok_src, max_index=0;
! t_float *vec_src;
! t_float max=-1.0e37;
! if((argc >= 2) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1))
! {
! beg_src = (int)atom_getintarg(0, argc, argv);
! n = (int)atom_getintarg(1, argc, argv);
! if(beg_src < 0)
! beg_src = 0;
! if(n < 0)
! n = 0;
!
! ok_src = iem_tab_check_arrays(gensym("tab_find_peaks"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+n);
!
! if(ok_src)
! {
! vec_src = x->x_beg_mem_src1 + beg_src;
! if(n)
! {
! for(i=0; i<n; i++)
! {
! if(vec_src[i] > max)
! {
! max = vec_src[i];
! max_index = i + beg_src;
! }
! }
! outlet_float(x->x_peak_value_out, max);
! outlet_float(x->x_peak_index_out, (t_float)max_index);
! outlet_bang(x->x_bang_out);
! }
! }
! }
! else
! {
! post("tab_find_peaks-ERROR: list need 2 float arguments:");
! post(" source_offset + number_of_samples_to_calc_max_index");
! }
}*/
***************
*** 339,343 ****
{
freebytes(x->x_beg_mem_work1, x->x_work_alloc * sizeof(int));
! freebytes(x->x_beg_mem_work2, x->x_work_alloc * sizeof(float));
}
}
--- 329,333 ----
{
freebytes(x->x_beg_mem_work1, x->x_work_alloc * sizeof(int));
! freebytes(x->x_beg_mem_work2, x->x_work_alloc * sizeof(t_float));
}
}
***************
*** 345,384 ****
static void *tab_find_peaks_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_find_peaks *x = (t_tab_find_peaks *)pd_new(tab_find_peaks_class);
! t_symbol *src;
!
! if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! }
! else
! {
! post("tab_find_peaks-ERROR: need 1 symbol argument:");
! post(" source_array_name");
! return(0);
! }
!
x->x_work_alloc = 0;
x->x_beg_mem_work1 = (int *)0;
! x->x_beg_mem_work2 = (float *)0;
!
! x->x_sym_scr1 = src;
! x->x_bang_out = (t_outlet *)outlet_new(&x->x_obj, &s_bang); // ready
x->x_sort_index_out = (t_outlet *)outlet_new(&x->x_obj, &s_float); // sort index
! x->x_peak_index_out = (t_outlet *)outlet_new(&x->x_obj, &s_float); // freq
! x->x_peak_value_out = (t_outlet *)outlet_new(&x->x_obj, &s_float); // value
! return(x);
}
void tab_find_peaks_setup(void)
{
! tab_find_peaks_class = class_new(gensym("tab_find_peaks"), (t_newmethod)tab_find_peaks_new, (t_method)tab_find_peaks_free,
! sizeof(t_tab_find_peaks), 0, A_GIMME, 0);
! class_addbang(tab_find_peaks_class, (t_method)tab_find_peaks_bang);
! /*class_addlist(tab_find_peaks_class, (t_method)tab_find_peaks_list);*/
! class_addmethod(tab_find_peaks_class, (t_method)tab_find_peaks_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_find_peaks_class, (t_method)tab_find_peaks_src, gensym("src1"), A_DEFSYMBOL, 0);
class_addmethod(tab_find_peaks_class, (t_method)tab_find_peaks_max_peaks, gensym("max_peaks"), A_DEFFLOAT, 0);
class_addmethod(tab_find_peaks_class, (t_method)tab_find_peaks_width_range, gensym("width_range"), A_GIMME, 0);
--- 335,374 ----
static void *tab_find_peaks_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_find_peaks *x = (t_tab_find_peaks *)pd_new(tab_find_peaks_class);
! t_symbol *src;
!
! if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! }
! else
! {
! post("tab_find_peaks-ERROR: need 1 symbol argument:");
! post(" source_array_name");
! return(0);
! }
!
x->x_work_alloc = 0;
x->x_beg_mem_work1 = (int *)0;
! x->x_beg_mem_work2 = (t_float *)0;
!
! x->x_sym_scr1 = src;
! x->x_bang_out = (t_outlet *)outlet_new(&x->x_obj, &s_bang); // ready
x->x_sort_index_out = (t_outlet *)outlet_new(&x->x_obj, &s_float); // sort index
! x->x_peak_index_out = (t_outlet *)outlet_new(&x->x_obj, &s_float); // freq
! x->x_peak_value_out = (t_outlet *)outlet_new(&x->x_obj, &s_float); // value
! return(x);
}
void tab_find_peaks_setup(void)
{
! tab_find_peaks_class = class_new(gensym("tab_find_peaks"), (t_newmethod)tab_find_peaks_new, (t_method)tab_find_peaks_free,
! sizeof(t_tab_find_peaks), 0, A_GIMME, 0);
! class_addbang(tab_find_peaks_class, (t_method)tab_find_peaks_bang);
! /*class_addlist(tab_find_peaks_class, (t_method)tab_find_peaks_list);*/
! class_addmethod(tab_find_peaks_class, (t_method)tab_find_peaks_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_find_peaks_class, (t_method)tab_find_peaks_src, gensym("src1"), A_DEFSYMBOL, 0);
class_addmethod(tab_find_peaks_class, (t_method)tab_find_peaks_max_peaks, gensym("max_peaks"), A_DEFFLOAT, 0);
class_addmethod(tab_find_peaks_class, (t_method)tab_find_peaks_width_range, gensym("width_range"), A_GIMME, 0);
***************
*** 386,389 ****
class_addmethod(tab_find_peaks_class, (t_method)tab_find_peaks_amp_sort, gensym("amp_sort"), 0);
class_addmethod(tab_find_peaks_class, (t_method)tab_find_peaks_freq_sort, gensym("freq_sort"), 0);
! class_sethelpsymbol(tab_find_peaks_class, gensym("iemhelp2/tab_find_peaks-help"));
}
--- 376,379 ----
class_addmethod(tab_find_peaks_class, (t_method)tab_find_peaks_amp_sort, gensym("amp_sort"), 0);
class_addmethod(tab_find_peaks_class, (t_method)tab_find_peaks_freq_sort, gensym("freq_sort"), 0);
! class_sethelpsymbol(tab_find_peaks_class, gensym("iemhelp2/tab_find_peaks-help"));
}
Index: tab_add_scalar.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_add_scalar.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_add_scalar.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_add_scalar.c 10 Nov 2006 17:15:47 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_add_scalar ------------------------------ */
--- 4,10 ----
***************
*** 22,34 ****
typedef struct _tab_add_scalar
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! float *x_beg_mem_src1;
! float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_add_scalar;
--- 12,24 ----
typedef struct _tab_add_scalar
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_add_scalar;
***************
*** 37,127 ****
static void tab_add_scalar_src(t_tab_add_scalar *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_add_scalar_float(t_tab_add_scalar *x, t_floatarg add)
{
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_add_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_add_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = vec_src1[i] + add;
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_add_scalar_dst(t_tab_add_scalar *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_add_scalar_list(t_tab_add_scalar *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_dst;
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst, add;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_dst = (int)atom_getintarg(1, argc, argv);
! n = (int)atom_getintarg(2, argc, argv);
! add = (t_float)atom_getfloatarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_add_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_add_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = vec_src1[i] + add;
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_add_scalar-ERROR: list need 4 float arguments:");
! post(" source1_offset + destination_offset + number_of_samples_to_add + add_scalar");
! }
}
--- 27,117 ----
static void tab_add_scalar_src(t_tab_add_scalar *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_add_scalar_float(t_tab_add_scalar *x, t_floatarg add)
{
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_add_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_add_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = vec_src1[i] + add;
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_add_scalar_dst(t_tab_add_scalar *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_add_scalar_list(t_tab_add_scalar *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_dst;
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst, add;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_dst = (int)atom_getintarg(1, argc, argv);
! n = (int)atom_getintarg(2, argc, argv);
! add = (t_float)atom_getfloatarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_add_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_add_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = vec_src1[i] + add;
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_add_scalar-ERROR: list need 4 float arguments:");
! post(" source1_offset + destination_offset + number_of_samples_to_add + add_scalar");
! }
}
***************
*** 132,173 ****
static void *tab_add_scalar_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_add_scalar *x = (t_tab_add_scalar *)pd_new(tab_add_scalar_class);
! t_symbol *src1, *dst;
!
! if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! }
! else
! {
! post("tab_add_scalar-ERROR: need 2 symbol arguments:");
! post(" source_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_add_scalar_setup(void)
{
! tab_add_scalar_class = class_new(gensym("tab_add_scalar"), (t_newmethod)tab_add_scalar_new, (t_method)tab_add_scalar_free,
! sizeof(t_tab_add_scalar), 0, A_GIMME, 0);
! class_addfloat(tab_add_scalar_class, (t_method)tab_add_scalar_float);
! class_addlist(tab_add_scalar_class, (t_method)tab_add_scalar_list);
! class_addmethod(tab_add_scalar_class, (t_method)tab_add_scalar_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_add_scalar_class, (t_method)tab_add_scalar_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_add_scalar_class, (t_method)tab_add_scalar_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_add_scalar_class, gensym("iemhelp2/tab_add_scalar-help"));
}
--- 122,163 ----
static void *tab_add_scalar_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_add_scalar *x = (t_tab_add_scalar *)pd_new(tab_add_scalar_class);
! t_symbol *src1, *dst;
!
! if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! }
! else
! {
! post("tab_add_scalar-ERROR: need 2 symbol arguments:");
! post(" source_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_add_scalar_setup(void)
{
! tab_add_scalar_class = class_new(gensym("tab_add_scalar"), (t_newmethod)tab_add_scalar_new, (t_method)tab_add_scalar_free,
! sizeof(t_tab_add_scalar), 0, A_GIMME, 0);
! class_addfloat(tab_add_scalar_class, (t_method)tab_add_scalar_float);
! class_addlist(tab_add_scalar_class, (t_method)tab_add_scalar_list);
! class_addmethod(tab_add_scalar_class, (t_method)tab_add_scalar_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_add_scalar_class, (t_method)tab_add_scalar_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_add_scalar_class, (t_method)tab_add_scalar_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_add_scalar_class, gensym("iemhelp2/tab_add_scalar-help"));
}
Index: tab_fft.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_fft.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_fft.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_fft.c 10 Nov 2006 17:15:47 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
#include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_fft ------------------------------ */
--- 4,11 ----
***************
*** 22,44 ****
typedef struct _tab_fft
{
! t_object x_obj;
! int x_size_src_re;
! int x_size_src_im;
! int x_size_dst_re;
! int x_size_dst_im;
! int x_offset_src_re;
! int x_offset_src_im;
! int x_offset_dst_re;
! int x_offset_dst_im;
! int x_fftsize;
! float *x_beg_mem_src_re;
! float *x_beg_mem_src_im;
! float *x_beg_mem_dst_re;
! float *x_beg_mem_dst_im;
! TAB_COMPLEX *x_sin_cos;
! t_symbol *x_sym_src_re;
! t_symbol *x_sym_src_im;
! t_symbol *x_sym_dst_re;
! t_symbol *x_sym_dst_im;
} t_tab_fft;
--- 13,35 ----
typedef struct _tab_fft
{
! t_object x_obj;
! int x_size_src_re;
! int x_size_src_im;
! int x_size_dst_re;
! int x_size_dst_im;
! int x_offset_src_re;
! int x_offset_src_im;
! int x_offset_dst_re;
! int x_offset_dst_im;
! int x_fftsize;
! t_float *x_beg_mem_src_re;
! t_float *x_beg_mem_src_im;
! t_float *x_beg_mem_dst_re;
! t_float *x_beg_mem_dst_im;
! TAB_COMPLEX *x_sin_cos;
! t_symbol *x_sym_src_re;
! t_symbol *x_sym_src_im;
! t_symbol *x_sym_dst_re;
! t_symbol *x_sym_dst_im;
} t_tab_fft;
***************
*** 47,400 ****
static void tab_fft_init(t_tab_fft *x)
{
! int i, fftsize = x->x_fftsize;
! float f, g;
! TAB_COMPLEX *sincos = x->x_sin_cos;
!
! g = 2.0f * 3.1415926538f / (float)fftsize;
! for(i=0; i<fftsize; i++)
! {
! f = g * (float)i;
! (*sincos).real = cos(f);
! (*sincos).imag = -sin(f);/*FFT*/
! sincos++;
! }
}
static void tab_fft_fftsize(t_tab_fft *x, t_floatarg f)
{
! int i=1, fftsize = (int)f;
!
! if(fftsize < 8)
! fftsize = 8;
!
! while(i <= fftsize)
! i *= 2;
! i /= 2;
!
! if(i != x->x_fftsize)
! {
! x->x_sin_cos = (TAB_COMPLEX *)resizebytes(x->x_sin_cos, x->x_fftsize*sizeof(TAB_COMPLEX), i*sizeof(TAB_COMPLEX));
! x->x_fftsize = i;
! }
! tab_fft_init(x);
}
static void tab_fft_src_re(t_tab_fft *x, t_symbol *s)
{
! x->x_sym_src_re = s;
}
static void tab_fft_src_im(t_tab_fft *x, t_symbol *s)
{
! x->x_sym_src_im = s;
}
static void tab_fft_dst_re(t_tab_fft *x, t_symbol *s)
{
! x->x_sym_dst_re = s;
}
static void tab_fft_dst_im(t_tab_fft *x, t_symbol *s)
{
! x->x_sym_dst_im = s;
}
static void tab_fft_bang(t_tab_fft *x)
{
! int i, j, k;
! int ok_src_re, ok_src_im, ok_dst_re, ok_dst_im;
! int w_index, w_inc, i_inc, v_index;
! int fftsize = x->x_fftsize;
! int fs1 = fftsize - 1;
! int fs2 = fftsize / 2;
! TAB_COMPLEX w;
! TAB_COMPLEX *sincos = x->x_sin_cos;
! t_float *vec_src_re, *vec_src_im, *vec_dst_re, *vec_dst_im;
! t_float old1_re, old1_im, old2_re, old2_im;
!
! ok_src_re = iem_tab_check_arrays(gensym("tab_fft"), x->x_sym_src_re, &x->x_beg_mem_src_re, &x->x_size_src_re, fftsize);
! ok_src_im = iem_tab_check_arrays(gensym("tab_fft"), x->x_sym_src_im, &x->x_beg_mem_src_im, &x->x_size_src_im, fftsize);
! ok_dst_re = iem_tab_check_arrays(gensym("tab_fft"), x->x_sym_dst_re, &x->x_beg_mem_dst_re, &x->x_size_dst_re, fftsize);
! ok_dst_im = iem_tab_check_arrays(gensym("tab_fft"), x->x_sym_dst_im, &x->x_beg_mem_dst_im, &x->x_size_dst_im, fftsize);
! if(ok_src_re && ok_src_im && ok_dst_re && ok_dst_im)
! {
! t_garray *a;
!
! vec_src_re=x->x_beg_mem_src_re;
! vec_src_im=x->x_beg_mem_src_im;
! vec_dst_re=x->x_beg_mem_dst_re;
! vec_dst_im=x->x_beg_mem_dst_im;
!
! for(k=0; k<fftsize; k++)
! {
! vec_dst_re[k] = vec_src_re[k];
! vec_dst_im[k] = vec_src_im[k];
! }
!
! i_inc = fs2;
! w_inc = 1;
! for(i=1; i<fftsize; i<<=1)
! {
! v_index = 0;
! for(j=0; j<i; j++)
! {
! w_index = 0;
! for(k=0; k<i_inc; k++)
! {
! old1_re = vec_dst_re[v_index];
! old1_im = vec_dst_im[v_index];
! old2_re = vec_dst_re[v_index+i_inc];
! old2_im = vec_dst_im[v_index+i_inc];
! w = sincos[w_index];
! vec_dst_re[v_index+i_inc] = (old1_re - old2_re)*w.real - (old1_im - old2_im)*w.imag;
! vec_dst_im[v_index+i_inc] = (old1_im - old2_im)*w.real + (old1_re - old2_re)*w.imag;
! vec_dst_re[v_index] = old1_re + old2_re;
! vec_dst_im[v_index] = old1_im + old2_im;
! w_index += w_inc;
! v_index++;
! }
! v_index += i_inc;
! }
! w_inc <<= 1;
! i_inc >>= 1;
! }
!
! j = 0;
! for(i=1;i<fs1;i++)
! {
! k = fs2;
! while(k <= j)
! {
! j = j - k;
! k >>= 1;
! }
! j = j + k;
! if(i < j)
! {
! old1_re = vec_dst_re[j];
! old1_im = vec_dst_im[j];
! vec_dst_re[j] = vec_dst_re[i];
! vec_dst_im[j] = vec_dst_im[i];
! vec_dst_re[i] = old1_re;
! vec_dst_im[i] = old1_im;
! }
! }
!
! // g = 2.0f / (float)fftsize;
! /*
! ein fehler tritt auf beim 0.sample, hier sollte nur mal 1.0 multipliziert werden
! wenn gelten soll : Energie im zeitfenster == Energie im Frequenz-dichte-fenster
!
! g = 1.0f;
! for(i = 0; i < fs2; i++)
! {
! vec_dst_re[i] *= g;
! vec_dst_im[i] *= g;
! }
! */
!
!
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_re, garray_class);
! garray_redraw(a);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_im, garray_class);
! garray_redraw(a);
! }
}
static void tab_fft_list(t_tab_fft *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src_re, beg_src_im, beg_dst_re, beg_dst_im;
! int i, j, k;
! int ok_src_re, ok_src_im, ok_dst_re, ok_dst_im;
! int w_index, w_inc, i_inc, v_index;
! int fftsize = x->x_fftsize;
! int fs1 = fftsize - 1;
! int fs2 = fftsize / 2;
! TAB_COMPLEX w;
! TAB_COMPLEX *sincos = x->x_sin_cos;
! t_float *vec_src_re, *vec_src_im, *vec_dst_re, *vec_dst_im;
! t_float old1_re, old1_im, old2_re, old2_im;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src_re = (int)atom_getintarg(0, argc, argv);
! beg_src_im = (int)atom_getintarg(1, argc, argv);
! beg_dst_re = (int)atom_getintarg(2, argc, argv);
! beg_dst_im = (int)atom_getintarg(3, argc, argv);
! if(beg_src_re < 0)
! beg_src_re = 0;
! if(beg_src_im < 0)
! beg_src_im = 0;
! if(beg_dst_re < 0)
! beg_dst_re = 0;
! if(beg_dst_im < 0)
! beg_dst_im = 0;
!
! ok_src_re = iem_tab_check_arrays(gensym("tab_fft"), x->x_sym_src_re, &x->x_beg_mem_src_re, &x->x_size_src_re, beg_src_re+fftsize);
! ok_src_im = iem_tab_check_arrays(gensym("tab_fft"), x->x_sym_src_im, &x->x_beg_mem_src_im, &x->x_size_src_im, beg_src_im+fftsize);
! ok_dst_re = iem_tab_check_arrays(gensym("tab_fft"), x->x_sym_dst_re, &x->x_beg_mem_dst_re, &x->x_size_dst_re, beg_dst_re+fftsize);
! ok_dst_im = iem_tab_check_arrays(gensym("tab_fft"), x->x_sym_dst_im, &x->x_beg_mem_dst_im, &x->x_size_dst_im, beg_dst_im+fftsize);
!
! if(ok_src_re && ok_src_im && ok_dst_re && ok_dst_im)
! {
! t_garray *a;
!
! vec_src_re=x->x_beg_mem_src_re + beg_src_re;
! vec_src_im=x->x_beg_mem_src_im + beg_src_im;
! vec_dst_re=x->x_beg_mem_dst_re + beg_dst_re;
! vec_dst_im=x->x_beg_mem_dst_im + beg_dst_im;
!
! for(k=0; k<fftsize; k++)
! {
! vec_dst_re[k] = vec_src_re[k];
! vec_dst_im[k] = vec_src_im[k];
! }
!
! i_inc = fs2;
! w_inc = 1;
! for(i=1; i<fftsize; i<<=1)
! {
! v_index = 0;
! for(j=0; j<i; j++)
! {
! w_index = 0;
! for(k=0; k<i_inc; k++)
! {
! old1_re = vec_dst_re[v_index];
! old1_im = vec_dst_im[v_index];
! old2_re = vec_dst_re[v_index+i_inc];
! old2_im = vec_dst_im[v_index+i_inc];
! w = sincos[w_index];
! vec_dst_re[v_index+i_inc] = (old1_re - old2_re)*w.real - (old1_im - old2_im)*w.imag;
! vec_dst_im[v_index+i_inc] = (old1_im - old2_im)*w.real + (old1_re - old2_re)*w.imag;
! vec_dst_re[v_index] = old1_re + old2_re;
! vec_dst_im[v_index] = old1_im + old2_im;
! w_index += w_inc;
! v_index++;
! }
! v_index += i_inc;
! }
! w_inc <<= 1;
! i_inc >>= 1;
! }
!
! j = 0;
! for(i=1;i<fs1;i++)
! {
! k = fs2;
! while(k <= j)
! {
! j = j - k;
! k >>= 1;
! }
! j = j + k;
! if(i < j)
! {
! old1_re = vec_dst_re[j];
! old1_im = vec_dst_im[j];
! vec_dst_re[j] = vec_dst_re[i];
! vec_dst_im[j] = vec_dst_im[i];
! vec_dst_re[i] = old1_re;
! vec_dst_im[i] = old1_im;
! }
! }
!
! // g = 2.0f / (float)fftsize;
! /*
! ein fehler tritt auf beim 0.sample, hier sollte nur mal 1.0 multipliziert werden
! wenn gelten soll : Energie im zeitfenster == Energie im Frequenz-dichte-fenster
!
! g = 1.0f;
! for(i = 0; i < fs2; i++)
! {
! vec_dst_re[i] *= g;
! vec_dst_im[i] *= g;
! }
! */
!
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_re, garray_class);
! garray_redraw(a);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_im, garray_class);
! garray_redraw(a);
! }
! }
! else
! {
! post("tab_fft-ERROR: list need 4 float arguments:");
! post(" source_real_offset + source_imag_offset + destination_real_offset + destination_imag_offset");
! }
}
static void tab_fft_free(t_tab_fft *x)
{
! freebytes(x->x_sin_cos, x->x_fftsize * sizeof(TAB_COMPLEX));
}
static void *tab_fft_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_fft *x = (t_tab_fft *)pd_new(tab_fft_class);
! t_symbol *src_re, *src_im, *dst_re, *dst_im;
! int fftsize, i=1;
!
! if((argc >= 5) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2) &&
! IS_A_SYMBOL(argv,3) &&
! IS_A_FLOAT(argv,4))
! {
! src_re = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src_im = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst_re = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! dst_im = (t_symbol *)atom_getsymbolarg(3, argc, argv);
! fftsize = (int)atom_getintarg(4, argc, argv);
! }
! else
! {
! post("tab_fft-ERROR: need 4 symbols + 1 float arguments:");
! post(" source_real_array_name + source_imag_array_name + destination_real_array_name + destination_imag_array_name + FFT-size");
! return(0);
! }
!
! if(fftsize < 8)
! fftsize = 8;
!
! while(i <= fftsize)
! i *= 2;
! i /= 2;
! fftsize = i;
!
! x->x_fftsize = fftsize;
! x->x_sym_src_re = src_re;
! x->x_sym_src_im = src_im;
! x->x_sym_dst_re = dst_re;
! x->x_sym_dst_im = dst_im;
! x->x_sin_cos = (TAB_COMPLEX *)getbytes(x->x_fftsize * sizeof(TAB_COMPLEX));
! tab_fft_init(x);
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_fft_setup(void)
{
! tab_fft_class = class_new(gensym("tab_fft"), (t_newmethod)tab_fft_new, (t_method)tab_fft_free,
! sizeof(t_tab_fft), 0, A_GIMME, 0);
! class_addbang(tab_fft_class, (t_method)tab_fft_bang);
! class_addlist(tab_fft_class, (t_method)tab_fft_list);
! class_addmethod(tab_fft_class, (t_method)tab_fft_fftsize, gensym("fftsize"), A_DEFFLOAT, 0);
! class_addmethod(tab_fft_class, (t_method)tab_fft_src_re, gensym("src_re"), A_DEFSYMBOL, 0);
! class_addmethod(tab_fft_class, (t_method)tab_fft_src_im, gensym("src_im"), A_DEFSYMBOL, 0);
! class_addmethod(tab_fft_class, (t_method)tab_fft_src_re, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_fft_class, (t_method)tab_fft_src_im, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_fft_class, (t_method)tab_fft_dst_re, gensym("dst_re"), A_DEFSYMBOL, 0);
! class_addmethod(tab_fft_class, (t_method)tab_fft_dst_im, gensym("dst_im"), A_DEFSYMBOL, 0);
! class_addmethod(tab_fft_class, (t_method)tab_fft_dst_re, gensym("dst1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_fft_class, (t_method)tab_fft_dst_im, gensym("dst2"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_fft_class, gensym("iemhelp2/tab_fft-help"));
}
--- 38,391 ----
static void tab_fft_init(t_tab_fft *x)
{
! int i, fftsize = x->x_fftsize;
! t_float f, g;
! TAB_COMPLEX *sincos = x->x_sin_cos;
!
! g = 2.0f * 3.1415926538f / (t_float)fftsize;
! for(i=0; i<fftsize; i++)
! {
! f = g * (t_float)i;
! (*sincos).real = cos(f);
! (*sincos).imag = -sin(f);/*FFT*/
! sincos++;
! }
}
static void tab_fft_fftsize(t_tab_fft *x, t_floatarg f)
{
! int i=1, fftsize = (int)f;
!
! if(fftsize < 8)
! fftsize = 8;
!
! while(i <= fftsize)
! i *= 2;
! i /= 2;
!
! if(i != x->x_fftsize)
! {
! x->x_sin_cos = (TAB_COMPLEX *)resizebytes(x->x_sin_cos, x->x_fftsize*sizeof(TAB_COMPLEX), i*sizeof(TAB_COMPLEX));
! x->x_fftsize = i;
! }
! tab_fft_init(x);
}
static void tab_fft_src_re(t_tab_fft *x, t_symbol *s)
{
! x->x_sym_src_re = s;
}
static void tab_fft_src_im(t_tab_fft *x, t_symbol *s)
{
! x->x_sym_src_im = s;
}
static void tab_fft_dst_re(t_tab_fft *x, t_symbol *s)
{
! x->x_sym_dst_re = s;
}
static void tab_fft_dst_im(t_tab_fft *x, t_symbol *s)
{
! x->x_sym_dst_im = s;
}
static void tab_fft_bang(t_tab_fft *x)
{
! int i, j, k;
! int ok_src_re, ok_src_im, ok_dst_re, ok_dst_im;
! int w_index, w_inc, i_inc, v_index;
! int fftsize = x->x_fftsize;
! int fs1 = fftsize - 1;
! int fs2 = fftsize / 2;
! TAB_COMPLEX w;
! TAB_COMPLEX *sincos = x->x_sin_cos;
! t_float *vec_src_re, *vec_src_im, *vec_dst_re, *vec_dst_im;
! t_float old1_re, old1_im, old2_re, old2_im;
!
! ok_src_re = iem_tab_check_arrays(gensym("tab_fft"), x->x_sym_src_re, &x->x_beg_mem_src_re, &x->x_size_src_re, fftsize);
! ok_src_im = iem_tab_check_arrays(gensym("tab_fft"), x->x_sym_src_im, &x->x_beg_mem_src_im, &x->x_size_src_im, fftsize);
! ok_dst_re = iem_tab_check_arrays(gensym("tab_fft"), x->x_sym_dst_re, &x->x_beg_mem_dst_re, &x->x_size_dst_re, fftsize);
! ok_dst_im = iem_tab_check_arrays(gensym("tab_fft"), x->x_sym_dst_im, &x->x_beg_mem_dst_im, &x->x_size_dst_im, fftsize);
! if(ok_src_re && ok_src_im && ok_dst_re && ok_dst_im)
! {
! t_garray *a;
!
! vec_src_re=x->x_beg_mem_src_re;
! vec_src_im=x->x_beg_mem_src_im;
! vec_dst_re=x->x_beg_mem_dst_re;
! vec_dst_im=x->x_beg_mem_dst_im;
!
! for(k=0; k<fftsize; k++)
! {
! vec_dst_re[k] = vec_src_re[k];
! vec_dst_im[k] = vec_src_im[k];
! }
!
! i_inc = fs2;
! w_inc = 1;
! for(i=1; i<fftsize; i<<=1)
! {
! v_index = 0;
! for(j=0; j<i; j++)
! {
! w_index = 0;
! for(k=0; k<i_inc; k++)
! {
! old1_re = vec_dst_re[v_index];
! old1_im = vec_dst_im[v_index];
! old2_re = vec_dst_re[v_index+i_inc];
! old2_im = vec_dst_im[v_index+i_inc];
! w = sincos[w_index];
! vec_dst_re[v_index+i_inc] = (old1_re - old2_re)*w.real - (old1_im - old2_im)*w.imag;
! vec_dst_im[v_index+i_inc] = (old1_im - old2_im)*w.real + (old1_re - old2_re)*w.imag;
! vec_dst_re[v_index] = old1_re + old2_re;
! vec_dst_im[v_index] = old1_im + old2_im;
! w_index += w_inc;
! v_index++;
! }
! v_index += i_inc;
! }
! w_inc <<= 1;
! i_inc >>= 1;
! }
!
! j = 0;
! for(i=1;i<fs1;i++)
! {
! k = fs2;
! while(k <= j)
! {
! j = j - k;
! k >>= 1;
! }
! j = j + k;
! if(i < j)
! {
! old1_re = vec_dst_re[j];
! old1_im = vec_dst_im[j];
! vec_dst_re[j] = vec_dst_re[i];
! vec_dst_im[j] = vec_dst_im[i];
! vec_dst_re[i] = old1_re;
! vec_dst_im[i] = old1_im;
! }
! }
!
! // g = 2.0f / (t_float)fftsize;
! /*
! ein fehler tritt auf beim 0.sample, hier sollte nur mal 1.0 multipliziert werden
! wenn gelten soll : Energie im zeitfenster == Energie im Frequenz-dichte-fenster
!
! g = 1.0f;
! for(i = 0; i < fs2; i++)
! {
! vec_dst_re[i] *= g;
! vec_dst_im[i] *= g;
! }
! */
!
!
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_re, garray_class);
! garray_redraw(a);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_im, garray_class);
! garray_redraw(a);
! }
}
static void tab_fft_list(t_tab_fft *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src_re, beg_src_im, beg_dst_re, beg_dst_im;
! int i, j, k;
! int ok_src_re, ok_src_im, ok_dst_re, ok_dst_im;
! int w_index, w_inc, i_inc, v_index;
! int fftsize = x->x_fftsize;
! int fs1 = fftsize - 1;
! int fs2 = fftsize / 2;
! TAB_COMPLEX w;
! TAB_COMPLEX *sincos = x->x_sin_cos;
! t_float *vec_src_re, *vec_src_im, *vec_dst_re, *vec_dst_im;
! t_float old1_re, old1_im, old2_re, old2_im;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src_re = (int)atom_getintarg(0, argc, argv);
! beg_src_im = (int)atom_getintarg(1, argc, argv);
! beg_dst_re = (int)atom_getintarg(2, argc, argv);
! beg_dst_im = (int)atom_getintarg(3, argc, argv);
! if(beg_src_re < 0)
! beg_src_re = 0;
! if(beg_src_im < 0)
! beg_src_im = 0;
! if(beg_dst_re < 0)
! beg_dst_re = 0;
! if(beg_dst_im < 0)
! beg_dst_im = 0;
!
! ok_src_re = iem_tab_check_arrays(gensym("tab_fft"), x->x_sym_src_re, &x->x_beg_mem_src_re, &x->x_size_src_re, beg_src_re+fftsize);
! ok_src_im = iem_tab_check_arrays(gensym("tab_fft"), x->x_sym_src_im, &x->x_beg_mem_src_im, &x->x_size_src_im, beg_src_im+fftsize);
! ok_dst_re = iem_tab_check_arrays(gensym("tab_fft"), x->x_sym_dst_re, &x->x_beg_mem_dst_re, &x->x_size_dst_re, beg_dst_re+fftsize);
! ok_dst_im = iem_tab_check_arrays(gensym("tab_fft"), x->x_sym_dst_im, &x->x_beg_mem_dst_im, &x->x_size_dst_im, beg_dst_im+fftsize);
!
! if(ok_src_re && ok_src_im && ok_dst_re && ok_dst_im)
! {
! t_garray *a;
!
! vec_src_re=x->x_beg_mem_src_re + beg_src_re;
! vec_src_im=x->x_beg_mem_src_im + beg_src_im;
! vec_dst_re=x->x_beg_mem_dst_re + beg_dst_re;
! vec_dst_im=x->x_beg_mem_dst_im + beg_dst_im;
!
! for(k=0; k<fftsize; k++)
! {
! vec_dst_re[k] = vec_src_re[k];
! vec_dst_im[k] = vec_src_im[k];
! }
!
! i_inc = fs2;
! w_inc = 1;
! for(i=1; i<fftsize; i<<=1)
! {
! v_index = 0;
! for(j=0; j<i; j++)
! {
! w_index = 0;
! for(k=0; k<i_inc; k++)
! {
! old1_re = vec_dst_re[v_index];
! old1_im = vec_dst_im[v_index];
! old2_re = vec_dst_re[v_index+i_inc];
! old2_im = vec_dst_im[v_index+i_inc];
! w = sincos[w_index];
! vec_dst_re[v_index+i_inc] = (old1_re - old2_re)*w.real - (old1_im - old2_im)*w.imag;
! vec_dst_im[v_index+i_inc] = (old1_im - old2_im)*w.real + (old1_re - old2_re)*w.imag;
! vec_dst_re[v_index] = old1_re + old2_re;
! vec_dst_im[v_index] = old1_im + old2_im;
! w_index += w_inc;
! v_index++;
! }
! v_index += i_inc;
! }
! w_inc <<= 1;
! i_inc >>= 1;
! }
!
! j = 0;
! for(i=1;i<fs1;i++)
! {
! k = fs2;
! while(k <= j)
! {
! j = j - k;
! k >>= 1;
! }
! j = j + k;
! if(i < j)
! {
! old1_re = vec_dst_re[j];
! old1_im = vec_dst_im[j];
! vec_dst_re[j] = vec_dst_re[i];
! vec_dst_im[j] = vec_dst_im[i];
! vec_dst_re[i] = old1_re;
! vec_dst_im[i] = old1_im;
! }
! }
!
! // g = 2.0f / (t_float)fftsize;
! /*
! ein fehler tritt auf beim 0.sample, hier sollte nur mal 1.0 multipliziert werden
! wenn gelten soll : Energie im zeitfenster == Energie im Frequenz-dichte-fenster
!
! g = 1.0f;
! for(i = 0; i < fs2; i++)
! {
! vec_dst_re[i] *= g;
! vec_dst_im[i] *= g;
! }
! */
!
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_re, garray_class);
! garray_redraw(a);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_im, garray_class);
! garray_redraw(a);
! }
! }
! else
! {
! post("tab_fft-ERROR: list need 4 float arguments:");
! post(" source_real_offset + source_imag_offset + destination_real_offset + destination_imag_offset");
! }
}
static void tab_fft_free(t_tab_fft *x)
{
! freebytes(x->x_sin_cos, x->x_fftsize * sizeof(TAB_COMPLEX));
}
static void *tab_fft_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_fft *x = (t_tab_fft *)pd_new(tab_fft_class);
! t_symbol *src_re, *src_im, *dst_re, *dst_im;
! int fftsize, i=1;
!
! if((argc >= 5) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2) &&
! IS_A_SYMBOL(argv,3) &&
! IS_A_FLOAT(argv,4))
! {
! src_re = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src_im = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst_re = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! dst_im = (t_symbol *)atom_getsymbolarg(3, argc, argv);
! fftsize = (int)atom_getintarg(4, argc, argv);
! }
! else
! {
! post("tab_fft-ERROR: need 4 symbols + 1 float arguments:");
! post(" source_real_array_name + source_imag_array_name + destination_real_array_name + destination_imag_array_name + FFT-size");
! return(0);
! }
!
! if(fftsize < 8)
! fftsize = 8;
!
! while(i <= fftsize)
! i *= 2;
! i /= 2;
! fftsize = i;
!
! x->x_fftsize = fftsize;
! x->x_sym_src_re = src_re;
! x->x_sym_src_im = src_im;
! x->x_sym_dst_re = dst_re;
! x->x_sym_dst_im = dst_im;
! x->x_sin_cos = (TAB_COMPLEX *)getbytes(x->x_fftsize * sizeof(TAB_COMPLEX));
! tab_fft_init(x);
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_fft_setup(void)
{
! tab_fft_class = class_new(gensym("tab_fft"), (t_newmethod)tab_fft_new, (t_method)tab_fft_free,
! sizeof(t_tab_fft), 0, A_GIMME, 0);
! class_addbang(tab_fft_class, (t_method)tab_fft_bang);
! class_addlist(tab_fft_class, (t_method)tab_fft_list);
! class_addmethod(tab_fft_class, (t_method)tab_fft_fftsize, gensym("fftsize"), A_DEFFLOAT, 0);
! class_addmethod(tab_fft_class, (t_method)tab_fft_src_re, gensym("src_re"), A_DEFSYMBOL, 0);
! class_addmethod(tab_fft_class, (t_method)tab_fft_src_im, gensym("src_im"), A_DEFSYMBOL, 0);
! class_addmethod(tab_fft_class, (t_method)tab_fft_src_re, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_fft_class, (t_method)tab_fft_src_im, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_fft_class, (t_method)tab_fft_dst_re, gensym("dst_re"), A_DEFSYMBOL, 0);
! class_addmethod(tab_fft_class, (t_method)tab_fft_dst_im, gensym("dst_im"), A_DEFSYMBOL, 0);
! class_addmethod(tab_fft_class, (t_method)tab_fft_dst_re, gensym("dst1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_fft_class, (t_method)tab_fft_dst_im, gensym("dst2"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_fft_class, gensym("iemhelp2/tab_fft-help"));
}
Index: tab_max_index.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_max_index.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_max_index.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_max_index.c 10 Nov 2006 17:15:48 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_max_index ------------------------------ */
--- 4,10 ----
***************
*** 22,33 ****
typedef struct _tab_max_index
{
! t_object x_obj;
! int x_size_src1;
! int x_offset_src1;
! float *x_beg_mem_src1;
! t_symbol *x_sym_scr1;
! void *x_bang_out;
! void *x_max_out;
! void *x_max_index_out;
} t_tab_max_index;
--- 12,23 ----
typedef struct _tab_max_index
{
! t_object x_obj;
! int x_size_src1;
! int x_offset_src1;
! t_float *x_beg_mem_src1;
! t_symbol *x_sym_scr1;
! void *x_bang_out;
! void *x_max_out;
! void *x_max_index_out;
} t_tab_max_index;
***************
*** 36,117 ****
static void tab_max_index_src(t_tab_max_index *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_max_index_bang(t_tab_max_index *x)
{
! int i, n;
! int ok_src, max_index=0;
! t_float *vec_src;
! t_float max=-1.0e37;
!
! ok_src = iem_tab_check_arrays(gensym("tab_max_index"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
!
! if(ok_src)
! {
! n = x->x_size_src1;
! vec_src = x->x_beg_mem_src1;
! if(n)
! {
! for(i=0; i<n; i++)
! {
! if(vec_src[i] > max)
! {
! max = vec_src[i];
! max_index = i;
! }
! }
! outlet_float(x->x_max_out, max);
! outlet_float(x->x_max_index_out, (float)max_index);
! outlet_bang(x->x_bang_out);
! }
! }
}
static void tab_max_index_list(t_tab_max_index *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src;
! int i, n;
! int ok_src, max_index=0;
! t_float *vec_src;
! t_float max=-1.0e37;
!
! if((argc >= 2) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1))
! {
! beg_src = (int)atom_getintarg(0, argc, argv);
! n = (int)atom_getintarg(1, argc, argv);
! if(beg_src < 0)
! beg_src = 0;
! if(n < 0)
! n = 0;
!
! ok_src = iem_tab_check_arrays(gensym("tab_max_index"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+n);
!
! if(ok_src)
! {
! vec_src = x->x_beg_mem_src1 + beg_src;
! if(n)
! {
! for(i=0; i<n; i++)
! {
! if(vec_src[i] > max)
! {
! max = vec_src[i];
! max_index = i + beg_src;
! }
! }
! outlet_float(x->x_max_out, max);
! outlet_float(x->x_max_index_out, (float)max_index);
! outlet_bang(x->x_bang_out);
! }
! }
! }
! else
! {
! post("tab_max_index-ERROR: list need 2 float arguments:");
! post(" source_offset + number_of_samples_to_calc_max_index");
! }
}
--- 26,107 ----
static void tab_max_index_src(t_tab_max_index *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_max_index_bang(t_tab_max_index *x)
{
! int i, n;
! int ok_src, max_index=0;
! t_float *vec_src;
! t_float max=-1.0e37;
!
! ok_src = iem_tab_check_arrays(gensym("tab_max_index"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
!
! if(ok_src)
! {
! n = x->x_size_src1;
! vec_src = x->x_beg_mem_src1;
! if(n)
! {
! for(i=0; i<n; i++)
! {
! if(vec_src[i] > max)
! {
! max = vec_src[i];
! max_index = i;
! }
! }
! outlet_float(x->x_max_out, max);
! outlet_float(x->x_max_index_out, (t_float)max_index);
! outlet_bang(x->x_bang_out);
! }
! }
}
static void tab_max_index_list(t_tab_max_index *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src;
! int i, n;
! int ok_src, max_index=0;
! t_float *vec_src;
! t_float max=-1.0e37;
!
! if((argc >= 2) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1))
! {
! beg_src = (int)atom_getintarg(0, argc, argv);
! n = (int)atom_getintarg(1, argc, argv);
! if(beg_src < 0)
! beg_src = 0;
! if(n < 0)
! n = 0;
!
! ok_src = iem_tab_check_arrays(gensym("tab_max_index"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+n);
!
! if(ok_src)
! {
! vec_src = x->x_beg_mem_src1 + beg_src;
! if(n)
! {
! for(i=0; i<n; i++)
! {
! if(vec_src[i] > max)
! {
! max = vec_src[i];
! max_index = i + beg_src;
! }
! }
! outlet_float(x->x_max_out, max);
! outlet_float(x->x_max_index_out, (t_float)max_index);
! outlet_bang(x->x_bang_out);
! }
! }
! }
! else
! {
! post("tab_max_index-ERROR: list need 2 float arguments:");
! post(" source_offset + number_of_samples_to_calc_max_index");
! }
}
***************
*** 122,155 ****
static void *tab_max_index_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_max_index *x = (t_tab_max_index *)pd_new(tab_max_index_class);
! t_symbol *src;
!
! if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! }
! else
! {
! post("tab_max_index-ERROR: need 1 symbol argument:");
! post(" source_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src;
! x->x_bang_out = outlet_new(&x->x_obj, &s_bang);
! x->x_max_index_out = outlet_new(&x->x_obj, &s_float);
! x->x_max_out = outlet_new(&x->x_obj, &s_float);
! return(x);
}
void tab_max_index_setup(void)
{
! tab_max_index_class = class_new(gensym("tab_max_index"), (t_newmethod)tab_max_index_new, (t_method)tab_max_index_free,
! sizeof(t_tab_max_index), 0, A_GIMME, 0);
! class_addbang(tab_max_index_class, (t_method)tab_max_index_bang);
! class_addlist(tab_max_index_class, (t_method)tab_max_index_list);
! class_addmethod(tab_max_index_class, (t_method)tab_max_index_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_max_index_class, (t_method)tab_max_index_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_max_index_class, gensym("iemhelp2/tab_max_index-help"));
}
--- 112,145 ----
static void *tab_max_index_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_max_index *x = (t_tab_max_index *)pd_new(tab_max_index_class);
! t_symbol *src;
!
! if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! }
! else
! {
! post("tab_max_index-ERROR: need 1 symbol argument:");
! post(" source_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src;
! x->x_bang_out = outlet_new(&x->x_obj, &s_bang);
! x->x_max_index_out = outlet_new(&x->x_obj, &s_float);
! x->x_max_out = outlet_new(&x->x_obj, &s_float);
! return(x);
}
void tab_max_index_setup(void)
{
! tab_max_index_class = class_new(gensym("tab_max_index"), (t_newmethod)tab_max_index_new, (t_method)tab_max_index_free,
! sizeof(t_tab_max_index), 0, A_GIMME, 0);
! class_addbang(tab_max_index_class, (t_method)tab_max_index_bang);
! class_addlist(tab_max_index_class, (t_method)tab_max_index_list);
! class_addmethod(tab_max_index_class, (t_method)tab_max_index_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_max_index_class, (t_method)tab_max_index_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_max_index_class, gensym("iemhelp2/tab_max_index-help"));
}
Index: tab_ge_scalar.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_ge_scalar.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_ge_scalar.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_ge_scalar.c 10 Nov 2006 17:15:47 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_ge_scalar ------------------------------ */
--- 4,10 ----
***************
*** 22,34 ****
typedef struct _tab_ge_scalar
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! float *x_beg_mem_src1;
! float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_ge_scalar;
--- 12,24 ----
typedef struct _tab_ge_scalar
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_ge_scalar;
***************
*** 37,136 ****
static void tab_ge_scalar_src(t_tab_ge_scalar *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_ge_scalar_float(t_tab_ge_scalar *x, t_floatarg compare)
{
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_ge_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_ge_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] >= compare)
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_ge_scalar_dst(t_tab_ge_scalar *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_ge_scalar_list(t_tab_ge_scalar *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_dst;
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst, compare;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_dst = (int)atom_getintarg(1, argc, argv);
! n = (int)atom_getintarg(2, argc, argv);
! compare = (t_float)atom_getfloatarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_ge_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_ge_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] >= compare)
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_ge_scalar-ERROR: list need 4 float arguments:");
! post(" source1_offset + destination_offset + number_of_samples_to_compare + compare_scalar");
}
}
--- 27,126 ----
static void tab_ge_scalar_src(t_tab_ge_scalar *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_ge_scalar_float(t_tab_ge_scalar *x, t_floatarg compare)
{
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_ge_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_ge_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] >= compare)
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_ge_scalar_dst(t_tab_ge_scalar *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_ge_scalar_list(t_tab_ge_scalar *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_dst;
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst, compare;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_dst = (int)atom_getintarg(1, argc, argv);
! n = (int)atom_getintarg(2, argc, argv);
! compare = (t_float)atom_getfloatarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_ge_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_ge_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] >= compare)
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_ge_scalar-ERROR: list need 4 float arguments:");
! post(" source1_offset + destination_offset + number_of_samples_to_compare + compare_scalar");
}
}
***************
*** 142,183 ****
static void *tab_ge_scalar_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_ge_scalar *x = (t_tab_ge_scalar *)pd_new(tab_ge_scalar_class);
! t_symbol *src1, *dst;
!
! if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! }
! else
! {
! post("tab_ge_scalar-ERROR: need 2 symbol arguments:");
! post(" source_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_ge_scalar_setup(void)
{
! tab_ge_scalar_class = class_new(gensym("tab_ge_scalar"), (t_newmethod)tab_ge_scalar_new, (t_method)tab_ge_scalar_free,
! sizeof(t_tab_ge_scalar), 0, A_GIMME, 0);
! class_addfloat(tab_ge_scalar_class, (t_method)tab_ge_scalar_float);
! class_addlist(tab_ge_scalar_class, (t_method)tab_ge_scalar_list);
! class_addmethod(tab_ge_scalar_class, (t_method)tab_ge_scalar_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ge_scalar_class, (t_method)tab_ge_scalar_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ge_scalar_class, (t_method)tab_ge_scalar_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_ge_scalar_class, gensym("iemhelp2/tab_ge_scalar-help"));
}
--- 132,173 ----
static void *tab_ge_scalar_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_ge_scalar *x = (t_tab_ge_scalar *)pd_new(tab_ge_scalar_class);
! t_symbol *src1, *dst;
!
! if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! }
! else
! {
! post("tab_ge_scalar-ERROR: need 2 symbol arguments:");
! post(" source_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_ge_scalar_setup(void)
{
! tab_ge_scalar_class = class_new(gensym("tab_ge_scalar"), (t_newmethod)tab_ge_scalar_new, (t_method)tab_ge_scalar_free,
! sizeof(t_tab_ge_scalar), 0, A_GIMME, 0);
! class_addfloat(tab_ge_scalar_class, (t_method)tab_ge_scalar_float);
! class_addlist(tab_ge_scalar_class, (t_method)tab_ge_scalar_list);
! class_addmethod(tab_ge_scalar_class, (t_method)tab_ge_scalar_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ge_scalar_class, (t_method)tab_ge_scalar_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_ge_scalar_class, (t_method)tab_ge_scalar_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_ge_scalar_class, gensym("iemhelp2/tab_ge_scalar-help"));
}
Index: tab_mls.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_mls.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_mls.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_mls.c 10 Nov 2006 17:15:48 -0000 1.2
***************
*** 4,19 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
--- 4,10 ----
***************
*** 22,30 ****
typedef struct _tab_mls
{
! t_object x_obj;
! int x_size_dst;
! int x_offset_dst;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_dst;
} t_tab_mls;
--- 13,21 ----
typedef struct _tab_mls
{
! t_object x_obj;
! int x_size_dst;
! int x_offset_dst;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_dst;
} t_tab_mls;
***************
*** 33,220 ****
static int tab_mls_exp2(int mls_order)
{
! int i, j=1;
!
! for(i=0; i<mls_order; i++)
! j *= 2;
! return(j);
}
static void tab_mls_calc(t_float *vec, int mls_order)
{
! int i, j;
! int work1=1, work2, exor;
! int mask, source, mls_size;
!
! switch(mls_order)
! {
! case 3:
! mask = 2+1;
! source = 4;
! break;
! case 4:
! mask = 2+1;
! source = 8;
! break;
! case 5:
! mask = 4+1;
! source = 16;
! break;
! case 6:
! mask = 2+1;
! source = 32;
! break;
! case 7:
! mask = 8+1;
! source = 64;
! break;
! case 8:
! mask = 32+8+2+1;
! source = 128;
! break;
! case 9:
! mask = 16+1;
! source = 256;
! break;
! case 10:
! mask = 8+1;
! source = 512;
! break;
! case 11:
! mask = 4+1;
! source = 1024;
! break;
! case 12:
! mask = 64+16+2+1;
! source = 2048;
! break;
! case 13:
! mask = 256+128+8+1;
! source = 4096;
! break;
! case 14:
! mask = 1024+64+2+1;
! source = 8192;
! break;
! case 15:
! mask = 2+1;
! source = 16384;
! break;
! case 16:
! mask = 32+8+4+1;
! source = 32768;
! break;
! case 17:
! mask = 8+1;
! source = 65536;
! break;
! case 18:
! mask = 128+1;
! source = 131072;
! break;
! case 19:
! mask = 32+4+2+1;
! source = 262144;
! break;
! case 20:
! mask = 8+1;
! source = 524288;
! break;
! }
!
! mls_size = 2*source - 1;
!
! for(i=0; i<mls_size; i++)
! {
! i = work1 & mask;
! work2 = work1 >> 1;
! exor = 0;
! for(j=0; j<lms_order; j++)
! {
! exor += & 1;
! work1 >>= 1;
! }
! if(exor & 1)
! {
! vec[i] = 1.0f;
! work1 = work2 | source;
! }
! else
! {
! vec[i] = -1.0f;
! work1 = work2;
! }
! }
! return;
}
static void tab_mls_dst(t_tab_mls *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_mls_float(t_tab_mls *x, t_floatarg fmls_order)
{
! int mls_order=(int)fmls_order;
! int ok_dst, mls_size;
!
! mls_size = tab_mls_exp2(mls_order) - 1;
! ok_dst = iem_tab_check_arrays(gensym("tab_mls"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, mls_size);
!
! if(ok_dst)
! {
! if((mls_order >= 3) && (mls_order <= 20))
! {
! t_garray *a;
!
! tab_mls_calc(x->x_beg_mem_dst, mls_order);
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_mls_list(t_tab_mls *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_dst;
! int i, n;
! int ok_dst;
! t_float *vec_dst, c;
!
! if((argc >= 3) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2))
! {
! beg_dst = (int)atom_getintarg(0, argc, argv);
! n = (int)atom_getintarg(1, argc, argv);
! c = (t_float)atom_getfloatarg(2, argc, argv);
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_dst = iem_tab_check_arrays(gensym("tab_mls"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_dst)
! {
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = c;
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_mls-ERROR: list need 3 float arguments:");
! post(" destination_offset + number_of_samples_to_copy + constant-value");
! }
}
--- 24,211 ----
static int tab_mls_exp2(int mls_order)
{
! int i, j=1;
!
! for(i=0; i<mls_order; i++)
! j *= 2;
! return(j);
}
static void tab_mls_calc(t_float *vec, int mls_order)
{
! int i, j;
! int work1=1, work2, exor;
! int mask, source, mls_size;
!
! switch(mls_order)
! {
! case 3:
! mask = 2+1;
! source = 4;
! break;
! case 4:
! mask = 2+1;
! source = 8;
! break;
! case 5:
! mask = 4+1;
! source = 16;
! break;
! case 6:
! mask = 2+1;
! source = 32;
! break;
! case 7:
! mask = 8+1;
! source = 64;
! break;
! case 8:
! mask = 32+8+2+1;
! source = 128;
! break;
! case 9:
! mask = 16+1;
! source = 256;
! break;
! case 10:
! mask = 8+1;
! source = 512;
! break;
! case 11:
! mask = 4+1;
! source = 1024;
! break;
! case 12:
! mask = 64+16+2+1;
! source = 2048;
! break;
! case 13:
! mask = 256+128+8+1;
! source = 4096;
! break;
! case 14:
! mask = 1024+64+2+1;
! source = 8192;
! break;
! case 15:
! mask = 2+1;
! source = 16384;
! break;
! case 16:
! mask = 32+8+4+1;
! source = 32768;
! break;
! case 17:
! mask = 8+1;
! source = 65536;
! break;
! case 18:
! mask = 128+1;
! source = 131072;
! break;
! case 19:
! mask = 32+4+2+1;
! source = 262144;
! break;
! case 20:
! mask = 8+1;
! source = 524288;
! break;
! }
!
! mls_size = 2*source - 1;
!
! for(i=0; i<mls_size; i++)
! {
! i = work1 & mask;
! work2 = work1 >> 1;
! exor = 0;
! for(j=0; j<lms_order; j++)
! {
! exor += & 1;
! work1 >>= 1;
! }
! if(exor & 1)
! {
! vec[i] = 1.0f;
! work1 = work2 | source;
! }
! else
! {
! vec[i] = -1.0f;
! work1 = work2;
! }
! }
! return;
}
static void tab_mls_dst(t_tab_mls *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_mls_float(t_tab_mls *x, t_floatarg fmls_order)
{
! int mls_order=(int)fmls_order;
! int ok_dst, mls_size;
!
! mls_size = tab_mls_exp2(mls_order) - 1;
! ok_dst = iem_tab_check_arrays(gensym("tab_mls"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, mls_size);
!
! if(ok_dst)
! {
! if((mls_order >= 3) && (mls_order <= 20))
! {
! t_garray *a;
!
! tab_mls_calc(x->x_beg_mem_dst, mls_order);
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_mls_list(t_tab_mls *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_dst;
! int i, n;
! int ok_dst;
! t_float *vec_dst, c;
!
! if((argc >= 3) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2))
! {
! beg_dst = (int)atom_getintarg(0, argc, argv);
! n = (int)atom_getintarg(1, argc, argv);
! c = (t_float)atom_getfloatarg(2, argc, argv);
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_dst = iem_tab_check_arrays(gensym("tab_mls"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_dst)
! {
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = c;
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_mls-ERROR: list need 3 float arguments:");
! post(" destination_offset + number_of_samples_to_copy + constant-value");
! }
}
***************
*** 225,256 ****
static void *tab_mls_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_mls *x = (t_tab_mls *)pd_new(tab_mls_class);
! t_symbol *dst;
! t_float time;
!
! if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! dst = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! }
! else
! {
! post("tab_mls-ERROR: need 1 symbol argument:");
! post(" destination_array_name");
! return(0);
! }
!
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_mls_setup(void)
{
! tab_mls_class = class_new(gensym("tab_mls"), (t_newmethod)tab_mls_new, (t_method)tab_mls_free,
! sizeof(t_tab_mls), 0, A_GIMME, 0);
! class_addfloat(tab_mls_class, (t_method)tab_mls_float);
! class_addlist(tab_mls_class, (t_method)tab_mls_list);
! class_addmethod(tab_mls_class, (t_method)tab_mls_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_mls_class, gensym("iemhelp2/tab_mls-help"));
}
--- 216,247 ----
static void *tab_mls_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_mls *x = (t_tab_mls *)pd_new(tab_mls_class);
! t_symbol *dst;
! t_float time;
!
! if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! dst = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! }
! else
! {
! post("tab_mls-ERROR: need 1 symbol argument:");
! post(" destination_array_name");
! return(0);
! }
!
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_mls_setup(void)
{
! tab_mls_class = class_new(gensym("tab_mls"), (t_newmethod)tab_mls_new, (t_method)tab_mls_free,
! sizeof(t_tab_mls), 0, A_GIMME, 0);
! class_addfloat(tab_mls_class, (t_method)tab_mls_float);
! class_addlist(tab_mls_class, (t_method)tab_mls_list);
! class_addmethod(tab_mls_class, (t_method)tab_mls_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_mls_class, gensym("iemhelp2/tab_mls-help"));
}
Index: tab_counter.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_counter.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_counter.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_counter.c 10 Nov 2006 17:15:47 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_counter ------------------------------ */
--- 4,10 ----
***************
*** 22,34 ****
typedef struct _tab_counter
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! float *x_beg_mem_src1;
! float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_counter;
--- 12,24 ----
typedef struct _tab_counter
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_counter;
***************
*** 37,161 ****
static void tab_counter_src(t_tab_counter *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_counter_bang(t_tab_counter *x)
{
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_counter"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_counter"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] == 0.0f)
! vec_dst[i] = 0.0f;
else
! vec_dst[i] += 1.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_counter_dst(t_tab_counter *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_counter_list(t_tab_counter *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_dst;
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst;
!
! if((argc >= 3) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_dst = (int)atom_getintarg(1, argc, argv);
! n = (int)atom_getintarg(2, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_counter"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_counter"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] == 0.0f)
! vec_dst[i] = 0.0f;
else
! vec_dst[i] += 1.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_counter-ERROR: list need 4 float arguments:");
! post(" source1_offset + destination_offset + number_of_samples_to_add + add_scalar");
! }
}
static void tab_counter_reset(t_tab_counter *x)
{
! int beg_dst;
! int i, n;
! int ok_dst;
! t_float *vec_dst;
!
! ok_dst = iem_tab_check_arrays(gensym("tab_counter"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_dst)
! {
! n = x->x_size_dst;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
vec_dst[i] = 0.0f;
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
--- 27,151 ----
static void tab_counter_src(t_tab_counter *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_counter_bang(t_tab_counter *x)
{
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_counter"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_counter"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] == 0.0f)
! vec_dst[i] = 0.0f;
else
! vec_dst[i] += 1.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_counter_dst(t_tab_counter *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_counter_list(t_tab_counter *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_dst;
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst;
!
! if((argc >= 3) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_dst = (int)atom_getintarg(1, argc, argv);
! n = (int)atom_getintarg(2, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_counter"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_counter"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] == 0.0f)
! vec_dst[i] = 0.0f;
else
! vec_dst[i] += 1.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_counter-ERROR: list need 4 float arguments:");
! post(" source1_offset + destination_offset + number_of_samples_to_add + add_scalar");
! }
}
static void tab_counter_reset(t_tab_counter *x)
{
! int beg_dst;
! int i, n;
! int ok_dst;
! t_float *vec_dst;
!
! ok_dst = iem_tab_check_arrays(gensym("tab_counter"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_dst)
! {
! n = x->x_size_dst;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
vec_dst[i] = 0.0f;
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
***************
*** 166,208 ****
static void *tab_counter_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_counter *x = (t_tab_counter *)pd_new(tab_counter_class);
! t_symbol *src1, *dst;
!
! if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! }
! else
! {
! post("tab_counter-ERROR: need 2 symbol arguments:");
! post(" source_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_counter_setup(void)
{
! tab_counter_class = class_new(gensym("tab_counter"), (t_newmethod)tab_counter_new, (t_method)tab_counter_free,
! sizeof(t_tab_counter), 0, A_GIMME, 0);
! class_addbang(tab_counter_class, (t_method)tab_counter_bang);
class_addlist(tab_counter_class, (t_method)tab_counter_list);
! class_addmethod(tab_counter_class, (t_method)tab_counter_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_counter_class, (t_method)tab_counter_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_counter_class, (t_method)tab_counter_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_addmethod(tab_counter_class, (t_method)tab_counter_reset, gensym("reset"), 0);
! class_sethelpsymbol(tab_counter_class, gensym("iemhelp2/tab_counter-help"));
}
--- 156,198 ----
static void *tab_counter_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_counter *x = (t_tab_counter *)pd_new(tab_counter_class);
! t_symbol *src1, *dst;
!
! if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! }
! else
! {
! post("tab_counter-ERROR: need 2 symbol arguments:");
! post(" source_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_counter_setup(void)
{
! tab_counter_class = class_new(gensym("tab_counter"), (t_newmethod)tab_counter_new, (t_method)tab_counter_free,
! sizeof(t_tab_counter), 0, A_GIMME, 0);
! class_addbang(tab_counter_class, (t_method)tab_counter_bang);
class_addlist(tab_counter_class, (t_method)tab_counter_list);
! class_addmethod(tab_counter_class, (t_method)tab_counter_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_counter_class, (t_method)tab_counter_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_counter_class, (t_method)tab_counter_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_addmethod(tab_counter_class, (t_method)tab_counter_reset, gensym("reset"), 0);
! class_sethelpsymbol(tab_counter_class, gensym("iemhelp2/tab_counter-help"));
}
Index: tab_lt.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_lt.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_lt.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_lt.c 10 Nov 2006 17:15:48 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_lt ------------------------------ */
--- 4,11 ----
***************
*** 22,38 ****
typedef struct _tab_lt
{
! t_object x_obj;
! int x_size_src1;
! int x_size_src2;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_src2;
! int x_offset_dst;
! float *x_beg_mem_src1;
! float *x_beg_mem_src2;
! float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_scr2;
! t_symbol *x_sym_dst;
} t_tab_lt;
--- 13,29 ----
typedef struct _tab_lt
{
! t_object x_obj;
! int x_size_src1;
! int x_size_src2;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_src2;
! int x_offset_dst;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_src2;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_scr2;
! t_symbol *x_sym_dst;
} t_tab_lt;
***************
*** 41,154 ****
static void tab_lt_src1(t_tab_lt *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_lt_src2(t_tab_lt *x, t_symbol *s)
{
! x->x_sym_scr2 = s;
}
static void tab_lt_dst(t_tab_lt *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_lt_bang(t_tab_lt *x)
{
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_lt"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_src2 = iem_tab_check_arrays(gensym("tab_lt"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_lt"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
! if(x->x_size_src2 < n)
! n = x->x_size_src2;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] < vec_src2[i])
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_lt_list(t_tab_lt *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_src2, beg_dst;
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_src2 = (int)atom_getintarg(1, argc, argv);
! beg_dst = (int)atom_getintarg(2, argc, argv);
! n = (int)atom_getintarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_src2 < 0)
! beg_src2 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_lt"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_src2 = iem_tab_check_arrays(gensym("tab_lt"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, beg_src2+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_lt"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_src2 = x->x_beg_mem_src2 + beg_src2;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] < vec_src2[i])
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_lt-ERROR: list need 4 float arguments:");
! post(" source1_offset + source2_offset + destination_offset + number_of_samples_to_compare");
! }
}
--- 32,145 ----
static void tab_lt_src1(t_tab_lt *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_lt_src2(t_tab_lt *x, t_symbol *s)
{
! x->x_sym_scr2 = s;
}
static void tab_lt_dst(t_tab_lt *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_lt_bang(t_tab_lt *x)
{
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_lt"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_src2 = iem_tab_check_arrays(gensym("tab_lt"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_lt"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
! if(x->x_size_src2 < n)
! n = x->x_size_src2;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] < vec_src2[i])
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_lt_list(t_tab_lt *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_src2, beg_dst;
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_src2 = (int)atom_getintarg(1, argc, argv);
! beg_dst = (int)atom_getintarg(2, argc, argv);
! n = (int)atom_getintarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_src2 < 0)
! beg_src2 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_lt"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_src2 = iem_tab_check_arrays(gensym("tab_lt"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, beg_src2+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_lt"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_src2 = x->x_beg_mem_src2 + beg_src2;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] < vec_src2[i])
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_lt-ERROR: list need 4 float arguments:");
! post(" source1_offset + source2_offset + destination_offset + number_of_samples_to_compare");
! }
}
***************
*** 159,206 ****
static void *tab_lt_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_lt *x = (t_tab_lt *)pd_new(tab_lt_class);
! t_symbol *src1, *src2, *dst;
! t_float time;
!
! if((argc >= 3) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! }
! else if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else
! {
! post("tab_lt-ERROR: need 3 symbols arguments:");
! post(" source1_array_name + source2_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_scr2 = src2;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_lt_setup(void)
{
! tab_lt_class = class_new(gensym("tab_lt"), (t_newmethod)tab_lt_new, (t_method)tab_lt_free,
! sizeof(t_tab_lt), 0, A_GIMME, 0);
! class_addbang(tab_lt_class, (t_method)tab_lt_bang);
! class_addlist(tab_lt_class, (t_method)tab_lt_list);
! class_addmethod(tab_lt_class, (t_method)tab_lt_src1, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_lt_class, (t_method)tab_lt_src2, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_lt_class, (t_method)tab_lt_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_lt_class, gensym("iemhelp2/tab_lt-help"));
}
--- 150,197 ----
static void *tab_lt_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_lt *x = (t_tab_lt *)pd_new(tab_lt_class);
! t_symbol *src1, *src2, *dst;
! t_float time;
!
! if((argc >= 3) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! }
! else if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else
! {
! post("tab_lt-ERROR: need 3 symbols arguments:");
! post(" source1_array_name + source2_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_scr2 = src2;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_lt_setup(void)
{
! tab_lt_class = class_new(gensym("tab_lt"), (t_newmethod)tab_lt_new, (t_method)tab_lt_free,
! sizeof(t_tab_lt), 0, A_GIMME, 0);
! class_addbang(tab_lt_class, (t_method)tab_lt_bang);
! class_addlist(tab_lt_class, (t_method)tab_lt_list);
! class_addmethod(tab_lt_class, (t_method)tab_lt_src1, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_lt_class, (t_method)tab_lt_src2, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_lt_class, (t_method)tab_lt_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_lt_class, gensym("iemhelp2/tab_lt-help"));
}
Index: tab_sub.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_sub.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_sub.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_sub.c 10 Nov 2006 17:15:48 -0000 1.2
***************
*** 4,19 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
--- 4,10 ----
***************
*** 22,38 ****
typedef struct _tab_sub
{
! t_object x_obj;
! int x_size_src1;
! int x_size_src2;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_src2;
! int x_offset_dst;
! float *x_beg_mem_src1;
! float *x_beg_mem_src2;
! float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_scr2;
! t_symbol *x_sym_dst;
} t_tab_sub;
--- 13,29 ----
typedef struct _tab_sub
{
! t_object x_obj;
! int x_size_src1;
! int x_size_src2;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_src2;
! int x_offset_dst;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_src2;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_scr2;
! t_symbol *x_sym_dst;
} t_tab_sub;
***************
*** 41,144 ****
static void tab_sub_src1(t_tab_sub *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_sub_src2(t_tab_sub *x, t_symbol *s)
{
! x->x_sym_scr2 = s;
}
static void tab_sub_dst(t_tab_sub *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_sub_bang(t_tab_sub *x)
{
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_sub"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_src2 = iem_tab_check_arrays(gensym("tab_sub"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_sub"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
! if(x->x_size_src2 < n)
! n = x->x_size_src2;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = vec_src1[i] - vec_src2[i];
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_sub_list(t_tab_sub *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_src2, beg_dst;
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_src2 = (int)atom_getintarg(1, argc, argv);
! beg_dst = (int)atom_getintarg(2, argc, argv);
! n = (int)atom_getintarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_src2 < 0)
! beg_src2 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_sub"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_src2 = iem_tab_check_arrays(gensym("tab_sub"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, beg_src2+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_sub"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_src2 = x->x_beg_mem_src2 + beg_src2;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = vec_src1[i] - vec_src2[i];
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_sub-ERROR: list need 4 float arguments:");
! post(" source1_offset + source2_offset + destination_offset + number_of_samples_to_sub");
! }
}
--- 32,135 ----
static void tab_sub_src1(t_tab_sub *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_sub_src2(t_tab_sub *x, t_symbol *s)
{
! x->x_sym_scr2 = s;
}
static void tab_sub_dst(t_tab_sub *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_sub_bang(t_tab_sub *x)
{
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_sub"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_src2 = iem_tab_check_arrays(gensym("tab_sub"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_sub"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
! if(x->x_size_src2 < n)
! n = x->x_size_src2;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = vec_src1[i] - vec_src2[i];
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_sub_list(t_tab_sub *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_src2, beg_dst;
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_src2 = (int)atom_getintarg(1, argc, argv);
! beg_dst = (int)atom_getintarg(2, argc, argv);
! n = (int)atom_getintarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_src2 < 0)
! beg_src2 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_sub"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_src2 = iem_tab_check_arrays(gensym("tab_sub"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, beg_src2+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_sub"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_src2 = x->x_beg_mem_src2 + beg_src2;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = vec_src1[i] - vec_src2[i];
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_sub-ERROR: list need 4 float arguments:");
! post(" source1_offset + source2_offset + destination_offset + number_of_samples_to_sub");
! }
}
***************
*** 149,196 ****
static void *tab_sub_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_sub *x = (t_tab_sub *)pd_new(tab_sub_class);
! t_symbol *src1, *src2, *dst;
! t_float time;
!
! if((argc >= 3) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! }
! else if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else
! {
! post("tab_sub-ERROR: need 3 symbols arguments:");
! post(" source1_array_name + source2_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_scr2 = src2;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_sub_setup(void)
{
! tab_sub_class = class_new(gensym("tab_sub"), (t_newmethod)tab_sub_new, (t_method)tab_sub_free,
! sizeof(t_tab_sub), 0, A_GIMME, 0);
! class_addbang(tab_sub_class, (t_method)tab_sub_bang);
! class_addlist(tab_sub_class, (t_method)tab_sub_list);
! class_addmethod(tab_sub_class, (t_method)tab_sub_src1, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_sub_class, (t_method)tab_sub_src2, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_sub_class, (t_method)tab_sub_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_sub_class, gensym("iemhelp2/tab_sub-help"));
}
--- 140,187 ----
static void *tab_sub_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_sub *x = (t_tab_sub *)pd_new(tab_sub_class);
! t_symbol *src1, *src2, *dst;
! t_float time;
!
! if((argc >= 3) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! }
! else if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else
! {
! post("tab_sub-ERROR: need 3 symbols arguments:");
! post(" source1_array_name + source2_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_scr2 = src2;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_sub_setup(void)
{
! tab_sub_class = class_new(gensym("tab_sub"), (t_newmethod)tab_sub_new, (t_method)tab_sub_free,
! sizeof(t_tab_sub), 0, A_GIMME, 0);
! class_addbang(tab_sub_class, (t_method)tab_sub_bang);
! class_addlist(tab_sub_class, (t_method)tab_sub_list);
! class_addmethod(tab_sub_class, (t_method)tab_sub_src1, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_sub_class, (t_method)tab_sub_src2, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_sub_class, (t_method)tab_sub_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_sub_class, gensym("iemhelp2/tab_sub-help"));
}
Index: tab_complex_inv.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_complex_inv.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_complex_inv.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_complex_inv.c 10 Nov 2006 17:15:47 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_complex_inv ------------------------------ */
--- 4,10 ----
***************
*** 22,42 ****
typedef struct _tab_complex_inv
{
! t_object x_obj;
! int x_size_src1_re;
! int x_size_dst_re;
! int x_size_src1_im;
! int x_size_dst_im;
! int x_offset_src1_re;
! int x_offset_dst_re;
! int x_offset_src1_im;
! int x_offset_dst_im;
! float *x_beg_mem_src1_re;
! float *x_beg_mem_dst_re;
! float *x_beg_mem_src1_im;
! float *x_beg_mem_dst_im;
! t_symbol *x_sym_scr1_re;
! t_symbol *x_sym_dst_re;
! t_symbol *x_sym_scr1_im;
! t_symbol *x_sym_dst_im;
} t_tab_complex_inv;
--- 12,32 ----
typedef struct _tab_complex_inv
{
! t_object x_obj;
! int x_size_src1_re;
! int x_size_dst_re;
! int x_size_src1_im;
! int x_size_dst_im;
! int x_offset_src1_re;
! int x_offset_dst_re;
! int x_offset_src1_im;
! int x_offset_dst_im;
! t_float *x_beg_mem_src1_re;
! t_float *x_beg_mem_dst_re;
! t_float *x_beg_mem_src1_im;
! t_float *x_beg_mem_dst_im;
! t_symbol *x_sym_scr1_re;
! t_symbol *x_sym_dst_re;
! t_symbol *x_sym_scr1_im;
! t_symbol *x_sym_dst_im;
} t_tab_complex_inv;
***************
*** 45,189 ****
static void tab_complex_inv_src1_re(t_tab_complex_inv *x, t_symbol *s)
{
! x->x_sym_scr1_re = s;
}
static void tab_complex_inv_src1_im(t_tab_complex_inv *x, t_symbol *s)
{
! x->x_sym_scr1_im = s;
}
static void tab_complex_inv_dst_re(t_tab_complex_inv *x, t_symbol *s)
{
! x->x_sym_dst_re = s;
}
static void tab_complex_inv_dst_im(t_tab_complex_inv *x, t_symbol *s)
{
! x->x_sym_dst_im = s;
}
static void tab_complex_inv_bang(t_tab_complex_inv *x)
{
! int i, n;
! int ok_src1_re, ok_dst_re;
! int ok_src1_im, ok_dst_im;
! t_float *vec_src1_re, *vec_dst_re;
! t_float *vec_src1_im, *vec_dst_im;
!
! ok_src1_re = iem_tab_check_arrays(gensym("tab_complex_inv"), x->x_sym_scr1_re, &x->x_beg_mem_src1_re, &x->x_size_src1_re, 0);
! ok_dst_re = iem_tab_check_arrays(gensym("tab_complex_inv"), x->x_sym_dst_re, &x->x_beg_mem_dst_re, &x->x_size_dst_re, 0);
! ok_src1_im = iem_tab_check_arrays(gensym("tab_complex_inv"), x->x_sym_scr1_im, &x->x_beg_mem_src1_im, &x->x_size_src1_im, 0);
! ok_dst_im = iem_tab_check_arrays(gensym("tab_complex_inv"), x->x_sym_dst_im, &x->x_beg_mem_dst_im, &x->x_size_dst_im, 0);
!
! if(ok_src1_re && ok_dst_re && ok_src1_im && ok_dst_im)
! {
! if(x->x_size_src1_re < x->x_size_dst_re)
! n = x->x_size_src1_re;
! else
! n = x->x_size_dst_re;
! if(x->x_size_src1_im < n)
! n = x->x_size_src1_im;
! if(x->x_size_dst_im < n)
! n = x->x_size_dst_im;
!
! vec_src1_re = x->x_beg_mem_src1_re;
! vec_dst_re = x->x_beg_mem_dst_re;
! vec_src1_im = x->x_beg_mem_src1_im;
! vec_dst_im = x->x_beg_mem_dst_im;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! {
! t_float re, im, abs;
!
! re = vec_src1_re[i];
! im = vec_src1_im[i];
! abs = 1.0f / (re*re + im*im);
! vec_dst_re[i] = re*abs;
! vec_dst_im[i] = -im*abs;
! }
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_re, garray_class);
! garray_redraw(a);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_im, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_complex_inv_list(t_tab_complex_inv *x, t_symbol *s, int argc, t_atom *argv)
{
! int i, n;
! int beg_src1_re, beg_dst_re;
! int beg_src1_im, beg_dst_im;
! int ok_src1_re, ok_dst_re;
! int ok_src1_im, ok_dst_im;
! t_float *vec_src1_re, *vec_dst_re;
! t_float *vec_src1_im, *vec_dst_im;
!
! if((argc >= 5) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3) &&
! IS_A_FLOAT(argv,4))
! {
! beg_src1_re = (int)atom_getintarg(0, argc, argv);
! beg_src1_im = (int)atom_getintarg(1, argc, argv);
! beg_dst_re = (int)atom_getintarg(2, argc, argv);
! beg_dst_im = (int)atom_getintarg(3, argc, argv);
! n = (int)atom_getintarg(4, argc, argv);
! if(beg_src1_re < 0)
! beg_src1_re = 0;
! if(beg_dst_re < 0)
! beg_dst_re = 0;
! if(beg_src1_im < 0)
! beg_src1_im = 0;
! if(beg_dst_im < 0)
! beg_dst_im = 0;
! if(n < 0)
! n = 0;
!
! ok_src1_re = iem_tab_check_arrays(gensym("tab_complex_inv"), x->x_sym_scr1_re, &x->x_beg_mem_src1_re, &x->x_size_src1_re, beg_src1_re+n);
! ok_dst_re = iem_tab_check_arrays(gensym("tab_complex_inv"), x->x_sym_dst_re, &x->x_beg_mem_dst_re, &x->x_size_dst_re, beg_dst_re+n);
! ok_src1_im = iem_tab_check_arrays(gensym("tab_complex_inv"), x->x_sym_scr1_im, &x->x_beg_mem_src1_im, &x->x_size_src1_im, beg_src1_im+n);
! ok_dst_im = iem_tab_check_arrays(gensym("tab_complex_inv"), x->x_sym_dst_im, &x->x_beg_mem_dst_im, &x->x_size_dst_im, beg_dst_im+n);
!
! if(ok_src1_re && ok_dst_re && ok_src1_im && ok_dst_im)
! {
! vec_src1_re = x->x_beg_mem_src1_re + beg_src1_re;
! vec_dst_re = x->x_beg_mem_dst_re + beg_dst_re;
! vec_src1_im = x->x_beg_mem_src1_im + beg_src1_im;
! vec_dst_im = x->x_beg_mem_dst_im + beg_dst_im;
!
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! {
! t_float re, im, abs;
!
! re = vec_src1_re[i];
! im = vec_src1_im[i];
! abs = 1.0f / (re*re + im*im);
! vec_dst_re[i] = re*abs;
! vec_dst_im[i] = -im*abs;
! }
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_re, garray_class);
! garray_redraw(a);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_im, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_complex_inv-ERROR: list need 5 float arguments:");
! post(" source1_real_offset + source1_imag_offset + destination_real_offset + destination_imag_offset + number_of_samples_to_complex_mul");
! }
}
--- 35,179 ----
static void tab_complex_inv_src1_re(t_tab_complex_inv *x, t_symbol *s)
{
! x->x_sym_scr1_re = s;
}
static void tab_complex_inv_src1_im(t_tab_complex_inv *x, t_symbol *s)
{
! x->x_sym_scr1_im = s;
}
static void tab_complex_inv_dst_re(t_tab_complex_inv *x, t_symbol *s)
{
! x->x_sym_dst_re = s;
}
static void tab_complex_inv_dst_im(t_tab_complex_inv *x, t_symbol *s)
{
! x->x_sym_dst_im = s;
}
static void tab_complex_inv_bang(t_tab_complex_inv *x)
{
! int i, n;
! int ok_src1_re, ok_dst_re;
! int ok_src1_im, ok_dst_im;
! t_float *vec_src1_re, *vec_dst_re;
! t_float *vec_src1_im, *vec_dst_im;
!
! ok_src1_re = iem_tab_check_arrays(gensym("tab_complex_inv"), x->x_sym_scr1_re, &x->x_beg_mem_src1_re, &x->x_size_src1_re, 0);
! ok_dst_re = iem_tab_check_arrays(gensym("tab_complex_inv"), x->x_sym_dst_re, &x->x_beg_mem_dst_re, &x->x_size_dst_re, 0);
! ok_src1_im = iem_tab_check_arrays(gensym("tab_complex_inv"), x->x_sym_scr1_im, &x->x_beg_mem_src1_im, &x->x_size_src1_im, 0);
! ok_dst_im = iem_tab_check_arrays(gensym("tab_complex_inv"), x->x_sym_dst_im, &x->x_beg_mem_dst_im, &x->x_size_dst_im, 0);
!
! if(ok_src1_re && ok_dst_re && ok_src1_im && ok_dst_im)
! {
! if(x->x_size_src1_re < x->x_size_dst_re)
! n = x->x_size_src1_re;
! else
! n = x->x_size_dst_re;
! if(x->x_size_src1_im < n)
! n = x->x_size_src1_im;
! if(x->x_size_dst_im < n)
! n = x->x_size_dst_im;
!
! vec_src1_re = x->x_beg_mem_src1_re;
! vec_dst_re = x->x_beg_mem_dst_re;
! vec_src1_im = x->x_beg_mem_src1_im;
! vec_dst_im = x->x_beg_mem_dst_im;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! {
! t_float re, im, abs;
!
! re = vec_src1_re[i];
! im = vec_src1_im[i];
! abs = 1.0f / (re*re + im*im);
! vec_dst_re[i] = re*abs;
! vec_dst_im[i] = -im*abs;
! }
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_re, garray_class);
! garray_redraw(a);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_im, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_complex_inv_list(t_tab_complex_inv *x, t_symbol *s, int argc, t_atom *argv)
{
! int i, n;
! int beg_src1_re, beg_dst_re;
! int beg_src1_im, beg_dst_im;
! int ok_src1_re, ok_dst_re;
! int ok_src1_im, ok_dst_im;
! t_float *vec_src1_re, *vec_dst_re;
! t_float *vec_src1_im, *vec_dst_im;
!
! if((argc >= 5) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3) &&
! IS_A_FLOAT(argv,4))
! {
! beg_src1_re = (int)atom_getintarg(0, argc, argv);
! beg_src1_im = (int)atom_getintarg(1, argc, argv);
! beg_dst_re = (int)atom_getintarg(2, argc, argv);
! beg_dst_im = (int)atom_getintarg(3, argc, argv);
! n = (int)atom_getintarg(4, argc, argv);
! if(beg_src1_re < 0)
! beg_src1_re = 0;
! if(beg_dst_re < 0)
! beg_dst_re = 0;
! if(beg_src1_im < 0)
! beg_src1_im = 0;
! if(beg_dst_im < 0)
! beg_dst_im = 0;
! if(n < 0)
! n = 0;
!
! ok_src1_re = iem_tab_check_arrays(gensym("tab_complex_inv"), x->x_sym_scr1_re, &x->x_beg_mem_src1_re, &x->x_size_src1_re, beg_src1_re+n);
! ok_dst_re = iem_tab_check_arrays(gensym("tab_complex_inv"), x->x_sym_dst_re, &x->x_beg_mem_dst_re, &x->x_size_dst_re, beg_dst_re+n);
! ok_src1_im = iem_tab_check_arrays(gensym("tab_complex_inv"), x->x_sym_scr1_im, &x->x_beg_mem_src1_im, &x->x_size_src1_im, beg_src1_im+n);
! ok_dst_im = iem_tab_check_arrays(gensym("tab_complex_inv"), x->x_sym_dst_im, &x->x_beg_mem_dst_im, &x->x_size_dst_im, beg_dst_im+n);
!
! if(ok_src1_re && ok_dst_re && ok_src1_im && ok_dst_im)
! {
! vec_src1_re = x->x_beg_mem_src1_re + beg_src1_re;
! vec_dst_re = x->x_beg_mem_dst_re + beg_dst_re;
! vec_src1_im = x->x_beg_mem_src1_im + beg_src1_im;
! vec_dst_im = x->x_beg_mem_dst_im + beg_dst_im;
!
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! {
! t_float re, im, abs;
!
! re = vec_src1_re[i];
! im = vec_src1_im[i];
! abs = 1.0f / (re*re + im*im);
! vec_dst_re[i] = re*abs;
! vec_dst_im[i] = -im*abs;
! }
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_re, garray_class);
! garray_redraw(a);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst_im, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_complex_inv-ERROR: list need 5 float arguments:");
! post(" source1_real_offset + source1_imag_offset + destination_real_offset + destination_imag_offset + number_of_samples_to_complex_mul");
! }
}
***************
*** 194,246 ****
static void *tab_complex_inv_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_complex_inv *x = (t_tab_complex_inv *)pd_new(tab_complex_inv_class);
! t_symbol *src1_re, *src2_re, *dst_re, *src1_im, *src2_im, *dst_im;
! t_float time;
!
! if((argc >= 4) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2) &&
! IS_A_SYMBOL(argv,3))
! {
! src1_re = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src1_im = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst_re = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! dst_im = (t_symbol *)atom_getsymbolarg(3, argc, argv);
! }
! else if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1_re = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src1_im = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst_re = src1_re;
! dst_im = src1_im;
! }
! else
! {
! post("tab_complex_inv-ERROR: need 4 symbols arguments:");
! post(" source1_real_array_name + source1_imag_array_name + destination_real_array_name + destination_imag_array_name");
! return(0);
! }
!
! x->x_sym_scr1_re = src1_re;
! x->x_sym_scr1_im = src1_im;
! x->x_sym_dst_re = dst_re;
! x->x_sym_dst_im = dst_im;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_complex_inv_setup(void)
{
! tab_complex_inv_class = class_new(gensym("tab_complex_inv"), (t_newmethod)tab_complex_inv_new, (t_method)tab_complex_inv_free,
! sizeof(t_tab_complex_inv), 0, A_GIMME, 0);
! class_addbang(tab_complex_inv_class, (t_method)tab_complex_inv_bang);
! class_addlist(tab_complex_inv_class, (t_method)tab_complex_inv_list);
! class_addmethod(tab_complex_inv_class, (t_method)tab_complex_inv_src1_re, gensym("src1_re"), A_DEFSYMBOL, 0);
! class_addmethod(tab_complex_inv_class, (t_method)tab_complex_inv_dst_re, gensym("dst_re"), A_DEFSYMBOL, 0);
! 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_dst_im, gensym("dst_im"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_complex_inv_class, gensym("iemhelp2/tab_complex_inv-help"));
}
--- 184,236 ----
static void *tab_complex_inv_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_complex_inv *x = (t_tab_complex_inv *)pd_new(tab_complex_inv_class);
! t_symbol *src1_re, *src2_re, *dst_re, *src1_im, *src2_im, *dst_im;
! t_float time;
!
! if((argc >= 4) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2) &&
! IS_A_SYMBOL(argv,3))
! {
! src1_re = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src1_im = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst_re = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! dst_im = (t_symbol *)atom_getsymbolarg(3, argc, argv);
! }
! else if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1_re = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src1_im = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst_re = src1_re;
! dst_im = src1_im;
! }
! else
! {
! post("tab_complex_inv-ERROR: need 4 symbols arguments:");
! post(" source1_real_array_name + source1_imag_array_name + destination_real_array_name + destination_imag_array_name");
! return(0);
! }
!
! x->x_sym_scr1_re = src1_re;
! x->x_sym_scr1_im = src1_im;
! x->x_sym_dst_re = dst_re;
! x->x_sym_dst_im = dst_im;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_complex_inv_setup(void)
{
! tab_complex_inv_class = class_new(gensym("tab_complex_inv"), (t_newmethod)tab_complex_inv_new, (t_method)tab_complex_inv_free,
! sizeof(t_tab_complex_inv), 0, A_GIMME, 0);
! class_addbang(tab_complex_inv_class, (t_method)tab_complex_inv_bang);
! class_addlist(tab_complex_inv_class, (t_method)tab_complex_inv_list);
! class_addmethod(tab_complex_inv_class, (t_method)tab_complex_inv_src1_re, gensym("src1_re"), A_DEFSYMBOL, 0);
! class_addmethod(tab_complex_inv_class, (t_method)tab_complex_inv_dst_re, gensym("dst_re"), A_DEFSYMBOL, 0);
! 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_dst_im, gensym("dst_im"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_complex_inv_class, gensym("iemhelp2/tab_complex_inv-help"));
}
Index: tab_add.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_add.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_add.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_add.c 10 Nov 2006 17:15:47 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_add ------------------------------ */
--- 4,10 ----
***************
*** 22,38 ****
typedef struct _tab_add
{
! t_object x_obj;
! int x_size_src1;
! int x_size_src2;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_src2;
! int x_offset_dst;
! float *x_beg_mem_src1;
! float *x_beg_mem_src2;
! float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_scr2;
! t_symbol *x_sym_dst;
} t_tab_add;
--- 12,28 ----
typedef struct _tab_add
{
! t_object x_obj;
! int x_size_src1;
! int x_size_src2;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_src2;
! int x_offset_dst;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_src2;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_scr2;
! t_symbol *x_sym_dst;
} t_tab_add;
***************
*** 41,144 ****
static void tab_add_src1(t_tab_add *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_add_src2(t_tab_add *x, t_symbol *s)
{
! x->x_sym_scr2 = s;
}
static void tab_add_dst(t_tab_add *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_add_bang(t_tab_add *x)
{
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_add"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_src2 = iem_tab_check_arrays(gensym("tab_add"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_add"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
! if(x->x_size_src2 < n)
! n = x->x_size_src2;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = vec_src1[i] + vec_src2[i];
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_add_list(t_tab_add *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_src2, beg_dst;
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_src2 = (int)atom_getintarg(1, argc, argv);
! beg_dst = (int)atom_getintarg(2, argc, argv);
! n = (int)atom_getintarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_src2 < 0)
! beg_src2 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_add"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_src2 = iem_tab_check_arrays(gensym("tab_add"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, beg_src2+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_add"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_src2 = x->x_beg_mem_src2 + beg_src2;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = vec_src1[i] + vec_src2[i];
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_add-ERROR: list need 4 float arguments:");
! post(" source1_offset + source2_offset + destination_offset + number_of_samples_to_add");
! }
}
--- 31,134 ----
static void tab_add_src1(t_tab_add *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_add_src2(t_tab_add *x, t_symbol *s)
{
! x->x_sym_scr2 = s;
}
static void tab_add_dst(t_tab_add *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_add_bang(t_tab_add *x)
{
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_add"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_src2 = iem_tab_check_arrays(gensym("tab_add"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_add"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
! if(x->x_size_src2 < n)
! n = x->x_size_src2;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_src2 = x->x_beg_mem_src2;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = vec_src1[i] + vec_src2[i];
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_add_list(t_tab_add *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_src2, beg_dst;
! int i, n;
! int ok_src1, ok_src2, ok_dst;
! t_float *vec_src1, *vec_src2, *vec_dst;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_src2 = (int)atom_getintarg(1, argc, argv);
! beg_dst = (int)atom_getintarg(2, argc, argv);
! n = (int)atom_getintarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_src2 < 0)
! beg_src2 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_add"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_src2 = iem_tab_check_arrays(gensym("tab_add"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, beg_src2+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_add"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_src2 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_src2 = x->x_beg_mem_src2 + beg_src2;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
! vec_dst[i] = vec_src1[i] + vec_src2[i];
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_add-ERROR: list need 4 float arguments:");
! post(" source1_offset + source2_offset + destination_offset + number_of_samples_to_add");
! }
}
***************
*** 149,196 ****
static void *tab_add_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_add *x = (t_tab_add *)pd_new(tab_add_class);
! t_symbol *src1, *src2, *dst;
! t_float time;
!
! if((argc >= 3) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! }
! else if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else
! {
! post("tab_add-ERROR: need 3 symbols arguments:");
! post(" source1_array_name + source2_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_scr2 = src2;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_add_setup(void)
{
! tab_add_class = class_new(gensym("tab_add"), (t_newmethod)tab_add_new, (t_method)tab_add_free,
! sizeof(t_tab_add), 0, A_GIMME, 0);
! class_addbang(tab_add_class, (t_method)tab_add_bang);
! class_addlist(tab_add_class, (t_method)tab_add_list);
! class_addmethod(tab_add_class, (t_method)tab_add_src1, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_add_class, (t_method)tab_add_src2, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_add_class, (t_method)tab_add_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_add_class, gensym("iemhelp2/tab_add-help"));
}
--- 139,186 ----
static void *tab_add_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_add *x = (t_tab_add *)pd_new(tab_add_class);
! t_symbol *src1, *src2, *dst;
! t_float time;
!
! if((argc >= 3) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1) &&
! IS_A_SYMBOL(argv,2))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(2, argc, argv);
! }
! else if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! src2 = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else
! {
! post("tab_add-ERROR: need 3 symbols arguments:");
! post(" source1_array_name + source2_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_scr2 = src2;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_add_setup(void)
{
! tab_add_class = class_new(gensym("tab_add"), (t_newmethod)tab_add_new, (t_method)tab_add_free,
! sizeof(t_tab_add), 0, A_GIMME, 0);
! class_addbang(tab_add_class, (t_method)tab_add_bang);
! class_addlist(tab_add_class, (t_method)tab_add_list);
! class_addmethod(tab_add_class, (t_method)tab_add_src1, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_add_class, (t_method)tab_add_src2, gensym("src2"), A_DEFSYMBOL, 0);
! class_addmethod(tab_add_class, (t_method)tab_add_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_add_class, gensym("iemhelp2/tab_add-help"));
}
Index: tab_le_scalar.c
===================================================================
RCS file: /cvsroot/pure-data/externals/iem/iem_tab/src/tab_le_scalar.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tab_le_scalar.c 10 Mar 2006 03:05:55 -0000 1.1
--- tab_le_scalar.c 10 Nov 2006 17:15:48 -0000 1.2
***************
*** 4,20 ****
iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2005 */
- #ifdef NT
- #pragma warning( disable : 4244 )
- #pragma warning( disable : 4305 )
- #endif
-
-
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
- #include <math.h>
- #include <stdio.h>
- #include <string.h>
-
/* -------------------------- tab_le_scalar ------------------------------ */
--- 4,10 ----
***************
*** 22,34 ****
typedef struct _tab_le_scalar
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! float *x_beg_mem_src1;
! float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_le_scalar;
--- 12,24 ----
typedef struct _tab_le_scalar
{
! t_object x_obj;
! int x_size_src1;
! int x_size_dst;
! int x_offset_src1;
! int x_offset_dst;
! t_float *x_beg_mem_src1;
! t_float *x_beg_mem_dst;
! t_symbol *x_sym_scr1;
! t_symbol *x_sym_dst;
} t_tab_le_scalar;
***************
*** 37,136 ****
static void tab_le_scalar_src(t_tab_le_scalar *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_le_scalar_float(t_tab_le_scalar *x, t_floatarg compare)
{
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_le_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_le_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] <= compare)
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_le_scalar_dst(t_tab_le_scalar *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_le_scalar_list(t_tab_le_scalar *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_dst;
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst, compare;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_dst = (int)atom_getintarg(1, argc, argv);
! n = (int)atom_getintarg(2, argc, argv);
! compare = (t_float)atom_getfloatarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_le_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_le_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] <= compare)
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_le_scalar-ERROR: list need 4 float arguments:");
! post(" source1_offset + destination_offset + number_of_samples_to_compare + compare_scalar");
}
}
--- 27,126 ----
static void tab_le_scalar_src(t_tab_le_scalar *x, t_symbol *s)
{
! x->x_sym_scr1 = s;
}
static void tab_le_scalar_float(t_tab_le_scalar *x, t_floatarg compare)
{
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_le_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
! ok_dst = iem_tab_check_arrays(gensym("tab_le_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0);
!
! if(ok_src1 && ok_dst)
! {
! if(x->x_size_src1 < x->x_size_dst)
! n = x->x_size_src1;
! else
! n = x->x_size_dst;
!
! vec_src1 = x->x_beg_mem_src1;
! vec_dst = x->x_beg_mem_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] <= compare)
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
}
static void tab_le_scalar_dst(t_tab_le_scalar *x, t_symbol *s)
{
! x->x_sym_dst = s;
}
static void tab_le_scalar_list(t_tab_le_scalar *x, t_symbol *s, int argc, t_atom *argv)
{
! int beg_src1, beg_dst;
! int i, n;
! int ok_src1, ok_dst;
! t_float *vec_src1, *vec_dst, compare;
!
! if((argc >= 4) &&
! IS_A_FLOAT(argv,0) &&
! IS_A_FLOAT(argv,1) &&
! IS_A_FLOAT(argv,2) &&
! IS_A_FLOAT(argv,3))
! {
! beg_src1 = (int)atom_getintarg(0, argc, argv);
! beg_dst = (int)atom_getintarg(1, argc, argv);
! n = (int)atom_getintarg(2, argc, argv);
! compare = (t_float)atom_getfloatarg(3, argc, argv);
! if(beg_src1 < 0)
! beg_src1 = 0;
! if(beg_dst < 0)
! beg_dst = 0;
! if(n < 0)
! n = 0;
!
! ok_src1 = iem_tab_check_arrays(gensym("tab_le_scalar"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src1+n);
! ok_dst = iem_tab_check_arrays(gensym("tab_le_scalar"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, beg_dst+n);
!
! if(ok_src1 && ok_dst)
! {
! vec_src1 = x->x_beg_mem_src1 + beg_src1;
! vec_dst = x->x_beg_mem_dst + beg_dst;
! if(n)
! {
! t_garray *a;
!
! for(i=0; i<n; i++)
{
if(vec_src1[i] <= compare)
! vec_dst[i] = 1.0f;
else
! vec_dst[i] = 0.0f;
}
! outlet_bang(x->x_obj.ob_outlet);
! a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class);
! garray_redraw(a);
! }
! }
! }
! else
! {
! post("tab_le_scalar-ERROR: list need 4 float arguments:");
! post(" source1_offset + destination_offset + number_of_samples_to_compare + compare_scalar");
}
}
***************
*** 142,183 ****
static void *tab_le_scalar_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_le_scalar *x = (t_tab_le_scalar *)pd_new(tab_le_scalar_class);
! t_symbol *src1, *dst;
!
! if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! }
! else
! {
! post("tab_le_scalar-ERROR: need 2 symbol arguments:");
! post(" source_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_le_scalar_setup(void)
{
! tab_le_scalar_class = class_new(gensym("tab_le_scalar"), (t_newmethod)tab_le_scalar_new, (t_method)tab_le_scalar_free,
! sizeof(t_tab_le_scalar), 0, A_GIMME, 0);
! class_addfloat(tab_le_scalar_class, (t_method)tab_le_scalar_float);
! class_addlist(tab_le_scalar_class, (t_method)tab_le_scalar_list);
! class_addmethod(tab_le_scalar_class, (t_method)tab_le_scalar_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_le_scalar_class, (t_method)tab_le_scalar_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_le_scalar_class, (t_method)tab_le_scalar_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_le_scalar_class, gensym("iemhelp2/tab_le_scalar-help"));
}
--- 132,173 ----
static void *tab_le_scalar_new(t_symbol *s, int argc, t_atom *argv)
{
! t_tab_le_scalar *x = (t_tab_le_scalar *)pd_new(tab_le_scalar_class);
! t_symbol *src1, *dst;
!
! if((argc >= 2) &&
! IS_A_SYMBOL(argv,0) &&
! IS_A_SYMBOL(argv,1))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = (t_symbol *)atom_getsymbolarg(1, argc, argv);
! }
! else if((argc >= 1) &&
! IS_A_SYMBOL(argv,0))
! {
! src1 = (t_symbol *)atom_getsymbolarg(0, argc, argv);
! dst = src1;
! }
! else
! {
! post("tab_le_scalar-ERROR: need 2 symbol arguments:");
! post(" source_array_name + destination_array_name");
! return(0);
! }
!
! x->x_sym_scr1 = src1;
! x->x_sym_dst = dst;
! outlet_new(&x->x_obj, &s_bang);
! return(x);
}
void tab_le_scalar_setup(void)
{
! tab_le_scalar_class = class_new(gensym("tab_le_scalar"), (t_newmethod)tab_le_scalar_new, (t_method)tab_le_scalar_free,
! sizeof(t_tab_le_scalar), 0, A_GIMME, 0);
! class_addfloat(tab_le_scalar_class, (t_method)tab_le_scalar_float);
! class_addlist(tab_le_scalar_class, (t_method)tab_le_scalar_list);
! class_addmethod(tab_le_scalar_class, (t_method)tab_le_scalar_src, gensym("src1"), A_DEFSYMBOL, 0);
! class_addmethod(tab_le_scalar_class, (t_method)tab_le_scalar_src, gensym("src"), A_DEFSYMBOL, 0);
! class_addmethod(tab_le_scalar_class, (t_method)tab_le_scalar_dst, gensym("dst"), A_DEFSYMBOL, 0);
! class_sethelpsymbol(tab_le_scalar_class, gensym("iemhelp2/tab_le_scalar-help"));
}
--- NEW FILE: tab_find_exact_peaks.c ---
/* 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 - 2005 */
#include "m_pd.h"
#include "iemlib.h"
#include "iem_tab.h"
/* -------------------------- tab_find_exact_peaks ------------------------------ */
#define IEMLIB_TAB_FIND_EXACT_PEAKS_SORT_MODE_AMP 0
#define IEMLIB_TAB_FIND_EXACT_PEAKS_SORT_MODE_FREQ 1
typedef struct _tab_find_exact_peaks
{
t_object x_obj;
int x_size_src1;
int x_offset_src1;
t_float *x_beg_mem_src1;
int x_work_alloc;
int *x_beg_mem_work1;
t_float *x_beg_mem_work2;
int x_sort_mode;
t_float x_hdiff;
int x_min_width;
int x_max_width;
int x_n_peaks;
t_symbol *x_sym_scr1;
t_outlet *x_bang_out;
t_outlet *x_sort_index_out;
t_outlet *x_peak_value_out;
t_outlet *x_peak_index_out;
} t_tab_find_exact_peaks;
static t_class *tab_find_exact_peaks_class;
static void tab_find_exact_peaks_max_peaks(t_tab_find_exact_peaks *x, t_floatarg fmax_peaks)
{
int max_peaks = (int)fmax_peaks;
if(max_peaks <= 0)
max_peaks = 1;
x->x_n_peaks = max_peaks;
}
static void tab_find_exact_peaks_width_range(t_tab_find_exact_peaks *x, t_symbol *s, int argc, t_atom *argv)
{
int minw, maxw, h;
if((argc >= 2) &&
IS_A_FLOAT(argv,0) &&
IS_A_FLOAT(argv,1))
{
minw = (int)atom_getintarg(0, argc, argv);
maxw = (int)atom_getintarg(1, argc, argv);
if(minw <= 0)
minw = 1;
if(maxw <= 0)
maxw = 1;
if(minw > maxw)
{
h = minw;
minw = maxw;
maxw = h;
}
x->x_min_width = minw;
x->x_max_width = maxw;
}
}
static void tab_find_exact_peaks_abs_min_height_diff(t_tab_find_exact_peaks *x, t_floatarg height_diff)
{
if(height_diff < 0.0f)
height_diff *= -1.0f;
x->x_hdiff = height_diff;
}
static void tab_find_exact_peaks_amp_sort(t_tab_find_exact_peaks *x)
{
x->x_sort_mode = IEMLIB_TAB_FIND_EXACT_PEAKS_SORT_MODE_AMP;
}
static void tab_find_exact_peaks_freq_sort(t_tab_find_exact_peaks *x)
{
x->x_sort_mode = IEMLIB_TAB_FIND_EXACT_PEAKS_SORT_MODE_FREQ;
}
static void tab_find_exact_peaks_src(t_tab_find_exact_peaks *x, t_symbol *s)
{
x->x_sym_scr1 = s;
}
static void tab_find_exact_peaks_bang(t_tab_find_exact_peaks *x)
{
int i, n, w, ww;
int ok_src, peak_index=0, sort_index=0;
t_float *vec_src, *vec_work2;
int *vec_work1;
t_float max=-1.0e37;
int max_peaks=x->x_n_peaks;
int min_width=x->x_min_width;
int max_width=x->x_max_width;
t_float abs_min_height_diff=x->x_hdiff;
ok_src = iem_tab_check_arrays(gensym("tab_find_exact_peaks"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0);
if(ok_src)
{
n = x->x_size_src1;
if(n)
{
if(!x->x_work_alloc)
{
x->x_beg_mem_work1 = (int *)getbytes(n * sizeof(int));
x->x_beg_mem_work2 = (t_float *)getbytes(n * sizeof(t_float));
x->x_work_alloc = n;
}
else if(n != x->x_work_alloc)
{
x->x_beg_mem_work1 = (int *)resizebytes(x->x_beg_mem_work1, x->x_work_alloc*sizeof(int), n*sizeof(int));
x->x_beg_mem_work2 = (t_float *)resizebytes(x->x_beg_mem_work2, x->x_work_alloc*sizeof(t_float), n*sizeof(t_float));
x->x_work_alloc = n;
}
vec_src = x->x_beg_mem_src1;
vec_work1 = x->x_beg_mem_work1;
vec_work2 = x->x_beg_mem_work2;
if(x->x_sort_mode == IEMLIB_TAB_FIND_EXACT_PEAKS_SORT_MODE_FREQ) // FREQ_SORT BEGIN
{
int sort_index=1,old=0,j;
for(i=0; i<n; i++)
{
vec_work1[i] = 0;
}
for(w=min_width; w<=max_width; w++) // w variiert zw. min u. max
{
for(ww=0; ww<w; ww++)
{
int beg=w-ww;
int end=n-1-ww;
int low_bord=beg-1;
int high_bord=n-end-1;
t_float diff_low,diff_high;
for(i=beg; i<end; i++)
{
diff_low = vec_src[i-low_bord] - abs_min_height_diff;
diff_high = vec_src[i+high_bord] - abs_min_height_diff;
if((vec_src[i-low_bord-1] < diff_low) && !vec_work1[i-low_bord] &&
(vec_src[i+high_bord+1] < diff_high) && !vec_work1[i+high_bord])
{
for(j=i-low_bord; j<=i+high_bord; j++)
vec_work1[j] = 1;
//post("f[%d]=%g, f[%d]=%g",i-low_bord,vec_src[i-low_bord],i+high_bord,vec_src[i+high_bord]);
}
}
}
}
old = vec_work1[0];
sort_index=1;
for(i=1; i<n; i++)
{
if(!old && vec_work1[i])
{
vec_work1[i] = 0;
j=i+1;
while(vec_work1[j])
{
vec_work1[j] = 0;
j++;
}
j--;
peak_index = (i + j) / 2;
if(sort_index <= max_peaks)
{
outlet_float(x->x_peak_value_out, vec_src[i]);
outlet_float(x->x_peak_index_out, (t_float)peak_index);
outlet_float(x->x_sort_index_out, sort_index);
sort_index++;
}
else
i = n+1;
}
old = vec_work1[i];
}
outlet_bang(x->x_bang_out);
} // FREQ_SORT END
else if(x->x_sort_mode == IEMLIB_TAB_FIND_EXACT_PEAKS_SORT_MODE_AMP) // AMP_SORT BEGIN
{
int sort_index=1,old=0,j;
for(i=0; i<n; i++)
{
vec_work1[i] = 0;
vec_work2[i] = 0.0f;
}
for(w=min_width; w<=max_width; w++) // w variiert zw. min u. max
{
for(ww=0; ww<w; ww++)
{
int beg=w-ww;
int end=n-1-ww;
int low_bord=beg-1;
int high_bord=n-end-1;
t_float diff_low,diff_high;
for(i=beg; i<end; i++)
{
diff_low = vec_src[i-low_bord] - abs_min_height_diff;
diff_high = vec_src[i+high_bord] - abs_min_height_diff;
if((vec_src[i-low_bord-1] < diff_low) && !vec_work1[i-low_bord] &&
(vec_src[i+high_bord+1] < diff_high) && !vec_work1[i+high_bord])
{
for(j=i-low_bord; j<=i+high_bord; j++)
{
vec_work1[j] = 1;
vec_work2[j] = vec_src[j];
}
//post("a[%d]=%g, a[%d]=%g",i-low_bord,vec_src[i-low_bord],i+high_bord,vec_src[i+high_bord]);
}
}
}
}
old = vec_work1[0];
for(sort_index=1; sort_index<=max_peaks; sort_index++)
{
max = -1.0e37;
peak_index = -1;
for(i=0; i<n; i++)
{
if(vec_work1[i])
{
if(vec_work2[i] > max)
{
max = vec_work2[i];
peak_index = i;
}
}
}
if(peak_index >= 0)
{
outlet_float(x->x_peak_value_out, max);
outlet_float(x->x_peak_index_out, (t_float)peak_index);
outlet_float(x->x_sort_index_out, sort_index);
vec_work1[peak_index] = 0;
vec_work2[peak_index] = 0.0f;
j=peak_index+1;
while(vec_work1[j])
{
vec_work1[j] = 0;
j++;
}
j=peak_index-1;
while(vec_work1[j])
{
vec_work1[j] = 0;
j--;
}
}
else
sort_index = max_peaks+1;
}
outlet_bang(x->x_bang_out);
}
} // AMP_SORT END
}
/*
[n] zu [n-1] u. [n+1] (ww=0)(w=1)(beg=1)(end=n-1)
[n-1] u. [n] zu [n-2] u. [n+1] (ww=0)(w=2)(beg=2)(end=n-1)
[n] u. [n+1] zu [n-1] u. [n+2] (ww=1)(w=2)(beg=1)(end=n-2)
[n-2] u. [n-1] u. [n] zu [n-3] u. [n+1] (ww=0)(w=3)(beg=3)(end=n-1)
[n-1] u. [n] u. [n+1] zu [n-2] u. [n+2] (ww=1)(w=3)(beg=2)(end=n-2)
[n] u. [n+1] u. [n+2] zu [n-1] u. [n+3] (ww=2)(w=3)(beg=1)(end=n-3)
*/
}
/*static void tab_find_exact_peaks_list(t_tab_find_exact_peaks *x, t_symbol *s, int argc, t_atom *argv)
{
int beg_src;
int i, n;
int ok_src, max_index=0;
t_float *vec_src;
t_float max=-1.0e37;
if((argc >= 2) &&
IS_A_FLOAT(argv,0) &&
IS_A_FLOAT(argv,1))
{
beg_src = (int)atom_getintarg(0, argc, argv);
n = (int)atom_getintarg(1, argc, argv);
if(beg_src < 0)
beg_src = 0;
if(n < 0)
n = 0;
ok_src = iem_tab_check_arrays(gensym("tab_find_exact_peaks"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, beg_src+n);
if(ok_src)
{
vec_src = x->x_beg_mem_src1 + beg_src;
if(n)
{
for(i=0; i<n; i++)
{
if(vec_src[i] > max)
{
max = vec_src[i];
max_index = i + beg_src;
}
}
outlet_float(x->x_peak_value_out, max);
outlet_float(x->x_peak_index_out, (t_float)max_index);
outlet_bang(x->x_bang_out);
}
}
}
else
{
post("tab_find_exact_peaks-ERROR: list need 2 float arguments:");
post(" source_offset + number_of_samples_to_calc_max_index");
}
}*/
static void tab_find_exact_peaks_free(t_tab_find_exact_peaks *x)
{
if(x->x_work_alloc)
{
freebytes(x->x_beg_mem_work1, x->x_work_alloc * sizeof(int));
freebytes(x->x_beg_mem_work2, x->x_work_alloc * sizeof(t_float));
}
}
static void *tab_find_exact_peaks_new(t_symbol *s, int argc, t_atom *argv)
{
t_tab_find_exact_peaks *x = (t_tab_find_exact_peaks *)pd_new(tab_find_exact_peaks_class);
t_symbol *src;
if((argc >= 1) &&
IS_A_SYMBOL(argv,0))
{
src = (t_symbol *)atom_getsymbolarg(0, argc, argv);
}
else
{
post("tab_find_exact_peaks-ERROR: need 1 symbol argument:");
post(" source_array_name");
return(0);
}
x->x_work_alloc = 0;
x->x_beg_mem_work1 = (int *)0;
x->x_beg_mem_work2 = (t_float *)0;
x->x_sym_scr1 = src;
x->x_bang_out = (t_outlet *)outlet_new(&x->x_obj, &s_bang); // ready
x->x_sort_index_out = (t_outlet *)outlet_new(&x->x_obj, &s_float); // sort index
x->x_peak_index_out = (t_outlet *)outlet_new(&x->x_obj, &s_float); // freq
x->x_peak_value_out = (t_outlet *)outlet_new(&x->x_obj, &s_float); // value
return(x);
}
void tab_find_exact_peaks_setup(void)
{
tab_find_exact_peaks_class = class_new(gensym("tab_find_exact_peaks"), (t_newmethod)tab_find_exact_peaks_new, (t_method)tab_find_exact_peaks_free,
sizeof(t_tab_find_exact_peaks), 0, A_GIMME, 0);
class_addbang(tab_find_exact_peaks_class, (t_method)tab_find_exact_peaks_bang);
/*class_addlist(tab_find_exact_peaks_class, (t_method)tab_find_exact_peaks_list);*/
class_addmethod(tab_find_exact_peaks_class, (t_method)tab_find_exact_peaks_src, gensym("src"), A_DEFSYMBOL, 0);
class_addmethod(tab_find_exact_peaks_class, (t_method)tab_find_exact_peaks_src, gensym("src1"), A_DEFSYMBOL, 0);
class_addmethod(tab_find_exact_peaks_class, (t_method)tab_find_exact_peaks_max_peaks, gensym("max_peaks"), A_DEFFLOAT, 0);
class_addmethod(tab_find_exact_peaks_class, (t_method)tab_find_exact_peaks_width_range, gensym("width_range"), A_GIMME, 0);
class_addmethod(tab_find_exact_peaks_class, (t_method)tab_find_exact_peaks_abs_min_height_diff, gensym("abs_min_height_diff"), A_DEFFLOAT, 0);
class_addmethod(tab_find_exact_peaks_class, (t_method)tab_find_exact_peaks_amp_sort, gensym("amp_sort"), 0);
class_addmethod(tab_find_exact_peaks_class, (t_method)tab_find_exact_peaks_freq_sort, gensym("freq_sort"), 0);
class_sethelpsymbol(tab_find_exact_peaks_class, gensym("iemhelp2/help-tab_find_exact_peaks"));
}