diff --git a/externals/iem/iem_adaptfilt/help/.DS_Store b/externals/iem/iem_adaptfilt/help/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 Binary files a/externals/iem/iem_adaptfilt/help/.DS_Store and /dev/null differ diff --git a/externals/iem/iem_adaptfilt/help/NLMSerr_in~-help.pd b/externals/iem/iem_adaptfilt/help/NLMSerr_in~-help.pd new file mode 100644 index 0000000000000000000000000000000000000000..da3eb5d750613677020e5d6d36e7b42f15d79319 --- /dev/null +++ b/externals/iem/iem_adaptfilt/help/NLMSerr_in~-help.pd @@ -0,0 +1,209 @@ +#N canvas 26 22 1132 728 10; +#N canvas 0 22 450 300 (subpatch) 0; +#X array W 100 float 0; +#X coords 0 1 99 -1 400 140 1; +#X restore 633 441 graph; +#X msg 46 156 update \$1; +#X msg 85 239 beta \$1; +#X obj 299 62 tgl 15 0 empty empty empty 0 -6 0 8 -225280 -1 -1 1 1 +; +#X obj 299 83 dsp; +#X floatatom 299 129 5 0 0 0 - - -; +#X floatatom 312 108 5 0 0 0 - - -; +#X text 662 278 2.arg: <float> learn-rate = beta; +#X obj 336 193 noise~; +#X msg 65 319 gamma \$1; +#X text 70 348 input signal; +#X text 344 295 desired signal; +#N canvas 0 22 450 300 (subpatch) 0; +#X array IR 40 float 0; +#X coords 0 1 39 -1 200 140 1; +#X restore 394 49 graph; +#X obj 54 540 unsig~; +#X floatatom 54 566 9 0 0 0 - - -; +#X obj 392 544 unsig~; +#X floatatom 392 564 9 0 0 0 - - -; +#X text 21 346 x(n); +#X text 449 295 d(n); +#X text 19 510 y(n) = W * x(n); +#X obj 336 278 FIR~ IR 32; +#X obj 612 103 loadbang; +#X text 712 267 (array-sizes have to be >= then FIR_size); +#X text 662 256 1.arg: <float> number of order of FIR-filter; +#N canvas 0 22 474 324 (subpatch) 0; +#X obj 48 46 inlet; +#X obj 205 47 inlet; +#X msg 205 71 \; IR const 0; +#X msg 48 120 \; IR 0 0 0 0 0.314287 0.8 0.75 0 0 0 0 -0.7 -0.65 0 +0 0 0.157143 0.128572 0 0 -0.128572 -0.1 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0; +#X obj 92 84 loadbang; +#X connect 0 0 3 0; +#X connect 1 0 2 0; +#X connect 4 0 3 0; +#X restore 613 78 pd; +#X obj 626 60 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X text 643 57 clear; +#X obj 613 41 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X text 630 38 load; +#X text 638 80 IR; +#X text 4 495 filtered output signal; +#X text 395 422 error signal; +#X text 369 434 e(n) = d(n) - W * x(n); +#X obj 83 512 cnv 8 1 1 empty empty * 0 7 0 14 -262144 -1 0; +#X obj 482 436 cnv 8 1 1 empty empty * 0 7 0 14 -262144 -1 0; +#N canvas 0 22 470 320 (subpatch) 0; +#X obj 137 73 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1 +; +#X msg 137 115 39; +#X msg 137 156 \$1 39; +#X msg 136 53 1; +#X obj 137 92 metro 200; +#X obj 136 24 inlet; +#X obj 137 135 tabread W; +#X obj 137 180 tabwrite W; +#X connect 0 0 4 0; +#X connect 1 0 6 0; +#X connect 2 0 7 0; +#X connect 3 0 0 0; +#X connect 4 0 1 0; +#X connect 5 0 3 0; +#X connect 6 0 2 0; +#X restore 612 124 pd; +#X text 637 130 update of W; +#X text 636 119 graphical; +#X text 662 313 4.arg: <symbol> table-name of W; +#X text 126 301 minimum input value; +#X msg 226 195 0.1; +#X msg 65 281 1e-05; +#X text 138 240 beta [0 .. 2]; +#X text 132 318 gamma [0 .. 1]; +#X obj 663 213 cnv 15 68 17 empty empty empty 20 12 0 14 -225280 -66577 +0; +#N canvas 0 22 499 295 FORMULAS 0; +#X obj 167 52 cnv 15 150 40 empty empty empty 20 12 0 14 -225280 -66577 +0; +#X obj 167 123 cnv 15 270 50 empty empty empty 20 12 0 14 -225280 -66577 +0; +#X obj 167 205 cnv 15 260 30 empty empty empty 20 12 0 14 -225280 -66577 +0; +#X text 280 129 beta; +#X text 231 146 >; +#X text 232 144 _; +#X text 232 138 _; +#X text 283 141 2; +#X text 346 141 2; +#X text 311 146 gamma * blocksize); +#X text 300 146 +; +#X text 243 146 x[n-i]; +#X text 174 135 my(n) =; +#X text 223 130 _________________________________; +#X text 16 135 normalized learn rate:; +#X text 173 56 y(n) = W * x(n); +#X obj 237 54 cnv 11 1 1 empty empty * 0 9 0 14 -225280 -1 0; +#X text 173 72 e(n) = d(n) - W * x(n); +#X obj 286 71 cnv 11 1 1 empty empty * 0 9 0 14 -225280 -1 0; +#X text 119 73 error:; +#X text 116 55 output:; +#X text 26 210 coefficient iteration:; +#X text 188 211 W(k+1 \, i) = W(k \, i) + my(n)* e(n)* x(n); +#X restore 664 213 pd FORMULAS; +#X obj 91 223 cnv 14 31 14 empty empty empty 20 12 0 14 -225280 -66577 +0; +#X floatatom 85 222 6 0 2 0 - - -; +#X text 134 221 learn-rate; +#X obj 65 301 cnv 14 31 14 empty empty empty 20 12 0 14 -225280 -66577 +0; +#X floatatom 65 301 8 0 2 0 - - -; +#X obj 347 389 -~; +#X text 232 431 err; +#X text 409 343 filt out; +#X msg 635 600 \; W const 0; +#X obj 28 365 delread~ causal_del 1.45126; +#X obj 392 325 delread~ feedback_del 1.45126; +#X msg 185 195 0.01; +#X msg 53 196 0; +#X msg 138 195 0.001; +#X obj 336 214 delwrite~ causal_del 20; +#X obj 67 472 delwrite~ feedback_del 20; +#X floatatom 111 690 9 0 0 0 - - -; +#X text 38 382 ref_filt; +#X text 155 404 ref_adapt; +#X obj 134 389 delread~ causal_del 2.90249; +#X obj 336 255 delread~ causal_del 2.90249; +#X obj 46 137 tgl 15 0 empty empty empty 0 -6 0 8 -225280 -1 -1 1 1 +; +#X text 41 118 Update ON / OFF; +#X msg 147 629 128; +#X msg 109 629 64; +#X obj 110 667 / 44.1; +#X obj 299 665 samplerate~; +#X obj 299 647 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 +-1 -1; +#X floatatom 300 706 5 0 0 0 - - -; +#X obj 300 686 * 0.001; +#X floatatom 189 687 9 0 0 0 - - -; +#X msg 190 627 128; +#X obj 188 664 / 44.1; +#X msg 225 627 192; +#X obj 299 627 loadbang; +#X text 660 364 (C) 2010 \, t.musil & m.guldenschuh \, IEM \, Graz +\, Austria; +#X text 688 377 [musil | guldenschuh]_AT_iem.at; +#X text 662 173 Normalized Least Mean Square with separated error and +adaption reference input (linear adaptive FIR-filter); +#X obj 53 450 NLMSerr_in~ 100 0.003 1e-05 W; +#X msg 114 282 1e-07; +#X msg 85 195 0.0001; +#X text 662 290 3.arg: <float> minimum input value gamma for; +#X text 716 301 energy calculation; +#X text 46 44 NLMSerr_in~; +#X connect 1 0 84 0; +#X connect 2 0 84 0; +#X connect 3 0 4 0; +#X connect 4 0 5 0; +#X connect 4 1 6 0; +#X connect 8 0 60 0; +#X connect 9 0 84 0; +#X connect 13 0 14 0; +#X connect 15 0 16 0; +#X connect 20 0 51 0; +#X connect 21 0 35 0; +#X connect 25 0 24 1; +#X connect 27 0 24 0; +#X connect 40 0 47 0; +#X connect 41 0 50 0; +#X connect 47 0 2 0; +#X connect 50 0 9 0; +#X connect 51 0 15 0; +#X connect 51 0 84 2; +#X connect 55 0 84 0; +#X connect 56 0 51 1; +#X connect 57 0 47 0; +#X connect 58 0 47 0; +#X connect 59 0 47 0; +#X connect 62 0 56 0; +#X connect 62 0 55 0; +#X connect 65 0 84 1; +#X connect 66 0 20 0; +#X connect 67 0 1 0; +#X connect 69 0 71 0; +#X connect 70 0 71 0; +#X connect 71 0 62 0; +#X connect 72 0 75 0; +#X connect 73 0 72 0; +#X connect 75 0 74 0; +#X connect 75 0 71 1; +#X connect 75 0 78 1; +#X connect 77 0 78 0; +#X connect 78 0 76 0; +#X connect 78 0 66 0; +#X connect 78 0 65 0; +#X connect 79 0 78 0; +#X connect 80 0 73 0; +#X connect 84 0 13 0; +#X connect 84 0 61 0; +#X connect 85 0 50 0; +#X connect 86 0 47 0; diff --git a/externals/iem/iem_adaptfilt/src/.DS_Store b/externals/iem/iem_adaptfilt/src/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 Binary files a/externals/iem/iem_adaptfilt/src/.DS_Store and /dev/null differ diff --git a/externals/iem/iem_adaptfilt/src/NLMSCC~.c b/externals/iem/iem_adaptfilt/src/NLMSCC~.c index 956049d4c7d468c5394e2794b9d2d6f36d1035b2..48f501acace66b24f65b717df50109d176942314 100644 --- a/externals/iem/iem_adaptfilt/src/NLMSCC~.c +++ b/externals/iem/iem_adaptfilt/src/NLMSCC~.c @@ -163,7 +163,7 @@ static t_int *NLMSCC_tilde_perform(t_int *w) t_float *wmax_filt_coeff = x->x_wmax_array_mem_beg; t_float my, my_err, sum; t_float beta = x->x_beta; - t_float gamma = x->x_gamma; + t_float gammax = x->x_gamma; t_int i, j, update_counter; t_int update = x->x_update; t_int ord8=n_order&0xfffffff8; @@ -230,7 +230,7 @@ static t_int *NLMSCC_tilde_perform(t_int *w) } for(j=0; j<ord_residual; j++) // residual sum += read_in_hist[-j] * read_in_hist[-j]; // [-j] only valid for Musil's double buffer structure - sum += gamma * gamma * (float)n_order; // convert gamma corresponding to filter order + sum += gammax * gammax * (float)n_order; // convert gammax corresponding to filter order my = beta / sum;// calculate mue @@ -312,7 +312,7 @@ static void *NLMSCC_tilde_new(t_symbol *s, t_int argc, t_atom *argv) t_symbol *wmin_name; t_symbol *wmax_name; t_float beta=0.1f; - t_float gamma=0.00001f; + t_float gammax=0.00001f; if((argc >= 6) && IS_A_FLOAT(argv,0) && //IS_A_FLOAT/SYMBOL from iemlib.h @@ -324,7 +324,7 @@ static void *NLMSCC_tilde_new(t_symbol *s, t_int argc, t_atom *argv) { n_order = (t_int)atom_getintarg(0, argc, argv); beta = (t_float)atom_getfloatarg(1, argc, argv); - gamma = (t_float)atom_getfloatarg(2, argc, argv); + gammax = (t_float)atom_getfloatarg(2, argc, argv); w_name = (t_symbol *)atom_getsymbolarg(3, argc, argv); wmin_name = (t_symbol *)atom_getsymbolarg(4, argc, argv); wmax_name = (t_symbol *)atom_getsymbolarg(5, argc, argv); @@ -334,10 +334,10 @@ static void *NLMSCC_tilde_new(t_symbol *s, t_int argc, t_atom *argv) if(beta > 2.0f) beta = 2.0f; - if(gamma < 0.0f) - gamma = 0.0f; - if(gamma > 1.0f) - gamma = 1.0f; + if(gammax < 0.0f) + gammax = 0.0f; + if(gammax > 1.0f) + gammax = 1.0f; if(n_order < 2) n_order = 2; @@ -353,7 +353,7 @@ static void *NLMSCC_tilde_new(t_symbol *s, t_int argc, t_atom *argv) x->x_n_order = n_order; x->x_update = 0; x->x_beta = beta; - x->x_gamma = gamma; + x->x_gamma = gammax; // 2 times in and one time desired_in memory allocation (history) x->x_in_hist = (t_float *)getbytes(2*x->x_n_order*sizeof(t_float)); @@ -382,7 +382,7 @@ void NLMSCC_tilde_setup(void) NLMSCC_tilde_class = class_new(gensym("NLMSCC~"), (t_newmethod)NLMSCC_tilde_new, (t_method)NLMSCC_tilde_free, sizeof(t_NLMSCC_tilde), 0, A_GIMME, 0); CLASS_MAINSIGNALIN(NLMSCC_tilde_class, t_NLMSCC_tilde, x_msi); - class_addmethod(NLMSCC_tilde_class, (t_method)NLMSCC_tilde_dsp, gensym("dsp"), A_CANT, 0); + class_addmethod(NLMSCC_tilde_class, (t_method)NLMSCC_tilde_dsp, gensym("dsp"), 0); class_addmethod(NLMSCC_tilde_class, (t_method)NLMSCC_tilde_update, gensym("update"), A_FLOAT, 0); // method: downsampling factor of learning (multiple of 2^N) class_addmethod(NLMSCC_tilde_class, (t_method)NLMSCC_tilde_beta, gensym("beta"), A_FLOAT, 0); //method: normalized learning rate class_addmethod(NLMSCC_tilde_class, (t_method)NLMSCC_tilde_gamma, gensym("gamma"), A_FLOAT, 0); // method: dithering noise related to signal diff --git a/externals/iem/iem_adaptfilt/src/NLMSerr_in~.c b/externals/iem/iem_adaptfilt/src/NLMSerr_in~.c new file mode 100644 index 0000000000000000000000000000000000000000..f48f302cd121e3528c07324965f6b36397b1d0d4 --- /dev/null +++ b/externals/iem/iem_adaptfilt/src/NLMSerr_in~.c @@ -0,0 +1,289 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +NLMS normalized least mean square (LMS) algorithm +lib iem_adaptfilt written by Markus Noisternig & Thomas Musil +noisternig_AT_iem.at; musil_AT_iem.at +(c) Institute of Electronic Music and Acoustics, Graz Austria 2005 */ + + +#include "m_pd.h" +#include "iemlib.h" +#include <math.h> +#include <stdio.h> +#include <string.h> + + +/* ----------------------- NLMSerr_in~ ------------------------------ */ +/* -- Normalized Least Mean Square (linear adaptive FIR-filter) -- */ +/* -- first input: reference signal -- */ +/* -- second input: desired signal -- */ +/* -- the difference to NLMS~ is: we have only one ERROR input instead of desired in minus filter out -- */ +/* -- that means there is no feedback -- */ + +/* for further information on adaptive filter design we refer to */ +/* [1] Haykin, "Adaptive Filter Theory", 4th ed, Prentice Hall */ +/* [2] Benesty, "Adaptive Signal Processing", Springer */ + + +typedef struct NLMSerr_in_tilde +{ + t_object x_obj;// common pd object structure + t_symbol *x_w_array_sym_name; + t_float *x_w_array_mem_beg; + t_float *x_ref_filt_in_hist;// history buffer for input signal reference for internal convolution = filter + t_float *x_ref_adapt_in_hist;// history buffer for input signal reference for internal adapting filter + t_int x_rw_index;// current read-write-index in circular buffer + t_int x_n_order;// order of filter or convolution + t_int x_update;// binary update parameter ON / OFF + t_float x_beta;// learn rate [0 .. 2] + t_float x_gamma;// regularization Parameter = minimum + t_float x_flt_sig_in1; +} t_NLMSerr_in_tilde; + +t_class *NLMSerr_in_tilde_class; + +static t_float *NLMSerr_in_tilde_check_array(t_symbol *array_sym_name, t_int length) +{ + int n_points; + t_garray *a; + t_float *vec; + + if(!(a = (t_garray *)pd_findbyclass(array_sym_name, garray_class))) + { + error("%s: no such array for NLMSerr_in~", array_sym_name->s_name); + return((t_float *)0); + } + else if(!garray_getfloatarray(a, &n_points, &vec)) + { + error("%s: bad template for NLMSerr_in~", array_sym_name->s_name); + return((t_float *)0); + } + else if(n_points < length) + { + error("%s: bad array-size for NLMSerr_in~: %d", array_sym_name->s_name, n_points); + return((t_float *)0); + } + else + { + return(vec); + } +} + +static void NLMSerr_in_tilde_beta(t_NLMSerr_in_tilde *x, t_floatarg f) // learn rate +{ + if(f < 0.0f) + f = 0.0f; + if(f > 2.0f) + f = 2.0f; + + x->x_beta = f; +} + +static void NLMSerr_in_tilde_gamma(t_NLMSerr_in_tilde *x, t_floatarg f) // regularization factor (dither) +{ + if(f < 0.0f) + f = 0.0f; + if(f > 1.0f) + f = 1.0f; + + x->x_gamma = f; +} + + +static void NLMSerr_in_tilde_update(t_NLMSerr_in_tilde *x, t_floatarg f) // downsample learn-rate +{ + t_int i=1, u = (t_int)f; + + if(u != 0) + u = 1; + x->x_update = u; +} + +/* ============== DSP ======================= */ + +static t_int *NLMSerr_in_tilde_perform_zero(t_int *w) +{ + t_NLMSerr_in_tilde *x = (t_NLMSerr_in_tilde *)(w[5]); + t_int n = (t_int)(w[6]); + t_float *filt_out = (t_float *)(w[4]); + t_int i; + + for(i=0; i<n; i++) + { + *filt_out++ = 0.0f; + } + return (w+7); +} + +static t_int *NLMSerr_in_tilde_perform(t_int *w) +{ + t_int n = (t_int)(w[6]); + t_NLMSerr_in_tilde *x = (t_NLMSerr_in_tilde *)(w[5]); + t_float *filt_out = (t_float *)(w[4]);// first sig out + t_float *err_in = (t_float *)(w[3]);// third sig in + t_float *ref_adapt_in = (t_float *)(w[2]);// second sig in + t_float *ref_filt_in = (t_float *)(w[1]);// first sig in + t_int n_order = x->x_n_order; /* number of filter-order */ + t_int rw_index = x->x_rw_index; /* current read write index in circular buffer */ + t_int update = x->x_update; + t_float beta = x->x_beta; /* learn rate */ + t_float gammax = x->x_gamma; /* minimum energy */ + t_float my, my_err, sum, errin; + t_int i, j, k; + + if(!x->x_w_array_mem_beg) + goto NLMSerr_in_tildeperfzero;// this is quick&dirty Musil/Miller style + + for(i=0; i<n; i++)// store history and convolve + { + x->x_ref_filt_in_hist[rw_index] = ref_filt_in[i]; // inputs of ref_filt save to history + x->x_ref_adapt_in_hist[rw_index] = ref_adapt_in[i]; // inputs of ref_adapt save to history + errin = err_in[i]; + + // begin convolution, filter : j++, k--, rw_index = aktueller index fuer lesen schreiben von history und convolution-beginn + sum = 0.0f; + k = rw_index; + for(j=0; j<n_order; j++) + { + sum += x->x_w_array_mem_beg[j] * x->x_ref_filt_in_hist[k]; + k--; + if(k < 0) + k = n_order - 1; + } + filt_out[i] = sum; + + + if(update) // downsampling for learn rate + { + sum = 0.0f;// calculate energy for last n-order samples in filter + k = rw_index; + for(j=0; j<n_order; j++) // unrolling quadrature calc + { + sum += x->x_ref_adapt_in_hist[k] * x->x_ref_adapt_in_hist[k]; // energie + k--; + if(k < 0) + k = n_order - 1; + } + sum += gammax * gammax * (float)n_order; // convert gammax corresponding to filter order + my = beta / sum;// calculate mue + + my_err = my * errin; + + k = rw_index; + for(j=0; j<n_order; j++) // without unroll + { + x->x_w_array_mem_beg[j] += x->x_ref_adapt_in_hist[k] * my_err; + k--; + if(k < 0) + k = n_order - 1; + } + } + rw_index++; + if(rw_index >= n_order) + rw_index = 0; + } + x->x_rw_index = rw_index; // back to start + return(w+7); + +NLMSerr_in_tildeperfzero: + + while(n--) + { + *filt_out++ = 0.0f; + } + return(w+7); +} + +static void NLMSerr_in_tilde_dsp(t_NLMSerr_in_tilde *x, t_signal **sp) +{ + x->x_w_array_mem_beg = NLMSerr_in_tilde_check_array(x->x_w_array_sym_name, x->x_n_order); + + if(!x->x_w_array_mem_beg) + dsp_add(NLMSerr_in_tilde_perform_zero, 6, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, x, sp[0]->s_n); + else + dsp_add(NLMSerr_in_tilde_perform, 6, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, x, sp[0]->s_n); +} + + +/* setup/setdown things */ + +static void NLMSerr_in_tilde_free(t_NLMSerr_in_tilde *x) +{ + freebytes(x->x_ref_filt_in_hist, x->x_n_order*sizeof(t_float)); + freebytes(x->x_ref_adapt_in_hist, x->x_n_order*sizeof(t_float)); +} + +static void *NLMSerr_in_tilde_new(t_symbol *s, t_int argc, t_atom *argv) +{ + t_NLMSerr_in_tilde *x = (t_NLMSerr_in_tilde *)pd_new(NLMSerr_in_tilde_class); + t_int i, n_order=39; + t_symbol *w_name; + t_float beta=0.01f; + t_float gammax=0.00001f; + + if((argc >= 4) && + IS_A_FLOAT(argv,0) && //IS_A_FLOAT/SYMBOL from iemlib.h + IS_A_FLOAT(argv,1) && + IS_A_FLOAT(argv,2) && + IS_A_SYMBOL(argv,3)) + { + n_order = (t_int)atom_getintarg(0, argc, argv); + beta = (t_float)atom_getfloatarg(1, argc, argv); + gammax = (t_float)atom_getfloatarg(2, argc, argv); + w_name = (t_symbol *)atom_getsymbolarg(3, argc, argv); + + if(beta < 0.0f) + beta = 0.0f; + if(beta > 2.0f) + beta = 2.0f; + + if(gammax < 0.0f) + gammax = 0.0f; + if(gammax > 1.0f) + gammax = 1.0f; + + if(n_order < 2) + n_order = 2; + if(n_order > 1111111) + n_order = 1111111; + + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); + outlet_new(&x->x_obj, &s_signal); + + x->x_flt_sig_in1 = 0; + x->x_n_order = n_order; + x->x_update = 0; + x->x_beta = beta; + x->x_gamma = gammax; + // 2 times in and one time err_in memory allocation (history) + x->x_ref_filt_in_hist = (t_float *)getbytes(x->x_n_order*sizeof(t_float)); + x->x_ref_adapt_in_hist = (t_float *)getbytes(x->x_n_order*sizeof(t_float)); + + // table-symbols will be linked to their memory in future (dsp_routine) + x->x_w_array_sym_name = gensym(w_name->s_name); + x->x_w_array_mem_beg = (t_float *)0; + + x->x_rw_index = 0; + + return(x); + } + else + { + post("NLMSerr_in~-ERROR: need 3 float- + 1 symbol-arguments:"); + post(" order_of_filter + learnrate_beta + security_value + array_name_taps"); + return(0); + } +} + +void NLMSerr_in_tilde_setup(void) +{ + NLMSerr_in_tilde_class = class_new(gensym("NLMSerr_in~"), (t_newmethod)NLMSerr_in_tilde_new, (t_method)NLMSerr_in_tilde_free, + sizeof(t_NLMSerr_in_tilde), 0, A_GIMME, 0); + CLASS_MAINSIGNALIN(NLMSerr_in_tilde_class, t_NLMSerr_in_tilde, x_flt_sig_in1); + class_addmethod(NLMSerr_in_tilde_class, (t_method)NLMSerr_in_tilde_dsp, gensym("dsp"), 0); + class_addmethod(NLMSerr_in_tilde_class, (t_method)NLMSerr_in_tilde_update, gensym("update"), A_FLOAT, 0); // method: downsampling factor of learning (multiple of 2^N) + class_addmethod(NLMSerr_in_tilde_class, (t_method)NLMSerr_in_tilde_beta, gensym("beta"), A_FLOAT, 0); //method: normalized learning rate + class_addmethod(NLMSerr_in_tilde_class, (t_method)NLMSerr_in_tilde_gamma, gensym("gamma"), A_FLOAT, 0); // method: dithering noise related to signal +} diff --git a/externals/iem/iem_adaptfilt/src/NLMS~.c b/externals/iem/iem_adaptfilt/src/NLMS~.c index 8b1f88ad4d695d6d2efe70c49dfac8475a53db71..f54efc64de19b3a807d3428a3993a70b785370a0 100644 --- a/externals/iem/iem_adaptfilt/src/NLMS~.c +++ b/externals/iem/iem_adaptfilt/src/NLMS~.c @@ -6,11 +6,6 @@ lib iem_adaptfilt written by Markus Noisternig & Thomas Musil noisternig_AT_iem.at; musil_AT_iem.at (c) Institute of Electronic Music and Acoustics, Graz Austria 2005 */ -#ifdef NT -#pragma warning( disable : 4244 ) -#pragma warning( disable : 4305 ) -#endif - #include "m_pd.h" #include "iemlib.h" @@ -149,7 +144,7 @@ static t_int *NLMS_tilde_perform(t_int *w) t_float *w_filt_coeff = x->x_w_array_mem_beg; t_float my, my_err, sum; t_float beta = x->x_beta; - t_float gamma = x->x_gamma; + t_float gammax = x->x_gamma; t_int i, j, update_counter; t_int update = x->x_update; t_int ord8=n_order&0xfffffff8; @@ -211,7 +206,7 @@ static t_int *NLMS_tilde_perform(t_int *w) } for(j=0; j<ord_residual; j++) // residual sum += read_in_hist[-j] * read_in_hist[-j]; // [-j] only valid for Musil's double buffer structure - sum += gamma * gamma * (float)n_order; // convert gamma corresponding to filter order + sum += gammax * gammax * (float)n_order; // convert gammax corresponding to filter order my = beta / sum;// calculate mue @@ -270,7 +265,7 @@ static void *NLMS_tilde_new(t_symbol *s, t_int argc, t_atom *argv) t_int i, n_order=39; t_symbol *w_name; t_float beta=0.1f; - t_float gamma=0.00001f; + t_float gammax=0.00001f; if((argc >= 4) && IS_A_FLOAT(argv,0) && //IS_A_FLOAT/SYMBOL from iemlib.h @@ -280,7 +275,7 @@ static void *NLMS_tilde_new(t_symbol *s, t_int argc, t_atom *argv) { n_order = (t_int)atom_getintarg(0, argc, argv); beta = (t_float)atom_getfloatarg(1, argc, argv); - gamma = (t_float)atom_getfloatarg(2, argc, argv); + gammax = (t_float)atom_getfloatarg(2, argc, argv); w_name = (t_symbol *)atom_getsymbolarg(3, argc, argv); if(beta < 0.0f) @@ -288,10 +283,10 @@ static void *NLMS_tilde_new(t_symbol *s, t_int argc, t_atom *argv) if(beta > 2.0f) beta = 2.0f; - if(gamma < 0.0f) - gamma = 0.0f; - if(gamma > 1.0f) - gamma = 1.0f; + if(gammax < 0.0f) + gammax = 0.0f; + if(gammax > 1.0f) + gammax = 1.0f; if(n_order < 2) n_order = 2; @@ -306,7 +301,7 @@ static void *NLMS_tilde_new(t_symbol *s, t_int argc, t_atom *argv) x->x_n_order = n_order; x->x_update = 0; x->x_beta = beta; - x->x_gamma = gamma; + x->x_gamma = gammax; // 2 times in and one time desired_in memory allocation (history) x->x_in_hist = (t_float *)getbytes(2*x->x_n_order*sizeof(t_float)); @@ -329,7 +324,7 @@ void NLMS_tilde_setup(void) NLMS_tilde_class = class_new(gensym("NLMS~"), (t_newmethod)NLMS_tilde_new, (t_method)NLMS_tilde_free, sizeof(t_NLMS_tilde), 0, A_GIMME, 0); CLASS_MAINSIGNALIN(NLMS_tilde_class, t_NLMS_tilde, x_msi); - class_addmethod(NLMS_tilde_class, (t_method)NLMS_tilde_dsp, gensym("dsp"), A_CANT, 0); + class_addmethod(NLMS_tilde_class, (t_method)NLMS_tilde_dsp, gensym("dsp"), 0); class_addmethod(NLMS_tilde_class, (t_method)NLMS_tilde_update, gensym("update"), A_FLOAT, 0); // method: downsampling factor of learning (multiple of 2^N) class_addmethod(NLMS_tilde_class, (t_method)NLMS_tilde_beta, gensym("beta"), A_FLOAT, 0); //method: normalized learning rate class_addmethod(NLMS_tilde_class, (t_method)NLMS_tilde_gamma, gensym("gamma"), A_FLOAT, 0); // method: dithering noise related to signal diff --git a/externals/iem/iem_adaptfilt/src/VC6/iem_adaptfilt.dsp b/externals/iem/iem_adaptfilt/src/VC6/iem_adaptfilt.dsp new file mode 100644 index 0000000000000000000000000000000000000000..ff0a2926e267bea0fea765ebf6aac5ce3c585391 --- /dev/null +++ b/externals/iem/iem_adaptfilt/src/VC6/iem_adaptfilt.dsp @@ -0,0 +1,85 @@ +# Microsoft Developer Studio Project File - Name="iem_adaptfilt" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=iem_adaptfilt - Win32 Debug +!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "iem_adaptfilt.mak". +!MESSAGE +!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "iem_adaptfilt.mak" CFG="iem_adaptfilt - Win32 Debug" +!MESSAGE +!MESSAGE Für die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "iem_adaptfilt - Win32 Release" (basierend auf "Win32 (x86) External Target") +!MESSAGE "iem_adaptfilt - Win32 Debug" (basierend auf "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "iem_adaptfilt - Win32 Release" + +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f makefile_win" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "makefile_win.exe" +# PROP BASE Bsc_Name "makefile_win.bsc" +# PROP BASE Target_Dir "" +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Cmd_Line "NMAKE /f makefile_win" +# PROP Rebuild_Opt "/a" +# PROP Target_File "iem_adaptfilt.exe" +# PROP Bsc_Name "iem_adaptfilt.bsc" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "iem_adaptfilt - Win32 Debug" + +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Cmd_Line "NMAKE /f makefile_win" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "makefile_win.exe" +# PROP BASE Bsc_Name "makefile_win.bsc" +# PROP BASE Target_Dir "" +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Cmd_Line "NMAKE /f makefile_win" +# PROP Rebuild_Opt "/a" +# PROP Target_File "iem_adaptfilt.exe" +# PROP Bsc_Name "iem_adaptfilt.bsc" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "iem_adaptfilt - Win32 Release" +# Name "iem_adaptfilt - Win32 Debug" + +!IF "$(CFG)" == "iem_adaptfilt - Win32 Release" + +!ELSEIF "$(CFG)" == "iem_adaptfilt - Win32 Debug" + +!ENDIF + +# Begin Source File + +SOURCE=.\makefile_win +# End Source File +# End Target +# End Project diff --git a/externals/iem/iem_adaptfilt/src/VC6/iem_adaptfilt.dsw b/externals/iem/iem_adaptfilt/src/VC6/iem_adaptfilt.dsw new file mode 100644 index 0000000000000000000000000000000000000000..5f9bde81084ef22bf4cbd2a525435678484f9e3c --- /dev/null +++ b/externals/iem/iem_adaptfilt/src/VC6/iem_adaptfilt.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELÖSCHT WERDEN! + +############################################################################### + +Project: "iem_adaptfilt"=.\iem_adaptfilt.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/externals/iem/iem_adaptfilt/src/VC6/makefile_win b/externals/iem/iem_adaptfilt/src/VC6/makefile_win new file mode 100644 index 0000000000000000000000000000000000000000..75562cdf5273e65809823bf550a0b9bb3e642a8a --- /dev/null +++ b/externals/iem/iem_adaptfilt/src/VC6/makefile_win @@ -0,0 +1,86 @@ + + +all: ..\iem_adaptfilt.dll + + + +VIS_CPP_PATH = "C:\Programme\Microsoft Visual Studio\Vc98" + + + +PD_INST_PATH = "C:\Programme\pd" + + + +PD_WIN_INCLUDE_PATH = /I. /I$(PD_INST_PATH)\src /I$(VIS_CPP_PATH)\include + + + +PD_WIN_C_FLAGS = /nologo /W3 /WX /DMSW /DNT /DPD /DWIN32 /DWINDOWS /Ox -DPA_LITTLE_ENDIAN + + + +PD_WIN_L_FLAGS = /nologo + + + +PD_WIN_LIB = /NODEFAULTLIB:libc /NODEFAULTLIB:oldnames /NODEFAULTLIB:kernel /NODEFAULTLIB:uuid \ + + $(VIS_CPP_PATH)\lib\libc.lib \ + + $(VIS_CPP_PATH)\lib\oldnames.lib \ + + $(VIS_CPP_PATH)\lib\kernel32.lib \ + + $(VIS_CPP_PATH)\lib\wsock32.lib \ + + $(VIS_CPP_PATH)\lib\winmm.lib \ + + $(PD_INST_PATH)\bin\pthreadVC.lib \ + + $(PD_INST_PATH)\bin\pd.lib + + + + +SRC = NLMS~.c \ + + NLMSerr_in~.c \ + + NLMSCC~.c \ + + n_CNLMS~.c \ + + n_CLNLMS~.c \ + + iem_adaptfilt.c + + + + + +OBJ = $(SRC:.c=.obj) + + + +.c.obj: + + cl $(PD_WIN_C_FLAGS) $(PD_WIN_INCLUDE_PATH) /c $*.c + + + +..\iem_adaptfilt.dll: $(OBJ) + + link $(PD_WIN_L_FLAGS) /dll /export:iem_adaptfilt_setup \ + + /out:..\iem_adaptfilt.dll $(OBJ) $(PD_WIN_LIB) + + + + +clean: + + del *.obj + + + diff --git a/externals/iem/iem_adaptfilt/src/VC7/iem_adaptfilt.vcproj b/externals/iem/iem_adaptfilt/src/VC7/iem_adaptfilt.vcproj new file mode 100644 index 0000000000000000000000000000000000000000..1117256d7618a218399c0c84a404f12a5b97e6f8 --- /dev/null +++ b/externals/iem/iem_adaptfilt/src/VC7/iem_adaptfilt.vcproj @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="7.10" + Name="iem_adaptfilt" + ProjectGUID="{6A44952F-0D55-44EE-9032-928368583BEC}" + SccProjectName="" + SccLocalPath="" + Keyword="MakeFileProj"> + <Platforms> + <Platform + Name="Win32"/> + </Platforms> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory=".\Debug" + IntermediateDirectory=".\Debug" + ConfigurationType="0" + ATLMinimizesCRunTimeLibraryUsage="FALSE"> + <Tool + Name="VCNMakeTool" + BuildCommandLine="NMAKE /f makefile_vc7proj" + ReBuildCommandLine="NMAKE /f makefile_vc7proj /a" + Output="iem_adaptfilt.exe"/> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory=".\Release" + IntermediateDirectory=".\Release" + ConfigurationType="0" + ATLMinimizesCRunTimeLibraryUsage="FALSE"> + <Tool + Name="VCNMakeTool" + BuildCommandLine="NMAKE /f makefile_vc7proj" + ReBuildCommandLine="NMAKE /f makefile_vc7proj /a" + Output="iem_adaptfilt.exe"/> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <File + RelativePath="iem_adaptfilt.bsc"> + </File> + <File + RelativePath="makefile_vc7proj"> + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/externals/iem/iem_adaptfilt/src/VC7/makefile_vc7proj b/externals/iem/iem_adaptfilt/src/VC7/makefile_vc7proj new file mode 100644 index 0000000000000000000000000000000000000000..c5022223ec25b88895d68ae4d2d54c7fcd1649b0 --- /dev/null +++ b/externals/iem/iem_adaptfilt/src/VC7/makefile_vc7proj @@ -0,0 +1,41 @@ +TARGET = iem_adaptfilt + +all: ..\$(TARGET).dll + +VIS_CPP_PATH = "C:\Programme\Microsoft Visual Studio .NET 2003\Vc7" +VIS_SDK_PATH = "C:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK" +PD_INST_PATH = "C:\Programme\pd" +PD_WIN_INCLUDE_PATH = /I. /I$(PD_INST_PATH)\src /I$(VIS_CPP_PATH)\include +PD_WIN_C_FLAGS = /nologo /W3 /WX /DMSW /DNT /DPD /DWIN32 /DWINDOWS /DHAVE_G_CANVAS_H /Ox -D_CRT_SECURE_NO_WARNINGS +PD_WIN_L_FLAGS = /nologo + +PD_WIN_LIB = /NODEFAULTLIB:libcmt /NODEFAULTLIB:oldnames /NODEFAULTLIB:kernel32 \ + $(VIS_CPP_PATH)\lib\libcmt.lib \ + $(VIS_CPP_PATH)\lib\oldnames.lib \ + $(VIS_SDK_PATH)\lib\kernel32.lib \ + $(PD_INST_PATH)\bin\pd.lib + +SRC = NLMS~.c \ + + NLMSerr_in~.c \ + + NLMSCC~.c \ + + n_CNLMS~.c \ + + n_CLNLMS~.c \ + + iem_adaptfilt.c + + +OBJ = $(SRC:.c=.obj) + +.c.obj: + cl $(PD_WIN_C_FLAGS) $(PD_WIN_INCLUDE_PATH) /c $*.c + +..\$(TARGET).dll: $(OBJ) + link $(PD_WIN_L_FLAGS) /dll /export:$(TARGET)_setup \ + /out:..\$(TARGET).dll $(OBJ) $(PD_WIN_LIB) + +clean: + del *.obj diff --git a/externals/iem/iem_adaptfilt/src/VC9/iem_adaptfilt.sln b/externals/iem/iem_adaptfilt/src/VC9/iem_adaptfilt.sln new file mode 100644 index 0000000000000000000000000000000000000000..775cab1bc767d60575cdcd7b639171dd075b63ef --- /dev/null +++ b/externals/iem/iem_adaptfilt/src/VC9/iem_adaptfilt.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "iem_adaptfilt", "iem_adaptfilt.vcproj", "{6A44952F-0D55-44EE-9032-928368583BEC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6A44952F-0D55-44EE-9032-928368583BEC}.Debug|Win32.ActiveCfg = Debug|Win32 + {6A44952F-0D55-44EE-9032-928368583BEC}.Debug|Win32.Build.0 = Debug|Win32 + {6A44952F-0D55-44EE-9032-928368583BEC}.Release|Win32.ActiveCfg = Release|Win32 + {6A44952F-0D55-44EE-9032-928368583BEC}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/externals/iem/iem_adaptfilt/src/VC9/iem_adaptfilt.vcproj b/externals/iem/iem_adaptfilt/src/VC9/iem_adaptfilt.vcproj new file mode 100644 index 0000000000000000000000000000000000000000..8f2cbbe3814e00cb32f10af3172c4d700cdd68b7 --- /dev/null +++ b/externals/iem/iem_adaptfilt/src/VC9/iem_adaptfilt.vcproj @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9,00" + Name="iem_adaptfilt" + ProjectGUID="{6A44952F-0D55-44EE-9032-928368583BEC}" + Keyword="MakeFileProj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory=".\Debug" + IntermediateDirectory=".\Debug" + ConfigurationType="0" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + ATLMinimizesCRunTimeLibraryUsage="false" + > + <Tool + Name="VCNMakeTool" + BuildCommandLine="NMAKE /f makefile_vc9proj" + ReBuildCommandLine="NMAKE /f makefile_vc9proj /a" + CleanCommandLine="" + Output="iem_adaptfilt.exe" + PreprocessorDefinitions="" + IncludeSearchPath="" + ForcedIncludes="" + AssemblySearchPath="" + ForcedUsingAssemblies="" + CompileAsManaged="" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory=".\Release" + IntermediateDirectory=".\Release" + ConfigurationType="0" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + ATLMinimizesCRunTimeLibraryUsage="false" + > + <Tool + Name="VCNMakeTool" + BuildCommandLine="NMAKE /f makefile_vc9proj" + ReBuildCommandLine="NMAKE /f makefile_vc9proj /a" + CleanCommandLine="" + Output="iem_adaptfilt.exe" + PreprocessorDefinitions="" + IncludeSearchPath="" + ForcedIncludes="" + AssemblySearchPath="" + ForcedUsingAssemblies="" + CompileAsManaged="" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <File + RelativePath="iem_adaptfilt.bsc" + > + </File> + <File + RelativePath="makefile_vc9proj" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/externals/iem/iem_adaptfilt/src/VC9/makefile_vc9proj b/externals/iem/iem_adaptfilt/src/VC9/makefile_vc9proj new file mode 100644 index 0000000000000000000000000000000000000000..4943e3bbc50fc86f42d5705b452428bdf7b15c6b --- /dev/null +++ b/externals/iem/iem_adaptfilt/src/VC9/makefile_vc9proj @@ -0,0 +1,35 @@ +TARGET = iem_adaptfilt + +all: ..\$(TARGET).dll + +VIS_CPP_PATH = "C:\Program Files\Microsoft Visual Studio 9.0\VC" +VIS_SDK_PATH = "C:\Program Files\Microsoft SDKs\Windows\v6.0A" +PD_INST_PATH = "C:\Program Files\pd-0.43.0" +PD_WIN_INCLUDE_PATH = /I. /I$(PD_INST_PATH)\src /I$(VIS_CPP_PATH)\include +PD_WIN_C_FLAGS = /nologo /W3 /WX /DMSW /DNT /DPD /DWIN32 /DWINDOWS /Ox -D_CRT_SECURE_NO_WARNINGS +PD_WIN_L_FLAGS = /nologo + +PD_WIN_LIB = /NODEFAULTLIB:libcmt /NODEFAULTLIB:oldnames /NODEFAULTLIB:kernel32 \ + $(VIS_CPP_PATH)\lib\libcmt.lib \ + $(VIS_CPP_PATH)\lib\oldnames.lib \ + $(VIS_SDK_PATH)\lib\kernel32.lib \ + $(PD_INST_PATH)\bin\pd.lib + +SRC = NLMS~.c \ + NLMSerr_in~.c \ + NLMSCC~.c \ + n_CNLMS~.c \ + n_CLNLMS~.c \ + iem_adaptfilt.c + +OBJ = $(SRC:.c=.obj) + +.c.obj: + cl $(PD_WIN_C_FLAGS) $(PD_WIN_INCLUDE_PATH) /c $*.c + +..\$(TARGET).dll: $(OBJ) + link $(PD_WIN_L_FLAGS) /dll /export:$(TARGET)_setup \ + /out:..\$(TARGET).dll $(OBJ) $(PD_WIN_LIB) + +clean: + del *.obj diff --git a/externals/iem/iem_adaptfilt/src/iem_adaptfilt.c b/externals/iem/iem_adaptfilt/src/iem_adaptfilt.c index a70d12f614578fe59b56e70967b5493c4b34e6e0..50d79adf845afa054c0994e4fd1c0adb7e1fe104 100644 --- a/externals/iem/iem_adaptfilt/src/iem_adaptfilt.c +++ b/externals/iem/iem_adaptfilt/src/iem_adaptfilt.c @@ -24,6 +24,7 @@ static void *iem_adaptfilt_new(void) } void NLMS_tilde_setup(void); +void NLMSerr_in_tilde_setup(void); void NLMSCC_tilde_setup(void); void n_CNLMS_tilde_setup(void); void n_CLNLMS_tilde_setup(void); @@ -33,6 +34,7 @@ void n_CLNLMS_tilde_setup(void); void iem_adaptfilt_setup(void) { NLMS_tilde_setup(); + NLMSerr_in_tilde_setup(); NLMSCC_tilde_setup(); n_CNLMS_tilde_setup(); n_CLNLMS_tilde_setup(); diff --git a/externals/iem/iem_adaptfilt/src/iem_adaptfilt.dsp b/externals/iem/iem_adaptfilt/src/iem_adaptfilt.dsp new file mode 100644 index 0000000000000000000000000000000000000000..ff0a2926e267bea0fea765ebf6aac5ce3c585391 --- /dev/null +++ b/externals/iem/iem_adaptfilt/src/iem_adaptfilt.dsp @@ -0,0 +1,85 @@ +# Microsoft Developer Studio Project File - Name="iem_adaptfilt" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=iem_adaptfilt - Win32 Debug +!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "iem_adaptfilt.mak". +!MESSAGE +!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "iem_adaptfilt.mak" CFG="iem_adaptfilt - Win32 Debug" +!MESSAGE +!MESSAGE Für die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "iem_adaptfilt - Win32 Release" (basierend auf "Win32 (x86) External Target") +!MESSAGE "iem_adaptfilt - Win32 Debug" (basierend auf "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "iem_adaptfilt - Win32 Release" + +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f makefile_win" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "makefile_win.exe" +# PROP BASE Bsc_Name "makefile_win.bsc" +# PROP BASE Target_Dir "" +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Cmd_Line "NMAKE /f makefile_win" +# PROP Rebuild_Opt "/a" +# PROP Target_File "iem_adaptfilt.exe" +# PROP Bsc_Name "iem_adaptfilt.bsc" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "iem_adaptfilt - Win32 Debug" + +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Cmd_Line "NMAKE /f makefile_win" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "makefile_win.exe" +# PROP BASE Bsc_Name "makefile_win.bsc" +# PROP BASE Target_Dir "" +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Cmd_Line "NMAKE /f makefile_win" +# PROP Rebuild_Opt "/a" +# PROP Target_File "iem_adaptfilt.exe" +# PROP Bsc_Name "iem_adaptfilt.bsc" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "iem_adaptfilt - Win32 Release" +# Name "iem_adaptfilt - Win32 Debug" + +!IF "$(CFG)" == "iem_adaptfilt - Win32 Release" + +!ELSEIF "$(CFG)" == "iem_adaptfilt - Win32 Debug" + +!ENDIF + +# Begin Source File + +SOURCE=.\makefile_win +# End Source File +# End Target +# End Project diff --git a/externals/iem/iem_adaptfilt/src/iem_adaptfilt.dsw b/externals/iem/iem_adaptfilt/src/iem_adaptfilt.dsw new file mode 100644 index 0000000000000000000000000000000000000000..5f9bde81084ef22bf4cbd2a525435678484f9e3c --- /dev/null +++ b/externals/iem/iem_adaptfilt/src/iem_adaptfilt.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELÖSCHT WERDEN! + +############################################################################### + +Project: "iem_adaptfilt"=.\iem_adaptfilt.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/externals/iem/iem_adaptfilt/src/iem_adaptfilt.sln b/externals/iem/iem_adaptfilt/src/iem_adaptfilt.sln new file mode 100644 index 0000000000000000000000000000000000000000..775cab1bc767d60575cdcd7b639171dd075b63ef --- /dev/null +++ b/externals/iem/iem_adaptfilt/src/iem_adaptfilt.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "iem_adaptfilt", "iem_adaptfilt.vcproj", "{6A44952F-0D55-44EE-9032-928368583BEC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6A44952F-0D55-44EE-9032-928368583BEC}.Debug|Win32.ActiveCfg = Debug|Win32 + {6A44952F-0D55-44EE-9032-928368583BEC}.Debug|Win32.Build.0 = Debug|Win32 + {6A44952F-0D55-44EE-9032-928368583BEC}.Release|Win32.ActiveCfg = Release|Win32 + {6A44952F-0D55-44EE-9032-928368583BEC}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/externals/iem/iem_adaptfilt/src/iem_adaptfilt.vcproj b/externals/iem/iem_adaptfilt/src/iem_adaptfilt.vcproj new file mode 100644 index 0000000000000000000000000000000000000000..8f2cbbe3814e00cb32f10af3172c4d700cdd68b7 --- /dev/null +++ b/externals/iem/iem_adaptfilt/src/iem_adaptfilt.vcproj @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9,00" + Name="iem_adaptfilt" + ProjectGUID="{6A44952F-0D55-44EE-9032-928368583BEC}" + Keyword="MakeFileProj" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory=".\Debug" + IntermediateDirectory=".\Debug" + ConfigurationType="0" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + ATLMinimizesCRunTimeLibraryUsage="false" + > + <Tool + Name="VCNMakeTool" + BuildCommandLine="NMAKE /f makefile_vc9proj" + ReBuildCommandLine="NMAKE /f makefile_vc9proj /a" + CleanCommandLine="" + Output="iem_adaptfilt.exe" + PreprocessorDefinitions="" + IncludeSearchPath="" + ForcedIncludes="" + AssemblySearchPath="" + ForcedUsingAssemblies="" + CompileAsManaged="" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory=".\Release" + IntermediateDirectory=".\Release" + ConfigurationType="0" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + ATLMinimizesCRunTimeLibraryUsage="false" + > + <Tool + Name="VCNMakeTool" + BuildCommandLine="NMAKE /f makefile_vc9proj" + ReBuildCommandLine="NMAKE /f makefile_vc9proj /a" + CleanCommandLine="" + Output="iem_adaptfilt.exe" + PreprocessorDefinitions="" + IncludeSearchPath="" + ForcedIncludes="" + AssemblySearchPath="" + ForcedUsingAssemblies="" + CompileAsManaged="" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <File + RelativePath="iem_adaptfilt.bsc" + > + </File> + <File + RelativePath="makefile_vc9proj" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/externals/iem/iem_adaptfilt/src/makefile_d_fat b/externals/iem/iem_adaptfilt/src/makefile_d_fat index 9412256aa1e754fb7838da6376b489f20c49f94f..d7c933aeda98c1522e85bca958868f02124ebb75 100644 --- a/externals/iem/iem_adaptfilt/src/makefile_d_fat +++ b/externals/iem/iem_adaptfilt/src/makefile_d_fat @@ -14,6 +14,7 @@ LFLAGS = -bundle -undefined suppress -flat_namespace # the sources SRC = NLMS~.c \ + NLMSerr_in~.c \ NLMSCC~.c \ n_CNLMS~.c \ n_CLNLMS~.c \ diff --git a/externals/iem/iem_adaptfilt/src/makefile_d_ppc b/externals/iem/iem_adaptfilt/src/makefile_d_ppc index e4f8f55b238358ca5b103bd482d0245f4ee7d792..d82257f9aa899505f29e75f680c07dda8b3b8e78 100644 --- a/externals/iem/iem_adaptfilt/src/makefile_d_ppc +++ b/externals/iem/iem_adaptfilt/src/makefile_d_ppc @@ -14,6 +14,7 @@ LFLAGS = -bundle -undefined suppress -flat_namespace # the sources SRC = NLMS~.c \ + NLMSerr_in~.c \ NLMSCC~.c \ n_CNLMS~.c \ n_CLNLMS~.c \ diff --git a/externals/iem/iem_adaptfilt/src/makefile_darwin b/externals/iem/iem_adaptfilt/src/makefile_darwin index 11405a031b3282da468f775db155b2f99f4ffc52..b09b45143f272ba18940a2cda8a48628b62b7f6c 100644 --- a/externals/iem/iem_adaptfilt/src/makefile_darwin +++ b/externals/iem/iem_adaptfilt/src/makefile_darwin @@ -19,6 +19,7 @@ SYSTEM = $(shell uname -m) # the sources SRC = NLMS~.c \ + NLMSerr_in~.c \ NLMSCC~.c \ n_CNLMS~.c \ n_CLNLMS~.c \ diff --git a/externals/iem/iem_adaptfilt/src/makefile_lin b/externals/iem/iem_adaptfilt/src/makefile_lin index 6db08d89206856cc5aa45a4aadbecad54d9a3fa4..d86e0564a84c5eabe9cb3b2622daebd38eebb455 100644 --- a/externals/iem/iem_adaptfilt/src/makefile_lin +++ b/externals/iem/iem_adaptfilt/src/makefile_lin @@ -18,6 +18,7 @@ SYSTEM = $(shell uname -m) # the sources SRC = NLMS~.c \ + NLMSerr_in~.c \ NLMSCC~.c \ n_CNLMS~.c \ n_CLNLMS~.c \ diff --git a/externals/iem/iem_adaptfilt/src/makefile_vc9proj b/externals/iem/iem_adaptfilt/src/makefile_vc9proj new file mode 100644 index 0000000000000000000000000000000000000000..4943e3bbc50fc86f42d5705b452428bdf7b15c6b --- /dev/null +++ b/externals/iem/iem_adaptfilt/src/makefile_vc9proj @@ -0,0 +1,35 @@ +TARGET = iem_adaptfilt + +all: ..\$(TARGET).dll + +VIS_CPP_PATH = "C:\Program Files\Microsoft Visual Studio 9.0\VC" +VIS_SDK_PATH = "C:\Program Files\Microsoft SDKs\Windows\v6.0A" +PD_INST_PATH = "C:\Program Files\pd-0.43.0" +PD_WIN_INCLUDE_PATH = /I. /I$(PD_INST_PATH)\src /I$(VIS_CPP_PATH)\include +PD_WIN_C_FLAGS = /nologo /W3 /WX /DMSW /DNT /DPD /DWIN32 /DWINDOWS /Ox -D_CRT_SECURE_NO_WARNINGS +PD_WIN_L_FLAGS = /nologo + +PD_WIN_LIB = /NODEFAULTLIB:libcmt /NODEFAULTLIB:oldnames /NODEFAULTLIB:kernel32 \ + $(VIS_CPP_PATH)\lib\libcmt.lib \ + $(VIS_CPP_PATH)\lib\oldnames.lib \ + $(VIS_SDK_PATH)\lib\kernel32.lib \ + $(PD_INST_PATH)\bin\pd.lib + +SRC = NLMS~.c \ + NLMSerr_in~.c \ + NLMSCC~.c \ + n_CNLMS~.c \ + n_CLNLMS~.c \ + iem_adaptfilt.c + +OBJ = $(SRC:.c=.obj) + +.c.obj: + cl $(PD_WIN_C_FLAGS) $(PD_WIN_INCLUDE_PATH) /c $*.c + +..\$(TARGET).dll: $(OBJ) + link $(PD_WIN_L_FLAGS) /dll /export:$(TARGET)_setup \ + /out:..\$(TARGET).dll $(OBJ) $(PD_WIN_LIB) + +clean: + del *.obj diff --git a/externals/iem/iem_adaptfilt/src/makefile_win b/externals/iem/iem_adaptfilt/src/makefile_win index 69f09be0e1d56ece6d36c0afb5942fc368fb773f..75562cdf5273e65809823bf550a0b9bb3e642a8a 100644 --- a/externals/iem/iem_adaptfilt/src/makefile_win +++ b/externals/iem/iem_adaptfilt/src/makefile_win @@ -1,44 +1,86 @@ + -all: iem_adaptfilt.dll +all: ..\iem_adaptfilt.dll + -VIS_CPP_PATH = "C:\Programme\Microsoft Visual Studio\Vc98" -PD_INST_PATH = "C:\Programme\pd-0.37-3" +VIS_CPP_PATH = "C:\Programme\Microsoft Visual Studio\Vc98" -PD_WIN_INCLUDE_PATH = /I. /I$(PD_INST_PATH)\src /I$(VIS_CPP_PATH)\include + -PD_WIN_C_FLAGS = /nologo /W3 /WX /DMSW /DNT /DPD /DWIN32 /DWINDOWS /Ox -DPA_LITTLE_ENDIAN +PD_INST_PATH = "C:\Programme\pd" -PD_WIN_L_FLAGS = /nologo + + +PD_WIN_INCLUDE_PATH = /I. /I$(PD_INST_PATH)\src /I$(VIS_CPP_PATH)\include -PD_WIN_LIB = /NODEFAULTLIB:libc /NODEFAULTLIB:oldnames /NODEFAULTLIB:kernel /NODEFAULTLIB:uuid \ - $(VIS_CPP_PATH)\lib\libc.lib \ - $(VIS_CPP_PATH)\lib\oldnames.lib \ - $(VIS_CPP_PATH)\lib\kernel32.lib \ - $(VIS_CPP_PATH)\lib\wsock32.lib \ - $(VIS_CPP_PATH)\lib\winmm.lib \ - $(PD_INST_PATH)\bin\pthreadVC.lib \ - $(PD_INST_PATH)\bin\pd.lib + +PD_WIN_C_FLAGS = /nologo /W3 /WX /DMSW /DNT /DPD /DWIN32 /DWINDOWS /Ox -DPA_LITTLE_ENDIAN -SRC = NLMS~.c \ - NLMSCC~.c \ - n_CNLMS~.c \ - n_CLNLMS~.c \ - iem_adaptfilt.c + +PD_WIN_L_FLAGS = /nologo -OBJ = $(SRC:.c=.obj) + -.c.obj: - cl $(PD_WIN_C_FLAGS) $(PD_WIN_INCLUDE_PATH) /c $*.c +PD_WIN_LIB = /NODEFAULTLIB:libc /NODEFAULTLIB:oldnames /NODEFAULTLIB:kernel /NODEFAULTLIB:uuid \ -iem_adaptfilt.dll: $(OBJ) - link $(PD_WIN_L_FLAGS) /dll /export:iem_adaptfilt_setup \ - /out:iem_adaptfilt.dll $(OBJ) $(PD_WIN_LIB) + $(VIS_CPP_PATH)\lib\libc.lib \ + $(VIS_CPP_PATH)\lib\oldnames.lib \ + + $(VIS_CPP_PATH)\lib\kernel32.lib \ + + $(VIS_CPP_PATH)\lib\wsock32.lib \ + + $(VIS_CPP_PATH)\lib\winmm.lib \ + + $(PD_INST_PATH)\bin\pthreadVC.lib \ + + $(PD_INST_PATH)\bin\pd.lib + + + + +SRC = NLMS~.c \ + + NLMSerr_in~.c \ + + NLMSCC~.c \ + + n_CNLMS~.c \ + + n_CLNLMS~.c \ + + iem_adaptfilt.c + + + + + +OBJ = $(SRC:.c=.obj) + + + +.c.obj: + + cl $(PD_WIN_C_FLAGS) $(PD_WIN_INCLUDE_PATH) /c $*.c + + + +..\iem_adaptfilt.dll: $(OBJ) + + link $(PD_WIN_L_FLAGS) /dll /export:iem_adaptfilt_setup \ + + /out:..\iem_adaptfilt.dll $(OBJ) $(PD_WIN_LIB) + + + + +clean: -clean: del *.obj + diff --git a/externals/iem/iem_adaptfilt/src/n_CLNLMS~.c b/externals/iem/iem_adaptfilt/src/n_CLNLMS~.c index 3661d85c17f89f364eb2f712e771220f272ea5d3..3153c0b98716d3ea1de66364ff1526919e632594 100644 --- a/externals/iem/iem_adaptfilt/src/n_CLNLMS~.c +++ b/externals/iem/iem_adaptfilt/src/n_CLNLMS~.c @@ -187,7 +187,7 @@ static t_int *n_CLNLMS_tilde_perform(t_int *w) t_float *w_filt_coeff; t_float my, my_err, sum; t_float beta = x->x_beta; - t_float hgamma, gamma = x->x_gamma; + t_float hgamma, gammax = x->x_gamma; t_float hkappa, kappa = x->x_kappa; t_float hleakage, leakage = x->x_leakage; t_int i, j, k, update_counter; @@ -202,7 +202,7 @@ static t_int *n_CLNLMS_tilde_perform(t_int *w) goto n_CLNLMS_tildeperfzero;// this is Musil/Miller style } - hgamma = gamma * gamma * (float)n_order; + hgamma = gammax * gammax * (float)n_order; //hkappa = kappa * kappa * (float)n_order; hkappa = kappa; // kappa regards to energy value, else use line above @@ -271,7 +271,7 @@ static t_int *n_CLNLMS_tilde_perform(t_int *w) } for(j=0; j<ord_residual; j++) // residual sum += read_in_hist[-j] * read_in_hist[-j]; // [-j] only valid for Musil's double buffer structure - sum += hgamma; // convert gamma corresponding to filter order + sum += hgamma; // convert gammax corresponding to filter order my = beta / sum;// calculate mue my_err = my * err_sum; @@ -403,7 +403,7 @@ static void *n_CLNLMS_tilde_new(t_symbol *s, t_int argc, t_atom *argv) t_int n_order=39, n_io=1; t_symbol *w_name; t_float beta=0.1f; - t_float gamma=0.00001f; + t_float gammax=0.00001f; t_float kappa = 1.0f; t_float leakage = 0.99f; @@ -419,7 +419,7 @@ static void *n_CLNLMS_tilde_new(t_symbol *s, t_int argc, t_atom *argv) n_io = (t_int)atom_getintarg(0, argc, argv); n_order = (t_int)atom_getintarg(1, argc, argv); beta = (t_float)atom_getfloatarg(2, argc, argv); - gamma = (t_float)atom_getfloatarg(3, argc, argv); + gammax = (t_float)atom_getfloatarg(3, argc, argv); kappa = (t_float)atom_getfloatarg(4, argc, argv); leakage = (t_float)atom_getfloatarg(5, argc, argv); w_name = (t_symbol *)atom_getsymbolarg(6, argc, argv); @@ -429,10 +429,10 @@ static void *n_CLNLMS_tilde_new(t_symbol *s, t_int argc, t_atom *argv) if(beta > 2.0f) beta = 2.0f; - if(gamma < 0.0f) - gamma = 0.0f; - if(gamma > 1.0f) - gamma = 1.0f; + if(gammax < 0.0f) + gammax = 0.0f; + if(gammax > 1.0f) + gammax = 1.0f; if(kappa < 0.0001f) kappa = 0.0001f; @@ -466,7 +466,7 @@ static void *n_CLNLMS_tilde_new(t_symbol *s, t_int argc, t_atom *argv) x->x_n_order = n_order; x->x_update = 0; x->x_beta = beta; - x->x_gamma = gamma; + x->x_gamma = gammax; x->x_kappa = kappa; x->x_leakage = leakage; x->x_my_kern = (t_n_CLNLMS_tilde_kern *)getbytes(x->x_n_io*sizeof(t_n_CLNLMS_tilde_kern)); @@ -494,7 +494,7 @@ void n_CLNLMS_tilde_setup(void) n_CLNLMS_tilde_class = class_new(gensym("n_CLNLMS~"), (t_newmethod)n_CLNLMS_tilde_new, (t_method)n_CLNLMS_tilde_free, sizeof(t_n_CLNLMS_tilde), 0, A_GIMME, 0); CLASS_MAINSIGNALIN(n_CLNLMS_tilde_class, t_n_CLNLMS_tilde, x_msi); - class_addmethod(n_CLNLMS_tilde_class, (t_method)n_CLNLMS_tilde_dsp, gensym("dsp"),A_CANT, 0); + class_addmethod(n_CLNLMS_tilde_class, (t_method)n_CLNLMS_tilde_dsp, gensym("dsp"), 0); class_addmethod(n_CLNLMS_tilde_class, (t_method)n_CLNLMS_tilde_update, gensym("update"), A_FLOAT, 0); // method: downsampling factor of learning (multiple of 2^N) class_addmethod(n_CLNLMS_tilde_class, (t_method)n_CLNLMS_tilde_beta, gensym("beta"), A_FLOAT, 0); //method: normalized learning rate class_addmethod(n_CLNLMS_tilde_class, (t_method)n_CLNLMS_tilde_gamma, gensym("gamma"), A_FLOAT, 0); // method: dithering noise related to signal diff --git a/externals/iem/iem_adaptfilt/src/n_CNLMS~.c b/externals/iem/iem_adaptfilt/src/n_CNLMS~.c index 26ac4ed16b92a8f778bf3a2cf78a3704fcb7c865..d1d6b514061814e945856674d19d1ff79091f974 100644 --- a/externals/iem/iem_adaptfilt/src/n_CNLMS~.c +++ b/externals/iem/iem_adaptfilt/src/n_CNLMS~.c @@ -177,7 +177,7 @@ static t_int *n_CNLMS_tilde_perform(t_int *w) t_float *w_filt_coeff; t_float my, my_err, sum; t_float beta = x->x_beta; - t_float hgamma, gamma = x->x_gamma; + t_float hgamma, gammax = x->x_gamma; t_float hkappa, kappa = x->x_kappa; t_int i, j, k, update_counter; t_int update = x->x_update; @@ -191,7 +191,7 @@ static t_int *n_CNLMS_tilde_perform(t_int *w) goto n_CNLMS_tildeperfzero;// this is Musil/Miller style } - hgamma = gamma * gamma * (float)n_order; + hgamma = gammax * gammax * (float)n_order; //hkappa = kappa * kappa * (float)n_order; hkappa = kappa;// kappa regards to energy value, else use line above @@ -260,7 +260,7 @@ static t_int *n_CNLMS_tilde_perform(t_int *w) } for(j=0; j<ord_residual; j++) // residual sum += read_in_hist[-j] * read_in_hist[-j]; // [-j] only valid for Musil's double buffer structure - sum += hgamma; // convert gamma corresponding to filter order + sum += hgamma; // convert gammax corresponding to filter order my = beta / sum;// calculate mue my_err = my * err_sum; @@ -392,7 +392,7 @@ static void *n_CNLMS_tilde_new(t_symbol *s, t_int argc, t_atom *argv) t_int n_order=39, n_io=1; t_symbol *w_name; t_float beta=0.1f; - t_float gamma=0.00001f; + t_float gammax=0.00001f; t_float kappa = 1.0f; if((argc >= 6) && @@ -406,7 +406,7 @@ static void *n_CNLMS_tilde_new(t_symbol *s, t_int argc, t_atom *argv) n_io = (t_int)atom_getintarg(0, argc, argv); n_order = (t_int)atom_getintarg(1, argc, argv); beta = (t_float)atom_getfloatarg(2, argc, argv); - gamma = (t_float)atom_getfloatarg(3, argc, argv); + gammax = (t_float)atom_getfloatarg(3, argc, argv); kappa = (t_float)atom_getfloatarg(4, argc, argv); w_name = (t_symbol *)atom_getsymbolarg(5, argc, argv); @@ -415,10 +415,10 @@ static void *n_CNLMS_tilde_new(t_symbol *s, t_int argc, t_atom *argv) if(beta > 2.0f) beta = 2.0f; - if(gamma < 0.0f) - gamma = 0.0f; - if(gamma > 1.0f) - gamma = 1.0f; + if(gammax < 0.0f) + gammax = 0.0f; + if(gammax > 1.0f) + gammax = 1.0f; if(kappa < 0.0001f) kappa = 0.0001f; @@ -447,7 +447,7 @@ static void *n_CNLMS_tilde_new(t_symbol *s, t_int argc, t_atom *argv) x->x_n_order = n_order; x->x_update = 0; x->x_beta = beta; - x->x_gamma = gamma; + x->x_gamma = gammax; x->x_kappa = kappa; x->x_my_kern = (t_n_CNLMS_tilde_kern *)getbytes(x->x_n_io*sizeof(t_n_CNLMS_tilde_kern)); for(i=0; i<n_io; i++) @@ -474,7 +474,7 @@ void n_CNLMS_tilde_setup(void) n_CNLMS_tilde_class = class_new(gensym("n_CNLMS~"), (t_newmethod)n_CNLMS_tilde_new, (t_method)n_CNLMS_tilde_free, sizeof(t_n_CNLMS_tilde), 0, A_GIMME, 0); CLASS_MAINSIGNALIN(n_CNLMS_tilde_class, t_n_CNLMS_tilde, x_msi); - class_addmethod(n_CNLMS_tilde_class, (t_method)n_CNLMS_tilde_dsp, gensym("dsp"), A_CANT, 0); + class_addmethod(n_CNLMS_tilde_class, (t_method)n_CNLMS_tilde_dsp, gensym("dsp"), 0); class_addmethod(n_CNLMS_tilde_class, (t_method)n_CNLMS_tilde_update, gensym("update"), A_FLOAT, 0); // method: downsampling factor of learning (multiple of 2^N) class_addmethod(n_CNLMS_tilde_class, (t_method)n_CNLMS_tilde_beta, gensym("beta"), A_FLOAT, 0); //method: normalized learning rate class_addmethod(n_CNLMS_tilde_class, (t_method)n_CNLMS_tilde_gamma, gensym("gamma"), A_FLOAT, 0); // method: dithering noise related to signal