From e9c0f3b6a6ec5ff6280c7955972cbbd6e336c4dd Mon Sep 17 00:00:00 2001 From: musil Date: Sun, 1 Feb 2009 07:30:18 +0000 Subject: changed for 64 bit array access svn path=/trunk/externals/iem/iem_bin_ambi/; revision=10708 --- src/bin_ambi_calc_HRTF.c | 46 ++++---- src/bin_ambi_reduced_decode.c | 163 +++++++++++++-------------- src/bin_ambi_reduced_decode2.c | 175 ++++++++++++++--------------- src/bin_ambi_reduced_decode_fft.c | 219 +++++++++++++++++++------------------ src/bin_ambi_reduced_decode_fft2.c | 141 ++++++++++++------------ src/bin_ambi_reduced_decode_fir.c | 188 ++++++++++++++++--------------- src/bin_ambi_reduced_decode_fir2.c | 128 +++++++++++----------- src/iem_bin_ambi.c | 4 +- src/iem_bin_ambi.h | 2 +- src/iemlib.h | 6 +- 10 files changed, 535 insertions(+), 537 deletions(-) (limited to 'src') diff --git a/src/bin_ambi_calc_HRTF.c b/src/bin_ambi_calc_HRTF.c index ec7a471..f2ea70f 100644 --- a/src/bin_ambi_calc_HRTF.c +++ b/src/bin_ambi_calc_HRTF.c @@ -1,7 +1,7 @@ /* For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. -iem_bin_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ +iem_bin_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2009 */ #include "m_pd.h" #include "iemlib.h" @@ -38,7 +38,7 @@ typedef struct _bin_ambi_calc_HRTF BIN_AMBI_COMPLEX *x_spec; BIN_AMBI_COMPLEX *x_sin_cos; iemarray_t *x_beg_fade_out_hrir; - float *x_beg_hrir; + t_float *x_beg_hrir; iemarray_t **x_beg_hrtf_re; iemarray_t **x_beg_hrtf_im; t_symbol **x_hrir_filename; @@ -54,13 +54,13 @@ static t_class *bin_ambi_calc_HRTF_class; static void bin_ambi_calc_HRTF_init_cos(t_bin_ambi_calc_HRTF *x) { int i, fftsize = x->x_fftsize; - float f, g; + t_float f, g; BIN_AMBI_COMPLEX *sincos = x->x_sin_cos; - g = 2.0f * 3.1415926538f / (float)fftsize; + g = 2.0f * 3.1415926538f / (t_float)fftsize; for(i=0; ix_obj.ob_outlet, &s_list, 2, x->x_at); } -static void bin_ambi_calc_HRTF_check_arrays(t_bin_ambi_calc_HRTF *x, float findex) +static void bin_ambi_calc_HRTF_check_arrays(t_bin_ambi_calc_HRTF *x, t_float findex) { int index=(int)findex - 1; int j, k, n; @@ -289,7 +289,7 @@ static void bin_ambi_calc_HRTF_check_arrays(t_bin_ambi_calc_HRTF *x, float finde iemarray_t *vec_fade_out_hrir; iemarray_t *vec_hrir, *vec_hrtf_re, *vec_hrtf_im; t_symbol *hrir, *hrtf_re, *hrtf_im; - float decr, sum; + t_float decr, sum; if(index < 0) index = 0; @@ -342,7 +342,7 @@ static void bin_ambi_calc_HRTF_check_arrays(t_bin_ambi_calc_HRTF *x, float finde for(j=0; jx_spec, x->x_fftsize * sizeof(BIN_AMBI_COMPLEX)); freebytes(x->x_sin_cos, x->x_fftsize * sizeof(BIN_AMBI_COMPLEX)); - freebytes(x->x_beg_hrir, x->x_fftsize * x->x_n_ls * sizeof(float)); - freebytes(x->x_beg_hrtf_re, x->x_n_ls * sizeof(float *)); - freebytes(x->x_beg_hrtf_im, x->x_n_ls * sizeof(float *)); + freebytes(x->x_beg_hrir, x->x_fftsize * x->x_n_ls * sizeof(t_float)); + freebytes(x->x_beg_hrtf_re, x->x_n_ls * sizeof(t_float *)); + freebytes(x->x_beg_hrtf_im, x->x_n_ls * sizeof(t_float *)); } /* @@ -540,7 +538,7 @@ static void *bin_ambi_calc_HRTF_new(t_symbol *s, int argc, t_atom *argv) x->x_sin_cos = (BIN_AMBI_COMPLEX *)getbytes(x->x_fftsize * sizeof(BIN_AMBI_COMPLEX)); x->x_beg_fade_out_hrir = 0; - x->x_beg_hrir = (float *)getbytes(x->x_fftsize * x->x_n_ls * sizeof(float)); + x->x_beg_hrir = (t_float *)getbytes(x->x_fftsize * x->x_n_ls * sizeof(t_float)); x->x_beg_hrtf_re = (iemarray_t **)getbytes(x->x_n_ls * sizeof(iemarray_t *)); x->x_beg_hrtf_im = (iemarray_t **)getbytes(x->x_n_ls * sizeof(iemarray_t *)); diff --git a/src/bin_ambi_reduced_decode.c b/src/bin_ambi_reduced_decode.c index 971ed64..ee1abd6 100644 --- a/src/bin_ambi_reduced_decode.c +++ b/src/bin_ambi_reduced_decode.c @@ -1,7 +1,7 @@ /* For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. -iem_bin_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ +iem_bin_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2009 */ #include "m_pd.h" #include "iemlib.h" @@ -46,7 +46,7 @@ typedef struct _bin_ambi_reduced_decode BIN_AMBI_COMPLEX *x_spec; BIN_AMBI_COMPLEX *x_sin_cos; iemarray_t *x_beg_fade_out_hrir; - float *x_beg_hrir; + t_float *x_beg_hrir; iemarray_t **x_beg_hrtf_re; iemarray_t **x_beg_hrtf_im; t_symbol **x_hrir_filename; @@ -74,20 +74,20 @@ static t_class *bin_ambi_reduced_decode_class; static void bin_ambi_reduced_decode_init_cos(t_bin_ambi_reduced_decode *x) { int i, fftsize = x->x_fftsize; - float f, g; + t_float f, g; BIN_AMBI_COMPLEX *sincos = x->x_sin_cos; - g = 2.0f * 3.1415926538f / (float)fftsize; + g = 2.0f * 3.1415926538f / (t_float)fftsize; for(i=0; ix_delta[index] = (int)(*delta_deg2rad); - x->x_phi[index] = i; + x->x_delta[xindex] = (int)(*delta_deg2rad); + x->x_phi[xindex] = i; *delta_deg2rad *= x->x_pi_over_180; *phi_deg2rad *= x->x_pi_over_180; @@ -194,7 +194,7 @@ static void bin_ambi_reduced_decode_do_2d(t_bin_ambi_reduced_decode *x, int argc { double delta=0.0, phi; double *dw = x->x_inv_work1; - int index; + int xindex; int order=x->x_n_order; int n_ambi = x->x_n_ambi; @@ -203,17 +203,17 @@ static void bin_ambi_reduced_decode_do_2d(t_bin_ambi_reduced_decode *x, int argc post("bin_ambi_reduced_decode ERROR: ls-input needs 1 index and 1 angle: ls_index + phi [degree]"); return; } - index = (int)atom_getint(argv++) - 1; + xindex = (int)atom_getint(argv++) - 1; phi = (double)atom_getfloat(argv); - if(index < 0) - index = 0; - if(index >= n_ambi) - index = n_ambi - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= n_ambi) + xindex = n_ambi - 1; - bin_ambi_reduced_decode_quant(x, &delta, &phi, index); + bin_ambi_reduced_decode_quant(x, &delta, &phi, xindex); - dw += index; + dw += xindex; *dw = 1.0; dw += n_ambi; @@ -315,7 +315,7 @@ static void bin_ambi_reduced_decode_do_3d(t_bin_ambi_reduced_decode *x, int argc double delta, phi; double cd, sd, cd2, cd3, sd2, csd, cp, sp, cp2, sp2, cp3, sp3, cp4, sp4; double *dw = x->x_inv_work1; - int index; + int xindex; int order=x->x_n_order; int n_ambi=x->x_n_ambi; @@ -324,18 +324,18 @@ static void bin_ambi_reduced_decode_do_3d(t_bin_ambi_reduced_decode *x, int argc post("bin_ambi_reduced_decode ERROR: ls-input needs 1 index and 2 angles: ls index + delta [degree] + phi [degree]"); return; } - index = (int)atom_getint(argv++) - 1; + xindex = (int)atom_getint(argv++) - 1; delta = atom_getfloat(argv++); phi = atom_getfloat(argv); - if(index < 0) - index = 0; - if(index >= n_ambi) - index = n_ambi - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= n_ambi) + xindex = n_ambi - 1; - bin_ambi_reduced_decode_quant(x, &delta, &phi, index); + bin_ambi_reduced_decode_quant(x, &delta, &phi, xindex); - dw += index; + dw += xindex; cd = cos(delta); sd = sin(delta); @@ -594,7 +594,7 @@ static void bin_ambi_reduced_decode_inverse(t_bin_ambi_reduced_decode *x) nz = bin_ambi_reduced_decode_eval_which_element_of_col_not_zero(x, i, i); if(nz < 0) { - post("bin_ambi_reduced_decode ERROR: matrix not regular !!!!"); + post("bin_ambi_reduced_decode ERROR: matrix singular !!!!"); return; } else @@ -661,38 +661,38 @@ n_ambi columns; n_ambi rows; */ -static void bin_ambi_reduced_decode_load_HRIR(t_bin_ambi_reduced_decode *x, float findex) +static void bin_ambi_reduced_decode_load_HRIR(t_bin_ambi_reduced_decode *x, t_float findex) { - int index=(int)findex - 1; + int xindex=(int)findex - 1; int p; char buf[60]; - if(index < 0) - index = 0; - if(index >= x->x_n_ambi) - index = x->x_n_ambi - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= x->x_n_ambi) + xindex = x->x_n_ambi - 1; - p = x->x_phi[index]; + p = x->x_phi[xindex]; if(p)/*change*/ p = 360 - p; if(p < 10) - sprintf(buf, "L%de00%da.wav", x->x_delta[index], p); + sprintf(buf, "L%de00%da.wav", x->x_delta[xindex], p); else if(p < 100) - sprintf(buf, "L%de0%da.wav", x->x_delta[index], p); + sprintf(buf, "L%de0%da.wav", x->x_delta[xindex], p); else - sprintf(buf, "L%de%da.wav", x->x_delta[index], p); - x->x_hrir_filename[index] = gensym(buf); + sprintf(buf, "L%de%da.wav", x->x_delta[xindex], p); + x->x_hrir_filename[xindex] = gensym(buf); - SETSYMBOL(x->x_at, x->x_hrir_filename[index]); - SETSYMBOL(x->x_at+1, x->x_s_hrir[index]); + SETSYMBOL(x->x_at, x->x_hrir_filename[xindex]); + SETSYMBOL(x->x_at+1, x->x_s_hrir[xindex]); outlet_list(x->x_obj.ob_outlet, &s_list, 2, x->x_at); } -static void bin_ambi_reduced_decode_check_arrays(t_bin_ambi_reduced_decode *x, float findex) +static void bin_ambi_reduced_decode_check_arrays(t_bin_ambi_reduced_decode *x, t_float findex) { - int index=(int)findex - 1; + int xindex=(int)findex - 1; int j, k, n; int fftsize = x->x_fftsize; int fs2=fftsize/2; @@ -703,16 +703,16 @@ static void bin_ambi_reduced_decode_check_arrays(t_bin_ambi_reduced_decode *x, f iemarray_t *vec_fade_out_hrir; iemarray_t *vec_hrtf_re, *vec_hrtf_im; t_symbol *hrir, *hrtf_re, *hrtf_im; - float decr, sum; + t_float decr, sum; - if(index < 0) - index = 0; - if(index >= x->x_n_ambi) - index = x->x_n_ambi - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= x->x_n_ambi) + xindex = x->x_n_ambi - 1; - hrir = x->x_s_hrir[index]; - hrtf_re = x->x_s_hrtf_re[index]; - hrtf_im = x->x_s_hrtf_im[index]; + hrir = x->x_s_hrir[xindex]; + hrtf_re = x->x_s_hrtf_re[xindex]; + hrtf_im = x->x_s_hrtf_im[xindex]; if (!(a = (t_garray *)pd_findbyclass(hrtf_re, garray_class))) error("%s: no such array", hrtf_re->s_name); @@ -732,15 +732,15 @@ static void bin_ambi_reduced_decode_check_arrays(t_bin_ambi_reduced_decode *x, f error("%s: bad template for bin_ambi_reduced_decode", hrir->s_name); else { - x->x_beg_hrtf_re[index] = vec_hrtf_re; - x->x_beg_hrtf_im[index] = vec_hrtf_im; + x->x_beg_hrtf_re[xindex] = vec_hrtf_re; + x->x_beg_hrtf_im[xindex] = vec_hrtf_im; if(npoints < fftsize) { post("bin_ambi_reduced_decode-WARNING: %s-array-size: %d < FFT-size: %d", hrir->s_name, npoints, fftsize); } vec = x->x_beg_hrir; - vec += index * fftsize; + vec += xindex * fftsize; if(x->x_beg_fade_out_hrir) { @@ -756,7 +756,7 @@ static void bin_ambi_reduced_decode_check_arrays(t_bin_ambi_reduced_decode *x, f for(j=0; jx_fftsize; BIN_AMBI_COMPLEX old1, old2, w; @@ -779,18 +779,18 @@ static void bin_ambi_reduced_decode_calc_reduced(t_bin_ambi_reduced_decode *x, f double *dv, *db=x->x_inv_work2; int n_ambi = x->x_n_ambi; int n_ambi2 = 2*n_ambi; - float mul; + t_float mul; - if(index < 0) - index = 0; - if(index >= n_ambi) - index = n_ambi - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= n_ambi) + xindex = n_ambi - 1; - vec_hrtf_re = x->x_beg_hrtf_re[index]; - vec_hrtf_im = x->x_beg_hrtf_im[index]; + vec_hrtf_re = x->x_beg_hrtf_re[xindex]; + vec_hrtf_im = x->x_beg_hrtf_im[xindex]; - dv = db + index + n_ambi; - mul = (float)(*dv); + dv = db + xindex + n_ambi; + mul = (t_float)(*dv); vec_hrir = x->x_beg_hrir; for(k=0; kx_beg_hrir; vec_hrir += j * fftsize; for(k=0; kx_at, 1.0f); else if(plus_minus[i] == '-') SETFLOAT(x->x_at, 2.0f); - SETFLOAT(x->x_at+1, (float)(i+1)); + SETFLOAT(x->x_at+1, (t_float)(i+1)); outlet_list(x->x_out_sign_sum, &s_list, 2, x->x_at); } } @@ -1060,9 +1061,9 @@ static void bin_ambi_reduced_decode_free(t_bin_ambi_reduced_decode *x) freebytes(x->x_spec, x->x_fftsize * sizeof(BIN_AMBI_COMPLEX)); freebytes(x->x_sin_cos, x->x_fftsize * sizeof(BIN_AMBI_COMPLEX)); - freebytes(x->x_beg_hrir, x->x_fftsize * x->x_n_ambi * sizeof(float)); - freebytes(x->x_beg_hrtf_re, x->x_n_ambi * sizeof(float *)); - freebytes(x->x_beg_hrtf_im, x->x_n_ambi * sizeof(float *)); + freebytes(x->x_beg_hrir, x->x_fftsize * x->x_n_ambi * sizeof(t_float)); + freebytes(x->x_beg_hrtf_re, x->x_n_ambi * sizeof(iemarray_t *)); + freebytes(x->x_beg_hrtf_im, x->x_n_ambi * sizeof(iemarray_t *)); } /* @@ -1211,7 +1212,7 @@ static void *bin_ambi_reduced_decode_new(t_symbol *s, int argc, t_atom *argv) x->x_sin_cos = (BIN_AMBI_COMPLEX *)getbytes(x->x_fftsize * sizeof(BIN_AMBI_COMPLEX)); x->x_beg_fade_out_hrir = 0; - x->x_beg_hrir = (float *)getbytes(x->x_fftsize * x->x_n_ambi * sizeof(float)); + x->x_beg_hrir = (t_float *)getbytes(x->x_fftsize * x->x_n_ambi * sizeof(t_float)); x->x_beg_hrtf_re = (iemarray_t **)getbytes(x->x_n_ambi * sizeof(iemarray_t *)); x->x_beg_hrtf_im = (iemarray_t **)getbytes(x->x_n_ambi * sizeof(iemarray_t *)); diff --git a/src/bin_ambi_reduced_decode2.c b/src/bin_ambi_reduced_decode2.c index d8bc40a..cfb50eb 100644 --- a/src/bin_ambi_reduced_decode2.c +++ b/src/bin_ambi_reduced_decode2.c @@ -1,7 +1,7 @@ /* For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. -iem_bin_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ +iem_bin_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2009 */ #include "m_pd.h" #include "iemlib.h" @@ -51,7 +51,7 @@ typedef struct _bin_ambi_reduced_decode2 BIN_AMBI_COMPLEX *x_spec; BIN_AMBI_COMPLEX *x_sin_cos; iemarray_t *x_beg_fade_out_hrir; - float *x_beg_hrir; + t_float *x_beg_hrir; iemarray_t **x_beg_hrtf_re; iemarray_t **x_beg_hrtf_im; t_symbol **x_hrir_filename; @@ -79,20 +79,20 @@ static t_class *bin_ambi_reduced_decode2_class; static void bin_ambi_reduced_decode2_init_cos(t_bin_ambi_reduced_decode2 *x) {/* initialize a whole sine and cosine wave over a fftsize array */ int i, fftsize = x->x_fftsize; - float f, g; + t_float f, g; BIN_AMBI_COMPLEX *sincos = x->x_sin_cos; - g = 2.0f * 3.1415926538f / (float)fftsize; + g = 2.0f * 3.1415926538f / (t_float)fftsize; for(i=0; ix_delta[index] = (int)(*delta_deg2rad); - x->x_phi[index] = i; + x->x_delta[xindex] = (int)(*delta_deg2rad); + x->x_phi[xindex] = i; *delta_deg2rad *= x->x_pi_over_180; *phi_deg2rad *= x->x_pi_over_180; @@ -199,7 +199,7 @@ static void bin_ambi_reduced_decode2_do_2d(t_bin_ambi_reduced_decode2 *x, int ar { double delta=0.0, phi; double *dw = x->x_transp; - int index; + int xindex; int order=x->x_n_order; int n_ls = x->x_n_ls; @@ -208,17 +208,17 @@ static void bin_ambi_reduced_decode2_do_2d(t_bin_ambi_reduced_decode2 *x, int ar post("bin_ambi_reduced_decode2 ERROR: ls-input needs 1 index and 1 angle: ls_index + phi [degree]"); return; } - index = (int)atom_getint(argv++) - 1; + xindex = (int)atom_getint(argv++) - 1; phi = (double)atom_getfloat(argv); - if(index < 0) - index = 0; - if(index >= n_ls) - index = n_ls - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= n_ls) + xindex = n_ls - 1; - bin_ambi_reduced_decode2_quant(x, &delta, &phi, index); + bin_ambi_reduced_decode2_quant(x, &delta, &phi, xindex); - dw += index * x->x_n_ambi; + dw += xindex * x->x_n_ambi; *dw++ = 1.0; *dw++ = cos(phi); @@ -295,7 +295,7 @@ static void bin_ambi_reduced_decode2_do_3d(t_bin_ambi_reduced_decode2 *x, int ar double delta, phi; double cd, sd, cd2, cd3, sd2, csd, cp, sp, cp2, sp2, cp3, sp3, cp4, sp4; double *dw = x->x_transp; - int index; + int xindex; int n_ls=x->x_n_ls; int order=x->x_n_order; @@ -304,23 +304,23 @@ static void bin_ambi_reduced_decode2_do_3d(t_bin_ambi_reduced_decode2 *x, int ar post("bin_ambi_reduced_decode2 ERROR: ls-input needs 1 index and 2 angles: ls index + delta [degree] + phi [degree]"); return; } - index = (int)atom_getint(argv++) - 1; + xindex = (int)atom_getint(argv++) - 1; delta = atom_getfloat(argv++); phi = atom_getfloat(argv); - if(index < 0) - index = 0; - if(index >= n_ls) - index = n_ls - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= n_ls) + xindex = n_ls - 1; - bin_ambi_reduced_decode2_quant(x, &delta, &phi, index); + bin_ambi_reduced_decode2_quant(x, &delta, &phi, xindex); cd = cos(delta); sd = sin(delta); cp = cos(phi); sp = sin(phi); - dw += index * x->x_n_ambi; + dw += xindex * x->x_n_ambi; *dw++ = 1.0; @@ -622,7 +622,7 @@ static void bin_ambi_reduced_decode2_inverse(t_bin_ambi_reduced_decode2 *x) nz = bin_ambi_reduced_decode2_eval_which_element_of_col_not_zero(x, i, i); if(nz < 0) { - post("bin_ambi_reduced_decode2 ERROR: matrix not regular !!!!"); + post("bin_ambi_reduced_decode2 ERROR: matrix singular !!!!"); x->x_seq_ok = 0; return; } @@ -690,38 +690,38 @@ n_ambi columns; n_ambi rows; */ -static void bin_ambi_reduced_decode2_load_HRIR(t_bin_ambi_reduced_decode2 *x, float findex) +static void bin_ambi_reduced_decode2_load_HRIR(t_bin_ambi_reduced_decode2 *x, t_float findex) { - int index=(int)findex - 1; + int xindex=(int)findex - 1; int p; char buf[60]; - if(index < 0) - index = 0; - if(index >= x->x_n_ls) - index = x->x_n_ls - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= x->x_n_ls) + xindex = x->x_n_ls - 1; - p = x->x_phi[index]; + p = x->x_phi[xindex]; if(p)/*change*/ p = 360 - p; if(p < 10) - sprintf(buf, "L%de00%da.wav", x->x_delta[index], p); + sprintf(buf, "L%de00%da.wav", x->x_delta[xindex], p); else if(p < 100) - sprintf(buf, "L%de0%da.wav", x->x_delta[index], p); + sprintf(buf, "L%de0%da.wav", x->x_delta[xindex], p); else - sprintf(buf, "L%de%da.wav", x->x_delta[index], p); - x->x_hrir_filename[index] = gensym(buf); + sprintf(buf, "L%de%da.wav", x->x_delta[xindex], p); + x->x_hrir_filename[xindex] = gensym(buf); - SETSYMBOL(x->x_at, x->x_hrir_filename[index]); - SETSYMBOL(x->x_at+1, x->x_s_hrir[index]); + SETSYMBOL(x->x_at, x->x_hrir_filename[xindex]); + SETSYMBOL(x->x_at+1, x->x_s_hrir[xindex]); outlet_list(x->x_obj.ob_outlet, &s_list, 2, x->x_at); } -static void bin_ambi_reduced_decode2_check_HRIR_arrays(t_bin_ambi_reduced_decode2 *x, float findex) +static void bin_ambi_reduced_decode2_check_HRIR_arrays(t_bin_ambi_reduced_decode2 *x, t_float findex) { - int index=(int)findex - 1; + int xindex=(int)findex - 1; int j, k, n; int fftsize = x->x_fftsize; int fs2=fftsize/2; @@ -730,14 +730,14 @@ static void bin_ambi_reduced_decode2_check_HRIR_arrays(t_bin_ambi_reduced_decode t_symbol *hrir; iemarray_t *vec_hrir, *vec_fade_out_hrir; t_float *vec; - float decr, sum; + t_float decr, sum; - if(index < 0) - index = 0; - if(index >= x->x_n_ls) - index = x->x_n_ls - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= x->x_n_ls) + xindex = x->x_n_ls - 1; - hrir = x->x_s_hrir[index]; + hrir = x->x_s_hrir[xindex]; if (!(a = (t_garray *)pd_findbyclass(hrir, garray_class))) error("%s: no such array", hrir->s_name); else if (!iemarray_getarray(a, &npoints, &vec_hrir)) @@ -749,7 +749,7 @@ static void bin_ambi_reduced_decode2_check_HRIR_arrays(t_bin_ambi_reduced_decode post("bin_ambi_reduced_decode2-WARNING: %s-array-size: %d < FFT-size: %d", hrir->s_name, npoints, fftsize); } vec = x->x_beg_hrir; - vec += index * fftsize; + vec += xindex * fftsize; if(x->x_beg_fade_out_hrir) { @@ -765,7 +765,7 @@ static void bin_ambi_reduced_decode2_check_HRIR_arrays(t_bin_ambi_reduced_decode for(j=0; jx_fftsize; iemarray_t *vec_hrtf_re, *vec_hrtf_im; t_symbol *hrtf_re, *hrtf_im; - if(index < 0) - index = 0; - if(index >= x->x_n_ambi) - index = x->x_n_ambi - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= x->x_n_ambi) + xindex = x->x_n_ambi - 1; - hrtf_re = x->x_s_hrtf_re[index]; - hrtf_im = x->x_s_hrtf_im[index]; + hrtf_re = x->x_s_hrtf_re[xindex]; + hrtf_im = x->x_s_hrtf_im[xindex]; if (!(a = (t_garray *)pd_findbyclass(hrtf_re, garray_class))) error("%s: no such array", hrtf_re->s_name); @@ -806,14 +806,14 @@ static void bin_ambi_reduced_decode2_check_HRTF_arrays(t_bin_ambi_reduced_decode error("%s: bad array-size: %d", hrtf_im->s_name, npoints); else { - x->x_beg_hrtf_re[index] = vec_hrtf_re; - x->x_beg_hrtf_im[index] = vec_hrtf_im; + x->x_beg_hrtf_re[xindex] = vec_hrtf_re; + x->x_beg_hrtf_im[xindex] = vec_hrtf_im; } } -static void bin_ambi_reduced_decode2_calc_reduced(t_bin_ambi_reduced_decode2 *x, float findex) +static void bin_ambi_reduced_decode2_calc_reduced(t_bin_ambi_reduced_decode2 *x, t_float findex) { - int index=(int)findex - 1; + int xindex=(int)findex - 1; int i, j, k, w_index, w_inc, i_inc, v_index, fs1, fs2; int fftsize = x->x_fftsize; BIN_AMBI_COMPLEX old1, old2, w; @@ -824,20 +824,20 @@ static void bin_ambi_reduced_decode2_calc_reduced(t_bin_ambi_reduced_decode2 *x, double *dv, *db=x->x_prod; int n_ambi = x->x_n_ambi; int n_ls = x->x_n_ls; - float mul; + t_float mul; if(x->x_seq_ok) { - if(index < 0) - index = 0; - if(index >= n_ambi) - index = n_ambi - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= n_ambi) + xindex = n_ambi - 1; - vec_hrtf_re = x->x_beg_hrtf_re[index]; - vec_hrtf_im = x->x_beg_hrtf_im[index]; + vec_hrtf_re = x->x_beg_hrtf_re[xindex]; + vec_hrtf_im = x->x_beg_hrtf_im[xindex]; - dv = db + index; - mul = (float)(*dv); + dv = db + xindex; + mul = (t_float)(*dv); vec_hrir = x->x_beg_hrir; for(k=0; kx_beg_hrir; vec_hrir += j * fftsize; for(k=0; kx_at, 1.0f); else if(plus_minus[i] == '-') SETFLOAT(x->x_at, 2.0f); - SETFLOAT(x->x_at+1, (float)(i+1)); + SETFLOAT(x->x_at+1, (t_float)(i+1)); outlet_list(x->x_out_sign_sum, &s_list, 2, x->x_at); } } @@ -1115,9 +1116,9 @@ static void bin_ambi_reduced_decode2_free(t_bin_ambi_reduced_decode2 *x) freebytes(x->x_spec, x->x_fftsize * sizeof(BIN_AMBI_COMPLEX)); freebytes(x->x_sin_cos, x->x_fftsize * sizeof(BIN_AMBI_COMPLEX)); - freebytes(x->x_beg_hrir, x->x_fftsize * x->x_n_ls * sizeof(float)); - freebytes(x->x_beg_hrtf_re, x->x_n_ambi * sizeof(float *)); - freebytes(x->x_beg_hrtf_im, x->x_n_ambi * sizeof(float *)); + freebytes(x->x_beg_hrir, x->x_fftsize * x->x_n_ls * sizeof(t_float)); + freebytes(x->x_beg_hrtf_re, x->x_n_ambi * sizeof(iemarray_t *)); + freebytes(x->x_beg_hrtf_im, x->x_n_ambi * sizeof(iemarray_t *)); } /* @@ -1287,7 +1288,7 @@ static void *bin_ambi_reduced_decode2_new(t_symbol *s, int argc, t_atom *argv) x->x_sin_cos = (BIN_AMBI_COMPLEX *)getbytes(x->x_fftsize * sizeof(BIN_AMBI_COMPLEX)); x->x_beg_fade_out_hrir = 0; - x->x_beg_hrir = (float *)getbytes(x->x_fftsize * x->x_n_ls * sizeof(float)); + x->x_beg_hrir = (t_float *)getbytes(x->x_fftsize * x->x_n_ls * sizeof(t_float)); x->x_beg_hrtf_re = (iemarray_t **)getbytes(x->x_n_ambi * sizeof(iemarray_t *)); x->x_beg_hrtf_im = (iemarray_t **)getbytes(x->x_n_ambi * sizeof(iemarray_t *)); diff --git a/src/bin_ambi_reduced_decode_fft.c b/src/bin_ambi_reduced_decode_fft.c index 696f5ea..04b4e0c 100644 --- a/src/bin_ambi_reduced_decode_fft.c +++ b/src/bin_ambi_reduced_decode_fft.c @@ -1,7 +1,7 @@ /* For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. -iem_bin_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ +iem_bin_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2009 */ #include "m_pd.h" #include "iemlib.h" @@ -55,7 +55,7 @@ typedef struct _bin_ambi_reduced_decode_fft BIN_AMBI_COMPLEX *x_spec; BIN_AMBI_COMPLEX *x_sin_cos; iemarray_t *x_beg_fade_out_hrir; - float *x_beg_hrir; + t_float *x_beg_hrir; iemarray_t **x_beg_hrtf_re; iemarray_t **x_beg_hrtf_im; t_symbol **x_hrir_filename; @@ -83,20 +83,20 @@ static t_class *bin_ambi_reduced_decode_fft_class; static void bin_ambi_reduced_decode_fft_init_cos(t_bin_ambi_reduced_decode_fft *x) {/* initialize a whole sine and cosine wave over a fftsize array */ int i, fftsize = x->x_fftsize; - float f, g; + t_float f, g; BIN_AMBI_COMPLEX *sincos = x->x_sin_cos; - g = 2.0f * 3.1415926538f / (float)fftsize; + g = 2.0f * 3.1415926538f / (t_float)fftsize; for(i=0; ix_delta[index] = (int)(*delta_deg2rad); - x->x_phi[index] = i; + x->x_delta[xindex] = (int)(*delta_deg2rad); + x->x_phi[xindex] = i; *delta_deg2rad *= x->x_pi_over_180; *phi_deg2rad *= x->x_pi_over_180; @@ -203,7 +203,7 @@ static void bin_ambi_reduced_decode_fft_do_2d(t_bin_ambi_reduced_decode_fft *x, { double delta=0.0, phi; double *dw = x->x_transp; - int index; + int xindex; int order=x->x_n_order; if(argc < 2) @@ -211,23 +211,23 @@ static void bin_ambi_reduced_decode_fft_do_2d(t_bin_ambi_reduced_decode_fft *x, post("bin_ambi_reduced_decode_fft ERROR: ls-input needs 1 index and 1 angle: ls_index + phi [degree]"); return; } - index = (int)atom_getint(argv++) - 1; + xindex = (int)atom_getint(argv++) - 1; phi = (double)atom_getfloat(argv); - if(index < 0) - index = 0; + if(xindex < 0) + xindex = 0; if(mode == BIN_AMBI_LS_IND) { - if(index >= x->x_n_ind_ls) - index = x->x_n_ind_ls - 1; + if(xindex >= x->x_n_ind_ls) + xindex = x->x_n_ind_ls - 1; } else if(mode == BIN_AMBI_LS_MRG) { if(x->x_n_mrg_mir_ls) { - if(index >= x->x_n_mrg_mir_ls) - index = x->x_n_mrg_mir_ls - 1; - index += x->x_n_ind_ls; + if(xindex >= x->x_n_mrg_mir_ls) + xindex = x->x_n_mrg_mir_ls - 1; + xindex += x->x_n_ind_ls; } else return; @@ -236,10 +236,10 @@ static void bin_ambi_reduced_decode_fft_do_2d(t_bin_ambi_reduced_decode_fft *x, { if(x->x_n_mrg_mir_ls) { - if(index >= x->x_n_mrg_mir_ls) - index = x->x_n_mrg_mir_ls - 1; - index += x->x_n_ind_ls; - index += x->x_n_mrg_mir_ls; + if(xindex >= x->x_n_mrg_mir_ls) + xindex = x->x_n_mrg_mir_ls - 1; + xindex += x->x_n_ind_ls; + xindex += x->x_n_mrg_mir_ls; } else return; @@ -248,10 +248,10 @@ static void bin_ambi_reduced_decode_fft_do_2d(t_bin_ambi_reduced_decode_fft *x, { if(x->x_n_ph_ls) { - if(index >= x->x_n_ph_ls) - index = x->x_n_ph_ls - 1; - index += x->x_n_ind_ls; - index += 2*x->x_n_mrg_mir_ls; + if(xindex >= x->x_n_ph_ls) + xindex = x->x_n_ph_ls - 1; + xindex += x->x_n_ind_ls; + xindex += 2*x->x_n_mrg_mir_ls; } else return; @@ -259,9 +259,9 @@ static void bin_ambi_reduced_decode_fft_do_2d(t_bin_ambi_reduced_decode_fft *x, else return; - bin_ambi_reduced_decode_fft_quant(x, &delta, &phi, index); + bin_ambi_reduced_decode_fft_quant(x, &delta, &phi, xindex); - dw += index * x->x_n_ambi; + dw += xindex * x->x_n_ambi; *dw++ = 1.0; *dw++ = cos(phi); @@ -338,7 +338,7 @@ static void bin_ambi_reduced_decode_fft_do_3d(t_bin_ambi_reduced_decode_fft *x, double delta, phi; double cd, sd, cd2, cd3, sd2, csd, cp, sp, cp2, sp2, cp3, sp3, cp4, sp4; double *dw = x->x_transp; - int index; + int xindex; int order=x->x_n_order; if(argc < 3) @@ -346,24 +346,24 @@ static void bin_ambi_reduced_decode_fft_do_3d(t_bin_ambi_reduced_decode_fft *x, post("bin_ambi_reduced_decode_fft ERROR: ls-input needs 1 index and 2 angles: ls index + delta [degree] + phi [degree]"); return; } - index = (int)atom_getint(argv++) - 1; + xindex = (int)atom_getint(argv++) - 1; delta = atom_getfloat(argv++); phi = atom_getfloat(argv); - if(index < 0) - index = 0; + if(xindex < 0) + xindex = 0; if(mode == BIN_AMBI_LS_IND) { - if(index >= x->x_n_ind_ls) - index = x->x_n_ind_ls - 1; + if(xindex >= x->x_n_ind_ls) + xindex = x->x_n_ind_ls - 1; } else if(mode == BIN_AMBI_LS_MRG) { if(x->x_n_mrg_mir_ls) { - if(index >= x->x_n_mrg_mir_ls) - index = x->x_n_mrg_mir_ls - 1; - index += x->x_n_ind_ls; + if(xindex >= x->x_n_mrg_mir_ls) + xindex = x->x_n_mrg_mir_ls - 1; + xindex += x->x_n_ind_ls; } else return; @@ -372,10 +372,10 @@ static void bin_ambi_reduced_decode_fft_do_3d(t_bin_ambi_reduced_decode_fft *x, { if(x->x_n_mrg_mir_ls) { - if(index >= x->x_n_mrg_mir_ls) - index = x->x_n_mrg_mir_ls - 1; - index += x->x_n_ind_ls; - index += x->x_n_mrg_mir_ls; + if(xindex >= x->x_n_mrg_mir_ls) + xindex = x->x_n_mrg_mir_ls - 1; + xindex += x->x_n_ind_ls; + xindex += x->x_n_mrg_mir_ls; } else return; @@ -384,10 +384,10 @@ static void bin_ambi_reduced_decode_fft_do_3d(t_bin_ambi_reduced_decode_fft *x, { if(x->x_n_ph_ls) { - if(index >= x->x_n_ph_ls) - index = x->x_n_ph_ls - 1; - index += x->x_n_ind_ls; - index += 2*x->x_n_mrg_mir_ls; + if(xindex >= x->x_n_ph_ls) + xindex = x->x_n_ph_ls - 1; + xindex += x->x_n_ind_ls; + xindex += 2*x->x_n_mrg_mir_ls; } else return; @@ -395,14 +395,14 @@ static void bin_ambi_reduced_decode_fft_do_3d(t_bin_ambi_reduced_decode_fft *x, else return; - bin_ambi_reduced_decode_fft_quant(x, &delta, &phi, index); + bin_ambi_reduced_decode_fft_quant(x, &delta, &phi, xindex); cd = cos(delta); sd = sin(delta); cp = cos(phi); sp = sin(phi); - dw += index * x->x_n_ambi; + dw += xindex * x->x_n_ambi; *dw++ = 1.0; @@ -746,7 +746,7 @@ static void bin_ambi_reduced_decode_fft_inverse(t_bin_ambi_reduced_decode_fft *x nz = bin_ambi_reduced_decode_fft_eval_which_element_of_col_not_zero(x, i, i); if(nz < 0) { - post("bin_ambi_reduced_decode_fft ERROR: matrix not regular !!!!"); + post("bin_ambi_reduced_decode_fft ERROR: matrix singular !!!!"); x->x_seq_ok = 0; return; } @@ -815,38 +815,38 @@ n_ambi columns; n_ambi rows; */ -static void bin_ambi_reduced_decode_fft_load_HRIR(t_bin_ambi_reduced_decode_fft *x, float findex) +static void bin_ambi_reduced_decode_fft_load_HRIR(t_bin_ambi_reduced_decode_fft *x, t_float findex) { - int index=(int)findex - 1; + int xindex=(int)findex - 1; int p; char buf[60]; - if(index < 0) - index = 0; - if(index >= (x->x_n_ind_ls + x->x_n_mrg_mir_ls)) - index = x->x_n_ind_ls + x->x_n_mrg_mir_ls - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= (x->x_n_ind_ls + x->x_n_mrg_mir_ls)) + xindex = x->x_n_ind_ls + x->x_n_mrg_mir_ls - 1; - p = x->x_phi[index]; + p = x->x_phi[xindex]; if(p)/*change*/ p = 360 - p; if(p < 10) - sprintf(buf, "L%de00%da.wav", x->x_delta[index], p); + sprintf(buf, "L%de00%da.wav", x->x_delta[xindex], p); else if(p < 100) - sprintf(buf, "L%de0%da.wav", x->x_delta[index], p); + sprintf(buf, "L%de0%da.wav", x->x_delta[xindex], p); else - sprintf(buf, "L%de%da.wav", x->x_delta[index], p); - x->x_hrir_filename[index] = gensym(buf); + sprintf(buf, "L%de%da.wav", x->x_delta[xindex], p); + x->x_hrir_filename[xindex] = gensym(buf); - SETSYMBOL(x->x_at, x->x_hrir_filename[index]); - SETSYMBOL(x->x_at+1, x->x_s_hrir[index]); + SETSYMBOL(x->x_at, x->x_hrir_filename[xindex]); + SETSYMBOL(x->x_at+1, x->x_s_hrir[xindex]); outlet_list(x->x_obj.ob_outlet, &s_list, 2, x->x_at); } -static void bin_ambi_reduced_decode_fft_check_HRIR_arrays(t_bin_ambi_reduced_decode_fft *x, float findex) +static void bin_ambi_reduced_decode_fft_check_HRIR_arrays(t_bin_ambi_reduced_decode_fft *x, t_float findex) { - int index=(int)findex - 1; + int xindex=(int)findex - 1; int j, k, n; int fftsize = x->x_fftsize; int fs2=fftsize/2; @@ -855,14 +855,14 @@ static void bin_ambi_reduced_decode_fft_check_HRIR_arrays(t_bin_ambi_reduced_dec t_symbol *hrir; t_float *vec; iemarray_t *vec_hrir, *vec_fade_out_hrir; - float decr, sum; + t_float decr, sum; - if(index < 0) - index = 0; - if(index >= (x->x_n_ind_ls + x->x_n_mrg_mir_ls)) - index = x->x_n_ind_ls + x->x_n_mrg_mir_ls - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= (x->x_n_ind_ls + x->x_n_mrg_mir_ls)) + xindex = x->x_n_ind_ls + x->x_n_mrg_mir_ls - 1; - hrir = x->x_s_hrir[index]; + hrir = x->x_s_hrir[xindex]; if (!(a = (t_garray *)pd_findbyclass(hrir, garray_class))) error("%s: no such array", hrir->s_name); else if (!iemarray_getarray(a, &npoints, &vec_hrir)) @@ -874,7 +874,7 @@ static void bin_ambi_reduced_decode_fft_check_HRIR_arrays(t_bin_ambi_reduced_dec post("bin_ambi_reduced_decode_fft-WARNING: %s-array-size: %d < FFT-size: %d", hrir->s_name, npoints, fftsize); } vec = x->x_beg_hrir; - vec += index * fftsize; + vec += xindex * fftsize; if(x->x_beg_fade_out_hrir) { @@ -890,7 +890,7 @@ static void bin_ambi_reduced_decode_fft_check_HRIR_arrays(t_bin_ambi_reduced_dec for(j=0; jx_fftsize; iemarray_t *vec_hrtf_re, *vec_hrtf_im; t_symbol *hrtf_re, *hrtf_im; - if(index < 0) - index = 0; - if(index >= x->x_n_ambi) - index = x->x_n_ambi - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= x->x_n_ambi) + xindex = x->x_n_ambi - 1; - hrtf_re = x->x_s_hrtf_re[index]; - hrtf_im = x->x_s_hrtf_im[index]; + hrtf_re = x->x_s_hrtf_re[xindex]; + hrtf_im = x->x_s_hrtf_im[xindex]; if (!(a = (t_garray *)pd_findbyclass(hrtf_re, garray_class))) error("%s: no such array", hrtf_re->s_name); @@ -931,14 +931,14 @@ static void bin_ambi_reduced_decode_fft_check_HRTF_arrays(t_bin_ambi_reduced_dec error("%s: bad array-size: %d", hrtf_im->s_name, npoints); else { - x->x_beg_hrtf_re[index] = vec_hrtf_re; - x->x_beg_hrtf_im[index] = vec_hrtf_im; + x->x_beg_hrtf_re[xindex] = vec_hrtf_re; + x->x_beg_hrtf_im[xindex] = vec_hrtf_im; } } -static void bin_ambi_reduced_decode_fft_calc_reduced(t_bin_ambi_reduced_decode_fft *x, float findex) +static void bin_ambi_reduced_decode_fft_calc_reduced(t_bin_ambi_reduced_decode_fft *x, t_float findex) { - int index=(int)findex - 1; + int xindex=(int)findex - 1; int i, j, k, w_index, w_inc, i_inc, v_index, fs1, fs2; int fftsize = x->x_fftsize; BIN_AMBI_COMPLEX old1, old2, w; @@ -949,20 +949,20 @@ static void bin_ambi_reduced_decode_fft_calc_reduced(t_bin_ambi_reduced_decode_f double *dv, *db=x->x_prod3; int n_ambi = x->x_n_ambi; int n_ls = x->x_n_ind_ls + x->x_n_mrg_mir_ls; - float mul; + t_float mul; if(x->x_seq_ok) { - if(index < 0) - index = 0; - if(index >= n_ambi) - index = n_ambi - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= n_ambi) + xindex = n_ambi - 1; - vec_hrtf_re = x->x_beg_hrtf_re[index]; - vec_hrtf_im = x->x_beg_hrtf_im[index]; + vec_hrtf_re = x->x_beg_hrtf_re[xindex]; + vec_hrtf_im = x->x_beg_hrtf_im[xindex]; - dv = db + index; - mul = (float)(*dv); + dv = db + xindex; + mul = (t_float)(*dv); vec_hrir = x->x_beg_hrir; for(k=0; kx_beg_hrir; vec_hrir += j * fftsize; for(k=0; kx_at, 1.0f); else if(plus_minus[i] == '-') SETFLOAT(x->x_at, 2.0f); - SETFLOAT(x->x_at+1, (float)(i+1)); + SETFLOAT(x->x_at+1, (t_float)(i+1)); outlet_list(x->x_out_sign_sum, &s_list, 2, x->x_at); } } @@ -1246,9 +1247,9 @@ static void bin_ambi_reduced_decode_fft_free(t_bin_ambi_reduced_decode_fft *x) freebytes(x->x_spec, x->x_fftsize * sizeof(BIN_AMBI_COMPLEX)); freebytes(x->x_sin_cos, x->x_fftsize * sizeof(BIN_AMBI_COMPLEX)); - freebytes(x->x_beg_hrir, x->x_fftsize * (x->x_n_ind_ls+x->x_n_mrg_mir_ls) * sizeof(float)); - freebytes(x->x_beg_hrtf_re, x->x_n_ambi * sizeof(float *)); - freebytes(x->x_beg_hrtf_im, x->x_n_ambi * sizeof(float *)); + freebytes(x->x_beg_hrir, x->x_fftsize * (x->x_n_ind_ls+x->x_n_mrg_mir_ls) * sizeof(t_float)); + freebytes(x->x_beg_hrtf_re, x->x_n_ambi * sizeof(iemarray_t *)); + freebytes(x->x_beg_hrtf_im, x->x_n_ambi * sizeof(iemarray_t *)); } /* @@ -1433,7 +1434,7 @@ static void *bin_ambi_reduced_decode_fft_new(t_symbol *s, int argc, t_atom *argv x->x_sin_cos = (BIN_AMBI_COMPLEX *)getbytes(x->x_fftsize * sizeof(BIN_AMBI_COMPLEX)); x->x_beg_fade_out_hrir = 0; - x->x_beg_hrir = (float *)getbytes(x->x_fftsize * (x->x_n_ind_ls+x->x_n_mrg_mir_ls) * sizeof(float)); + x->x_beg_hrir = (t_float *)getbytes(x->x_fftsize * (x->x_n_ind_ls+x->x_n_mrg_mir_ls) * sizeof(t_float)); x->x_beg_hrtf_re = (iemarray_t **)getbytes(x->x_n_ambi * sizeof(iemarray_t *)); x->x_beg_hrtf_im = (iemarray_t **)getbytes(x->x_n_ambi * sizeof(iemarray_t *)); diff --git a/src/bin_ambi_reduced_decode_fft2.c b/src/bin_ambi_reduced_decode_fft2.c index d629787..9d0e11d 100644 --- a/src/bin_ambi_reduced_decode_fft2.c +++ b/src/bin_ambi_reduced_decode_fft2.c @@ -1,7 +1,7 @@ /* For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. -iem_bin_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ +iem_bin_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2009 */ #include "m_pd.h" @@ -95,7 +95,7 @@ static void bin_ambi_reduced_decode_fft2_init_cos(t_bin_ambi_reduced_decode_fft2 } } -static void bin_ambi_reduced_decode_fft2_convert(t_bin_ambi_reduced_decode_fft2 *x, double *delta_deg2rad, double *phi_deg2rad, int index) +static void bin_ambi_reduced_decode_fft2_convert(t_bin_ambi_reduced_decode_fft2 *x, double *delta_deg2rad, double *phi_deg2rad, int xindex) { double q = 1.0; double d = *delta_deg2rad; @@ -111,8 +111,8 @@ static void bin_ambi_reduced_decode_fft2_convert(t_bin_ambi_reduced_decode_fft2 while(p >= 360.0) p -= 360.0; - x->x_delta[index] = (int)(d); - x->x_phi[index] = (int)(p); + x->x_delta[xindex] = (int)(d); + x->x_phi[xindex] = (int)(p); *delta_deg2rad = d*x->x_pi_over_180; *phi_deg2rad = p*x->x_pi_over_180; @@ -122,7 +122,7 @@ static void bin_ambi_reduced_decode_fft2_do_2d(t_bin_ambi_reduced_decode_fft2 *x { double delta=0.0, phi; double *dw = x->x_transp; - int index; + int xindex; int order=x->x_n_order; if(argc < 2) @@ -130,23 +130,23 @@ static void bin_ambi_reduced_decode_fft2_do_2d(t_bin_ambi_reduced_decode_fft2 *x post("bin_ambi_reduced_decode_fft2 ERROR: ls-input needs 1 index and 1 angle: ls_index + phi [degree]"); return; } - index = (int)atom_getint(argv++) - 1; + xindex = (int)atom_getint(argv++) - 1; phi = (double)atom_getfloat(argv); - if(index < 0) - index = 0; + if(xindex < 0) + xindex = 0; if(mode == BIN_AMBI_LS_REAL) { - if(index >= x->x_n_real_ls) - index = x->x_n_real_ls - 1; + if(xindex >= x->x_n_real_ls) + xindex = x->x_n_real_ls - 1; } else if(mode == BIN_AMBI_LS_PHT) { if(x->x_n_pht_ls) { - if(index >= x->x_n_pht_ls) - index = x->x_n_pht_ls - 1; - index += x->x_n_real_ls; + if(xindex >= x->x_n_pht_ls) + xindex = x->x_n_pht_ls - 1; + xindex += x->x_n_real_ls; } else return; @@ -154,9 +154,9 @@ static void bin_ambi_reduced_decode_fft2_do_2d(t_bin_ambi_reduced_decode_fft2 *x else return; - bin_ambi_reduced_decode_fft2_convert(x, &delta, &phi, index); + bin_ambi_reduced_decode_fft2_convert(x, &delta, &phi, xindex); - dw += index * x->x_n_ambi; + dw += xindex * x->x_n_ambi; *dw++ = 1.0; *dw++ = cos(phi); @@ -233,7 +233,7 @@ static void bin_ambi_reduced_decode_fft2_do_3d(t_bin_ambi_reduced_decode_fft2 *x double delta, phi; double cd, sd, cd2, cd3, sd2, csd, cp, sp, cp2, sp2, cp3, sp3, cp4, sp4; double *dw = x->x_transp; - int index; + int xindex; int order=x->x_n_order; if(argc < 3) @@ -241,24 +241,24 @@ static void bin_ambi_reduced_decode_fft2_do_3d(t_bin_ambi_reduced_decode_fft2 *x post("bin_ambi_reduced_decode_fft2 ERROR: ls-input needs 1 index and 2 angles: ls index + delta [degree] + phi [degree]"); return; } - index = (int)atom_getint(argv++) - 1; + xindex = (int)atom_getint(argv++) - 1; delta = atom_getfloat(argv++); phi = atom_getfloat(argv); - if(index < 0) - index = 0; + if(xindex < 0) + xindex = 0; if(mode == BIN_AMBI_LS_REAL) { - if(index >= x->x_n_real_ls) - index = x->x_n_real_ls - 1; + if(xindex >= x->x_n_real_ls) + xindex = x->x_n_real_ls - 1; } else if(mode == BIN_AMBI_LS_PHT) { if(x->x_n_pht_ls) { - if(index >= x->x_n_pht_ls) - index = x->x_n_pht_ls - 1; - index += x->x_n_real_ls; + if(xindex >= x->x_n_pht_ls) + xindex = x->x_n_pht_ls - 1; + xindex += x->x_n_real_ls; } else return; @@ -266,14 +266,14 @@ static void bin_ambi_reduced_decode_fft2_do_3d(t_bin_ambi_reduced_decode_fft2 *x else return; - bin_ambi_reduced_decode_fft2_convert(x, &delta, &phi, index); + bin_ambi_reduced_decode_fft2_convert(x, &delta, &phi, xindex); cd = cos(delta); sd = sin(delta); cp = cos(phi); sp = sin(phi); - dw += index * x->x_n_ambi; + dw += xindex * x->x_n_ambi; *dw++ = 1.0; @@ -637,7 +637,7 @@ static void bin_ambi_reduced_decode_fft2_inverse(t_bin_ambi_reduced_decode_fft2 } } - post("matrix_inverse nonsingular"); + post("matrix_inverse regular"); x->x_seq_ok = 1; } @@ -715,7 +715,7 @@ static void bin_ambi_reduced_decode_fft2_ipht_ireal_muladd(t_bin_ambi_reduced_de static void bin_ambi_reduced_decode_fft2_load_HRIR(t_bin_ambi_reduced_decode_fft2 *x, t_symbol *s, int argc, t_atom *argv) { - int index; + int xindex; t_symbol *hrirname; if(argc < 2) @@ -723,38 +723,38 @@ static void bin_ambi_reduced_decode_fft2_load_HRIR(t_bin_ambi_reduced_decode_fft post("bin_ambi_reduced_decode_fft2 ERROR: load_HRIR needs 1 index and 1 HRIR-wav"); return; } - index = (int)atom_getint(argv++) - 1; + xindex = (int)atom_getint(argv++) - 1; hrirname = atom_getsymbol(argv); - if(index < 0) - index = 0; - if(index >= x->x_n_real_ls) - index = x->x_n_real_ls - 1; - x->x_hrir_filename[index] = hrirname; + if(xindex < 0) + xindex = 0; + if(xindex >= x->x_n_real_ls) + xindex = x->x_n_real_ls - 1; + x->x_hrir_filename[xindex] = hrirname; - SETSYMBOL(x->x_at, x->x_hrir_filename[index]); - SETSYMBOL(x->x_at+1, x->x_s_hrir[index]); + SETSYMBOL(x->x_at, x->x_hrir_filename[xindex]); + SETSYMBOL(x->x_at+1, x->x_s_hrir[xindex]); outlet_list(x->x_obj.ob_outlet, &s_list, 2, x->x_at); } static void bin_ambi_reduced_decode_fft2_check_HRIR_arrays(t_bin_ambi_reduced_decode_fft2 *x, t_floatarg findex) { - int index=(int)findex - 1; + int xindex=(int)findex - 1; int j, k, n; int fftsize = x->x_fftsize; int fs2=fftsize/2; t_garray *a; int npoints; t_symbol *hrir; - t_float*vec; + t_float *vec; iemarray_t *vec_hrir, *vec_fade_out_hrir; t_float decr, sum; - if(index < 0) - index = 0; - if(index >= x->x_n_real_ls) - index = x->x_n_real_ls - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= x->x_n_real_ls) + xindex = x->x_n_real_ls - 1; - hrir = x->x_s_hrir[index]; + hrir = x->x_s_hrir[xindex]; if (!(a = (t_garray *)pd_findbyclass(hrir, garray_class))) error("%s: no such array", hrir->s_name); else if (!iemarray_getarray(a, &npoints, &vec_hrir)) @@ -766,7 +766,7 @@ static void bin_ambi_reduced_decode_fft2_check_HRIR_arrays(t_bin_ambi_reduced_de post("bin_ambi_reduced_decode_fft2-WARNING: %s-array-size: %d < FFT-size: %d", hrir->s_name, npoints, fftsize); } vec = x->x_beg_hrir; - vec += index * fftsize; + vec += xindex * fftsize; if(x->x_beg_fade_out_hrir) { @@ -794,20 +794,20 @@ static void bin_ambi_reduced_decode_fft2_check_HRIR_arrays(t_bin_ambi_reduced_de static void bin_ambi_reduced_decode_fft2_check_HRTF_arrays(t_bin_ambi_reduced_decode_fft2 *x, t_floatarg findex) { - int index=(int)findex - 1; + int xindex=(int)findex - 1; t_garray *a; int npoints; int fftsize = x->x_fftsize; iemarray_t *vec_hrtf_re, *vec_hrtf_im; t_symbol *hrtf_re, *hrtf_im; - if(index < 0) - index = 0; - if(index >= x->x_n_ambi) - index = x->x_n_ambi - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= x->x_n_ambi) + xindex = x->x_n_ambi - 1; - hrtf_re = x->x_s_hrtf_re[index]; - hrtf_im = x->x_s_hrtf_im[index]; + hrtf_re = x->x_s_hrtf_re[xindex]; + hrtf_im = x->x_s_hrtf_im[xindex]; if (!(a = (t_garray *)pd_findbyclass(hrtf_re, garray_class))) error("%s: no such array", hrtf_re->s_name); @@ -823,14 +823,14 @@ static void bin_ambi_reduced_decode_fft2_check_HRTF_arrays(t_bin_ambi_reduced_de error("%s: bad array-size: %d", hrtf_im->s_name, npoints); else { - x->x_beg_hrtf_re[index] = vec_hrtf_re; - x->x_beg_hrtf_im[index] = vec_hrtf_im; + x->x_beg_hrtf_re[xindex] = vec_hrtf_re; + x->x_beg_hrtf_im[xindex] = vec_hrtf_im; } } static void bin_ambi_reduced_decode_fft2_calc_reduced(t_bin_ambi_reduced_decode_fft2 *x, t_floatarg findex) { - int index=(int)findex - 1; + int xindex=(int)findex - 1; int i, j, k, w_index, w_inc, i_inc, v_index, fs1, fs2; int fftsize = x->x_fftsize; BIN_AMBI_COMPLEX old1, old2, w; @@ -845,15 +845,15 @@ static void bin_ambi_reduced_decode_fft2_calc_reduced(t_bin_ambi_reduced_decode_ if(x->x_seq_ok) { - if(index < 0) - index = 0; - if(index >= n_ambi) - index = n_ambi - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= n_ambi) + xindex = n_ambi - 1; - vec_hrtf_re = x->x_beg_hrtf_re[index]; - vec_hrtf_im = x->x_beg_hrtf_im[index]; + vec_hrtf_re = x->x_beg_hrtf_re[xindex]; + vec_hrtf_im = x->x_beg_hrtf_im[xindex]; - dv = db + index; + dv = db + xindex; mul = (t_float)(*dv); vec_hrir = x->x_beg_hrir; for(k=0; kx_sin_cos, x->x_fftsize * sizeof(BIN_AMBI_COMPLEX)); freebytes(x->x_beg_hrir, x->x_fftsize * x->x_n_real_ls * sizeof(t_float)); - freebytes(x->x_beg_hrtf_re, x->x_n_ambi * sizeof(t_float *)); - freebytes(x->x_beg_hrtf_im, x->x_n_ambi * sizeof(t_float *)); + freebytes(x->x_beg_hrtf_re, x->x_n_ambi * sizeof(iemarray_t *)); + freebytes(x->x_beg_hrtf_im, x->x_n_ambi * sizeof(iemarray_t *)); } /* diff --git a/src/bin_ambi_reduced_decode_fir.c b/src/bin_ambi_reduced_decode_fir.c index 4f3a19c..19783da 100644 --- a/src/bin_ambi_reduced_decode_fir.c +++ b/src/bin_ambi_reduced_decode_fir.c @@ -1,7 +1,7 @@ /* For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. -iem_bin_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ +iem_bin_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2009 */ #include "m_pd.h" #include "iemlib.h" @@ -53,7 +53,7 @@ typedef struct _bin_ambi_reduced_decode_fir int *x_phi_sym; int *x_sym_flag; iemarray_t *x_beg_fade_out_hrir; - float *x_beg_hrir; + t_float *x_beg_hrir; iemarray_t **x_beg_hrir_red; t_symbol **x_hrir_filename; t_symbol **x_s_hrir; @@ -76,7 +76,7 @@ typedef struct _bin_ambi_reduced_decode_fir static t_class *bin_ambi_reduced_decode_fir_class; -static void bin_ambi_reduced_decode_fir_quant(t_bin_ambi_reduced_decode_fir *x, double *delta_deg2rad, double *phi_deg2rad, int index) +static void bin_ambi_reduced_decode_fir_quant(t_bin_ambi_reduced_decode_fir *x, double *delta_deg2rad, double *phi_deg2rad, int xindex) { double q = 1.0; double d = *delta_deg2rad; @@ -172,8 +172,8 @@ static void bin_ambi_reduced_decode_fir_quant(t_bin_ambi_reduced_decode_fir *x, p = (double)i; *phi_deg2rad = p; - x->x_delta[index] = (int)(*delta_deg2rad); - x->x_phi[index] = i; + x->x_delta[xindex] = (int)(*delta_deg2rad); + x->x_phi[xindex] = i; *delta_deg2rad *= x->x_pi_over_180; *phi_deg2rad *= x->x_pi_over_180; @@ -183,7 +183,7 @@ static void bin_ambi_reduced_decode_fir_do_2d(t_bin_ambi_reduced_decode_fir *x, { double delta=0.0, phi; double *dw = x->x_transp; - int index; + int xindex; int order=x->x_n_order; if(argc < 2) @@ -191,23 +191,23 @@ static void bin_ambi_reduced_decode_fir_do_2d(t_bin_ambi_reduced_decode_fir *x, post("bin_ambi_reduced_decode_fir ERROR: ls-input needs 1 index and 1 angle: ls_index + phi [degree]"); return; } - index = (int)atom_getint(argv++) - 1; + xindex = (int)atom_getint(argv++) - 1; phi = (double)atom_getfloat(argv); - if(index < 0) - index = 0; + if(xindex < 0) + xindex = 0; if(mode == BIN_AMBI_LS_IND) { - if(index >= x->x_n_ind_ls) - index = x->x_n_ind_ls - 1; + if(xindex >= x->x_n_ind_ls) + xindex = x->x_n_ind_ls - 1; } else if(mode == BIN_AMBI_LS_MRG) { if(x->x_n_mrg_mir_ls) { - if(index >= x->x_n_mrg_mir_ls) - index = x->x_n_mrg_mir_ls - 1; - index += x->x_n_ind_ls; + if(xindex >= x->x_n_mrg_mir_ls) + xindex = x->x_n_mrg_mir_ls - 1; + xindex += x->x_n_ind_ls; } else return; @@ -216,10 +216,10 @@ static void bin_ambi_reduced_decode_fir_do_2d(t_bin_ambi_reduced_decode_fir *x, { if(x->x_n_mrg_mir_ls) { - if(index >= x->x_n_mrg_mir_ls) - index = x->x_n_mrg_mir_ls - 1; - index += x->x_n_ind_ls; - index += x->x_n_mrg_mir_ls; + if(xindex >= x->x_n_mrg_mir_ls) + xindex = x->x_n_mrg_mir_ls - 1; + xindex += x->x_n_ind_ls; + xindex += x->x_n_mrg_mir_ls; } else return; @@ -228,10 +228,10 @@ static void bin_ambi_reduced_decode_fir_do_2d(t_bin_ambi_reduced_decode_fir *x, { if(x->x_n_ph_ls) { - if(index >= x->x_n_ph_ls) - index = x->x_n_ph_ls - 1; - index += x->x_n_ind_ls; - index += 2*x->x_n_mrg_mir_ls; + if(xindex >= x->x_n_ph_ls) + xindex = x->x_n_ph_ls - 1; + xindex += x->x_n_ind_ls; + xindex += 2*x->x_n_mrg_mir_ls; } else return; @@ -239,9 +239,9 @@ static void bin_ambi_reduced_decode_fir_do_2d(t_bin_ambi_reduced_decode_fir *x, else return; - bin_ambi_reduced_decode_fir_quant(x, &delta, &phi, index); + bin_ambi_reduced_decode_fir_quant(x, &delta, &phi, xindex); - dw += index * x->x_n_ambi; + dw += xindex * x->x_n_ambi; *dw++ = 1.0; *dw++ = cos(phi); @@ -318,7 +318,7 @@ static void bin_ambi_reduced_decode_fir_do_3d(t_bin_ambi_reduced_decode_fir *x, double delta, phi; double cd, sd, cd2, cd3, sd2, csd, cp, sp, cp2, sp2, cp3, sp3, cp4, sp4; double *dw = x->x_transp; - int index; + int xindex; int order=x->x_n_order; if(argc < 3) @@ -326,24 +326,24 @@ static void bin_ambi_reduced_decode_fir_do_3d(t_bin_ambi_reduced_decode_fir *x, post("bin_ambi_reduced_decode_fir ERROR: ls-input needs 1 index and 2 angles: ls index + delta [degree] + phi [degree]"); return; } - index = (int)atom_getint(argv++) - 1; + xindex = (int)atom_getint(argv++) - 1; delta = atom_getfloat(argv++); phi = atom_getfloat(argv); - if(index < 0) - index = 0; + if(xindex < 0) + xindex = 0; if(mode == BIN_AMBI_LS_IND) { - if(index >= x->x_n_ind_ls) - index = x->x_n_ind_ls - 1; + if(xindex >= x->x_n_ind_ls) + xindex = x->x_n_ind_ls - 1; } else if(mode == BIN_AMBI_LS_MRG) { if(x->x_n_mrg_mir_ls) { - if(index >= x->x_n_mrg_mir_ls) - index = x->x_n_mrg_mir_ls - 1; - index += x->x_n_ind_ls; + if(xindex >= x->x_n_mrg_mir_ls) + xindex = x->x_n_mrg_mir_ls - 1; + xindex += x->x_n_ind_ls; } else return; @@ -352,10 +352,10 @@ static void bin_ambi_reduced_decode_fir_do_3d(t_bin_ambi_reduced_decode_fir *x, { if(x->x_n_mrg_mir_ls) { - if(index >= x->x_n_mrg_mir_ls) - index = x->x_n_mrg_mir_ls - 1; - index += x->x_n_ind_ls; - index += x->x_n_mrg_mir_ls; + if(xindex >= x->x_n_mrg_mir_ls) + xindex = x->x_n_mrg_mir_ls - 1; + xindex += x->x_n_ind_ls; + xindex += x->x_n_mrg_mir_ls; } else return; @@ -364,10 +364,10 @@ static void bin_ambi_reduced_decode_fir_do_3d(t_bin_ambi_reduced_decode_fir *x, { if(x->x_n_ph_ls) { - if(index >= x->x_n_ph_ls) - index = x->x_n_ph_ls - 1; - index += x->x_n_ind_ls; - index += 2*x->x_n_mrg_mir_ls; + if(xindex >= x->x_n_ph_ls) + xindex = x->x_n_ph_ls - 1; + xindex += x->x_n_ind_ls; + xindex += 2*x->x_n_mrg_mir_ls; } else return; @@ -375,14 +375,14 @@ static void bin_ambi_reduced_decode_fir_do_3d(t_bin_ambi_reduced_decode_fir *x, else return; - bin_ambi_reduced_decode_fir_quant(x, &delta, &phi, index); + bin_ambi_reduced_decode_fir_quant(x, &delta, &phi, xindex); cd = cos(delta); sd = sin(delta); cp = cos(phi); sp = sin(phi); - dw += index * x->x_n_ambi; + dw += xindex * x->x_n_ambi; *dw++ = 1.0; @@ -726,7 +726,7 @@ static void bin_ambi_reduced_decode_fir_inverse(t_bin_ambi_reduced_decode_fir *x nz = bin_ambi_reduced_decode_fir_eval_which_element_of_col_not_zero(x, i, i); if(nz < 0) { - post("bin_ambi_reduced_decode_fir ERROR: matrix not regular !!!!"); + post("bin_ambi_reduced_decode_fir ERROR: matrix singular !!!!"); x->x_seq_ok = 0; return; } @@ -795,38 +795,38 @@ n_ambi columns; n_ambi rows; */ -static void bin_ambi_reduced_decode_fir_load_HRIR(t_bin_ambi_reduced_decode_fir *x, float findex) +static void bin_ambi_reduced_decode_fir_load_HRIR(t_bin_ambi_reduced_decode_fir *x, t_float findex) { - int index=(int)findex - 1; + int xindex=(int)findex - 1; int p; char buf[60]; - if(index < 0) - index = 0; - if(index >= (x->x_n_ind_ls + x->x_n_mrg_mir_ls)) - index = x->x_n_ind_ls + x->x_n_mrg_mir_ls - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= (x->x_n_ind_ls + x->x_n_mrg_mir_ls)) + xindex = x->x_n_ind_ls + x->x_n_mrg_mir_ls - 1; - p = x->x_phi[index]; + p = x->x_phi[xindex]; if(p)/*change*/ p = 360 - p; if(p < 10) - sprintf(buf, "L%de00%da.wav", x->x_delta[index], p); + sprintf(buf, "L%de00%da.wav", x->x_delta[xindex], p); else if(p < 100) - sprintf(buf, "L%de0%da.wav", x->x_delta[index], p); + sprintf(buf, "L%de0%da.wav", x->x_delta[xindex], p); else - sprintf(buf, "L%de%da.wav", x->x_delta[index], p); - x->x_hrir_filename[index] = gensym(buf); + sprintf(buf, "L%de%da.wav", x->x_delta[xindex], p); + x->x_hrir_filename[xindex] = gensym(buf); - SETSYMBOL(x->x_at, x->x_hrir_filename[index]); - SETSYMBOL(x->x_at+1, x->x_s_hrir[index]); + SETSYMBOL(x->x_at, x->x_hrir_filename[xindex]); + SETSYMBOL(x->x_at+1, x->x_s_hrir[xindex]); outlet_list(x->x_obj.ob_outlet, &s_list, 2, x->x_at); } -static void bin_ambi_reduced_decode_fir_check_HRIR_LS_arrays(t_bin_ambi_reduced_decode_fir *x, float findex) +static void bin_ambi_reduced_decode_fir_check_HRIR_LS_arrays(t_bin_ambi_reduced_decode_fir *x, t_float findex) { - int index=(int)findex - 1; + int xindex=(int)findex - 1; int j, k, n; int firsize = x->x_firsize; int fs2=firsize/2; @@ -836,14 +836,14 @@ static void bin_ambi_reduced_decode_fir_check_HRIR_LS_arrays(t_bin_ambi_reduced_ iemarray_t *vec_hrir; t_float *vec; iemarray_t *vec_fade_out_hrir; - float decr, sum; + t_float decr, sum; - if(index < 0) - index = 0; - if(index >= (x->x_n_ind_ls + x->x_n_mrg_mir_ls)) - index = x->x_n_ind_ls + x->x_n_mrg_mir_ls - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= (x->x_n_ind_ls + x->x_n_mrg_mir_ls)) + xindex = x->x_n_ind_ls + x->x_n_mrg_mir_ls - 1; - hrir = x->x_s_hrir[index]; + hrir = x->x_s_hrir[xindex]; if (!(a = (t_garray *)pd_findbyclass(hrir, garray_class))) error("%s: no such array", hrir->s_name); else if (!iemarray_getarray(a, &npoints, &vec_hrir)) @@ -855,7 +855,7 @@ static void bin_ambi_reduced_decode_fir_check_HRIR_LS_arrays(t_bin_ambi_reduced_ post("bin_ambi_reduced_decode_fir-WARNING: %s-array-size: %d < FFT-size: %d", hrir->s_name, npoints, firsize); } vec = x->x_beg_hrir; - vec += index * firsize; + vec += xindex * firsize; if(x->x_beg_fade_out_hrir) { @@ -871,7 +871,7 @@ static void bin_ambi_reduced_decode_fir_check_HRIR_LS_arrays(t_bin_ambi_reduced_ for(j=0; jx_firsize; iemarray_t *vec_hrir_red; t_symbol *hrir_red; - if(index < 0) - index = 0; - if(index >= x->x_n_ambi) - index = x->x_n_ambi - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= x->x_n_ambi) + xindex = x->x_n_ambi - 1; - hrir_red = x->x_s_hrir_red[index]; + hrir_red = x->x_s_hrir_red[xindex]; if (!(a = (t_garray *)pd_findbyclass(hrir_red, garray_class))) error("%s: no such array", hrir_red->s_name); @@ -905,48 +905,46 @@ static void bin_ambi_reduced_decode_fir_check_HRIR_RED_arrays(t_bin_ambi_reduced error("%s: bad array-size: %d", hrir_red->s_name, npoints); else { - x->x_beg_hrir_red[index] = vec_hrir_red; + x->x_beg_hrir_red[xindex] = vec_hrir_red; } } -static void bin_ambi_reduced_decode_fir_calc_reduced(t_bin_ambi_reduced_decode_fir *x, float findex) +static void bin_ambi_reduced_decode_fir_calc_reduced(t_bin_ambi_reduced_decode_fir *x, t_float findex) { - int index=(int)findex - 1; + int xindex=(int)findex - 1; int i, j; int firsize = x->x_firsize; t_float *vec_hrir; - iemarray_t*vec_hrir_red; + iemarray_t *vec_hrir_red; double *dv; int n_ambi = x->x_n_ambi; int n_ls = x->x_n_ind_ls + x->x_n_mrg_mir_ls; - float mul; + t_float mul; if(x->x_seq_ok) { - if(index < 0) - index = 0; - if(index >= n_ambi) - index = n_ambi - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= n_ambi) + xindex = n_ambi - 1; - vec_hrir_red = x->x_beg_hrir_red[index]; + vec_hrir_red = x->x_beg_hrir_red[xindex]; - dv = x->x_prod3 + index; - mul = (float)(*dv); + dv = x->x_prod3 + xindex; + mul = (t_float)(*dv); vec_hrir = x->x_beg_hrir; for(i=0; ix_beg_hrir; vec_hrir += j * firsize; for(i=0; ix_at, 1.0f); else if(plus_minus[i] == '-') SETFLOAT(x->x_at, 2.0f); - SETFLOAT(x->x_at+1, (float)(i+1)); + SETFLOAT(x->x_at+1, (t_float)(i+1)); outlet_list(x->x_out_sign_sum, &s_list, 2, x->x_at); } } @@ -1152,8 +1150,8 @@ static void bin_ambi_reduced_decode_fir_free(t_bin_ambi_reduced_decode_fir *x) freebytes(x->x_phi_sym, (x->x_n_ind_ls+x->x_n_mrg_mir_ls) * sizeof(int)); freebytes(x->x_sym_flag, (x->x_n_ind_ls+x->x_n_mrg_mir_ls) * sizeof(int)); - freebytes(x->x_beg_hrir, x->x_firsize * (x->x_n_ind_ls+x->x_n_mrg_mir_ls) * sizeof(float)); - freebytes(x->x_beg_hrir_red, x->x_n_ambi * sizeof(float *)); + freebytes(x->x_beg_hrir, x->x_firsize * (x->x_n_ind_ls+x->x_n_mrg_mir_ls) * sizeof(t_float)); + freebytes(x->x_beg_hrir_red, x->x_n_ambi * sizeof(iemarray_t *)); } /* @@ -1310,7 +1308,7 @@ static void *bin_ambi_reduced_decode_fir_new(t_symbol *s, int argc, t_atom *argv x->x_sym_flag = (int *)getbytes((x->x_n_ind_ls+x->x_n_mrg_mir_ls) * sizeof(int)); x->x_beg_fade_out_hrir = 0; - x->x_beg_hrir = (float *)getbytes(x->x_firsize * (x->x_n_ind_ls+x->x_n_mrg_mir_ls) * sizeof(float)); + x->x_beg_hrir = (t_float *)getbytes(x->x_firsize * (x->x_n_ind_ls+x->x_n_mrg_mir_ls) * sizeof(t_float)); x->x_beg_hrir_red = (iemarray_t **)getbytes(x->x_n_ambi * sizeof(iemarray_t *)); x->x_sqrt3 = sqrt(3.0); diff --git a/src/bin_ambi_reduced_decode_fir2.c b/src/bin_ambi_reduced_decode_fir2.c index 8ee3de5..b491a31 100644 --- a/src/bin_ambi_reduced_decode_fir2.c +++ b/src/bin_ambi_reduced_decode_fir2.c @@ -1,7 +1,7 @@ /* For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. -iem_bin_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ +iem_bin_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2009 */ #include "m_pd.h" #include "iemlib.h" @@ -75,7 +75,7 @@ typedef struct _bin_ambi_reduced_decode_fir2 static t_class *bin_ambi_reduced_decode_fir2_class; -static void bin_ambi_reduced_decode_fir2_convert(t_bin_ambi_reduced_decode_fir2 *x, double *delta_deg2rad, double *phi_deg2rad, int index) +static void bin_ambi_reduced_decode_fir2_convert(t_bin_ambi_reduced_decode_fir2 *x, double *delta_deg2rad, double *phi_deg2rad, int xindex) { double q = 1.0; double d = *delta_deg2rad; @@ -91,8 +91,8 @@ static void bin_ambi_reduced_decode_fir2_convert(t_bin_ambi_reduced_decode_fir2 while(p >= 360.0) p -= 360.0; - x->x_delta[index] = (int)(d); - x->x_phi[index] = (int)(p); + x->x_delta[xindex] = (int)(d); + x->x_phi[xindex] = (int)(p); *delta_deg2rad = d*x->x_pi_over_180; *phi_deg2rad = p*x->x_pi_over_180; @@ -102,7 +102,7 @@ static void bin_ambi_reduced_decode_fir2_do_2d(t_bin_ambi_reduced_decode_fir2 *x { double delta=0.0, phi; double *dw = x->x_transp; - int index; + int xindex; int order=x->x_n_order; if(argc < 2) @@ -110,23 +110,23 @@ static void bin_ambi_reduced_decode_fir2_do_2d(t_bin_ambi_reduced_decode_fir2 *x post("bin_ambi_reduced_decode_fir2 ERROR: ls-input needs 1 index and 1 angle: ls_index + phi [degree]"); return; } - index = (int)atom_getint(argv++) - 1; + xindex = (int)atom_getint(argv++) - 1; phi = (double)atom_getfloat(argv); - if(index < 0) - index = 0; + if(xindex < 0) + xindex = 0; if(mode == BIN_AMBI_LS_REAL) { - if(index >= x->x_n_real_ls) - index = x->x_n_real_ls - 1; + if(xindex >= x->x_n_real_ls) + xindex = x->x_n_real_ls - 1; } else if(mode == BIN_AMBI_LS_PHT) { if(x->x_n_pht_ls) { - if(index >= x->x_n_pht_ls) - index = x->x_n_pht_ls - 1; - index += x->x_n_real_ls; + if(xindex >= x->x_n_pht_ls) + xindex = x->x_n_pht_ls - 1; + xindex += x->x_n_real_ls; } else return; @@ -134,9 +134,9 @@ static void bin_ambi_reduced_decode_fir2_do_2d(t_bin_ambi_reduced_decode_fir2 *x else return; - bin_ambi_reduced_decode_fir2_convert(x, &delta, &phi, index); + bin_ambi_reduced_decode_fir2_convert(x, &delta, &phi, xindex); - dw += index * x->x_n_ambi; + dw += xindex * x->x_n_ambi; *dw++ = 1.0; *dw++ = cos(phi); @@ -213,7 +213,7 @@ static void bin_ambi_reduced_decode_fir2_do_3d(t_bin_ambi_reduced_decode_fir2 *x double delta, phi; double cd, sd, cd2, cd3, sd2, csd, cp, sp, cp2, sp2, cp3, sp3, cp4, sp4; double *dw = x->x_transp; - int index; + int xindex; int order=x->x_n_order; if(argc < 3) @@ -221,24 +221,24 @@ static void bin_ambi_reduced_decode_fir2_do_3d(t_bin_ambi_reduced_decode_fir2 *x post("bin_ambi_reduced_decode_fir2 ERROR: ls-input needs 1 index and 2 angles: ls index + delta [degree] + phi [degree]"); return; } - index = (int)atom_getint(argv++) - 1; + xindex = (int)atom_getint(argv++) - 1; delta = atom_getfloat(argv++); phi = atom_getfloat(argv); - if(index < 0) - index = 0; + if(xindex < 0) + xindex = 0; if(mode == BIN_AMBI_LS_REAL) { - if(index >= x->x_n_real_ls) - index = x->x_n_real_ls - 1; + if(xindex >= x->x_n_real_ls) + xindex = x->x_n_real_ls - 1; } else if(mode == BIN_AMBI_LS_PHT) { if(x->x_n_pht_ls) { - if(index >= x->x_n_pht_ls) - index = x->x_n_pht_ls - 1; - index += x->x_n_real_ls; + if(xindex >= x->x_n_pht_ls) + xindex = x->x_n_pht_ls - 1; + xindex += x->x_n_real_ls; } else return; @@ -246,14 +246,14 @@ static void bin_ambi_reduced_decode_fir2_do_3d(t_bin_ambi_reduced_decode_fir2 *x else return; - bin_ambi_reduced_decode_fir2_convert(x, &delta, &phi, index); + bin_ambi_reduced_decode_fir2_convert(x, &delta, &phi, xindex); cd = cos(delta); sd = sin(delta); cp = cos(phi); sp = sin(phi); - dw += index * x->x_n_ambi; + dw += xindex * x->x_n_ambi; *dw++ = 1.0; @@ -616,7 +616,7 @@ static void bin_ambi_reduced_decode_fir2_inverse(t_bin_ambi_reduced_decode_fir2 } } - post("matrix_inverse nonsingular"); + post("matrix_inverse regular"); x->x_seq_ok = 1; } @@ -694,7 +694,7 @@ static void bin_ambi_reduced_decode_fir2_ipht_ireal_muladd(t_bin_ambi_reduced_de static void bin_ambi_reduced_decode_fir2_load_HRIR(t_bin_ambi_reduced_decode_fir2 *x, t_symbol *s, int argc, t_atom *argv) { - int index; + int xindex; t_symbol *hrirname; if(argc < 2) @@ -702,22 +702,22 @@ static void bin_ambi_reduced_decode_fir2_load_HRIR(t_bin_ambi_reduced_decode_fir post("bin_ambi_reduced_decode_fir2 ERROR: load_HRIR needs 1 index and 1 HRIR-wav"); return; } - index = (int)atom_getint(argv++) - 1; + xindex = (int)atom_getint(argv++) - 1; hrirname = atom_getsymbol(argv); - if(index < 0) - index = 0; - if(index >= x->x_n_real_ls) - index = x->x_n_real_ls - 1; - x->x_hrir_filename[index] = hrirname; - - SETSYMBOL(x->x_at, x->x_hrir_filename[index]); - SETSYMBOL(x->x_at+1, x->x_s_hrir[index]); + if(xindex < 0) + xindex = 0; + if(xindex >= x->x_n_real_ls) + xindex = x->x_n_real_ls - 1; + x->x_hrir_filename[xindex] = hrirname; + + SETSYMBOL(x->x_at, x->x_hrir_filename[xindex]); + SETSYMBOL(x->x_at+1, x->x_s_hrir[xindex]); outlet_list(x->x_obj.ob_outlet, &s_list, 2, x->x_at); } static void bin_ambi_reduced_decode_fir2_check_HRIR_arrays(t_bin_ambi_reduced_decode_fir2 *x, t_floatarg findex) { - int index=(int)findex - 1; + int xindex=(int)findex - 1; int j, k, n; int firsize = x->x_firsize; t_garray *a; @@ -727,12 +727,12 @@ static void bin_ambi_reduced_decode_fir2_check_HRIR_arrays(t_bin_ambi_reduced_de iemarray_t *vec_hrir, *vec_fade_out_hrir; t_float decr, sum; - if(index < 0) - index = 0; - if(index >= x->x_n_real_ls) - index = x->x_n_real_ls - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= x->x_n_real_ls) + xindex = x->x_n_real_ls - 1; - hrir = x->x_s_hrir[index]; + hrir = x->x_s_hrir[xindex]; if (!(a = (t_garray *)pd_findbyclass(hrir, garray_class))) error("%s: no such array", hrir->s_name); else if (!iemarray_getarray(a, &npoints, &vec_hrir)) @@ -744,7 +744,7 @@ static void bin_ambi_reduced_decode_fir2_check_HRIR_arrays(t_bin_ambi_reduced_de post("bin_ambi_reduced_decode_fir2-WARNING: %s-array-size: %d < FIR-size: %d", hrir->s_name, npoints, firsize); } vec = x->x_beg_hrir; - vec += index * firsize; + vec += xindex * firsize; if(x->x_beg_fade_out_hrir) { @@ -772,19 +772,19 @@ static void bin_ambi_reduced_decode_fir2_check_HRIR_arrays(t_bin_ambi_reduced_de static void bin_ambi_reduced_decode_fir2_check_HRIR_RED_arrays(t_bin_ambi_reduced_decode_fir2 *x, t_floatarg findex) { - int index=(int)findex - 1; + int xindex=(int)findex - 1; t_garray *a; int npoints; int firsize = x->x_firsize; iemarray_t *vec_hrir_red; t_symbol *hrir_red; - if(index < 0) - index = 0; - if(index >= x->x_n_ambi) - index = x->x_n_ambi - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= x->x_n_ambi) + xindex = x->x_n_ambi - 1; - hrir_red = x->x_s_hrir_red[index]; + hrir_red = x->x_s_hrir_red[xindex]; if (!(a = (t_garray *)pd_findbyclass(hrir_red, garray_class))) error("%s: no such array", hrir_red->s_name); @@ -794,17 +794,17 @@ static void bin_ambi_reduced_decode_fir2_check_HRIR_RED_arrays(t_bin_ambi_reduce error("%s: bad array-size: %d", hrir_red->s_name, npoints); else { - x->x_beg_hrir_red[index] = vec_hrir_red; + x->x_beg_hrir_red[xindex] = vec_hrir_red; } } static void bin_ambi_reduced_decode_fir2_calc_reduced(t_bin_ambi_reduced_decode_fir2 *x, t_floatarg findex) { - int index=(int)findex - 1; + int xindex=(int)findex - 1; int i, j; int firsize = x->x_firsize; t_float *vec_hrir; - iemarray_t*vec_hrir_red; + iemarray_t *vec_hrir_red; double *dv; int n_ambi = x->x_n_ambi; int n_ls = x->x_n_real_ls; @@ -812,20 +812,18 @@ static void bin_ambi_reduced_decode_fir2_calc_reduced(t_bin_ambi_reduced_decode_ if(x->x_seq_ok) { - if(index < 0) - index = 0; - if(index >= n_ambi) - index = n_ambi - 1; + if(xindex < 0) + xindex = 0; + if(xindex >= n_ambi) + xindex = n_ambi - 1; - vec_hrir_red = x->x_beg_hrir_red[index]; + vec_hrir_red = x->x_beg_hrir_red[xindex]; - dv = x->x_prod3 + index; + dv = x->x_prod3 + xindex; mul = (t_float)(*dv); vec_hrir = x->x_beg_hrir; for(i=0; ix_sym_flag, x->x_n_real_ls * sizeof(int)); freebytes(x->x_beg_hrir, x->x_firsize * x->x_n_real_ls * sizeof(t_float)); - freebytes(x->x_beg_hrir_red, x->x_n_ambi * sizeof(t_float *)); + freebytes(x->x_beg_hrir_red, x->x_n_ambi * sizeof(iemarray_t *)); } /* diff --git a/src/iem_bin_ambi.c b/src/iem_bin_ambi.c index 5fb40e2..c1af546 100644 --- a/src/iem_bin_ambi.c +++ b/src/iem_bin_ambi.c @@ -1,7 +1,7 @@ /* For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. -iem_bin_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ +iem_bin_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2009 */ #include "m_pd.h" @@ -36,6 +36,6 @@ void iem_bin_ambi_setup(void) bin_ambi_reduced_decode_fft2_setup(); bin_ambi_reduced_decode_fir2_setup(); - post("iem_bin_ambi (R-1.17) library loaded! (c) Thomas Musil 11.2006"); + post("iem_bin_ambi (R-1.18) library loaded! (c) Thomas Musil 01.2009"); post(" musil%ciem.at iem KUG Graz Austria", '@'); } diff --git a/src/iem_bin_ambi.h b/src/iem_bin_ambi.h index a323340..ddf966d 100644 --- a/src/iem_bin_ambi.h +++ b/src/iem_bin_ambi.h @@ -1,7 +1,7 @@ /* For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. -iem_bin_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2006 */ +iem_bin_ambi written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2009 */ #ifndef __IEMBINAMBI_H__ #define __IEMBINAMBI_H__ diff --git a/src/iemlib.h b/src/iemlib.h index 4757df9..97b088b 100644 --- a/src/iemlib.h +++ b/src/iemlib.h @@ -1,7 +1,7 @@ /* For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. -iemlib written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2007 */ +iemlib written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2009 */ #ifndef __IEMLIB_H__ #define __IEMLIB_H__ @@ -99,16 +99,18 @@ union tabfudge_f #endif - /* on 64bit systems we cannot use garray_getfloatarray... */ #if (defined __x86_64__) # define iemarray_t t_word # define iemarray_getarray garray_getfloatwords # define iemarray_getfloat(pointer, index) (pointer[index].w_float) +# define iemarray_setfloat(pointer, index, fvalue) (pointer[index].w_float = fvalue) #else # define iemarray_t t_float # define iemarray_getarray garray_getfloatarray # define iemarray_getfloat(pointer, index) (pointer[index]) +# define iemarray_setfloat(pointer, index, fvalue) (pointer[index] = fvalue) #endif + #endif -- cgit v1.2.1