aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Holzmann <grholzi@users.sourceforge.net>2005-07-12 14:09:53 +0000
committerGeorg Holzmann <grholzi@users.sourceforge.net>2005-07-12 14:09:53 +0000
commitefa45f81b5dcb9609b1e2365a51b7a25a1ba2ce0 (patch)
tree8c9598e22824a77457bc4150796eb65ddc387027
parentbf408e3e5a3c657758e61519fa5698a6f1526bce (diff)
initial commit of adaptive
svn path=/trunk/externals/grh/; revision=3317
-rwxr-xr-xadaptive/doc/help-lms2~.pd232
-rwxr-xr-xadaptive/doc/help-lms~.pd179
-rwxr-xr-xadaptive/doc/help-nlms2~.pd238
-rwxr-xr-xadaptive/doc/help-nlms~.pd186
-rwxr-xr-xadaptive/examples/01.system_identification.pd318
-rwxr-xr-xadaptive/examples/02.persistent_excitation.pd396
-rwxr-xr-xadaptive/examples/03.undermodeling.pd238
-rwxr-xr-xadaptive/examples/04.misadjustment.pd475
-rwxr-xr-xadaptive/examples/05.tracking.pd791
-rwxr-xr-xadaptive/examples/06.interference_cancelation.pd323
-rwxr-xr-xadaptive/examples/07.adaptive_equalization.pd447
-rwxr-xr-xadaptive/examples/08.decision-directed_equalization.pd167
-rwxr-xr-xadaptive/examples/coef.dat12
-rwxr-xr-xadaptive/examples/spectrum~.pd243
-rwxr-xr-xadaptive/src/adaptive.c158
-rwxr-xr-xadaptive/src/adaptive.h34
-rwxr-xr-xadaptive/src/lms2~.c332
-rwxr-xr-xadaptive/src/lms~.c295
-rwxr-xr-xadaptive/src/makefile48
-rwxr-xr-xadaptive/src/makefile_mingw46
-rwxr-xr-xadaptive/src/makefile_msvc39
-rwxr-xr-xadaptive/src/nlms2~.c359
-rwxr-xr-xadaptive/src/nlms3~.c423
-rwxr-xr-xadaptive/src/nlms~.c324
24 files changed, 6303 insertions, 0 deletions
diff --git a/adaptive/doc/help-lms2~.pd b/adaptive/doc/help-lms2~.pd
new file mode 100755
index 0000000..6910a02
--- /dev/null
+++ b/adaptive/doc/help-lms2~.pd
@@ -0,0 +1,232 @@
+#N canvas 213 0 700 678 10;
+#X floatatom 37 482 8 0 0 0 - - -;
+#X obj 45 279 r message;
+#N canvas 0 0 260 260 unsig~ 0;
+#X obj 22 42 inlet~;
+#X text 62 42 ~signal_in~;
+#X obj 22 168 outlet;
+#X text 69 169 float-out;
+#X obj 22 142 snapshot~;
+#X obj 39 119 metro 300;
+#X obj 40 70 loadbang;
+#X msg 40 95 1;
+#X connect 0 0 4 0;
+#X connect 4 0 2 0;
+#X connect 5 0 4 0;
+#X connect 6 0 7 0;
+#X connect 7 0 5 0;
+#X restore 37 460 pd unsig~;
+#X text 89 219 input signal x[n];
+#X text 176 259 reference signal d[n];
+#X text 176 274 (desired signal);
+#X text 108 461 output signal y[n];
+#X text 35 166 init arg1: nr. of coefficients;
+#X text 35 179 init arg2: stepsize parameter mu;
+#X text 198 641 (c) Georg Holzmann <grh@mur.at> \, 2005;
+#X text 39 520 some more info:;
+#X obj 219 24 cnv 15 258 58 empty empty empty 10 22 0 14 -1 -66577
+0;
+#X obj 223 28 cnv 15 250 50 empty empty lms2~ 10 24 0 14 -228992 -1
+0;
+#X text 350 38 adaptive systems;
+#X text 360 54 for Pure Data;
+#X text 35 599 in the example folder !;
+#X text 35 586 For much more examples see patches;
+#X obj 38 218 sig~ 2;
+#X obj 124 258 sig~ 1;
+#X text 85 134 outputs for e[n] and c[n];
+#X floatatom 82 434 8 0 0 0 - - -;
+#N canvas 0 0 260 260 unsig~ 0;
+#X obj 22 42 inlet~;
+#X text 62 42 ~signal_in~;
+#X obj 22 168 outlet;
+#X text 69 169 float-out;
+#X obj 22 142 snapshot~;
+#X obj 39 119 metro 300;
+#X obj 40 70 loadbang;
+#X msg 40 95 1;
+#X connect 0 0 4 0;
+#X connect 4 0 2 0;
+#X connect 5 0 4 0;
+#X connect 6 0 7 0;
+#X connect 7 0 5 0;
+#X restore 82 412 pd unsig~;
+#X text 153 413 error signal e[n];
+#X obj 123 343 unpack f f;
+#X floatatom 123 383 5 0 0 0 - - -;
+#X floatatom 188 366 5 0 0 0 - - -;
+#X text 162 383 c0[n];
+#X text 230 366 c1[n];
+#X text 128 323 coefficients:;
+#X text 36 122 lms2~: same as lms~ \, but with additional;
+#X obj 37 304 lms2~ 2 1e-04;
+#N canvas 347 29 502 634 LMS_EXPLANATION 0;
+#X text 35 135 x[n] ... input signal of the system;
+#X text 35 120 c[n] ... coefficient vector of the system;
+#X text 35 104 y[n] ... output signal of the system;
+#X text 43 369 d[n] ... desired signal \, reference signal;
+#X text 50 74 -> y[n] = c0[n]*x[n] + c1[n]*x[n-1] + c2[n]*x[n-2] +
+...;
+#X text 32 195 The LMS Adaptation Algorithm:;
+#X text 70 226 c[n] = c[n-1] + mu*e[n]*x[n];
+#X text 43 309 mu ... step-size parameter (learning rate);
+#X text 42 279 c[n] ... new coefficient vector;
+#X text 42 294 c[n-1] ... old coefficient vector;
+#X text 42 325 e[n] ... error sample at time n \, LMS tries to minimize
+this error;
+#X text 43 353 x[n] ... tap-input vector at time n;
+#X text 71 241 with e[n] = d[n] - y[n];
+#X text 33 33 An adaptive system is simply a FIR filter with the coefficients
+c[n] \, which can be learned.;
+#X text 104 485 0 < mu < 2/(abs(x[n])^2);
+#X text 38 517 -> abs(x[n])^2 is the tap-input energy;
+#X text 60 532 at time n (lenght of x[n] is PDs;
+#X text 35 579 Note: this only ensures "stability on average";
+#X text 60 547 blocksize - so use block~ to change it!);
+#X text 34 432 How to choose mu ?;
+#X text 34 455 Sufficient (deterministic) stability condition:;
+#X restore 38 561 pd LMS_EXPLANATION;
+#N canvas 812 118 510 736 LMS2_EXAMPLE 0;
+#X obj 31 109 sig~ 2;
+#X obj 116 110 sig~ 1;
+#X text 36 87 x[n];
+#X text 124 91 d[n];
+#X text 31 234 y[n];
+#X obj 40 159 r \$0-lms;
+#X text 115 28 x[n] = 2 \, d[n] = 1 \, N = 1 (= nr. of coefficients)
+;
+#X text 26 29 EXAMPLE:;
+#N canvas 0 0 450 300 graph3 0;
+#X array x 1024 float 0;
+#X array y 1024 float 0;
+#X array d 1024 float 0;
+#X coords 0 2 1023 0 400 140 1;
+#X restore 51 302 graph;
+#N canvas 422 247 876 321 plot_logic 0;
+#X obj 37 162 tabwrite~ x;
+#X obj 123 162 tabwrite~ y;
+#X obj 209 162 tabwrite~ d;
+#X obj 179 77 metro 100;
+#X obj 179 26 loadbang;
+#X msg 179 52 1;
+#X obj 514 58 loadbang;
+#X obj 37 136 r~ x_;
+#X obj 123 136 r~ y_;
+#X obj 209 136 r~ d_;
+#X msg 505 153 \; x yticks 0 0.25 2;
+#X msg 489 121 \; x xticks 0 32 2;
+#X msg 646 150 \; x ylabel 1060 0 0.5 1 1.5 2;
+#X msg 622 105 \; x xlabel -0.2 0 256 512 768 1024;
+#X obj 296 102 r~ e_;
+#X obj 297 161 tabwrite~ e;
+#X obj 297 131 *~;
+#X msg 498 224 \; e xticks 0 32 2;
+#X msg 514 256 \; e yticks 0 0.25 2;
+#X msg 631 208 \; e xlabel -0.2 0 256 512 768 1024;
+#X msg 655 253 \; e ylabel 1060 0 0.5 1 1.5 2;
+#X obj 541 198 loadbang;
+#X connect 3 0 0 0;
+#X connect 3 0 1 0;
+#X connect 3 0 2 0;
+#X connect 3 0 15 0;
+#X connect 4 0 5 0;
+#X connect 5 0 3 0;
+#X connect 6 0 11 0;
+#X connect 6 0 10 0;
+#X connect 6 0 13 0;
+#X connect 6 0 12 0;
+#X connect 7 0 0 0;
+#X connect 8 0 1 0;
+#X connect 9 0 2 0;
+#X connect 14 0 16 0;
+#X connect 14 0 16 1;
+#X connect 16 0 15 0;
+#X connect 21 0 17 0;
+#X connect 21 0 18 0;
+#X connect 21 0 19 0;
+#X connect 21 0 20 0;
+#X restore 198 246 pd plot_logic;
+#X obj 341 244 s \$0-lms;
+#X msg 341 220 adaptation 1;
+#X obj 341 199 loadbang;
+#X obj 198 207 s \$0-lms;
+#X msg 198 171 mu \$1;
+#X floatatom 210 150 8 0 0 0 - - -;
+#X text 275 147 <- try different mu;
+#X msg 199 109 clear;
+#X text 242 110 <- clear to start new adaptation;
+#X text 189 461 -- 1024 samples --;
+#X obj 37 131 s~ x_;
+#X obj 125 132 s~ d_;
+#X obj 31 213 s~ y_;
+#X obj 74 213 s~ e_;
+#N canvas 0 0 450 300 graph3 0;
+#X array e 1024 float 0;
+#X coords 0 2 1023 0 400 140 1;
+#X restore 48 534 graph;
+#X text 195 693 -- 1024 samples --;
+#X text 47 510 squared error e^2[n] (learning curve):;
+#X obj 30 181 lms2~ 1 1e-05;
+#X connect 0 0 20 0;
+#X connect 0 0 27 0;
+#X connect 1 0 21 0;
+#X connect 1 0 27 1;
+#X connect 5 0 27 0;
+#X connect 11 0 10 0;
+#X connect 12 0 11 0;
+#X connect 14 0 13 0;
+#X connect 15 0 14 0;
+#X connect 17 0 13 0;
+#X connect 27 0 22 0;
+#X connect 27 1 23 0;
+#X restore 38 540 pd LMS2_EXAMPLE;
+#X msg 384 373 getmu;
+#X msg 384 352 mu \$1;
+#X floatatom 392 333 8 0 0 0 - - -;
+#X msg 384 408 getN;
+#X msg 384 497 help;
+#X msg 384 228 clear;
+#X msg 384 295 print;
+#X msg 384 465 read demo.dat;
+#X msg 384 195 getadaptation;
+#X obj 384 152 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+1;
+#X msg 384 173 adaptation \$1;
+#X msg 384 444 write demo.dat;
+#X obj 384 526 s message;
+#X text 487 173 turn adaptation on/off;
+#X text 432 222 clear current coefficients;
+#X text 432 235 and set them back to 0;
+#X text 433 294 print current coefficients;
+#X text 435 356 set/get stepsize parameter;
+#X text 436 370 mu (learning rate);
+#X text 425 408 get Nr. of coefficients;
+#X text 495 461 and mu to file;
+#X text 495 447 write/read coefficients;
+#X msg 384 264 init_unity;
+#X text 464 251 set first coefficient to 1 \,;
+#X text 466 264 all others to 0 (= delay;
+#X text 465 277 free transmission);
+#X connect 1 0 30 0;
+#X connect 2 0 0 0;
+#X connect 17 0 30 0;
+#X connect 18 0 30 1;
+#X connect 21 0 20 0;
+#X connect 23 0 24 0;
+#X connect 23 1 25 0;
+#X connect 30 0 2 0;
+#X connect 30 1 21 0;
+#X connect 30 2 23 0;
+#X connect 33 0 45 0;
+#X connect 34 0 45 0;
+#X connect 35 0 34 0;
+#X connect 36 0 45 0;
+#X connect 37 0 45 0;
+#X connect 38 0 45 0;
+#X connect 39 0 45 0;
+#X connect 40 0 45 0;
+#X connect 41 0 45 0;
+#X connect 42 0 43 0;
+#X connect 43 0 45 0;
+#X connect 44 0 45 0;
+#X connect 55 0 45 0;
diff --git a/adaptive/doc/help-lms~.pd b/adaptive/doc/help-lms~.pd
new file mode 100755
index 0000000..b16149e
--- /dev/null
+++ b/adaptive/doc/help-lms~.pd
@@ -0,0 +1,179 @@
+#N canvas 148 190 700 570 10;
+#X msg 395 341 getmu;
+#X msg 395 320 mu \$1;
+#X floatatom 403 301 8 0 0 0 - - -;
+#X msg 395 376 getN;
+#X msg 395 465 help;
+#X msg 395 196 clear;
+#X msg 395 263 print;
+#X floatatom 37 365 8 0 0 0 - - -;
+#X msg 395 433 read demo.dat;
+#X msg 395 163 getadaptation;
+#X obj 395 120 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+1;
+#X msg 395 141 adaptation \$1;
+#X msg 395 412 write demo.dat;
+#X text 36 122 LMS: least mean square adaptation algorithm;
+#X obj 45 279 r message;
+#X obj 395 494 s message;
+#N canvas 0 0 260 260 unsig~ 0;
+#X obj 22 42 inlet~;
+#X text 62 42 ~signal_in~;
+#X obj 22 168 outlet;
+#X text 69 169 float-out;
+#X obj 22 142 snapshot~;
+#X obj 39 119 metro 300;
+#X obj 40 70 loadbang;
+#X msg 40 95 1;
+#X connect 0 0 4 0;
+#X connect 4 0 2 0;
+#X connect 5 0 4 0;
+#X connect 6 0 7 0;
+#X connect 7 0 5 0;
+#X restore 37 343 pd unsig~;
+#X text 89 219 input signal x[n];
+#X text 169 248 reference signal d[n];
+#X text 169 263 (desired signal);
+#X text 108 344 output signal y[n];
+#X obj 37 304 lms~ 2 1e-04;
+#X text 35 160 init arg1: nr. of coefficients;
+#X text 498 141 turn adaptation on/off;
+#X text 443 190 clear current coefficients;
+#X text 443 203 and set them back to 0;
+#X text 444 262 print current coefficients;
+#X text 35 173 init arg2: stepsize parameter mu;
+#X text 446 324 set/get stepsize parameter;
+#X text 447 338 mu (learning rate);
+#X text 436 376 get Nr. of coefficients;
+#X text 506 429 and mu to file;
+#X text 506 415 write/read coefficients;
+#X text 223 536 (c) Georg Holzmann <grh@mur.at> \, 2005;
+#N canvas 347 29 502 634 LMS_EXPLANATION 0;
+#X text 35 135 x[n] ... input signal of the system;
+#X text 35 120 c[n] ... coefficient vector of the system;
+#X text 35 104 y[n] ... output signal of the system;
+#X text 43 369 d[n] ... desired signal \, reference signal;
+#X text 50 74 -> y[n] = c0[n]*x[n] + c1[n]*x[n-1] + c2[n]*x[n-2] +
+...;
+#X text 32 195 The LMS Adaptation Algorithm:;
+#X text 70 226 c[n] = c[n-1] + mu*e[n]*x[n];
+#X text 43 309 mu ... step-size parameter (learning rate);
+#X text 42 279 c[n] ... new coefficient vector;
+#X text 42 294 c[n-1] ... old coefficient vector;
+#X text 42 325 e[n] ... error sample at time n \, LMS tries to minimize
+this error;
+#X text 43 353 x[n] ... tap-input vector at time n;
+#X text 71 241 with e[n] = d[n] - y[n];
+#X text 33 33 An adaptive system is simply a FIR filter with the coefficients
+c[n] \, which can be learned.;
+#X text 104 485 0 < mu < 2/(abs(x[n])^2);
+#X text 38 517 -> abs(x[n])^2 is the tap-input energy;
+#X text 60 532 at time n (lenght of x[n] is PDs;
+#X text 35 579 Note: this only ensures "stability on average";
+#X text 60 547 blocksize - so use block~ to change it!);
+#X text 34 432 How to choose mu ?;
+#X text 34 455 Sufficient (deterministic) stability condition:;
+#X restore 38 429 pd LMS_EXPLANATION;
+#X text 36 407 some more info:;
+#N canvas 536 326 510 502 LMS_EXAMPLE 0;
+#X obj 31 109 sig~ 2;
+#X obj 108 109 sig~ 1;
+#X text 36 87 x[n];
+#X text 116 90 d[n];
+#X text 31 234 y[n];
+#X obj 40 159 r \$0-lms;
+#X text 115 28 x[n] = 2 \, d[n] = 1 \, N = 1 (= nr. of coefficients)
+;
+#X text 26 29 EXAMPLE:;
+#N canvas 0 0 450 300 graph3 0;
+#X array x 1024 float 0;
+#X array y 1024 float 0;
+#X array d 1024 float 0;
+#X coords 0 2 1023 0 400 140 1;
+#X restore 51 302 graph;
+#N canvas 422 247 725 220 plot_logic 0;
+#X obj 72 168 tabwrite~ x;
+#X obj 158 168 tabwrite~ y;
+#X obj 244 168 tabwrite~ d;
+#X obj 191 105 metro 100;
+#X obj 191 54 loadbang;
+#X msg 191 80 1;
+#X obj 386 57 loadbang;
+#X obj 72 142 r~ x_;
+#X obj 158 142 r~ y_;
+#X obj 244 142 r~ d_;
+#X msg 362 153 \; x yticks 0 0.25 2;
+#X msg 346 121 \; x xticks 0 32 2;
+#X msg 503 150 \; x ylabel 1060 0 0.5 1 1.5 2;
+#X msg 479 105 \; x xlabel -0.2 0 256 512 768 1024;
+#X connect 3 0 0 0;
+#X connect 3 0 1 0;
+#X connect 3 0 2 0;
+#X connect 4 0 5 0;
+#X connect 5 0 3 0;
+#X connect 6 0 11 0;
+#X connect 6 0 10 0;
+#X connect 6 0 13 0;
+#X connect 6 0 12 0;
+#X connect 7 0 0 0;
+#X connect 8 0 1 0;
+#X connect 9 0 2 0;
+#X restore 198 246 pd plot_logic;
+#X obj 341 244 s \$0-lms;
+#X msg 341 220 adaptation 1;
+#X obj 341 199 loadbang;
+#X obj 198 207 s \$0-lms;
+#X msg 198 171 mu \$1;
+#X floatatom 210 150 8 0 0 0 - - -;
+#X text 275 147 <- try different mu;
+#X msg 199 109 clear;
+#X text 242 110 <- clear to start new adaptation;
+#X obj 30 181 lms~ 1 1e-05;
+#X text 189 461 -- 1024 samples --;
+#X obj 37 131 s~ x_;
+#X obj 117 131 s~ d_;
+#X obj 31 213 s~ y_;
+#X connect 0 0 19 0;
+#X connect 0 0 21 0;
+#X connect 1 0 19 1;
+#X connect 1 0 22 0;
+#X connect 5 0 19 0;
+#X connect 11 0 10 0;
+#X connect 12 0 11 0;
+#X connect 14 0 13 0;
+#X connect 15 0 14 0;
+#X connect 17 0 13 0;
+#X connect 19 0 23 0;
+#X restore 38 451 pd LMS_EXAMPLE;
+#X obj 219 24 cnv 15 258 58 empty empty empty 10 22 0 14 -1 -66577
+0;
+#X obj 223 28 cnv 15 250 50 empty empty lms~ 10 24 0 14 -228992 -1
+0;
+#X text 350 38 adaptive systems;
+#X text 360 54 for Pure Data;
+#X text 34 488 in the example folder !;
+#X text 35 474 For much more examples see patches;
+#X obj 38 218 sig~ 2;
+#X obj 117 247 sig~ 1;
+#X msg 395 232 init_unity;
+#X text 475 219 set first coefficient to 1 \,;
+#X text 477 232 all others to 0 (= delay;
+#X text 476 245 free transmission);
+#X connect 0 0 15 0;
+#X connect 1 0 15 0;
+#X connect 2 0 1 0;
+#X connect 3 0 15 0;
+#X connect 4 0 15 0;
+#X connect 5 0 15 0;
+#X connect 6 0 15 0;
+#X connect 8 0 15 0;
+#X connect 9 0 15 0;
+#X connect 10 0 11 0;
+#X connect 11 0 15 0;
+#X connect 12 0 15 0;
+#X connect 14 0 21 0;
+#X connect 16 0 7 0;
+#X connect 21 0 16 0;
+#X connect 43 0 21 0;
+#X connect 44 0 21 1;
+#X connect 45 0 15 0;
diff --git a/adaptive/doc/help-nlms2~.pd b/adaptive/doc/help-nlms2~.pd
new file mode 100755
index 0000000..ea103ba
--- /dev/null
+++ b/adaptive/doc/help-nlms2~.pd
@@ -0,0 +1,238 @@
+#N canvas 108 136 700 678 10;
+#X floatatom 37 482 8 0 0 0 - - -;
+#X obj 45 279 r message;
+#N canvas 0 0 260 260 unsig~ 0;
+#X obj 22 42 inlet~;
+#X text 62 42 ~signal_in~;
+#X obj 22 168 outlet;
+#X text 69 169 float-out;
+#X obj 22 142 snapshot~;
+#X obj 39 119 metro 300;
+#X obj 40 70 loadbang;
+#X msg 40 95 1;
+#X connect 0 0 4 0;
+#X connect 4 0 2 0;
+#X connect 5 0 4 0;
+#X connect 6 0 7 0;
+#X connect 7 0 5 0;
+#X restore 37 460 pd unsig~;
+#X text 89 219 input signal x[n];
+#X text 182 252 reference signal d[n];
+#X text 182 267 (desired signal);
+#X text 108 461 output signal y[n];
+#X text 35 166 init arg1: nr. of coefficients;
+#X text 35 179 init arg2: stepsize parameter mu;
+#X text 221 646 (c) Georg Holzmann <grh@mur.at> \, 2005;
+#X text 39 520 some more info:;
+#X obj 219 24 cnv 15 258 58 empty empty empty 10 22 0 14 -1 -66577
+0;
+#X obj 223 28 cnv 15 250 50 empty empty nlms2~ 10 24 0 14 -228992 -1
+0;
+#X text 350 38 adaptive systems;
+#X text 360 54 for Pure Data;
+#X text 35 599 in the example folder !;
+#X text 35 586 For much more examples see patches;
+#X obj 38 218 sig~ 2;
+#X obj 130 251 sig~ 1;
+#X text 93 134 outputs for e[n] and c[n];
+#X floatatom 82 434 8 0 0 0 - - -;
+#N canvas 0 0 260 260 unsig~ 0;
+#X obj 22 42 inlet~;
+#X text 62 42 ~signal_in~;
+#X obj 22 168 outlet;
+#X text 69 169 float-out;
+#X obj 22 142 snapshot~;
+#X obj 39 119 metro 300;
+#X obj 40 70 loadbang;
+#X msg 40 95 1;
+#X connect 0 0 4 0;
+#X connect 4 0 2 0;
+#X connect 5 0 4 0;
+#X connect 6 0 7 0;
+#X connect 7 0 5 0;
+#X restore 82 412 pd unsig~;
+#X text 153 413 error signal e[n];
+#X obj 130 342 unpack f f;
+#X floatatom 130 382 5 0 0 0 - - -;
+#X floatatom 195 365 5 0 0 0 - - -;
+#X text 169 382 c0[n];
+#X text 237 365 c1[n];
+#X text 135 322 coefficients:;
+#X text 36 122 nlms2~: same as nlms~ \, but with additional;
+#X obj 37 304 nlms2~ 2 0.001;
+#N canvas 812 118 510 736 NLMS2_EXAMPLE 0;
+#X obj 31 109 sig~ 2;
+#X obj 123 108 sig~ 1;
+#X text 36 87 x[n];
+#X text 131 89 d[n];
+#X text 31 234 y[n];
+#X obj 40 159 r \$0-lms;
+#X text 115 28 x[n] = 2 \, d[n] = 1 \, N = 1 (= nr. of coefficients)
+;
+#X text 26 29 EXAMPLE:;
+#N canvas 0 0 450 300 graph3 0;
+#X array x 1024 float 0;
+#X array y 1024 float 0;
+#X array d 1024 float 0;
+#X coords 0 2 1023 0 400 140 1;
+#X restore 51 302 graph;
+#N canvas 422 247 876 321 plot_logic 0;
+#X obj 37 162 tabwrite~ x;
+#X obj 123 162 tabwrite~ y;
+#X obj 209 162 tabwrite~ d;
+#X obj 179 77 metro 100;
+#X obj 179 26 loadbang;
+#X msg 179 52 1;
+#X obj 514 58 loadbang;
+#X obj 37 136 r~ x_;
+#X obj 123 136 r~ y_;
+#X obj 209 136 r~ d_;
+#X msg 505 153 \; x yticks 0 0.25 2;
+#X msg 489 121 \; x xticks 0 32 2;
+#X msg 646 150 \; x ylabel 1060 0 0.5 1 1.5 2;
+#X msg 622 105 \; x xlabel -0.2 0 256 512 768 1024;
+#X obj 296 102 r~ e_;
+#X obj 297 161 tabwrite~ e;
+#X obj 297 131 *~;
+#X msg 498 224 \; e xticks 0 32 2;
+#X msg 514 256 \; e yticks 0 0.25 2;
+#X msg 631 208 \; e xlabel -0.2 0 256 512 768 1024;
+#X msg 655 253 \; e ylabel 1060 0 0.5 1 1.5 2;
+#X obj 541 198 loadbang;
+#X connect 3 0 0 0;
+#X connect 3 0 1 0;
+#X connect 3 0 2 0;
+#X connect 3 0 15 0;
+#X connect 4 0 5 0;
+#X connect 5 0 3 0;
+#X connect 6 0 11 0;
+#X connect 6 0 10 0;
+#X connect 6 0 13 0;
+#X connect 6 0 12 0;
+#X connect 7 0 0 0;
+#X connect 8 0 1 0;
+#X connect 9 0 2 0;
+#X connect 14 0 16 0;
+#X connect 14 0 16 1;
+#X connect 16 0 15 0;
+#X connect 21 0 17 0;
+#X connect 21 0 18 0;
+#X connect 21 0 19 0;
+#X connect 21 0 20 0;
+#X restore 198 246 pd plot_logic;
+#X obj 341 244 s \$0-lms;
+#X msg 341 220 adaptation 1;
+#X obj 341 199 loadbang;
+#X obj 198 207 s \$0-lms;
+#X msg 198 171 mu \$1;
+#X floatatom 210 150 8 0 0 0 - - -;
+#X text 275 147 <- try different mu;
+#X msg 199 109 clear;
+#X text 242 110 <- clear to start new adaptation;
+#X text 189 461 -- 1024 samples --;
+#X obj 37 131 s~ x_;
+#X obj 132 130 s~ d_;
+#X obj 31 213 s~ y_;
+#X obj 76 213 s~ e_;
+#N canvas 0 0 450 300 graph3 0;
+#X array e 1024 float 0;
+#X coords 0 2 1023 0 400 140 1;
+#X restore 48 534 graph;
+#X text 195 693 -- 1024 samples --;
+#X text 47 510 squared error e^2[n] (learning curve):;
+#X obj 30 181 nlms2~ 1 0.001;
+#X connect 0 0 20 0;
+#X connect 0 0 27 0;
+#X connect 1 0 21 0;
+#X connect 1 0 27 1;
+#X connect 5 0 27 0;
+#X connect 11 0 10 0;
+#X connect 12 0 11 0;
+#X connect 14 0 13 0;
+#X connect 15 0 14 0;
+#X connect 17 0 13 0;
+#X connect 27 0 22 0;
+#X connect 27 1 23 0;
+#X restore 38 540 pd NLMS2_EXAMPLE;
+#N canvas 347 29 502 539 NLMS_EXPLANATION 0;
+#X text 35 135 x[n] ... input signal of the system;
+#X text 35 120 c[n] ... coefficient vector of the system;
+#X text 35 104 y[n] ... output signal of the system;
+#X text 35 398 d[n] ... desired signal \, reference signal;
+#X text 50 74 -> y[n] = c0[n]*x[n] + c1[n]*x[n-1] + c2[n]*x[n-2] +
+...;
+#X text 35 312 mu ... step-size parameter (learning rate);
+#X text 34 282 c[n] ... new coefficient vector;
+#X text 34 297 c[n-1] ... old coefficient vector;
+#X text 34 354 e[n] ... error sample at time n \, LMS tries to minimize
+this error;
+#X text 35 382 x[n] ... tap-input vector at time n;
+#X text 71 241 with e[n] = d[n] - y[n];
+#X text 33 33 An adaptive system is simply a FIR filter with the coefficients
+c[n] \, which can be learned.;
+#X text 36 440 How to choose mu ?;
+#X text 36 463 Sufficient (deterministic) stability condition:;
+#X text 32 195 The normalized LMS Adaptation Algorithm:;
+#X text 70 226 c[n] = c[n-1] + mu/(alpha+abs(x[n])^2) *e[n]*x[n];
+#X text 34 327 alpha ... a small positive constant \, only to avoid
+division by zero;
+#X text 152 490 0 < mu < 2;
+#X restore 38 561 pd NLMS_EXPLANATION;
+#X msg 387 352 getmu;
+#X msg 387 331 mu \$1;
+#X floatatom 395 312 8 0 0 0 - - -;
+#X msg 387 460 getN;
+#X msg 387 549 help;
+#X msg 387 209 clear;
+#X msg 387 276 print;
+#X msg 387 517 read demo.dat;
+#X msg 387 173 getadaptation;
+#X obj 387 130 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+1;
+#X msg 387 151 adaptation \$1;
+#X msg 387 496 write demo.dat;
+#X obj 387 578 s message;
+#X text 490 151 turn adaptation on/off;
+#X text 435 203 clear current coefficients;
+#X text 435 216 and set them back to 0;
+#X text 436 275 print current coefficients;
+#X text 438 335 set/get stepsize parameter;
+#X text 439 349 mu (learning rate);
+#X text 428 460 get Nr. of coefficients;
+#X text 498 513 and mu to file;
+#X text 498 499 write/read coefficients;
+#X floatatom 395 382 8 0 0 0 - - -;
+#X msg 387 401 alpha \$1;
+#X msg 387 422 getalpha;
+#X text 456 403 set/get alpha (normally;
+#X text 457 417 you don't need that);
+#X msg 387 246 init_unity;
+#X text 467 233 set first coefficient to 1 \,;
+#X text 469 246 all others to 0 (= delay;
+#X text 468 259 free transmission);
+#X connect 1 0 30 0;
+#X connect 2 0 0 0;
+#X connect 17 0 30 0;
+#X connect 18 0 30 1;
+#X connect 21 0 20 0;
+#X connect 23 0 24 0;
+#X connect 23 1 25 0;
+#X connect 30 0 2 0;
+#X connect 30 1 21 0;
+#X connect 30 2 23 0;
+#X connect 33 0 45 0;
+#X connect 34 0 45 0;
+#X connect 35 0 34 0;
+#X connect 36 0 45 0;
+#X connect 37 0 45 0;
+#X connect 38 0 45 0;
+#X connect 39 0 45 0;
+#X connect 40 0 45 0;
+#X connect 41 0 45 0;
+#X connect 42 0 43 0;
+#X connect 43 0 45 0;
+#X connect 44 0 45 0;
+#X connect 55 0 56 0;
+#X connect 56 0 45 0;
+#X connect 57 0 45 0;
+#X connect 60 0 45 0;
diff --git a/adaptive/doc/help-nlms~.pd b/adaptive/doc/help-nlms~.pd
new file mode 100755
index 0000000..d58ef68
--- /dev/null
+++ b/adaptive/doc/help-nlms~.pd
@@ -0,0 +1,186 @@
+#N canvas 0 0 700 667 10;
+#X msg 395 342 getmu;
+#X msg 395 321 mu \$1;
+#X floatatom 403 302 8 0 0 0 - - -;
+#X msg 395 450 getN;
+#X msg 395 539 help;
+#X msg 395 199 clear;
+#X msg 395 266 print;
+#X floatatom 37 406 8 0 0 0 - - -;
+#X msg 395 507 read demo.dat;
+#X msg 395 163 getadaptation;
+#X obj 395 120 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+1;
+#X msg 395 141 adaptation \$1;
+#X msg 395 486 write demo.dat;
+#X obj 45 320 r message;
+#X obj 395 568 s message;
+#N canvas 0 0 260 260 unsig~ 0;
+#X obj 22 42 inlet~;
+#X text 62 42 ~signal_in~;
+#X obj 22 168 outlet;
+#X text 69 169 float-out;
+#X obj 22 142 snapshot~;
+#X obj 39 119 metro 300;
+#X obj 40 70 loadbang;
+#X msg 40 95 1;
+#X connect 0 0 4 0;
+#X connect 4 0 2 0;
+#X connect 5 0 4 0;
+#X connect 6 0 7 0;
+#X connect 7 0 5 0;
+#X restore 37 384 pd unsig~;
+#X text 89 260 input signal x[n];
+#X text 177 287 reference signal d[n];
+#X text 177 302 (desired signal);
+#X text 108 385 output signal y[n];
+#X text 35 172 init arg1: nr. of coefficients;
+#X text 498 141 turn adaptation on/off;
+#X text 443 193 clear current coefficients;
+#X text 443 206 and set them back to 0;
+#X text 444 265 print current coefficients;
+#X text 35 185 init arg2: stepsize parameter mu;
+#X text 446 325 set/get stepsize parameter;
+#X text 447 339 mu (learning rate);
+#X text 436 450 get Nr. of coefficients;
+#X text 506 503 and mu to file;
+#X text 506 489 write/read coefficients;
+#X text 206 622 (c) Georg Holzmann <grh@mur.at> \, 2005;
+#X text 36 481 some more info:;
+#X obj 219 24 cnv 15 258 58 empty empty empty 10 22 0 14 -1 -66577
+0;
+#X obj 223 28 cnv 15 250 50 empty empty nlms~ 10 24 0 14 -228992 -1
+0;
+#X text 350 38 adaptive systems;
+#X text 360 54 for Pure Data;
+#X text 34 562 in the example folder !;
+#X text 35 548 For much more examples see patches;
+#X obj 38 259 sig~ 2;
+#X obj 125 286 sig~ 1;
+#X text 36 134 Normalized LMS: normalized least mean square;
+#X text 146 147 adaptation algorithm;
+#N canvas 347 29 502 539 NLMS_EXPLANATION 0;
+#X text 35 135 x[n] ... input signal of the system;
+#X text 35 120 c[n] ... coefficient vector of the system;
+#X text 35 104 y[n] ... output signal of the system;
+#X text 35 398 d[n] ... desired signal \, reference signal;
+#X text 50 74 -> y[n] = c0[n]*x[n] + c1[n]*x[n-1] + c2[n]*x[n-2] +
+...;
+#X text 35 312 mu ... step-size parameter (learning rate);
+#X text 34 282 c[n] ... new coefficient vector;
+#X text 34 297 c[n-1] ... old coefficient vector;
+#X text 34 354 e[n] ... error sample at time n \, LMS tries to minimize
+this error;
+#X text 35 382 x[n] ... tap-input vector at time n;
+#X text 71 241 with e[n] = d[n] - y[n];
+#X text 33 33 An adaptive system is simply a FIR filter with the coefficients
+c[n] \, which can be learned.;
+#X text 36 440 How to choose mu ?;
+#X text 36 463 Sufficient (deterministic) stability condition:;
+#X text 32 195 The normalized LMS Adaptation Algorithm:;
+#X text 70 226 c[n] = c[n-1] + mu/(alpha+abs(x[n])^2) *e[n]*x[n];
+#X text 34 327 alpha ... a small positive constant \, only to avoid
+division by zero;
+#X text 152 490 0 < mu < 2;
+#X restore 38 503 pd NLMS_EXPLANATION;
+#N canvas 536 326 510 502 NLMS_EXAMPLE 0;
+#X obj 31 109 sig~ 2;
+#X obj 116 111 sig~ 1;
+#X text 36 87 x[n];
+#X text 124 92 d[n];
+#X text 31 234 y[n];
+#X text 115 28 x[n] = 2 \, d[n] = 1 \, N = 1 (= nr. of coefficients)
+;
+#X text 26 29 EXAMPLE:;
+#N canvas 0 0 450 300 graph3 0;
+#X array x 1024 float 0;
+#X array y 1024 float 0;
+#X array d 1024 float 0;
+#X coords 0 2 1023 0 400 140 1;
+#X restore 51 302 graph;
+#N canvas 422 247 725 220 plot_logic 0;
+#X obj 72 168 tabwrite~ x;
+#X obj 158 168 tabwrite~ y;
+#X obj 244 168 tabwrite~ d;
+#X obj 191 105 metro 100;
+#X obj 191 54 loadbang;
+#X msg 191 80 1;
+#X obj 386 57 loadbang;
+#X obj 72 142 r~ x_;
+#X obj 158 142 r~ y_;
+#X obj 244 142 r~ d_;
+#X msg 362 153 \; x yticks 0 0.25 2;
+#X msg 346 121 \; x xticks 0 32 2;
+#X msg 503 150 \; x ylabel 1060 0 0.5 1 1.5 2;
+#X msg 479 105 \; x xlabel -0.2 0 256 512 768 1024;
+#X connect 3 0 0 0;
+#X connect 3 0 1 0;
+#X connect 3 0 2 0;
+#X connect 4 0 5 0;
+#X connect 5 0 3 0;
+#X connect 6 0 11 0;
+#X connect 6 0 10 0;
+#X connect 6 0 13 0;
+#X connect 6 0 12 0;
+#X connect 7 0 0 0;
+#X connect 8 0 1 0;
+#X connect 9 0 2 0;
+#X restore 198 246 pd plot_logic;
+#X msg 341 220 adaptation 1;
+#X obj 341 199 loadbang;
+#X msg 198 171 mu \$1;
+#X floatatom 210 150 8 0 0 0 - - -;
+#X text 275 147 <- try different mu;
+#X msg 199 109 clear;
+#X text 242 110 <- clear to start new adaptation;
+#X text 189 461 -- 1024 samples --;
+#X obj 37 131 s~ x_;
+#X obj 125 133 s~ d_;
+#X obj 31 213 s~ y_;
+#X obj 40 159 r \$0-nlms;
+#X obj 198 207 s \$0-nlms;
+#X obj 341 244 s \$0-nlms;
+#X obj 30 181 nlms~ 1 0.001;
+#X connect 0 0 17 0;
+#X connect 0 0 23 0;
+#X connect 1 0 18 0;
+#X connect 1 0 23 1;
+#X connect 9 0 22 0;
+#X connect 10 0 9 0;
+#X connect 11 0 21 0;
+#X connect 12 0 11 0;
+#X connect 14 0 21 0;
+#X connect 20 0 23 0;
+#X connect 23 0 19 0;
+#X restore 38 525 pd NLMS_EXAMPLE;
+#X floatatom 403 372 8 0 0 0 - - -;
+#X msg 395 391 alpha \$1;
+#X msg 395 412 getalpha;
+#X text 464 393 set/get alpha (normally;
+#X text 465 407 you don't need that);
+#X obj 38 345 nlms~ 2 0.001;
+#X msg 395 236 init_unity;
+#X text 475 223 set first coefficient to 1 \,;
+#X text 477 236 all others to 0 (= delay;
+#X text 476 249 free transmission);
+#X connect 0 0 14 0;
+#X connect 1 0 14 0;
+#X connect 2 0 1 0;
+#X connect 3 0 14 0;
+#X connect 4 0 14 0;
+#X connect 5 0 14 0;
+#X connect 6 0 14 0;
+#X connect 8 0 14 0;
+#X connect 9 0 14 0;
+#X connect 10 0 11 0;
+#X connect 11 0 14 0;
+#X connect 12 0 14 0;
+#X connect 13 0 50 0;
+#X connect 15 0 7 0;
+#X connect 39 0 50 0;
+#X connect 40 0 50 1;
+#X connect 45 0 46 0;
+#X connect 46 0 14 0;
+#X connect 47 0 14 0;
+#X connect 50 0 15 0;
+#X connect 51 0 14 0;
diff --git a/adaptive/examples/01.system_identification.pd b/adaptive/examples/01.system_identification.pd
new file mode 100755
index 0000000..57ae99f
--- /dev/null
+++ b/adaptive/examples/01.system_identification.pd
@@ -0,0 +1,318 @@
+#N canvas 0 68 891 823 10;
+#N canvas 10 567 633 314 unknown_system~ 0;
+#X obj 26 26 inlet~;
+#X obj 26 268 outlet~;
+#X obj 115 227 s~ unknown_signal;
+#X text 116 249 (for visualization);
+#X obj 26 113 fexpr~ $f2*$x1 + $f3*$x1[-1] + $f4*$x1[-2];
+#X obj 122 81 f 0.33;
+#X obj 218 81 f 0.33;
+#X obj 315 82 f 0.33;
+#X obj 122 53 r a0;
+#X obj 218 55 r a1;
+#X obj 315 56 r a2;
+#X connect 0 0 4 0;
+#X connect 4 0 1 0;
+#X connect 4 0 2 0;
+#X connect 5 0 4 1;
+#X connect 6 0 4 2;
+#X connect 7 0 4 3;
+#X connect 8 0 5 0;
+#X connect 9 0 6 0;
+#X connect 10 0 7 0;
+#X restore 245 268 pd unknown_system~;
+#X obj 305 434 tgl 20 0 audio_io empty empty 0 -6 0 8 -262144 -1 -1
+0 1;
+#X text 330 436 <- Audio IO;
+#N canvas 523 194 390 347 adaptive_filter~ 0;
+#X obj 37 35 inlet~;
+#X text 22 15 input signal;
+#X obj 143 35 inlet~;
+#X text 122 15 desired signal;
+#X obj 36 291 outlet~;
+#X msg 249 63 adaptation 1;
+#X obj 249 42 loadbang;
+#X obj 224 214 s~ adaptive_signal;
+#X text 224 234 (for visualization);
+#X obj 249 141 r clear;
+#X msg 248 162 clear;
+#X obj 37 156 lms2~ 3 0.01;
+#X obj 116 265 unpack f f f;
+#X obj 116 293 outlet;
+#X obj 162 293 outlet;
+#X obj 208 293 outlet;
+#X obj 249 94 r mu;
+#X msg 249 116 mu \$1;
+#X connect 0 0 11 0;
+#X connect 2 0 11 1;
+#X connect 5 0 11 0;
+#X connect 6 0 5 0;
+#X connect 9 0 10 0;
+#X connect 10 0 11 0;
+#X connect 11 0 4 0;
+#X connect 11 0 7 0;
+#X connect 11 2 12 0;
+#X connect 12 0 13 0;
+#X connect 12 1 14 0;
+#X connect 12 2 15 0;
+#X connect 16 0 17 0;
+#X connect 17 0 11 0;
+#X restore 117 337 pd adaptive_filter~;
+#X obj 524 255 spectrum~;
+#N canvas 0 0 450 300 graph6 0;
+#X array adapt 512 float 0;
+#X coords 0 1 511 -1 200 140 1;
+#X restore 656 625 graph;
+#X text 700 769 -- 512 samples ---;
+#X obj 46 438 tgl 20 0 scopes_on empty empty 0 -6 0 8 -262144 -1 -1
+0 1;
+#X obj 524 238 r~ adaptive_signal;
+#X text 125 241 x[n];
+#X text 256 300 d[n];
+#X text 107 356 y[n];
+#X obj 775 238 r scopes_on;
+#X obj 775 26 r scopes_on;
+#X obj 524 26 r~ unknown_signal;
+#N canvas 0 0 450 300 graph6 0;
+#X array unkn 512 float 0;
+#X coords 0 1 511 -1 200 140 1;
+#X restore 654 453 graph;
+#X text 698 597 -- 512 samples ---;
+#X text 76 438 <- Visualization IO;
+#X text 481 137 (1);
+#X text 481 338 (2);
+#N canvas 452 215 456 231 scope_stuff 0;
+#X obj 45 38 r~ adaptive_signal;
+#X obj 83 63 r scopes_on;
+#X obj 279 69 r scopes_on;
+#X obj 241 44 r~ unknown_signal;
+#X obj 83 96 metro 1000;
+#X obj 44 139 tabwrite~ adapt;
+#X obj 279 95 metro 1000;
+#X obj 240 138 tabwrite~ unkn;
+#X connect 0 0 5 0;
+#X connect 1 0 4 0;
+#X connect 2 0 6 0;
+#X connect 3 0 7 0;
+#X connect 4 0 5 0;
+#X connect 6 0 7 0;
+#X restore 755 795 pd scope_stuff;
+#X text 582 510 (3);
+#X text 581 686 (4);
+#X text 86 760 (3) d[n] in time domain;
+#X text 86 777 (4) y[n] in time domain;
+#X text 86 742 (2) amplitude of the output signal y[n];
+#X text 86 711 (1) amplitude of the desired signal d[n] (= output of
+the unknown system);
+#X obj 84 599 bng 20 250 50 0 clear empty empty 0 -6 0 8 -262144 -1
+-1;
+#X text 113 601 <- clear coefficients \, so adaptation will start again
+;
+#X floatatom 46 471 5 0 100 0 - init_tlp tlp;
+#X obj 685 26 r tlp;
+#X obj 685 238 r tlp;
+#X text 90 469 <- temporal lowpass for spectrum view (0...100);
+#X text 54 689 VISUALIZATIONS:;
+#X text 42 522 unknown system:;
+#X text 72 546 d[n] =;
+#X floatatom 159 378 5 0 0 1 c0 - -;
+#X floatatom 223 378 5 0 0 1 c1 - -;
+#X floatatom 285 378 5 0 0 1 c2 - -;
+#X text 40 578 adaptive filter:;
+#X floatatom 84 627 8 0 0 0 - mur mu;
+#X text 146 627 <- step size parameter mu (learning rate);
+#N canvas 215 124 617 210 init 0;
+#X msg 43 99 2;
+#X obj 269 45 loadbang;
+#X obj 43 122 s init_tlp;
+#X msg 138 98 0.33;
+#X msg 179 99 0.33;
+#X msg 223 100 0.33;
+#X obj 138 121 s a0r;
+#X obj 178 122 s a1r;
+#X obj 223 123 s a2r;
+#X obj 295 123 s mur;
+#X msg 294 99 0.01;
+#X msg 515 103 \; pd dsp \$1;
+#X obj 515 78 r audio_io;
+#X obj 381 123 s signalr;
+#X msg 380 98 0;
+#X connect 0 0 2 0;
+#X connect 1 0 0 0;
+#X connect 1 0 3 0;
+#X connect 1 0 4 0;
+#X connect 1 0 5 0;
+#X connect 1 0 10 0;
+#X connect 1 0 14 0;
+#X connect 3 0 6 0;
+#X connect 4 0 7 0;
+#X connect 5 0 8 0;
+#X connect 10 0 9 0;
+#X connect 12 0 11 0;
+#X connect 14 0 13 0;
+#X restore 699 795 pd init;
+#X floatatom 125 547 4 0 1 0 - a0r a0;
+#X text 158 547 x[n] +;
+#X text 244 547 x[n-1] +;
+#X floatatom 211 547 4 0 1 0 - a1r a1;
+#X floatatom 312 548 4 0 1 0 - a2r a2;
+#X text 345 549 x[n-2];
+#N canvas 425 56 479 415 PROBLEM_DESCRIPTION 0;
+#X text 33 89 In this example the adaptive filter tries to identify
+an unknown system.;
+#X text 34 124 The unknown system is a FIR filter of order 3 and the
+adaptive system is an adaptive transversal filter using the LMS algorithm
+(see lms~ help-patch) with 3 coefficients.;
+#X text 75 224 d[n] = h0*x[n] + h1*x[n-1] + h2*x[n-2];
+#X text 35 188 unknown system:;
+#X text 74 209 FIR Filter \, order = 3;
+#X text 35 259 adaptive system:;
+#X text 77 278 LMS \, 3 coefficients (c0 \, c1 \, c2);
+#X text 35 342 The System Identification problem is sucessfull \, if
+c0=h0 \, c1=h1 and c2=h2. Then the unknown and the adaptive system
+have the same behavior.;
+#X text 60 40 SYSTEM IDENTIFICATION IN A NOISE FREE ENVIRONMENT;
+#X text 77 292 step-size parameter mu;
+#X restore 34 94 pd PROBLEM_DESCRIPTION;
+#N canvas 298 58 425 643 OBSERVATIONS 0;
+#X text 24 20 OBSERVATIONS;
+#X obj 27 119 bng 20 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#N canvas 863 469 389 255 mu1 0;
+#X obj 20 14 inlet;
+#X obj 20 68 s signalr;
+#X msg 20 47 0;
+#X obj 20 111 s clear;
+#X obj 20 179 s mur;
+#X msg 20 158 0.5;
+#X connect 0 0 2 0;
+#X connect 0 0 3 0;
+#X connect 0 0 5 0;
+#X connect 2 0 1 0;
+#X connect 5 0 4 0;
+#X restore 27 143 pd mu1;
+#X text 26 95 e.g. mu = 0.5:;
+#X obj 29 201 bng 20 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X text 26 179 e.g. mu = 1e-05:;
+#X text 25 59 1) influenc of mu:;
+#X text 84 119 -> very fast adaptation \, but c0 \, c1 \, c2;
+#X text 104 134 are not so precise;
+#X text 83 201 -> slower adaptation \, but very precise;
+#X text 27 430 2) influenc of white vs. non-white input signal:;
+#X obj 30 490 bng 20 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#N canvas 863 469 389 255 mu2 0;
+#X obj 20 14 inlet;
+#X obj 20 68 s signalr;
+#X msg 20 47 0;
+#X obj 20 111 s clear;
+#X obj 20 179 s mur;
+#X msg 20 158 1e-05;
+#X connect 0 0 2 0;
+#X connect 0 0 3 0;
+#X connect 0 0 5 0;
+#X connect 2 0 1 0;
+#X connect 5 0 4 0;
+#X restore 29 225 pd mu2;
+#N canvas 863 469 389 255 in1 0;
+#X obj 20 14 inlet;
+#X obj 20 68 s signalr;
+#X msg 20 47 0;
+#X obj 20 111 s clear;
+#X obj 20 179 s mur;
+#X msg 20 158 0.001;
+#X connect 0 0 2 0;
+#X connect 0 0 3 0;
+#X connect 0 0 5 0;
+#X connect 2 0 1 0;
+#X connect 5 0 4 0;
+#X restore 30 514 pd in1;
+#X obj 32 570 bng 20 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#N canvas 863 469 389 255 in2 0;
+#X obj 20 14 inlet;
+#X obj 20 68 s signalr;
+#X obj 20 111 s clear;
+#X obj 20 179 s mur;
+#X msg 20 47 1;
+#X msg 20 158 0.001;
+#X connect 0 0 4 0;
+#X connect 0 0 2 0;
+#X connect 0 0 5 0;
+#X connect 4 0 1 0;
+#X connect 5 0 3 0;
+#X restore 32 594 pd in2;
+#X text 28 469 white signal:;
+#X text 30 550 non-white signal:;
+#X text 87 569 -> c0 \, c1 \, c2 not precise;
+#X text 90 489 -> c0 \, c1 \, c2 precise;
+#X text 29 274 how to choose mu ?;
+#X text 72 300 0 < mu < 2/(abs(x[n])^2);
+#X text 72 321 -> abs(x[n])^2 is the tap-input energy;
+#X text 94 336 at time n (lenght of x[n] is PDs;
+#X text 46 373 Note: this only ensures "stability on average";
+#X text 94 351 blocksize - so use block~ to change it!);
+#X connect 1 0 2 0;
+#X connect 4 0 12 0;
+#X connect 11 0 13 0;
+#X connect 14 0 15 0;
+#X restore 34 120 pd OBSERVATIONS;
+#X text 33 73 ReadMe:;
+#N canvas 0 0 642 300 input_signal~ 0;
+#X obj 77 90 noise~;
+#X obj 201 84 inlet;
+#X obj 77 217 *~;
+#X obj 210 273 outlet~;
+#X obj 201 115 sel 0 1;
+#X msg 91 190 1;
+#X msg 121 190 0;
+#X obj 325 88 noise~;
+#X text 53 64 white signal:;
+#X text 292 63 non white signal:;
+#X obj 322 224 *~;
+#X msg 336 197 1;
+#X msg 366 197 0;
+#X obj 324 112 hip~ 300;
+#X obj 492 148 bp~ 2543 2;
+#X obj 406 149 bp~ 1000 3;
+#X obj 323 148 bp~ 100 2;
+#X connect 0 0 2 0;
+#X connect 1 0 4 0;
+#X connect 2 0 3 0;
+#X connect 4 0 5 0;
+#X connect 4 0 12 0;
+#X connect 4 1 6 0;
+#X connect 4 1 11 0;
+#X connect 5 0 2 1;
+#X connect 6 0 2 1;
+#X connect 7 0 13 0;
+#X connect 10 0 3 0;
+#X connect 11 0 10 1;
+#X connect 12 0 10 1;
+#X connect 13 0 14 0;
+#X connect 13 0 15 0;
+#X connect 13 0 16 0;
+#X connect 14 0 10 0;
+#X connect 15 0 10 0;
+#X connect 16 0 10 0;
+#X restore 117 210 pd input_signal~;
+#X obj 117 162 vradio 20 1 1 2 empty signalr empty 0 -6 0 8 -262144
+-1 -1 0;
+#X text 144 163 white signal (noise);
+#X text 145 183 non white signal (filtered noise);
+#X obj 524 43 spectrum~;
+#X text 33 32 SYSTEM IDENTIFICATION IN A NOISE FREE ENVIRONMENT;
+#X connect 0 0 3 1;
+#X connect 3 1 36 0;
+#X connect 3 2 37 0;
+#X connect 3 3 38 0;
+#X connect 8 0 4 0;
+#X connect 12 0 4 2;
+#X connect 13 0 56 2;
+#X connect 14 0 56 0;
+#X connect 30 0 56 1;
+#X connect 31 0 4 1;
+#X connect 52 0 0 0;
+#X connect 52 0 3 0;
+#X connect 53 0 52 0;
diff --git a/adaptive/examples/02.persistent_excitation.pd b/adaptive/examples/02.persistent_excitation.pd
new file mode 100755
index 0000000..9bafbba
--- /dev/null
+++ b/adaptive/examples/02.persistent_excitation.pd
@@ -0,0 +1,396 @@
+#N struct num float x float y float col;
+#N canvas 21 113 829 606 10;
+#X obj 34 430 tgl 20 0 audio_io empty empty 0 -6 0 8 -262144 -1 -1
+1 1;
+#X text 59 432 <- Audio IO;
+#X text 122 266 x[n];
+#X text 251 316 d[n];
+#X text 104 379 y[n];
+#X obj 75 495 bng 20 250 50 0 clear empty empty 0 -6 0 8 -262144 -1
+-1;
+#X text 104 497 <- clear coefficients \, so adaptation will start again
+;
+#X text 542 496 unknown system:;
+#X text 571 520 d[n] =;
+#X floatatom 178 383 5 0 0 1 c0 - C0;
+#X floatatom 242 383 8 0 0 1 c1 - C1;
+#X text 31 471 adaptive filter:;
+#X floatatom 75 523 8 0 0 0 - mur mu;
+#X text 137 523 <- step size parameter mu (learning rate);
+#N canvas 215 124 617 210 init 0;
+#X msg 43 99 2;
+#X obj 269 45 loadbang;
+#X obj 43 122 s init_tlp;
+#X msg 138 98 0.33;
+#X msg 179 99 0.33;
+#X msg 223 100 0.33;
+#X obj 138 121 s a0r;
+#X obj 178 122 s a1r;
+#X obj 223 123 s a2r;
+#X obj 295 123 s mur;
+#X msg 515 103 \; pd dsp \$1;
+#X obj 515 78 r audio_io;
+#X obj 381 123 s signalr;
+#X msg 380 98 0;
+#X obj 182 180 s A1r;
+#X obj 142 179 s A0r;
+#X msg 183 157 2;
+#X msg 142 156 1;
+#X msg 294 99 0.001;
+#X connect 0 0 2 0;
+#X connect 1 0 0 0;
+#X connect 1 0 3 0;
+#X connect 1 0 4 0;
+#X connect 1 0 5 0;
+#X connect 1 0 18 0;
+#X connect 1 0 13 0;
+#X connect 1 0 17 0;
+#X connect 1 0 16 0;
+#X connect 3 0 6 0;
+#X connect 4 0 7 0;
+#X connect 5 0 8 0;
+#X connect 11 0 10 0;
+#X connect 13 0 12 0;
+#X connect 16 0 14 0;
+#X connect 17 0 15 0;
+#X connect 18 0 9 0;
+#X restore 644 578 pd init;
+#X floatatom 623 521 4 0 1.5 0 - A0r A0;
+#X text 657 521 x[n] +;
+#N canvas 425 56 483 381 PROBLEM_DESCRIPTION 0;
+#X text 35 188 unknown system:;
+#X text 35 259 adaptive system:;
+#X text 77 292 step-size parameter mu;
+#X text 74 209 FIR Filter: h=(1 \, 2) \, order = 2;
+#X text 75 225 d[n] = h0*x[n] + h1*x[n-1] (N=M);
+#X text 77 278 nlms2~ \, 2 coefficients (c0 \, c1);
+#X text 34 124 The unknown system is a FIR filter of order 2 and the
+adaptive system is an adaptive transversal filter using the NLMS algorithm
+(see nlms2~ help-patch) with 2 coefficients.;
+#X text 35 89 In this exmaple the adaptation path is beeing visualized
+in the c[n]-plane.;
+#X text 33 340 When can the unknown system be identified successfully
+?;
+#X text 32 42 PERSISTENT EXCITATION;
+#X restore 34 94 pd PROBLEM_DESCRIPTION;
+#N canvas 663 87 465 688 OBSERVATIONS 0;
+#X text 24 20 OBSERVATIONS;
+#X text 24 60 input signals 1 + 4:;
+#X text 48 77 The unknown system can be identified successfully.;
+#X text 24 103 input signals 2:;
+#X text 54 119 Adaptation doesn't work at all.;
+#X text 21 149 input signals 3:;
+#X text 51 165 Adaptation works \, but with an offset.;
+#X text 23 225 EXPLANATION;
+#X text 26 256 The unknown system can be identified \, if the Wiener-Hopf
+equation can be solved:;
+#X text 69 297 c_opt = R_x^-1 * p;
+#X text 257 294 (Wiener-Hopf equation);
+#X text 27 323 c_opt ... optimal coefficient vector c0 \, c1 \, c2
+\, ...;
+#X text 28 338 R_x ... autocorrelation matrix of the input signal x[n]
+;
+#X text 156 429 det(R_x) != 0;
+#X text 27 393 The Wiener-Hopf equation can only be solved \, if the
+determinant of R_x is not singular:;
+#X text 45 511 x[n] = sin(theta*n + phi);
+#X text 45 530 -> for N=2:;
+#X text 133 557 R_x =;
+#X text 275 547 cos(theta);
+#X text 236 566 cos(theta);
+#X text 221 567 [;
+#X text 220 547 [;
+#X text 355 547 ];
+#X text 355 566 ];
+#X text 175 558 0.5 *;
+#X text 239 548 1;
+#X text 331 567 1;
+#X text 40 622 -> det(R_x) = 0 \, if theta = 0 \, pi \, 2*pi \, ...
+;
+#X text 40 606 -> det(R_x) = 1 - cos^2(theta);
+#X text 24 639 (which is the case with input signal 2 = critical sampling)
+;
+#X text 26 483 In our example (signal 1+2):;
+#X text 28 352 p ... crosscorrelation vector between the desired output
+d[n] and the input signal x[n];
+#X restore 34 120 pd OBSERVATIONS;
+#X text 33 72 ReadMe:;
+#X obj 114 166 vradio 15 1 1 4 empty empty empty 0 -6 0 8 -262144 -1
+-1 2;
+#X floatatom 709 521 4 0 2 0 - A1r A1;
+#X text 743 521 x[n-1];
+#X text 132 197 3) x[n]=cos[pi*n]+2;
+#X text 132 212 4) white noise;
+#X text 132 164 1) x[n]=cos[0.5*pi*n] -> f=samplerate/4;
+#X text 132 181 2) x[n]=cos[pi*n] -> f=samplerate/2;
+#N canvas 0 0 450 300 c-plane 0;
+#X scalar num 100 200 600 \;;
+#X scalar num 132.83 181.096 841 \;;
+#X coords -100 300 200 -100 300 300 1;
+#X restore 486 131 pd c-plane;
+#N canvas 220 179 544 257 c-plane-stuff 0;
+#N canvas 118 400 523 253 num 0;
+#X text 104 54 float with x \, y values \; col for color \;;
+#X text 97 157 visualization of the float \, col is the color \;;
+#X obj 101 88 struct num float x float y float col;
+#X obj 90 184 filledpolygon col col 0 0 0 0 0 9 9 9 0 0 9;
+#X restore 27 36 pd num;
+#N canvas 663 380 461 298 init 0;
+#X msg 329 146 clear;
+#X obj 258 241 pointer;
+#X msg 223 91 bang;
+#X obj 137 22 loadbang;
+#X text 263 93 Initialization;
+#X obj 212 150 t b b b;
+#X msg 159 91 bang;
+#X obj 221 120 t b b;
+#X text 74 90 add another;
+#X obj 329 172 s pd-c-plane;
+#X msg 250 216 traverse pd-c-plane \, bang;
+#X obj 168 264 append num x y;
+#X obj 137 46 t b b b;
+#X obj 34 130 s \$0-initp;
+#X text 29 153 init pointers;
+#X msg 162 218 0;
+#X msg 201 220 0;
+#X connect 0 0 9 0;
+#X connect 1 0 11 2;
+#X connect 2 0 7 0;
+#X connect 3 0 12 0;
+#X connect 5 0 15 0;
+#X connect 5 1 16 0;
+#X connect 5 2 10 0;
+#X connect 6 0 5 0;
+#X connect 7 0 5 0;
+#X connect 7 1 0 0;
+#X connect 10 0 1 0;
+#X connect 12 0 13 0;
+#X connect 12 1 6 0;
+#X connect 12 2 2 0;
+#X connect 15 0 11 0;
+#X connect 16 0 11 1;
+#X restore 28 75 pd init;
+#X text 80 37 <- graphical representation of a number;
+#N canvas 944 527 415 326 coef_h 0;
+#X obj 219 222 pointer;
+#X msg 219 147 traverse pd-c-plane \, next;
+#X obj 175 24 r \$0-initp;
+#X obj 113 275 set num x y col;
+#X obj 100 186 * 100;
+#X obj 146 185 * 100;
+#X obj 100 159 r A0;
+#X obj 175 48 t b b b;
+#X obj 84 240 f 0;
+#X obj 130 239 f 0;
+#X msg 84 80 1;
+#X obj 84 124 t b b;
+#X obj 146 159 r A1;
+#X obj 84 101 metro 50;
+#X msg 197 249 600;
+#X connect 0 0 3 3;
+#X connect 1 0 0 0;
+#X connect 2 0 7 0;
+#X connect 4 0 8 1;
+#X connect 5 0 9 1;
+#X connect 6 0 4 0;
+#X connect 7 0 10 0;
+#X connect 7 1 14 0;
+#X connect 7 2 1 0;
+#X connect 8 0 3 0;
+#X connect 9 0 3 1;
+#X connect 10 0 13 0;
+#X connect 11 0 8 0;
+#X connect 11 1 9 0;
+#X connect 12 0 5 0;
+#X connect 13 0 11 0;
+#X connect 14 0 3 2;
+#X restore 26 137 pd coef_h;
+#N canvas 796 564 451 326 coef_c 0;
+#X obj 219 222 pointer;
+#X obj 175 24 r \$0-initp;
+#X obj 113 275 set num x y col;
+#X obj 100 186 * 100;
+#X obj 146 185 * 100;
+#X obj 84 240 f 0;
+#X obj 130 239 f 0;
+#X msg 84 80 1;
+#X obj 84 124 t b b;
+#X obj 100 159 r C0;
+#X obj 146 159 r C1;
+#X obj 175 48 t b b b;
+#X msg 219 147 traverse pd-c-plane \, next \, next;
+#X obj 84 101 metro 50;
+#X msg 197 249 841;
+#X connect 0 0 2 3;
+#X connect 1 0 11 0;
+#X connect 3 0 5 1;
+#X connect 4 0 6 1;
+#X connect 5 0 2 0;
+#X connect 6 0 2 1;
+#X connect 7 0 13 0;
+#X connect 8 0 5 0;
+#X connect 8 1 6 0;
+#X connect 9 0 3 0;
+#X connect 10 0 4 0;
+#X connect 11 0 7 0;
+#X connect 11 1 14 0;
+#X connect 11 2 12 0;
+#X connect 12 0 0 0;
+#X connect 13 0 8 0;
+#X connect 14 0 2 2;
+#X restore 27 107 pd coef_c;
+#X msg 165 126 \; . xticks 0 0.1 5;
+#X msg 165 164 \; . yticks 0 0.1 5;
+#X msg 303 128 \; . xlabel -1.15 -1 0 1 2;
+#X msg 302 163 \; . ylabel -1.1 -1 0 1 2 3;
+#X obj 165 80 loadbang;
+#X connect 9 0 5 0;
+#X connect 9 0 6 0;
+#X connect 9 0 7 0;
+#X connect 9 0 8 0;
+#X restore 698 578 pd c-plane-stuff;
+#N canvas 0 0 450 300 graph2 0;
+#X array . 1 float 3;
+#A 0 -0.97332;
+#X coords -1 3 2 -1 300 300 1;
+#X restore 486 131 graph;
+#X text 479 112 c1;
+#X text 790 423 c0;
+#X text 521 87 orange: adaptive system (c0 \, c1);
+#N canvas 771 151 438 319 input_signal~ 0;
+#X obj 175 34 inlet;
+#X obj 188 281 outlet~;
+#X msg 296 64 print else;
+#X obj 235 162 noise~;
+#X obj 262 188 *~;
+#X obj 190 183 +~ 2;
+#X obj 190 161 osc~;
+#X obj 35 39 samplerate~;
+#X obj 116 160 osc~;
+#X obj 35 17 loadbang;
+#X obj 115 194 *~;
+#X obj 35 157 osc~;
+#X obj 34 197 *~;
+#X obj 189 212 *~;
+#X obj 175 56 sel 0 1 2 3;
+#N canvas 264 424 366 206 distribute_msg 0;
+#X obj 66 26 inlet;
+#X obj 108 26 inlet;
+#X obj 154 26 inlet;
+#X obj 206 28 inlet;
+#X msg 114 91 0;
+#X msg 166 94 0;
+#X msg 215 93 0;
+#X msg 108 66 1;
+#X msg 154 66 1;
+#X msg 70 91 0;
+#X obj 54 124 outlet;
+#X obj 111 126 outlet;
+#X obj 165 124 outlet;
+#X obj 217 124 outlet;
+#X msg 206 65 0.3;
+#X msg 64 67 0.3;
+#X connect 0 0 15 0;
+#X connect 0 0 4 0;
+#X connect 0 0 5 0;
+#X connect 0 0 6 0;
+#X connect 1 0 7 0;
+#X connect 1 0 9 0;
+#X connect 1 0 5 0;
+#X connect 1 0 6 0;
+#X connect 2 0 8 0;
+#X connect 2 0 9 0;
+#X connect 2 0 4 0;
+#X connect 2 0 6 0;
+#X connect 3 0 14 0;
+#X connect 3 0 9 0;
+#X connect 3 0 4 0;
+#X connect 3 0 5 0;
+#X connect 4 0 11 0;
+#X connect 5 0 12 0;
+#X connect 6 0 13 0;
+#X connect 7 0 11 0;
+#X connect 8 0 12 0;
+#X connect 9 0 10 0;
+#X connect 14 0 13 0;
+#X connect 15 0 10 0;
+#X restore 175 86 pd distribute_msg;
+#X obj 35 133 / 4;
+#X obj 116 133 / 2;
+#X obj 190 133 / 2;
+#X connect 0 0 14 0;
+#X connect 3 0 4 0;
+#X connect 4 0 1 0;
+#X connect 5 0 13 0;
+#X connect 6 0 5 0;
+#X connect 7 0 16 0;
+#X connect 7 0 17 0;
+#X connect 7 0 18 0;
+#X connect 8 0 10 0;
+#X connect 9 0 7 0;
+#X connect 10 0 1 0;
+#X connect 11 0 12 0;
+#X connect 12 0 1 0;
+#X connect 13 0 1 0;
+#X connect 14 0 15 0;
+#X connect 14 1 15 1;
+#X connect 14 2 15 2;
+#X connect 14 3 15 3;
+#X connect 14 4 2 0;
+#X connect 15 0 12 1;
+#X connect 15 1 10 1;
+#X connect 15 2 13 1;
+#X connect 15 3 4 1;
+#X connect 16 0 11 0;
+#X connect 17 0 8 0;
+#X connect 18 0 6 0;
+#X restore 114 233 pd input_signal~;
+#N canvas 10 567 359 314 unknown_system~ 0;
+#X obj 26 26 inlet~;
+#X obj 26 268 outlet~;
+#X obj 26 113 fexpr~ $f2*$x1 + $f3*$x1[-1];
+#X obj 217 92 r A1r;
+#X obj 121 88 r A0r;
+#X connect 0 0 2 0;
+#X connect 2 0 1 0;
+#X connect 3 0 2 2;
+#X connect 4 0 2 1;
+#X restore 243 292 pd unknown_system~;
+#N canvas 523 194 390 347 adaptive_filter~ 0;
+#X obj 37 35 inlet~;
+#X text 22 15 input signal;
+#X obj 143 35 inlet~;
+#X text 122 15 desired signal;
+#X obj 38 275 outlet~;
+#X msg 249 63 adaptation 1;
+#X obj 249 42 loadbang;
+#X obj 249 141 r clear;
+#X msg 248 162 clear;
+#X obj 123 249 outlet;
+#X obj 188 249 outlet;
+#X obj 249 94 r mu;
+#X msg 249 116 mu \$1;
+#X obj 123 221 unpack f f;
+#X obj 37 156 nlms2~ 2 0.01;
+#X connect 0 0 14 0;
+#X connect 2 0 14 1;
+#X connect 5 0 14 0;
+#X connect 6 0 5 0;
+#X connect 7 0 8 0;
+#X connect 8 0 14 0;
+#X connect 11 0 12 0;
+#X connect 12 0 14 0;
+#X connect 13 0 9 0;
+#X connect 13 1 10 0;
+#X connect 14 0 4 0;
+#X connect 14 2 13 0;
+#X restore 114 360 pd adaptive_filter~;
+#X text 484 47 Visualization in the c-plane:;
+#X text 33 32 PERSISTENT EXCITATION;
+#X text 521 74 red: unknown system (h0 \, h1);
+#X connect 20 0 33 0;
+#X connect 33 0 35 0;
+#X connect 33 0 34 0;
+#X connect 34 0 35 1;
+#X connect 35 1 9 0;
+#X connect 35 2 10 0;
diff --git a/adaptive/examples/03.undermodeling.pd b/adaptive/examples/03.undermodeling.pd
new file mode 100755
index 0000000..7a194da
--- /dev/null
+++ b/adaptive/examples/03.undermodeling.pd
@@ -0,0 +1,238 @@
+#N canvas 0 68 891 823 10;
+#N canvas 10 567 633 314 unknown_system~ 0;
+#X obj 26 26 inlet~;
+#X obj 26 268 outlet~;
+#X obj 115 227 s~ unknown_signal;
+#X text 116 249 (for visualization);
+#X obj 26 113 fexpr~ $f2*$x1 + $f3*$x1[-1] + $f4*$x1[-2];
+#X obj 122 81 f 0.33;
+#X obj 218 81 f 0.33;
+#X obj 315 82 f 0.33;
+#X obj 122 53 r a0;
+#X obj 218 55 r a1;
+#X obj 315 56 r a2;
+#X connect 0 0 4 0;
+#X connect 4 0 1 0;
+#X connect 4 0 2 0;
+#X connect 5 0 4 1;
+#X connect 6 0 4 2;
+#X connect 7 0 4 3;
+#X connect 8 0 5 0;
+#X connect 9 0 6 0;
+#X connect 10 0 7 0;
+#X restore 245 268 pd unknown_system~;
+#X obj 305 434 tgl 20 0 audio_io empty empty 0 -6 0 8 -262144 -1 -1
+1 1;
+#X text 330 436 <- Audio IO;
+#N canvas 523 194 390 347 adaptive_filter~ 0;
+#X obj 37 35 inlet~;
+#X text 22 15 input signal;
+#X obj 143 35 inlet~;
+#X text 122 15 desired signal;
+#X obj 36 291 outlet~;
+#X msg 249 63 adaptation 1;
+#X obj 249 42 loadbang;
+#X obj 224 214 s~ adaptive_signal;
+#X text 224 234 (for visualization);
+#X obj 249 141 r clear;
+#X msg 248 162 clear;
+#X obj 116 293 outlet;
+#X obj 181 294 outlet;
+#X obj 249 94 r mu;
+#X msg 249 116 mu \$1;
+#X obj 37 156 lms2~ 2 0.01;
+#X obj 116 265 unpack f f;
+#X connect 0 0 15 0;
+#X connect 2 0 15 1;
+#X connect 5 0 15 0;
+#X connect 6 0 5 0;
+#X connect 9 0 10 0;
+#X connect 10 0 15 0;
+#X connect 13 0 14 0;
+#X connect 14 0 15 0;
+#X connect 15 0 4 0;
+#X connect 15 0 7 0;
+#X connect 15 2 16 0;
+#X connect 16 0 11 0;
+#X connect 16 1 12 0;
+#X restore 117 337 pd adaptive_filter~;
+#X obj 524 255 spectrum~;
+#N canvas 0 0 450 300 graph6 0;
+#X array adapt 512 float 0;
+#X coords 0 1 511 -1 200 140 1;
+#X restore 656 625 graph;
+#X text 700 769 -- 512 samples ---;
+#X obj 46 438 tgl 20 0 scopes_on empty empty 0 -6 0 8 -262144 -1 -1
+1 1;
+#X obj 524 238 r~ adaptive_signal;
+#X text 125 241 x[n];
+#X text 256 300 d[n];
+#X text 107 356 y[n];
+#X obj 775 238 r scopes_on;
+#X obj 775 26 r scopes_on;
+#X obj 524 26 r~ unknown_signal;
+#N canvas 0 0 450 300 graph6 0;
+#X array unkn 512 float 0;
+#X coords 0 1 511 -1 200 140 1;
+#X restore 654 453 graph;
+#X text 698 597 -- 512 samples ---;
+#X text 76 438 <- Visualization IO;
+#X text 481 137 (1);
+#X text 481 338 (2);
+#N canvas 452 215 456 231 scope_stuff 0;
+#X obj 45 38 r~ adaptive_signal;
+#X obj 83 63 r scopes_on;
+#X obj 279 69 r scopes_on;
+#X obj 241 44 r~ unknown_signal;
+#X obj 83 96 metro 1000;
+#X obj 44 139 tabwrite~ adapt;
+#X obj 279 95 metro 1000;
+#X obj 240 138 tabwrite~ unkn;
+#X connect 0 0 5 0;
+#X connect 1 0 4 0;
+#X connect 2 0 6 0;
+#X connect 3 0 7 0;
+#X connect 4 0 5 0;
+#X connect 6 0 7 0;
+#X restore 755 795 pd scope_stuff;
+#X text 582 510 (3);
+#X text 581 686 (4);
+#X text 86 760 (3) d[n] in time domain;
+#X text 86 777 (4) y[n] in time domain;
+#X text 86 742 (2) amplitude of the output signal y[n];
+#X text 86 711 (1) amplitude of the desired signal d[n] (= output of
+the unknown system);
+#X obj 84 599 bng 20 250 50 0 clear empty empty 0 -6 0 8 -262144 -1
+-1;
+#X text 113 601 <- clear coefficients \, so adaptation will start again
+;
+#X floatatom 46 471 5 0 100 0 - init_tlp tlp;
+#X obj 685 26 r tlp;
+#X obj 685 238 r tlp;
+#X text 90 469 <- temporal lowpass for spectrum view (0...100);
+#X text 54 689 VISUALIZATIONS:;
+#X text 42 522 unknown system:;
+#X text 72 546 d[n] =;
+#X floatatom 181 375 5 0 0 1 c0 - -;
+#X floatatom 245 375 5 0 0 1 c1 - -;
+#X text 40 578 adaptive filter:;
+#X floatatom 84 627 8 0 0 0 - mur mu;
+#X text 146 627 <- step size parameter mu (learning rate);
+#N canvas 215 124 617 210 init 0;
+#X msg 43 99 2;
+#X obj 269 45 loadbang;
+#X obj 43 122 s init_tlp;
+#X msg 138 98 0.33;
+#X msg 179 99 0.33;
+#X msg 223 100 0.33;
+#X obj 138 121 s a0r;
+#X obj 178 122 s a1r;
+#X obj 223 123 s a2r;
+#X obj 295 123 s mur;
+#X msg 294 99 0.01;
+#X msg 515 103 \; pd dsp \$1;
+#X obj 515 78 r audio_io;
+#X obj 381 123 s signalr;
+#X msg 380 98 0;
+#X connect 0 0 2 0;
+#X connect 1 0 0 0;
+#X connect 1 0 3 0;
+#X connect 1 0 4 0;
+#X connect 1 0 5 0;
+#X connect 1 0 10 0;
+#X connect 1 0 14 0;
+#X connect 3 0 6 0;
+#X connect 4 0 7 0;
+#X connect 5 0 8 0;
+#X connect 10 0 9 0;
+#X connect 12 0 11 0;
+#X connect 14 0 13 0;
+#X restore 699 795 pd init;
+#X floatatom 125 547 4 0 1 0 - a0r a0;
+#X text 158 547 x[n] +;
+#X text 244 547 x[n-1] +;
+#X floatatom 211 547 4 0 1 0 - a1r a1;
+#X floatatom 312 548 4 0 1 0 - a2r a2;
+#X text 345 549 x[n-2];
+#N canvas 741 100 479 337 PROBLEM_DESCRIPTION 0;
+#X text 75 224 d[n] = h0*x[n] + h1*x[n-1] + h2*x[n-2];
+#X text 35 188 unknown system:;
+#X text 74 209 FIR Filter \, order = 3;
+#X text 35 259 adaptive system:;
+#X text 77 292 step-size parameter mu;
+#X text 34 124 The unknown system is a FIR filter of order 3 and the
+adaptive system is an adaptive transversal filter using the LMS algorithm
+(see lms~ help-patch) with 2 coefficients.;
+#X text 77 278 LMS \, 2 coefficients (c0 \, c1);
+#X text 60 40 SYSTEM IDENTIFICATION: UNDERMODELING;
+#X text 33 85 In the case of undermodeling the order of the unknown
+system is higher than the order of the adaptive system.;
+#X restore 34 94 pd PROBLEM_DESCRIPTION;
+#N canvas 694 157 425 265 OBSERVATIONS 0;
+#X text 24 20 OBSERVATIONS;
+#X text 20 71 White Noise Case:;
+#X text 22 152 Non-White Case:;
+#X text 47 193 this case the error of the adaptive system is;
+#X text 48 209 much higher !;
+#X text 48 176 h0 \, h1 and h2 have influence on the error \, so in
+;
+#X text 51 96 only h1 and h2 have influence on the error;
+#X text 53 111 (min. error);
+#X restore 34 120 pd OBSERVATIONS;
+#X text 33 73 ReadMe:;
+#N canvas 0 0 642 300 input_signal~ 0;
+#X obj 77 90 noise~;
+#X obj 201 84 inlet;
+#X obj 77 217 *~;
+#X obj 210 273 outlet~;
+#X obj 201 115 sel 0 1;
+#X msg 91 190 1;
+#X msg 121 190 0;
+#X obj 325 88 noise~;
+#X text 53 64 white signal:;
+#X text 292 63 non white signal:;
+#X obj 322 224 *~;
+#X msg 336 197 1;
+#X msg 366 197 0;
+#X obj 324 112 hip~ 300;
+#X obj 492 148 bp~ 2543 2;
+#X obj 406 149 bp~ 1000 3;
+#X obj 323 148 bp~ 100 2;
+#X connect 0 0 2 0;
+#X connect 1 0 4 0;
+#X connect 2 0 3 0;
+#X connect 4 0 5 0;
+#X connect 4 0 12 0;
+#X connect 4 1 6 0;
+#X connect 4 1 11 0;
+#X connect 5 0 2 1;
+#X connect 6 0 2 1;
+#X connect 7 0 13 0;
+#X connect 10 0 3 0;
+#X connect 11 0 10 1;
+#X connect 12 0 10 1;
+#X connect 13 0 14 0;
+#X connect 13 0 15 0;
+#X connect 13 0 16 0;
+#X connect 14 0 10 0;
+#X connect 15 0 10 0;
+#X connect 16 0 10 0;
+#X restore 117 210 pd input_signal~;
+#X obj 117 162 vradio 20 1 1 2 empty signalr empty 0 -6 0 8 -262144
+-1 -1 0;
+#X text 144 163 white signal (noise);
+#X text 145 183 non white signal (filtered noise);
+#X obj 524 43 spectrum~;
+#X text 109 32 SYSTEM IDENTIFICATION: UNDERMODELING;
+#X connect 0 0 3 1;
+#X connect 3 1 36 0;
+#X connect 3 2 37 0;
+#X connect 8 0 4 0;
+#X connect 12 0 4 2;
+#X connect 13 0 55 2;
+#X connect 14 0 55 0;
+#X connect 30 0 55 1;
+#X connect 31 0 4 1;
+#X connect 51 0 0 0;
+#X connect 51 0 3 0;
+#X connect 52 0 51 0;
diff --git a/adaptive/examples/04.misadjustment.pd b/adaptive/examples/04.misadjustment.pd
new file mode 100755
index 0000000..8a963dd
--- /dev/null
+++ b/adaptive/examples/04.misadjustment.pd
@@ -0,0 +1,475 @@
+#N canvas 0 276 944 596 10;
+#N canvas 10 567 633 314 unknown_system~ 0;
+#X obj 26 26 inlet~;
+#X obj 26 268 outlet~;
+#X obj 26 113 fexpr~ $f2*$x1 + $f3*$x1[-1] + $f4*$x1[-2];
+#X obj 122 80 r a0;
+#X obj 218 82 r a1;
+#X obj 315 83 r a2;
+#X connect 0 0 2 0;
+#X connect 2 0 1 0;
+#X connect 3 0 2 1;
+#X connect 4 0 2 2;
+#X connect 5 0 2 3;
+#X restore 172 208 pd unknown_system~;
+#X obj 44 433 tgl 20 0 audio_io empty empty 0 -6 0 8 -262144 -1 -1
+0 1;
+#X text 69 435 <- Audio IO;
+#N canvas 253 248 419 287 adaptive_filter~ 0;
+#X obj 37 35 inlet~;
+#X text 22 15 input signal;
+#X obj 143 35 inlet~;
+#X text 122 15 desired signal;
+#X obj 37 255 outlet~;
+#X msg 249 63 adaptation 1;
+#X obj 249 42 loadbang;
+#X obj 249 141 r clear;
+#X msg 248 162 clear;
+#X obj 37 149 lms2~ 3 0.01;
+#X obj 116 227 unpack f f f;
+#X obj 162 255 outlet;
+#X obj 208 255 outlet;
+#X obj 249 94 r mu;
+#X msg 249 116 mu \$1;
+#X obj 116 255 outlet;
+#N canvas 0 0 450 300 calc_misalignment 0;
+#X obj 19 20 inlet;
+#X obj 19 70 unpack f f f;
+#X obj 175 105 r a0;
+#X obj 227 105 r a1;
+#X obj 280 105 r a2;
+#X obj 19 126 expr (($f1-$f4)+($f2-$f5)+($f3-$f6))/3;
+#X obj 19 156 sig~;
+#X obj 19 184 s~ misalignment;
+#X connect 0 0 1 0;
+#X connect 1 0 5 0;
+#X connect 1 1 5 1;
+#X connect 1 2 5 2;
+#X connect 2 0 5 3;
+#X connect 3 0 5 4;
+#X connect 4 0 5 5;
+#X connect 5 0 6 0;
+#X connect 6 0 7 0;
+#X restore 269 254 pd calc_misalignment;
+#X obj 75 180 s~ lms_error;
+#X connect 0 0 9 0;
+#X connect 2 0 9 1;
+#X connect 5 0 9 0;
+#X connect 6 0 5 0;
+#X connect 7 0 8 0;
+#X connect 8 0 9 0;
+#X connect 9 0 4 0;
+#X connect 9 1 17 0;
+#X connect 9 2 10 0;
+#X connect 9 2 16 0;
+#X connect 10 0 15 0;
+#X connect 10 1 11 0;
+#X connect 10 2 12 0;
+#X connect 13 0 14 0;
+#X connect 14 0 9 0;
+#X restore 43 308 pd adaptive_filter~;
+#X text 51 212 x[n];
+#X text 183 230 d[n];
+#X text 33 327 y[n];
+#X obj 84 550 bng 20 250 50 0 clear empty empty 0 -6 0 8 -262144 -1
+-1;
+#X text 113 552 <- clear coefficients \, so adaptation will start again
+;
+#X text 42 470 unknown system:;
+#X text 72 494 d[n] =;
+#X floatatom 85 349 6 0 0 1 c0 - -;
+#X floatatom 149 349 6 0 0 1 c1 - -;
+#X floatatom 211 349 6 0 0 1 c2 - -;
+#X text 40 529 adaptive filter:;
+#X floatatom 408 167 8 0 0 0 mu: mur mu;
+#N canvas 215 124 811 210 init 0;
+#X obj 321 45 loadbang;
+#X msg 138 98 0.33;
+#X msg 179 99 0.33;
+#X msg 223 100 0.33;
+#X obj 138 121 s a0r;
+#X obj 178 122 s a1r;
+#X obj 223 123 s a2r;
+#X obj 330 124 s mur;
+#X msg 329 100 0.01;
+#X msg 625 114 \; pd dsp \$1;
+#X obj 625 89 r audio_io;
+#X obj 395 127 s noiser;
+#X msg 394 104 40;
+#X obj 463 130 s amp_in_r;
+#X msg 463 108 100;
+#X connect 0 0 1 0;
+#X connect 0 0 2 0;
+#X connect 0 0 3 0;
+#X connect 0 0 8 0;
+#X connect 0 0 12 0;
+#X connect 0 0 14 0;
+#X connect 1 0 4 0;
+#X connect 2 0 5 0;
+#X connect 3 0 6 0;
+#X connect 8 0 7 0;
+#X connect 10 0 9 0;
+#X connect 12 0 11 0;
+#X connect 14 0 13 0;
+#X restore 862 557 pd init;
+#X floatatom 125 495 4 0 1 0 - a0r a0;
+#X text 158 495 x[n] +;
+#X text 243 496 x[n-1] +;
+#X floatatom 210 496 4 0 1 0 - a1r a1;
+#X floatatom 311 497 4 0 1 0 - a2r a2;
+#X text 344 496 x[n-2];
+#N canvas 327 0 479 730 PROBLEM_DESCRIPTION 0;
+#X text 29 126 The unknown system is a FIR filter of order 3 and the
+adaptive system is an adaptive transversal filter using the LMS algorithm
+(see lms~ help-patch) with 3 coefficients.;
+#X text 75 224 d[n] = h0*x[n] + h1*x[n-1] + h2*x[n-2];
+#X text 35 188 unknown system:;
+#X text 74 209 FIR Filter \, order = 3;
+#X text 35 259 adaptive system:;
+#X text 77 278 LMS \, 3 coefficients (c0 \, c1 \, c2);
+#X text 77 292 step-size parameter mu;
+#X text 188 40 MISADJUSTMENT;
+#X text 28 84 This patch calculates the misadjustment in a noisy system
+identification problem.;
+#X text 33 325 The input signal and the additional noise are uniformly
+distributed random numbers with zero mean and different variances.
+;
+#X text 29 399 Mean Square Error: MSE[n] = E[abs(e[n])^2];
+#X text 29 416 MSE_min: Minimum Error = variance^2 of the additional
+noise;
+#X text 29 497 limes n to infinity MSE[n] = MSE_excess + MSE_min;
+#X text 26 538 The ratio of the Excess Error and the Minimum Error
+is defined as the Misadjustment:;
+#X text 109 573 MISADJ = MSE_excess / MSE_min;
+#X text 28 619 LMS Adaptive Filter Design Trade Off:;
+#X text 142 644 tao * MISADJ = N/2;
+#X text 108 673 N ... Nr of coefficients;
+#X text 107 687 tao ... convergence time constant;
+#X text 39 448 v[n] = c[n]-h[n] \, so the difference between the adaptive
+and the unknown system;
+#X text 29 433 MSE_excess: Excess Error = E[v[n]^2*x[n]^2] (Misalignment)
+;
+#X restore 34 94 pd PROBLEM_DESCRIPTION;
+#X text 33 73 ReadMe:;
+#N canvas 0 0 320 300 input_signal~ 0;
+#X obj 89 69 noise~;
+#X obj 89 196 *~;
+#X obj 89 255 outlet~;
+#X text 65 43 white signal:;
+#X obj 105 151 r amp_in;
+#X obj 105 174 dbtorms;
+#X obj 219 212 env~;
+#X obj 219 232 dbtorms;
+#X obj 219 254 s in_power;
+#X obj 107 222 s~ in_sig;
+#X connect 0 0 1 0;
+#X connect 1 0 2 0;
+#X connect 1 0 6 0;
+#X connect 1 0 9 0;
+#X connect 4 0 5 0;
+#X connect 5 0 1 1;
+#X connect 6 0 7 0;
+#X connect 7 0 8 0;
+#X restore 43 181 pd input_signal~;
+#X obj 172 271 +~;
+#N canvas 0 0 450 300 add_noise~ 0;
+#X obj 142 69 noise~;
+#X obj 142 173 *~;
+#X obj 158 111 r noise;
+#X obj 142 251 outlet~;
+#X obj 158 143 dbtorms;
+#X obj 266 191 s~ add-noise;
+#X connect 0 0 1 0;
+#X connect 1 0 3 0;
+#X connect 1 0 5 0;
+#X connect 2 0 4 0;
+#X connect 4 0 1 1;
+#X restore 224 255 pd add_noise~;
+#X floatatom 771 163 5 0 0 1 dB noiser noise;
+#X floatatom 583 166 5 0 0 1 dB amp_in_r amp_in;
+#X text 33 30 MISADJUSTMENT - NOISY SYSTEM IDENTIFICATION;
+#X text 408 65 different cases:;
+#N canvas 40 12 322 729 case-study 0;
+#X obj 24 21 inlet;
+#X obj 24 50 sel 0 1 2 3 4 5 6 7;
+#X obj 79 127 s mur;
+#X obj 121 128 s noiser;
+#X obj 182 128 s amp_in_r;
+#X obj 24 126 s start;
+#X msg 24 103 bang;
+#X obj 24 78 t b b;
+#X msg 182 105 100;
+#X msg 79 104 0.01;
+#X obj 78 202 s mur;
+#X obj 120 203 s noiser;
+#X obj 181 203 s amp_in_r;
+#X obj 23 201 s start;
+#X msg 23 178 bang;
+#X obj 23 153 t b b;
+#X obj 77 279 s mur;
+#X obj 119 280 s noiser;
+#X obj 180 280 s amp_in_r;
+#X obj 22 278 s start;
+#X msg 22 255 bang;
+#X obj 22 230 t b b;
+#X obj 77 355 s mur;
+#X obj 119 356 s noiser;
+#X obj 180 356 s amp_in_r;
+#X obj 22 354 s start;
+#X msg 22 331 bang;
+#X obj 22 306 t b b;
+#X obj 78 430 s mur;
+#X obj 120 431 s noiser;
+#X obj 181 431 s amp_in_r;
+#X obj 23 429 s start;
+#X msg 23 406 bang;
+#X obj 23 381 t b b;
+#X obj 78 506 s mur;
+#X obj 120 507 s noiser;
+#X obj 181 507 s amp_in_r;
+#X obj 23 505 s start;
+#X msg 23 482 bang;
+#X obj 23 457 t b b;
+#X msg 78 483 0.01;
+#X obj 78 581 s mur;
+#X obj 120 582 s noiser;
+#X obj 181 582 s amp_in_r;
+#X obj 23 580 s start;
+#X msg 23 557 bang;
+#X obj 23 532 t b b;
+#X obj 78 660 s mur;
+#X obj 120 661 s noiser;
+#X obj 181 661 s amp_in_r;
+#X obj 23 659 s start;
+#X msg 23 636 bang;
+#X obj 23 611 t b b;
+#X msg 120 105 30;
+#X msg 119 180 50;
+#X msg 181 180 70;
+#X msg 78 179 0.001;
+#X msg 77 256 0.001;
+#X msg 180 257 97;
+#X msg 118 257 50;
+#X msg 118 333 80;
+#X msg 180 333 40;
+#X msg 77 332 2;
+#X msg 78 407 0.005;
+#X msg 119 408 4;
+#X msg 181 408 10;
+#X msg 181 484 90;
+#X msg 120 484 60;
+#X msg 181 559 98;
+#X msg 119 559 80;
+#X msg 78 558 0.008;
+#X msg 119 638 40;
+#X msg 181 638 80;
+#X msg 78 637 0.9;
+#X connect 0 0 1 0;
+#X connect 1 0 7 0;
+#X connect 1 1 15 0;
+#X connect 1 2 21 0;
+#X connect 1 3 27 0;
+#X connect 1 4 33 0;
+#X connect 1 5 39 0;
+#X connect 1 6 46 0;
+#X connect 1 7 52 0;
+#X connect 6 0 5 0;
+#X connect 7 0 6 0;
+#X connect 7 1 9 0;
+#X connect 7 1 53 0;
+#X connect 7 1 8 0;
+#X connect 8 0 4 0;
+#X connect 9 0 2 0;
+#X connect 14 0 13 0;
+#X connect 15 0 14 0;
+#X connect 15 1 56 0;
+#X connect 15 1 54 0;
+#X connect 15 1 55 0;
+#X connect 20 0 19 0;
+#X connect 21 0 20 0;
+#X connect 21 1 57 0;
+#X connect 21 1 59 0;
+#X connect 21 1 58 0;
+#X connect 26 0 25 0;
+#X connect 27 0 26 0;
+#X connect 27 1 62 0;
+#X connect 27 1 60 0;
+#X connect 27 1 61 0;
+#X connect 32 0 31 0;
+#X connect 33 0 32 0;
+#X connect 33 1 63 0;
+#X connect 33 1 64 0;
+#X connect 33 1 65 0;
+#X connect 38 0 37 0;
+#X connect 39 0 38 0;
+#X connect 39 1 40 0;
+#X connect 39 1 67 0;
+#X connect 39 1 66 0;
+#X connect 40 0 34 0;
+#X connect 45 0 44 0;
+#X connect 46 0 45 0;
+#X connect 46 1 70 0;
+#X connect 46 1 69 0;
+#X connect 46 1 68 0;
+#X connect 51 0 50 0;
+#X connect 52 0 51 0;
+#X connect 52 1 73 0;
+#X connect 52 1 71 0;
+#X connect 52 1 72 0;
+#X connect 53 0 3 0;
+#X connect 54 0 11 0;
+#X connect 55 0 12 0;
+#X connect 56 0 10 0;
+#X connect 57 0 16 0;
+#X connect 58 0 18 0;
+#X connect 59 0 17 0;
+#X connect 60 0 23 0;
+#X connect 61 0 24 0;
+#X connect 62 0 22 0;
+#X connect 63 0 28 0;
+#X connect 64 0 29 0;
+#X connect 65 0 30 0;
+#X connect 66 0 36 0;
+#X connect 67 0 35 0;
+#X connect 68 0 43 0;
+#X connect 69 0 42 0;
+#X connect 70 0 41 0;
+#X connect 71 0 48 0;
+#X connect 72 0 49 0;
+#X connect 73 0 47 0;
+#X restore 410 112 pd case-study;
+#N canvas 0 0 450 300 graph3 0;
+#X array MSE 20000 float 0;
+#X coords 0 100 19999 0 400 140 1;
+#X restore 408 318 graph;
+#N canvas 176 526 1013 385 visualisation 0;
+#X obj 29 34 r start;
+#X obj 29 60 t b b;
+#X obj 59 85 s clear;
+#X obj 29 241 tabwrite~ MSE;
+#X text 283 29 Excess Error:;
+#X obj 705 95 t b f;
+#X text 454 32 Misadjustment:;
+#X obj 457 122 /;
+#X msg 429 337 \; MSE yticks 0 5 5;
+#X text 662 34 MSE:;
+#X obj 285 204 dbtorms;
+#X msg 552 337 \; MSE ylabel 20600 0 25 50 75 100;
+#X obj 300 169 s excess_db;
+#X obj 305 233 s excess;
+#X obj 644 127 +;
+#X obj 809 73 r~ add-noise;
+#X obj 809 117 dbtorms;
+#X obj 809 141 s noise_power;
+#X obj 72 138 r~ add-noise;
+#X obj 429 268 loadbang;
+#X obj 644 75 r excess;
+#X obj 705 75 r noise_power;
+#X obj 659 155 s mse;
+#X obj 658 205 s mse_db;
+#X obj 644 180 rmstodb;
+#X obj 457 73 r excess;
+#X obj 518 94 t b f;
+#X obj 518 74 r noise_power;
+#X obj 457 153 s misadj;
+#X obj 285 145 env~ 64;
+#X obj 809 95 env~ 64;
+#X obj 56 195 env~ 64;
+#X msg 429 302 \; MSE xticks 0 500 5;
+#X msg 563 302 \; MSE xlabel -10 0 5000 10000 15000 20000;
+#X floatatom 356 205 5 0 0 0 - - -;
+#X obj 284 76 r~ misalignment;
+#X obj 56 172 +~;
+#X obj 302 102 r~ in_sig;
+#X obj 285 123 *~;
+#X connect 0 0 1 0;
+#X connect 1 0 3 0;
+#X connect 1 1 2 0;
+#X connect 5 0 14 0;
+#X connect 5 1 14 1;
+#X connect 7 0 28 0;
+#X connect 10 0 13 0;
+#X connect 14 0 22 0;
+#X connect 14 0 24 0;
+#X connect 15 0 30 0;
+#X connect 16 0 17 0;
+#X connect 18 0 36 1;
+#X connect 19 0 8 0;
+#X connect 19 0 11 0;
+#X connect 19 0 32 0;
+#X connect 19 0 33 0;
+#X connect 20 0 14 0;
+#X connect 21 0 5 0;
+#X connect 24 0 23 0;
+#X connect 25 0 7 0;
+#X connect 26 0 7 0;
+#X connect 26 1 7 1;
+#X connect 27 0 26 0;
+#X connect 29 0 10 0;
+#X connect 29 0 12 0;
+#X connect 29 0 34 0;
+#X connect 30 0 16 0;
+#X connect 31 0 3 0;
+#X connect 35 0 38 0;
+#X connect 36 0 31 0;
+#X connect 37 0 38 1;
+#X connect 38 0 29 0;
+#X connect 38 0 36 0;
+#X restore 742 557 pd visualisation;
+#X text 387 183 (step-size);
+#X text 504 166 in-signal:;
+#X floatatom 583 183 6 0 0 1 rms in_power -;
+#X floatatom 771 180 6 0 0 1 rms noise_power -;
+#X text 695 163 add-noise:;
+#X obj 410 84 hradio 25 1 0 8 empty empty empty 0 -6 0 8 -262144 -1
+-1 0;
+#X text 408 229 Excess Error:;
+#X floatatom 509 229 5 0 0 1 dB excess_db -;
+#X floatatom 586 229 7 0 0 1 rms excess -;
+#X text 567 228 ->;
+#X text 402 253 Misadjustment:;
+#X floatatom 509 253 7 0 0 1 - misadj -;
+#X text 469 279 MSE:;
+#X floatatom 509 278 5 0 0 1 dB mse_db -;
+#X floatatom 586 278 7 0 0 1 rms mse -;
+#X text 567 277 ->;
+#X text 790 292 MSE [dB];
+#X obj 712 250 bng 20 250 50 0 start empty empty 0 -6 0 8 -262144 -1
+-1;
+#X text 830 463 [samples];
+#X text 741 252 <- draw MSE;
+#N canvas 876 202 465 319 OBSERVATIONS 0;
+#X text 22 22 OBSERVATIONS;
+#X text 24 61 different cases:;
+#X text 24 137 3) slow learning \, but adaptation works;
+#X text 24 96 1) little bit add-noise \, adaptation works well;
+#X text 24 116 2) too much add-noise;
+#X text 24 192 5) very low in-signal and add-noise \, adaptation does
+not work;
+#X text 24 225 6) adaptation works;
+#X text 24 244 7) very high add-noise level \, but adaptation works
+;
+#X text 24 263 8) adaptation works \, high step-size (so in some cases
+this will be unstable);
+#X text 23 158 4) more add-noise than in-signal and very high step-size
+-> so sometimes this is unstable !;
+#X restore 34 120 pd OBSERVATIONS;
+#X text 418 90 1;
+#X text 442 90 2;
+#X text 467 90 3;
+#X text 492 90 4;
+#X text 517 90 5;
+#X text 542 90 6;
+#X text 567 90 7;
+#X text 592 90 8;
+#X text 537 183 power:;
+#X text 727 179 power:;
+#X connect 0 0 26 0;
+#X connect 3 1 11 0;
+#X connect 3 2 12 0;
+#X connect 3 3 13 0;
+#X connect 25 0 0 0;
+#X connect 25 0 3 0;
+#X connect 26 0 3 1;
+#X connect 27 0 26 1;
+#X connect 40 0 32 0;
diff --git a/adaptive/examples/05.tracking.pd b/adaptive/examples/05.tracking.pd
new file mode 100755
index 0000000..0713c26
--- /dev/null
+++ b/adaptive/examples/05.tracking.pd
@@ -0,0 +1,791 @@
+#N canvas 320 114 944 684 10;
+#N canvas 10 567 727 354 unknown_system~ 0;
+#X obj 26 26 inlet~;
+#X obj 24 323 outlet~;
+#X text 229 33 y[n] = ramp*x[0] + x[-1] + ramp*x[-2] + x[-3] + ramp*x[-4]
++ x[-5] + ramp*x[-6] + x[-7] + ramp*x[-7];
+#X text 228 74 and ramp decreases linearly from 1 to -1;
+#X obj 25 238 *~;
+#X obj 41 213 r~ ramp;
+#X obj 61 188 z~ 1;
+#X obj 106 188 z~ 2;
+#X obj 105 237 *~;
+#X obj 121 212 r~ ramp;
+#X obj 189 236 *~;
+#X obj 205 211 r~ ramp;
+#X obj 145 187 z~ 3;
+#X obj 190 187 z~ 4;
+#X obj 276 236 *~;
+#X obj 292 211 r~ ramp;
+#X obj 361 236 *~;
+#X obj 377 211 r~ ramp;
+#X obj 232 187 z~ 5;
+#X obj 277 187 z~ 6;
+#X obj 317 187 z~ 7;
+#X obj 362 187 z~ 8;
+#N canvas 0 0 411 300 ramp 0;
+#X obj 21 266 outlet~;
+#X obj 22 195 line~;
+#X obj 22 95 t b b;
+#X msg 52 118 1;
+#X floatatom 134 157 8 0 0 0 - - -;
+#X text 198 158 2000 samples in ms;
+#X obj 22 35 inlet;
+#X obj 199 223 snapshot~;
+#X floatatom 202 251 5 0 0 0 - - -;
+#X obj 206 201 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X obj 125 55 r length;
+#X obj 125 78 f 2000;
+#X obj 175 102 samplerate~;
+#X obj 175 80 loadbang;
+#X obj 125 124 / 44.1;
+#X obj 175 123 / 1000;
+#X obj 22 164 pack -1 45;
+#X connect 1 0 0 0;
+#X connect 1 0 7 0;
+#X connect 2 0 16 0;
+#X connect 2 1 3 0;
+#X connect 3 0 1 0;
+#X connect 6 0 2 0;
+#X connect 7 0 8 0;
+#X connect 9 0 7 0;
+#X connect 10 0 11 0;
+#X connect 11 0 14 0;
+#X connect 12 0 15 0;
+#X connect 13 0 12 0;
+#X connect 14 0 4 0;
+#X connect 14 0 16 1;
+#X connect 15 0 14 1;
+#X connect 16 0 1 0;
+#X restore 505 210 pd ramp;
+#X obj 505 231 s~ ramp;
+#X obj 505 187 r start_ramp;
+#X obj 567 279 snapshot~;
+#X msg 567 232 1;
+#X obj 568 211 loadbang;
+#X obj 567 303 s h_even;
+#X obj 643 304 s h_odd;
+#X msg 643 281 1;
+#X obj 567 256 metro 100;
+#X connect 0 0 4 0;
+#X connect 0 0 6 0;
+#X connect 0 0 7 0;
+#X connect 0 0 12 0;
+#X connect 0 0 13 0;
+#X connect 0 0 18 0;
+#X connect 0 0 19 0;
+#X connect 0 0 20 0;
+#X connect 0 0 21 0;
+#X connect 4 0 1 0;
+#X connect 5 0 4 1;
+#X connect 6 0 1 0;
+#X connect 7 0 8 0;
+#X connect 8 0 1 0;
+#X connect 9 0 8 1;
+#X connect 10 0 1 0;
+#X connect 11 0 10 1;
+#X connect 12 0 1 0;
+#X connect 13 0 10 0;
+#X connect 14 0 1 0;
+#X connect 15 0 14 1;
+#X connect 16 0 1 0;
+#X connect 17 0 16 1;
+#X connect 18 0 1 0;
+#X connect 19 0 14 0;
+#X connect 20 0 1 0;
+#X connect 21 0 16 0;
+#X connect 22 0 23 0;
+#X connect 22 0 25 0;
+#X connect 24 0 22 0;
+#X connect 25 0 28 0;
+#X connect 26 0 31 0;
+#X connect 27 0 26 0;
+#X connect 30 0 29 0;
+#X connect 31 0 25 0;
+#X connect 31 0 30 0;
+#X restore 172 197 pd unknown_system~;
+#X obj 99 355 tgl 20 0 audio_io empty empty 0 -6 0 8 -262144 -1 -1
+1 1;
+#X text 124 357 <- Audio IO;
+#N canvas 660 263 433 287 adaptive_filter~ 0;
+#X obj 37 35 inlet~;
+#X text 22 15 input signal;
+#X obj 143 35 inlet~;
+#X text 122 15 desired signal;
+#X obj 37 255 outlet~;
+#X msg 249 63 adaptation 1;
+#X obj 249 42 loadbang;
+#X obj 249 94 r mu;
+#X msg 249 135 mu \$1;
+#X obj 37 149 lms2~ 9 1e-04;
+#X obj 313 114 r read;
+#N canvas 0 0 450 300 read_coef 0;
+#X obj 18 23 inlet;
+#X msg 32 106 read coef.dat;
+#X obj 18 189 outlet;
+#X connect 0 0 1 0;
+#X connect 1 0 2 0;
+#X restore 313 136 pd read_coef;
+#X obj 249 114 / 1000;
+#N canvas 732 262 450 300 calc_misalignment 0;
+#X obj 12 14 inlet;
+#X obj 12 45 unpack f f f f f f f f f;
+#X obj 12 76 sig~;
+#X obj 45 76 sig~;
+#X obj 78 76 sig~;
+#X obj 111 76 sig~;
+#X obj 144 76 sig~;
+#X obj 177 76 sig~;
+#X obj 209 76 sig~;
+#X obj 242 76 sig~;
+#X obj 275 76 sig~;
+#X obj 13 104 r~ ramp;
+#X obj 13 129 -~;
+#X obj 44 129 -~ 1;
+#X obj 79 105 r~ ramp;
+#X obj 79 130 -~;
+#X obj 110 130 -~ 1;
+#X obj 145 104 r~ ramp;
+#X obj 145 129 -~;
+#X obj 176 129 -~ 1;
+#X obj 210 104 r~ ramp;
+#X obj 210 129 -~;
+#X obj 241 129 -~ 1;
+#X obj 275 105 r~ ramp;
+#X obj 275 130 -~;
+#X obj 146 205 /~ 9;
+#X obj 146 227 s~ misalignment;
+#X connect 0 0 1 0;
+#X connect 1 0 2 0;
+#X connect 1 1 3 0;
+#X connect 1 2 4 0;
+#X connect 1 3 5 0;
+#X connect 1 4 6 0;
+#X connect 1 5 7 0;
+#X connect 1 6 8 0;
+#X connect 1 7 9 0;
+#X connect 1 8 10 0;
+#X connect 2 0 12 0;
+#X connect 3 0 13 0;
+#X connect 4 0 15 0;
+#X connect 5 0 16 0;
+#X connect 6 0 18 0;
+#X connect 7 0 19 0;
+#X connect 8 0 21 0;
+#X connect 9 0 22 0;
+#X connect 10 0 24 0;
+#X connect 11 0 12 1;
+#X connect 12 0 25 0;
+#X connect 13 0 25 0;
+#X connect 14 0 15 1;
+#X connect 15 0 25 0;
+#X connect 16 0 25 0;
+#X connect 17 0 18 1;
+#X connect 18 0 25 0;
+#X connect 19 0 25 0;
+#X connect 20 0 21 1;
+#X connect 21 0 25 0;
+#X connect 22 0 25 0;
+#X connect 23 0 24 1;
+#X connect 24 0 25 0;
+#X connect 25 0 26 0;
+#X restore 249 185 pd calc_misalignment;
+#N canvas 0 0 450 300 send_coef 0;
+#X obj 25 68 unpack f f f f f f f f f;
+#X obj 25 261 s _0;
+#X obj 57 261 s _1;
+#X obj 89 261 s _2;
+#X obj 121 261 s _3;
+#X obj 153 261 s _4;
+#X obj 185 261 s _5;
+#X obj 217 261 s _6;
+#X obj 249 261 s _7;
+#X obj 281 261 s _8;
+#X obj 25 42 inlet;
+#X obj 25 102 speedlim 100;
+#X obj 45 130 speedlim 100;
+#X obj 65 154 speedlim 100;
+#X obj 86 180 speedlim 100;
+#X obj 116 103 speedlim 100;
+#X obj 136 131 speedlim 100;
+#X obj 156 155 speedlim 100;
+#X obj 177 181 speedlim 100;
+#X obj 270 181 speedlim 100;
+#X connect 0 0 11 0;
+#X connect 0 1 12 0;
+#X connect 0 2 13 0;
+#X connect 0 3 14 0;
+#X connect 0 4 15 0;
+#X connect 0 5 16 0;
+#X connect 0 6 17 0;
+#X connect 0 7 18 0;
+#X connect 0 8 19 0;
+#X connect 10 0 0 0;
+#X connect 11 0 1 0;
+#X connect 12 0 2 0;
+#X connect 13 0 3 0;
+#X connect 14 0 4 0;
+#X connect 15 0 5 0;
+#X connect 16 0 6 0;
+#X connect 17 0 7 0;
+#X connect 18 0 8 0;
+#X connect 19 0 9 0;
+#X restore 123 231 pd send_coef;
+#X connect 0 0 9 0;
+#X connect 2 0 9 1;
+#X connect 5 0 9 0;
+#X connect 6 0 5 0;
+#X connect 7 0 12 0;
+#X connect 8 0 9 0;
+#X connect 9 0 4 0;
+#X connect 9 2 13 0;
+#X connect 9 2 14 0;
+#X connect 10 0 11 0;
+#X connect 11 0 9 0;
+#X connect 12 0 8 0;
+#X restore 43 297 pd adaptive_filter~;
+#X text 51 201 x[n];
+#X text 183 219 d[n];
+#X text 33 316 y[n];
+#X floatatom 406 89 5 0 0 0 mu: mur mu;
+#N canvas 215 124 811 210 init 0;
+#X obj 321 45 loadbang;
+#X obj 330 124 s mur;
+#X msg 625 114 \; pd dsp \$1;
+#X obj 625 89 r audio_io;
+#X obj 395 127 s noiser;
+#X obj 463 130 s amp_in_r;
+#X msg 463 108 100;
+#X obj 175 146 s lengthr;
+#X msg 176 125 2000;
+#X msg 394 104 100;
+#X msg 329 100 1;
+#X connect 0 0 10 0;
+#X connect 0 0 9 0;
+#X connect 0 0 6 0;
+#X connect 0 0 8 0;
+#X connect 3 0 2 0;
+#X connect 6 0 5 0;
+#X connect 8 0 7 0;
+#X connect 9 0 4 0;
+#X connect 10 0 1 0;
+#X restore 845 651 pd init;
+#N canvas 0 145 485 394 PROBLEM_DESCRIPTION 0;
+#X text 29 288 unknown system:;
+#X text 201 29 TRACKING;
+#X text 30 118 The number of coefficients N=9 for the unknown and the
+adaptive system.;
+#X text 30 156 For an observation interval of 2000 samples \, the coefficients
+ot the unknown system do not remain constant: all even-indexed coefficients
+(h[0] \, h[2] \, ...) decrease linearly from the initial 1 to a final
+-1 \, all odd-indexed coefficients are constant 1;
+#X text 30 232 At the beginning the adaptive system has already found
+the unknown system (so all coefficients are 1).;
+#X text 55 308 h(n)= 1 for n=0..8;
+#X text 60 352 N = 9;
+#X text 29 333 number of coefficients for filter and unknown system:
+;
+#X text 32 66 In this example we want to examine the tracking behaviour
+of the LMS-algorithm in a time varying noisy sytem idebtification problem.
+;
+#X restore 34 94 pd PROBLEM_DESCRIPTION;
+#X text 33 73 ReadMe:;
+#N canvas 0 0 320 300 input_signal~ 0;
+#X obj 89 69 noise~;
+#X obj 89 196 *~;
+#X obj 89 255 outlet~;
+#X text 65 43 white signal:;
+#X obj 105 151 r amp_in;
+#X obj 105 174 dbtorms;
+#X obj 219 212 env~;
+#X obj 219 232 dbtorms;
+#X obj 219 254 s in_power;
+#X obj 107 223 s~ in_sig;
+#X connect 0 0 1 0;
+#X connect 1 0 2 0;
+#X connect 1 0 6 0;
+#X connect 1 0 9 0;
+#X connect 4 0 5 0;
+#X connect 5 0 1 1;
+#X connect 6 0 7 0;
+#X connect 7 0 8 0;
+#X restore 43 170 pd input_signal~;
+#X obj 172 260 +~;
+#N canvas 0 0 450 300 add_noise~ 0;
+#X obj 142 69 noise~;
+#X obj 142 173 *~;
+#X obj 158 111 r noise;
+#X obj 142 251 outlet~;
+#X obj 158 143 dbtorms;
+#X obj 266 191 s~ add-noise;
+#X connect 0 0 1 0;
+#X connect 1 0 3 0;
+#X connect 1 0 5 0;
+#X connect 2 0 4 0;
+#X connect 4 0 1 1;
+#X restore 224 244 pd add_noise~;
+#X floatatom 769 87 5 0 0 1 dB noiser noise;
+#X floatatom 581 88 5 0 0 1 dB amp_in_r amp_in;
+#N canvas 0 0 450 300 graph3 0;
+#X array MSE 20000 float 0;
+#X coords 0 100 19999 90 400 140 1;
+#X restore 405 254 graph;
+#N canvas 391 507 889 385 visualisation 0;
+#X obj 29 34 r start;
+#X obj 29 295 tabwrite~ MSE;
+#X obj 505 84 t b f;
+#X text 462 23 MSE:;
+#X obj 444 116 +;
+#X obj 617 65 r~ add-noise;
+#X obj 617 109 dbtorms;
+#X obj 617 133 s noise_power;
+#X obj 168 194 r~ add-noise;
+#X obj 56 221 +~;
+#X obj 429 268 loadbang;
+#X obj 444 64 r excess;
+#X obj 505 64 r noise_power;
+#X obj 459 144 s mse;
+#X obj 458 194 s mse_db;
+#X obj 444 169 rmstodb;
+#X obj 617 87 env~ 64;
+#X obj 56 249 env~ 64;
+#X msg 429 302 \; MSE xticks 0 500 5;
+#X obj 29 60 t b b b;
+#X obj 51 121 s start_ramp;
+#X obj 57 162 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X text 294 24 Excess Error:;
+#X obj 294 192 dbtorms;
+#X obj 309 157 s excess_db;
+#X obj 314 221 s excess;
+#X obj 294 133 env~ 64;
+#X floatatom 365 193 5 0 0 0 - - -;
+#X obj 293 64 r~ misalignment;
+#X obj 311 90 r~ in_sig;
+#X obj 294 111 *~;
+#X msg 552 337 \; MSE ylabel 20600 90 95 100;
+#X msg 563 302 \; MSE xlabel 89 0 5000 10000 15000 20000;
+#X connect 0 0 19 0;
+#X connect 2 0 4 0;
+#X connect 2 1 4 1;
+#X connect 4 0 13 0;
+#X connect 4 0 15 0;
+#X connect 5 0 16 0;
+#X connect 6 0 7 0;
+#X connect 8 0 9 1;
+#X connect 9 0 17 0;
+#X connect 10 0 31 0;
+#X connect 10 0 18 0;
+#X connect 10 0 32 0;
+#X connect 11 0 4 0;
+#X connect 12 0 2 0;
+#X connect 15 0 14 0;
+#X connect 16 0 6 0;
+#X connect 17 0 1 0;
+#X connect 19 0 1 0;
+#X connect 19 0 21 0;
+#X connect 19 1 20 0;
+#X connect 23 0 25 0;
+#X connect 26 0 23 0;
+#X connect 26 0 24 0;
+#X connect 26 0 27 0;
+#X connect 28 0 30 0;
+#X connect 29 0 30 1;
+#X connect 30 0 26 0;
+#X connect 30 0 9 0;
+#X restore 727 651 pd visualisation;
+#X text 385 105 (step-size);
+#X text 502 88 in-signal:;
+#X floatatom 581 105 6 0 0 1 rms in_power -;
+#X floatatom 769 104 6 0 0 1 rms noise_power -;
+#X text 693 87 add-noise:;
+#X text 468 216 MSE:;
+#X floatatom 508 215 5 0 0 1 dB mse_db -;
+#X floatatom 585 215 7 0 0 1 rms mse -;
+#X text 566 214 ->;
+#X text 787 228 MSE [dB];
+#X text 827 399 [samples];
+#X text 30 23 TRACKING - TIME VARYING NOISY SYSTEM IDENTIFICATION;
+#N canvas 0 0 450 110 NEEDED_EXTERNALS 0;
+#X text 17 31 For this patch you will need the zexy external by IOhannes
+Zmoelnig and the iemlib by Thomas Musil.;
+#X text 18 70 You can download them here: http://pd.iem.at;
+#X restore 793 7 pd NEEDED_EXTERNALS;
+#X text 444 90 e-03;
+#X text 536 104 power:;
+#X text 724 104 power:;
+#X floatatom 508 155 8 0 0 0 - lengthr length;
+#X text 421 154 ramp-length:;
+#X text 568 155 samples;
+#X text 407 198 Excess Error:;
+#X floatatom 508 198 5 0 0 1 dB excess_db -;
+#X floatatom 585 198 7 0 0 1 rms excess -;
+#X text 566 197 ->;
+#X obj 99 399 vradio 15 1 0 3 empty empty empty 0 -6 0 8 -262144 -1
+-1 2;
+#X text 116 398 too small mu;
+#X text 117 414 too big mu;
+#X text 117 428 proper step size;
+#N canvas 500 68 462 300 OBSERVATIONS 0;
+#X text 20 19 OBSERVATIONS;
+#X text 20 94 1.study:;
+#X text 42 124 too big mu: unstable;
+#X text 20 63 See the effect of different step sizes mu.;
+#X text 43 135 proper mu: adaptation works;
+#X text 19 182 Now we try to find the optimal step size mu.;
+#X text 19 207 2.study: candidate step sizes;
+#X text 42 112 too small mu: adaptation not possible;
+#X text 43 229 the optimal mu is something about mu=0.004;
+#X text 43 244 for mu < 0.004 the adaptation needs more time;
+#X text 43 258 for mu > 0.004 the coefficients are very unprecise;
+#X restore 34 116 pd OBSERVATIONS;
+#N canvas 0 0 450 300 graph1 0;
+#X array unknown 10 float 2;
+#X coords 0 1.2 9 -1.2 200 140 1;
+#X restore 400 474 graph;
+#N canvas 0 0 450 300 graph1 0;
+#X array adaptive 10 float 2;
+#X coords 0 1.2 9 -1.2 200 140 1;
+#X restore 691 472 graph;
+#X text 351 451 impulse response unknown system:;
+#X text 635 450 impulse response adaptive system:;
+#N canvas 37 0 1161 468 draw_tables 0;
+#X obj 37 20 r _0;
+#X obj 37 85 tabwrite adaptive;
+#X msg 151 61 1;
+#X obj 37 44 t f b;
+#X obj 188 86 tabwrite adaptive;
+#X obj 188 45 t f b;
+#X obj 341 86 tabwrite adaptive;
+#X obj 341 45 t f b;
+#X obj 490 87 tabwrite adaptive;
+#X obj 490 46 t f b;
+#X obj 643 89 tabwrite adaptive;
+#X obj 643 48 t f b;
+#X msg 302 62 2;
+#X msg 455 62 3;
+#X msg 604 63 4;
+#X msg 757 65 5;
+#X obj 188 21 r _1;
+#X obj 341 21 r _2;
+#X obj 490 22 r _3;
+#X obj 643 24 r _4;
+#X obj 37 179 tabwrite adaptive;
+#X obj 37 138 t f b;
+#X obj 190 179 tabwrite adaptive;
+#X obj 190 138 t f b;
+#X obj 339 180 tabwrite adaptive;
+#X obj 339 139 t f b;
+#X obj 492 182 tabwrite adaptive;
+#X obj 492 141 t f b;
+#X msg 151 155 6;
+#X msg 304 155 7;
+#X msg 453 156 8;
+#X msg 606 158 9;
+#X obj 37 114 r _5;
+#X obj 190 114 r _6;
+#X obj 339 115 r _7;
+#X obj 492 117 r _8;
+#X obj 36 252 r h_even;
+#X obj 187 252 r h_odd;
+#X msg 150 290 1;
+#X obj 36 273 t f b;
+#X obj 187 274 t f b;
+#X obj 340 274 t f b;
+#X obj 489 275 t f b;
+#X obj 642 277 t f b;
+#X msg 301 291 2;
+#X msg 454 291 3;
+#X msg 603 292 4;
+#X msg 756 294 5;
+#X obj 36 367 t f b;
+#X obj 189 367 t f b;
+#X obj 338 368 t f b;
+#X obj 491 370 t f b;
+#X msg 150 384 6;
+#X msg 303 384 7;
+#X msg 452 385 8;
+#X msg 605 387 9;
+#X obj 36 314 tabwrite unknown;
+#X obj 187 315 tabwrite unknown;
+#X obj 340 315 tabwrite unknown;
+#X obj 489 316 tabwrite unknown;
+#X obj 642 318 tabwrite unknown;
+#X obj 36 408 tabwrite unknown;
+#X obj 189 408 tabwrite unknown;
+#X obj 338 409 tabwrite unknown;
+#X obj 491 411 tabwrite unknown;
+#X obj 340 253 r h_even;
+#X obj 642 255 r h_even;
+#X obj 189 346 r h_even;
+#X obj 491 349 r h_even;
+#X obj 489 254 r h_odd;
+#X obj 36 345 r h_odd;
+#X obj 338 347 r h_odd;
+#X obj 861 114 loadbang;
+#X msg 861 142 \; adaptive yticks 0 0.1 5;
+#X msg 861 181 \; adaptive ylabel 9.7 -1 -0.5 0 0.5 1;
+#X msg 860 217 \; unknown yticks 0 0.1 5;
+#X msg 860 256 \; unknown ylabel 9.7 -1 -0.5 0 0.5 1;
+#X connect 0 0 3 0;
+#X connect 2 0 1 1;
+#X connect 3 0 1 0;
+#X connect 3 1 2 0;
+#X connect 5 0 4 0;
+#X connect 5 1 12 0;
+#X connect 7 0 6 0;
+#X connect 7 1 13 0;
+#X connect 9 0 8 0;
+#X connect 9 1 14 0;
+#X connect 11 0 10 0;
+#X connect 11 1 15 0;
+#X connect 12 0 4 1;
+#X connect 13 0 6 1;
+#X connect 14 0 8 1;
+#X connect 15 0 10 1;
+#X connect 16 0 5 0;
+#X connect 17 0 7 0;
+#X connect 18 0 9 0;
+#X connect 19 0 11 0;
+#X connect 21 0 20 0;
+#X connect 21 1 28 0;
+#X connect 23 0 22 0;
+#X connect 23 1 29 0;
+#X connect 25 0 24 0;
+#X connect 25 1 30 0;
+#X connect 27 0 26 0;
+#X connect 27 1 31 0;
+#X connect 28 0 20 1;
+#X connect 29 0 22 1;
+#X connect 30 0 24 1;
+#X connect 31 0 26 1;
+#X connect 32 0 21 0;
+#X connect 33 0 23 0;
+#X connect 34 0 25 0;
+#X connect 35 0 27 0;
+#X connect 36 0 39 0;
+#X connect 37 0 40 0;
+#X connect 38 0 56 1;
+#X connect 39 0 56 0;
+#X connect 39 1 38 0;
+#X connect 40 0 57 0;
+#X connect 40 1 44 0;
+#X connect 41 0 58 0;
+#X connect 41 1 45 0;
+#X connect 42 0 59 0;
+#X connect 42 1 46 0;
+#X connect 43 0 60 0;
+#X connect 43 1 47 0;
+#X connect 44 0 57 1;
+#X connect 45 0 58 1;
+#X connect 46 0 59 1;
+#X connect 47 0 60 1;
+#X connect 48 0 61 0;
+#X connect 48 1 52 0;
+#X connect 49 0 62 0;
+#X connect 49 1 53 0;
+#X connect 50 0 63 0;
+#X connect 50 1 54 0;
+#X connect 51 0 64 0;
+#X connect 51 1 55 0;
+#X connect 52 0 61 1;
+#X connect 53 0 62 1;
+#X connect 54 0 63 1;
+#X connect 55 0 64 1;
+#X connect 65 0 41 0;
+#X connect 66 0 43 0;
+#X connect 67 0 49 0;
+#X connect 68 0 51 0;
+#X connect 69 0 42 0;
+#X connect 70 0 48 0;
+#X connect 71 0 50 0;
+#X connect 72 0 73 0;
+#X connect 72 0 74 0;
+#X connect 72 0 75 0;
+#X connect 72 0 76 0;
+#X restore 623 651 pd draw_tables;
+#N canvas 40 12 435 335 mu-study-1 0;
+#X obj 24 21 inlet;
+#X obj 79 128 s mur;
+#X obj 138 128 s noiser;
+#X obj 200 128 s amp_in_r;
+#X obj 24 126 s start;
+#X msg 24 103 bang;
+#X msg 200 105 100;
+#X obj 78 202 s mur;
+#X obj 120 203 s noiser;
+#X obj 181 203 s amp_in_r;
+#X obj 23 201 s start;
+#X msg 23 178 bang;
+#X obj 77 279 s mur;
+#X obj 119 280 s noiser;
+#X obj 180 280 s amp_in_r;
+#X obj 22 278 s start;
+#X msg 22 255 bang;
+#X obj 24 50 sel 0 1 2;
+#X msg 137 105 100;
+#X msg 119 180 100;
+#X msg 181 180 100;
+#X msg 180 257 100;
+#X msg 120 257 100;
+#X msg 78 179 1000;
+#X msg 77 256 1;
+#X obj 275 128 s read;
+#X obj 257 203 s read;
+#X obj 256 280 s read;
+#X obj 24 78 t b b b;
+#X obj 23 153 t b b b;
+#X obj 22 230 t b b b;
+#X msg 79 105 1e-05;
+#X connect 0 0 17 0;
+#X connect 5 0 4 0;
+#X connect 6 0 3 0;
+#X connect 11 0 10 0;
+#X connect 16 0 15 0;
+#X connect 17 0 28 0;
+#X connect 17 1 29 0;
+#X connect 17 2 30 0;
+#X connect 18 0 2 0;
+#X connect 19 0 8 0;
+#X connect 20 0 9 0;
+#X connect 21 0 14 0;
+#X connect 22 0 13 0;
+#X connect 23 0 7 0;
+#X connect 24 0 12 0;
+#X connect 28 0 5 0;
+#X connect 28 1 31 0;
+#X connect 28 1 18 0;
+#X connect 28 1 6 0;
+#X connect 28 2 25 0;
+#X connect 29 0 11 0;
+#X connect 29 1 23 0;
+#X connect 29 1 19 0;
+#X connect 29 1 20 0;
+#X connect 29 2 26 0;
+#X connect 30 0 16 0;
+#X connect 30 1 24 0;
+#X connect 30 1 22 0;
+#X connect 30 1 21 0;
+#X connect 30 2 27 0;
+#X connect 31 0 1 0;
+#X restore 99 446 pd mu-study-1;
+#N canvas 56 35 192 821 mu-study-2 0;
+#X obj 24 21 inlet;
+#X obj 79 127 s mur;
+#X obj 24 126 s start;
+#X msg 24 103 bang;
+#X obj 78 202 s mur;
+#X obj 23 201 s start;
+#X msg 23 178 bang;
+#X obj 77 279 s mur;
+#X obj 22 278 s start;
+#X msg 22 255 bang;
+#X obj 24 50 sel 0 1 2 3 4 5 6 7;
+#X obj 77 352 s mur;
+#X obj 22 351 s start;
+#X msg 22 328 bang;
+#X obj 76 427 s mur;
+#X obj 21 426 s start;
+#X msg 21 403 bang;
+#X obj 75 504 s mur;
+#X obj 20 503 s start;
+#X msg 20 480 bang;
+#X obj 75 580 s mur;
+#X obj 20 579 s start;
+#X msg 20 556 bang;
+#X obj 74 657 s mur;
+#X obj 19 656 s start;
+#X msg 19 633 bang;
+#X msg 75 557 1;
+#X obj 24 78 t b b b;
+#X obj 23 153 t b b b;
+#X obj 22 230 t b b b;
+#X obj 22 303 t b b b;
+#X obj 21 378 t b b b;
+#X obj 20 455 t b b b;
+#X obj 20 531 t b b b;
+#X obj 19 608 t b b b;
+#X obj 119 127 s read;
+#X obj 118 202 s read;
+#X obj 117 279 s read;
+#X obj 117 352 s read;
+#X obj 116 427 s read;
+#X obj 115 504 s read;
+#X obj 115 580 s read;
+#X obj 114 657 s read;
+#X msg 79 104 100;
+#X msg 78 179 10;
+#X msg 74 634 0.1;
+#X msg 75 481 2;
+#X msg 76 405 4;
+#X msg 77 329 6;
+#X msg 77 256 8;
+#X connect 0 0 10 0;
+#X connect 3 0 2 0;
+#X connect 6 0 5 0;
+#X connect 9 0 8 0;
+#X connect 10 0 27 0;
+#X connect 10 1 28 0;
+#X connect 10 2 29 0;
+#X connect 10 3 30 0;
+#X connect 10 4 31 0;
+#X connect 10 5 32 0;
+#X connect 10 6 33 0;
+#X connect 10 7 34 0;
+#X connect 13 0 12 0;
+#X connect 16 0 15 0;
+#X connect 19 0 18 0;
+#X connect 22 0 21 0;
+#X connect 25 0 24 0;
+#X connect 26 0 20 0;
+#X connect 27 0 3 0;
+#X connect 27 1 43 0;
+#X connect 27 2 35 0;
+#X connect 28 0 6 0;
+#X connect 28 1 44 0;
+#X connect 28 2 36 0;
+#X connect 29 0 9 0;
+#X connect 29 1 49 0;
+#X connect 29 2 37 0;
+#X connect 30 0 13 0;
+#X connect 30 1 48 0;
+#X connect 30 2 38 0;
+#X connect 31 0 16 0;
+#X connect 31 1 47 0;
+#X connect 31 2 39 0;
+#X connect 32 0 19 0;
+#X connect 32 1 46 0;
+#X connect 32 2 40 0;
+#X connect 33 0 22 0;
+#X connect 33 1 26 0;
+#X connect 33 2 41 0;
+#X connect 34 0 25 0;
+#X connect 34 1 45 0;
+#X connect 34 2 42 0;
+#X connect 43 0 1 0;
+#X connect 44 0 4 0;
+#X connect 45 0 23 0;
+#X connect 46 0 17 0;
+#X connect 47 0 14 0;
+#X connect 48 0 11 0;
+#X connect 49 0 7 0;
+#X restore 99 632 pd mu-study-2;
+#X obj 99 509 vradio 15 1 0 8 empty empty empty 0 -6 0 8 -262144 -1
+-1 7;
+#X text 97 488 candidate step sizes:;
+#X text 117 508 mu=0.1;
+#X text 117 523 mu=0.01;
+#X text 117 538 mu=0.008;
+#X text 117 553 mu=0.006;
+#X text 117 568 mu=0.004;
+#X text 117 583 mu=0.002;
+#X text 117 598 mu=0.001;
+#X text 117 614 mu=0.0001;
+#X connect 0 0 12 0;
+#X connect 11 0 0 0;
+#X connect 11 0 3 0;
+#X connect 12 0 3 1;
+#X connect 13 0 12 1;
+#X connect 41 0 51 0;
+#X connect 53 0 52 0;
diff --git a/adaptive/examples/06.interference_cancelation.pd b/adaptive/examples/06.interference_cancelation.pd
new file mode 100755
index 0000000..622b646
--- /dev/null
+++ b/adaptive/examples/06.interference_cancelation.pd
@@ -0,0 +1,323 @@
+#N canvas 28 0 821 766 10;
+#N canvas 880 339 427 348 adaptive_filter~ 0;
+#X obj 37 35 inlet~;
+#X text 22 15 input signal;
+#X obj 138 35 inlet~;
+#X text 122 15 desired signal;
+#X obj 36 291 outlet~;
+#X msg 265 110 adaptation 1;
+#X obj 265 89 loadbang;
+#X msg 264 209 clear;
+#X obj 265 141 r mu;
+#X msg 265 163 mu \$1;
+#X obj 88 291 outlet~;
+#X obj 269 38 block~ 128;
+#X obj 37 155 nlms2~ 100 0.01;
+#X connect 0 0 12 0;
+#X connect 2 0 12 1;
+#X connect 5 0 12 0;
+#X connect 6 0 5 0;
+#X connect 7 0 12 0;
+#X connect 8 0 9 0;
+#X connect 9 0 12 0;
+#X connect 12 0 4 0;
+#X connect 12 1 10 0;
+#X restore 133 428 pd adaptive_filter~;
+#X text 257 404 d[n];
+#X text 140 447 y[n];
+#N canvas 0 0 450 300 speech_sample~ 0;
+#X obj 15 26 inlet;
+#X obj 44 262 outlet~;
+#X obj 45 202 readsf~;
+#X msg 45 144 open /win/Georg/pd/holzilib/samples/Mandarin.wav;
+#X obj 130 80 openpanel;
+#X obj 130 57 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X msg 130 105 set open \$1;
+#X obj 89 224 t b b;
+#X msg 73 170 1;
+#X obj 15 83 t f b;
+#X obj 183 41 inlet;
+#X connect 0 0 9 0;
+#X connect 2 0 1 0;
+#X connect 2 1 7 0;
+#X connect 3 0 2 0;
+#X connect 4 0 6 0;
+#X connect 5 0 4 0;
+#X connect 6 0 3 0;
+#X connect 7 0 8 0;
+#X connect 7 1 3 0;
+#X connect 8 0 2 0;
+#X connect 9 0 2 0;
+#X connect 9 1 3 0;
+#X connect 10 0 4 0;
+#X restore 135 203 pd speech_sample~;
+#N canvas 427 384 325 189 delay~ 0;
+#X obj 15 20 inlet~;
+#X obj 15 136 outlet~;
+#X obj 15 47 delwrite~ \$0-line 100;
+#X obj 15 104 delread~ \$0-line 10;
+#X text 30 77 10 ms delay;
+#X connect 0 0 2 0;
+#X connect 3 0 1 0;
+#X restore 134 376 pd delay~;
+#X obj 135 173 tgl 25 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1
+1;
+#X obj 471 255 spectrum~;
+#X obj 471 238 r~ adaptive_signal;
+#X obj 722 238 r scopes_on;
+#X obj 722 26 r scopes_on;
+#X text 428 137 (1);
+#X text 428 338 (2);
+#X obj 632 26 r tlp;
+#X obj 632 238 r tlp;
+#X obj 471 43 spectrum~;
+#X obj 471 26 r~ input_signal;
+#X obj 249 183 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X text 222 167 open sample;
+#X text 138 178 IO;
+#X text 25 25 PERIODIC INTERFERENCE CANCELATION WITHOUT AN EXTERNAL
+REFERENCE SOURCE;
+#N canvas 609 171 479 356 PROBLEM_DESCRIPTION 0;
+#X text 119 29 PERIODIC INTERFERENCE CANCELATION;
+#X text 24 74 In this example the adaptive filter is used as an adaptive
+linear predictor to remove a periodic interference broadband signal.
+;
+#X text 62 204 LMS \, 100 coefficients (c0 \, c1 \, ...c100) ->sharper
+filter and less distortion \, step-sze parameter mu;
+#X text 24 122 A speech signal is used as the broadband signal and
+a sine is used as the interference signal. The speechsignal serves
+as input signal and is delayed about 10 ms.;
+#X text 21 186 adaptive filter:;
+#X text 29 271 The interference cancelation is sucessfull \, if the
+inteference signal is removed such that only the speechsignal is audible
+(prediction error).;
+#X restore 27 92 pd PROBLEM_DESCRIPTION;
+#N canvas 852 16 434 175 OBSERVATIONS 0;
+#X text 17 24 OBSERVATIONS;
+#X text 15 68 With an order of 100 the interference cancelation works
+quite well.;
+#X text 15 106 For lower frequencies (< 300) the cancelation is not
+as satisfying as for higher frequencies.;
+#X restore 27 116 pd OBSERVATIONS;
+#X text 26 71 ReadMe:;
+#X obj 296 695 tgl 20 0 audio_io empty empty 0 -6 0 8 -262144 -1 -1
+1 1;
+#X text 321 697 <- Audio IO;
+#X obj 37 699 tgl 20 0 scopes_on empty empty 0 -6 0 8 -262144 -1 -1
+0 1;
+#X text 67 699 <- Visualization IO;
+#X floatatom 37 732 5 0 100 0 - init_tlp tlp;
+#X text 81 730 <- temporal lowpass for spectrum view (0...100);
+#N canvas 752 62 617 210 init 0;
+#X msg 43 99 2;
+#X obj 256 43 loadbang;
+#X obj 43 122 s init_tlp;
+#X obj 257 122 s mur;
+#X msg 256 98 0.01;
+#X msg 515 103 \; pd dsp \$1;
+#X obj 515 78 r audio_io;
+#X msg 138 96 90;
+#X obj 139 122 s vol;
+#X obj 188 122 s sel_in;
+#X msg 187 96 0;
+#X msg 336 89 \; f1 1000 \; f2 8070 \; f3 12050 \; a1 90 \; a2 35 \;
+a3 68 \;;
+#X connect 0 0 2 0;
+#X connect 1 0 0 0;
+#X connect 1 0 4 0;
+#X connect 1 0 7 0;
+#X connect 1 0 10 0;
+#X connect 1 0 11 0;
+#X connect 4 0 3 0;
+#X connect 6 0 5 0;
+#X connect 7 0 8 0;
+#X connect 10 0 9 0;
+#X restore 750 662 pd init;
+#X floatatom 371 641 6 0 0 0 - mur mu;
+#X obj 471 467 spectrum~;
+#X obj 722 450 r scopes_on;
+#X obj 632 450 r tlp;
+#X text 428 550 (3);
+#X text 269 448 e[n];
+#X obj 471 450 r~ filter_signal;
+#N canvas 647 406 282 264 osci~ 0;
+#X obj 43 79 osc~ 440;
+#X obj 44 168 *~;
+#X obj 147 112 dbtorms;
+#X obj 43 38 inlet;
+#X obj 147 38 inlet;
+#X obj 146 152 line~;
+#X msg 146 132 \$1 50;
+#X obj 44 200 outlet~;
+#X connect 0 0 1 0;
+#X connect 1 0 7 0;
+#X connect 2 0 6 0;
+#X connect 3 0 0 0;
+#X connect 4 0 2 0;
+#X connect 5 0 1 1;
+#X connect 6 0 5 0;
+#X restore 151 289 pd osci~;
+#X floatatom 151 261 5 0 20000 1 Hz f1 -;
+#X floatatom 164 275 4 0 120 1 dB a1 -;
+#N canvas 647 406 282 264 osci~ 0;
+#X obj 43 79 osc~ 440;
+#X obj 44 168 *~;
+#X obj 147 112 dbtorms;
+#X obj 43 38 inlet;
+#X obj 147 38 inlet;
+#X obj 146 152 line~;
+#X msg 146 132 \$1 50;
+#X obj 44 200 outlet~;
+#X connect 0 0 1 0;
+#X connect 1 0 7 0;
+#X connect 2 0 6 0;
+#X connect 3 0 0 0;
+#X connect 4 0 2 0;
+#X connect 5 0 1 1;
+#X connect 6 0 5 0;
+#X restore 218 289 pd osci~;
+#X floatatom 218 261 5 0 20000 1 Hz f2 -;
+#X floatatom 231 275 4 0 120 1 dB a2 -;
+#N canvas 647 406 282 264 osci~ 0;
+#X obj 43 79 osc~ 440;
+#X obj 44 168 *~;
+#X obj 147 112 dbtorms;
+#X obj 43 38 inlet;
+#X obj 147 38 inlet;
+#X obj 146 152 line~;
+#X msg 146 132 \$1 50;
+#X obj 44 200 outlet~;
+#X connect 0 0 1 0;
+#X connect 1 0 7 0;
+#X connect 2 0 6 0;
+#X connect 3 0 0 0;
+#X connect 4 0 2 0;
+#X connect 5 0 1 1;
+#X connect 6 0 5 0;
+#X restore 285 289 pd osci~;
+#X floatatom 285 261 5 0 20000 1 Hz f3 -;
+#X floatatom 298 275 4 0 120 1 dB a3 -;
+#X text 150 238 interference signals:;
+#N canvas 880 450 292 275 input~ 0;
+#X obj 17 24 inlet~;
+#X obj 138 24 inlet~;
+#X obj 18 89 +~;
+#X obj 19 121 *~ 0.1;
+#X obj 19 225 outlet~;
+#X obj 47 169 s~ input_signal;
+#X connect 0 0 2 0;
+#X connect 1 0 2 1;
+#X connect 2 0 3 0;
+#X connect 3 0 4 0;
+#X connect 3 0 5 0;
+#X restore 134 321 pd input~;
+#N canvas 880 302 450 408 audio_out~ 0;
+#X obj 67 41 inlet;
+#X text 63 24 volume;
+#X obj 272 37 inlet;
+#X obj 67 61 dbtorms;
+#X msg 67 81 \$1 50;
+#X text 249 21 select insignal;
+#X obj 272 97 sel 0 1 2;
+#X msg 68 150 1 50;
+#X msg 105 150 0 50;
+#X obj 68 177 line~;
+#X obj 51 219 *~;
+#X msg 199 149 1 50;
+#X msg 236 149 0 50;
+#X obj 199 176 line~;
+#X obj 182 219 *~;
+#X msg 310 150 1 50;
+#X msg 347 150 0 50;
+#X obj 310 177 line~;
+#X obj 293 219 *~;
+#X obj 293 198 r~ filter_signal;
+#X obj 52 289 *~;
+#X obj 67 262 line~;
+#X obj 52 364 dac~ 1 2;
+#X obj 158 364 outlet;
+#X obj 182 198 r~ input_signal;
+#X obj 51 198 r~ adaptive_signal;
+#X connect 0 0 3 0;
+#X connect 0 0 23 0;
+#X connect 2 0 6 0;
+#X connect 3 0 4 0;
+#X connect 4 0 21 0;
+#X connect 6 0 7 0;
+#X connect 6 0 12 0;
+#X connect 6 0 16 0;
+#X connect 6 1 11 0;
+#X connect 6 1 8 0;
+#X connect 6 1 16 0;
+#X connect 6 2 15 0;
+#X connect 6 2 12 0;
+#X connect 6 2 8 0;
+#X connect 7 0 9 0;
+#X connect 8 0 9 0;
+#X connect 9 0 10 1;
+#X connect 10 0 20 0;
+#X connect 11 0 13 0;
+#X connect 12 0 13 0;
+#X connect 13 0 14 1;
+#X connect 14 0 20 0;
+#X connect 15 0 17 0;
+#X connect 16 0 17 0;
+#X connect 17 0 18 1;
+#X connect 18 0 20 0;
+#X connect 19 0 18 0;
+#X connect 20 0 22 0;
+#X connect 20 0 22 1;
+#X connect 21 0 20 1;
+#X connect 24 0 14 0;
+#X connect 25 0 10 0;
+#X restore 35 586 pd audio_out~;
+#X floatatom 35 605 5 0 0 1 dB - -;
+#X obj 35 450 vsl 20 128 0 127 0 0 empty vol empty 0 -8 0 8 -262144
+-1 -1 9000 1;
+#X obj 130 543 vradio 20 1 0 3 empty sel_in empty 0 -6 0 8 -262144
+-1 -1 0;
+#X text 233 640 learning rate (mu):;
+#X obj 260 465 s~ adaptive_signal;
+#X obj 134 465 s~ filter_signal;
+#X text 152 545 filtered output (e[n]);
+#X text 104 340 x[n];
+#X text 152 565 input signal (x[n] \, d[n]);
+#X text 153 584 periodic signal (y[n]);
+#X text 34 432 vol;
+#X text 120 525 select;
+#X text 496 689 VISUALIZATIONS:;
+#X text 529 711 (1) input signal (= voice + sine);
+#X text 529 741 (3) y[n] (~ only sine);
+#X text 529 726 (2) error signal (~ only voice);
+#X text 47 259 modify freq ->;
+#X connect 0 0 54 0;
+#X connect 0 1 53 0;
+#X connect 3 0 47 0;
+#X connect 4 0 0 0;
+#X connect 5 0 3 0;
+#X connect 7 0 6 0;
+#X connect 8 0 6 2;
+#X connect 9 0 14 2;
+#X connect 12 0 14 1;
+#X connect 13 0 6 1;
+#X connect 15 0 14 0;
+#X connect 16 0 3 1;
+#X connect 32 0 31 2;
+#X connect 33 0 31 1;
+#X connect 36 0 31 0;
+#X connect 37 0 47 1;
+#X connect 38 0 37 0;
+#X connect 39 0 37 1;
+#X connect 40 0 47 1;
+#X connect 41 0 40 0;
+#X connect 42 0 40 1;
+#X connect 43 0 47 1;
+#X connect 44 0 43 0;
+#X connect 45 0 43 1;
+#X connect 47 0 0 1;
+#X connect 47 0 4 0;
+#X connect 48 0 49 0;
+#X connect 50 0 48 0;
+#X connect 51 0 48 1;
diff --git a/adaptive/examples/07.adaptive_equalization.pd b/adaptive/examples/07.adaptive_equalization.pd
new file mode 100755
index 0000000..49ae4af
--- /dev/null
+++ b/adaptive/examples/07.adaptive_equalization.pd
@@ -0,0 +1,447 @@
+#N canvas 0 0 838 657 10;
+#N canvas 713 200 450 300 delay~ 0;
+#X obj 74 145 delread~ \$0-line 10;
+#X obj 124 86 delwrite~ \$0-line 2000;
+#X obj 125 64 r~ input;
+#X obj 74 170 throw~ in_delayed;
+#X obj 74 26 inlet;
+#X connect 0 0 3 0;
+#X connect 2 0 1 0;
+#X connect 4 0 0 0;
+#X restore 292 335 pd delay~;
+#N canvas 221 213 610 340 channel~ 0;
+#X obj 218 294 s~ channel;
+#X obj 40 28 r~ input;
+#X obj 56 78 expr if($f1==1 \, 1 \, 0);
+#X obj 56 58 r mode;
+#X obj 56 98 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
+;
+#X obj 40 116 *~;
+#X obj 234 59 r mode;
+#X obj 234 99 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
+;
+#X obj 218 117 *~;
+#X obj 218 29 r~ eq;
+#X obj 234 79 expr if($f1==2 \, 1 \, 0);
+#N canvas 582 508 581 396 a_room~ 0;
+#X obj 29 30 inlet~;
+#X obj 27 358 outlet~;
+#X obj 367 219 bp~ 500 10;
+#X obj 29 144 dac~;
+#X obj 27 273 adc~;
+#X text 27 163 speaker;
+#X text 25 211 a room;
+#X text 25 254 micro;
+#X obj 46 53 s~ vol_out;
+#X obj 28 89 *~;
+#X obj 57 89 r~ out_vol;
+#X obj 27 300 *~;
+#X obj 56 300 r~ in_vol;
+#X obj 398 170 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1
+1;
+#X obj 366 185 *~;
+#X obj 398 130 r channel;
+#X obj 368 291 *~;
+#X text 365 104 dummy filter + latency;
+#X obj 174 101 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+1;
+#X obj 29 116 *~;
+#X obj 174 61 r channel;
+#X text 169 40 real room;
+#X obj 27 330 *~;
+#X obj 174 81 expr if($f1==1 \, 1 \, 0);
+#X obj 398 150 expr if($f1==0 \, 1 \, 0);
+#X obj 369 266 delread~ \$0-line2 10;
+#X obj 368 242 delwrite~ \$0-line2 11;
+#X connect 0 0 8 0;
+#X connect 0 0 9 0;
+#X connect 0 0 14 0;
+#X connect 2 0 26 0;
+#X connect 4 0 11 0;
+#X connect 9 0 19 0;
+#X connect 10 0 9 1;
+#X connect 11 0 22 0;
+#X connect 12 0 11 1;
+#X connect 13 0 14 1;
+#X connect 13 0 16 1;
+#X connect 14 0 2 0;
+#X connect 15 0 24 0;
+#X connect 16 0 1 0;
+#X connect 18 0 19 1;
+#X connect 18 0 22 1;
+#X connect 19 0 3 0;
+#X connect 20 0 23 0;
+#X connect 22 0 1 0;
+#X connect 23 0 18 0;
+#X connect 24 0 13 0;
+#X connect 25 0 16 0;
+#X restore 218 207 pd a_room~;
+#X obj 385 31 catch~ channel_in;
+#X obj 402 59 r mode;
+#X obj 402 99 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
+;
+#X obj 386 117 *~;
+#X obj 402 79 expr if($f1==0 \, 1 \, 0);
+#X obj 231 239 throw~ channel_out;
+#X connect 1 0 5 0;
+#X connect 2 0 4 0;
+#X connect 3 0 2 0;
+#X connect 4 0 5 1;
+#X connect 5 0 11 0;
+#X connect 6 0 10 0;
+#X connect 7 0 8 1;
+#X connect 8 0 11 0;
+#X connect 9 0 8 0;
+#X connect 10 0 7 0;
+#X connect 11 0 0 0;
+#X connect 11 0 17 0;
+#X connect 12 0 15 0;
+#X connect 13 0 16 0;
+#X connect 14 0 15 1;
+#X connect 15 0 11 0;
+#X connect 16 0 14 0;
+#X restore 78 354 pd channel~;
+#N canvas 775 0 479 464 PROBLEM_DESCRIPTION 0;
+#X text 166 24 INVERSE MODELLING;
+#X text 34 66 Now the signal source is split up into an unknown channel
+and the desired signal is delayed added into the adaption process.
+;
+#X text 32 115 The goal is to adapt the channel \, so that the overal
+system has a flat frequency response:;
+#X text 32 177 So the overal system is a delayed version of the input
+signal.;
+#X text 47 312 1 select a channel (dummy system or a real room - so
+you will need a loudspeaker and a microphone);
+#X text 142 154 H_ch(z) * H_eq(z) = z^-M;
+#X text 45 381 3 train the system \, to get H_eq(z) (use speech- or
+music samples to train the real room);
+#X text 46 414 4 use the euqlized system (in case of a real room you
+should have a nearly flat frequency response in that room);
+#X text 30 290 Usage of the patch:;
+#X text 47 347 2 measure the latency of your system (for real room:
+don't forget to turn on the volumes for micro and speaker);
+#X text 60 239 a) dummy system: a simple bandpass filter with a delay
+;
+#X text 62 253 b) real room: loudspeaker - a room - micro;
+#X text 29 221 You can select between two different channels:;
+#X restore 28 83 pd PROBLEM_DESCRIPTION;
+#N canvas 844 224 455 275 OBSERVATIONS 0;
+#X text 152 22 OBSERVATIONS;
+#X text 32 95 The magnitude of the frequency response can be equalized.
+;
+#X text 14 75 dummy system:;
+#X text 16 128 a real room:;
+#X text 33 148 The magnitude of the frequency can only be equalized
+if you have an input signal with high energy.;
+#X text 31 181 The adaptation has problems with noise as input signal
+\, because noise is totally uncorrelated \, so you to measure the latency
+very precise.;
+#X text 30 227 Because of that it is better to use more correlated
+signals such as music or speech samples.;
+#X restore 28 107 pd OBSERVATIONS;
+#X text 27 62 ReadMe:;
+#X obj 491 42 spectrum~;
+#X obj 742 25 r scopes_on;
+#X obj 652 25 r tlp;
+#N canvas 752 62 617 210 init 0;
+#X msg 43 99 2;
+#X obj 256 43 loadbang;
+#X obj 43 122 s init_tlp;
+#X obj 213 120 s mur;
+#X msg 212 96 0.01;
+#X msg 515 103 \; pd dsp \$1;
+#X obj 515 78 r audio_io;
+#X obj 145 122 s moder;
+#X msg 145 100 3;
+#X obj 268 119 s channelr;
+#X msg 268 97 0;
+#X obj 352 119 s insigr;
+#X msg 353 98 0;
+#X connect 0 0 2 0;
+#X connect 1 0 0 0;
+#X connect 1 0 4 0;
+#X connect 1 0 8 0;
+#X connect 1 0 10 0;
+#X connect 1 0 12 0;
+#X connect 4 0 3 0;
+#X connect 6 0 5 0;
+#X connect 8 0 7 0;
+#X connect 10 0 9 0;
+#X connect 12 0 11 0;
+#X restore 770 449 pd init;
+#X obj 491 254 spectrum~;
+#X obj 742 237 r scopes_on;
+#X obj 652 237 r tlp;
+#X text 496 497 VISUALIZATIONS:;
+#X obj 298 577 tgl 20 0 audio_io empty empty 0 -6 0 8 -262144 -1 -1
+0 1;
+#X text 323 579 <- Audio IO;
+#X obj 42 579 tgl 20 0 scopes_on empty empty 0 -6 0 8 -262144 -1 -1
+0 1;
+#X text 69 581 <- Visualization IO;
+#X floatatom 42 612 5 0 100 0 - init_tlp tlp;
+#X text 83 612 <- temporal lowpass for spectrum view (0...100);
+#X floatatom 367 533 6 0 0 0 - mur mu;
+#X text 229 532 learning rate (mu):;
+#X text 26 26 ADAPTIVE EQUALIZATION: INVERSE MODELING;
+#X obj 491 25 r~ eq;
+#X obj 491 237 r~ channel;
+#N canvas 869 353 450 300 input_signal~ 0;
+#X obj 59 74 noise~;
+#X obj 58 244 s~ input;
+#X obj 333 120 inlet;
+#N canvas 0 0 450 300 sample~ 0;
+#X obj 15 26 inlet;
+#X obj 44 262 outlet~;
+#X obj 45 202 readsf~;
+#X msg 45 144 open /win/Georg/pd/holzilib/samples/Mandarin.wav;
+#X obj 130 80 openpanel;
+#X obj 130 57 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X msg 130 105 set open \$1;
+#X obj 89 224 t b b;
+#X msg 73 170 1;
+#X obj 15 83 t f b;
+#X obj 183 41 inlet;
+#X connect 0 0 9 0;
+#X connect 2 0 1 0;
+#X connect 2 1 7 0;
+#X connect 3 0 2 0;
+#X connect 4 0 6 0;
+#X connect 5 0 4 0;
+#X connect 6 0 3 0;
+#X connect 7 0 8 0;
+#X connect 7 1 3 0;
+#X connect 8 0 2 0;
+#X connect 9 0 2 0;
+#X connect 9 1 3 0;
+#X connect 10 0 4 0;
+#X restore 268 150 pd sample~;
+#X obj 268 74 r insig;
+#X obj 268 98 expr if($f1==1 \, 1 \, 0);
+#X obj 268 122 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+1;
+#X obj 58 138 *~;
+#X obj 106 75 r insig;
+#X obj 106 123 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+1;
+#X obj 106 99 expr if($f1==0 \, 1 \, 0);
+#X connect 0 0 7 0;
+#X connect 2 0 3 1;
+#X connect 3 0 1 0;
+#X connect 4 0 5 0;
+#X connect 5 0 6 0;
+#X connect 6 0 3 0;
+#X connect 7 0 1 0;
+#X connect 8 0 10 0;
+#X connect 9 0 7 1;
+#X connect 10 0 9 0;
+#X restore 144 293 pd input_signal~;
+#N canvas 573 367 441 300 adaptive_equalizer~ 0;
+#X obj 52 248 s~ eq;
+#X obj 71 184 r~ channel;
+#N canvas 922 527 390 347 nlms3~ 0;
+#X obj 37 35 inlet~;
+#X obj 268 36 inlet~;
+#X text 247 16 desired signal;
+#X obj 36 291 outlet~;
+#X obj 261 135 loadbang;
+#X msg 264 300 clear;
+#X obj 262 250 r mu;
+#X msg 262 272 mu \$1;
+#X obj 150 34 inlet~;
+#X text 36 313 outsig1;
+#X text 38 14 insig1;
+#X text 149 15 insig2;
+#X msg 274 201 init_unity;
+#X obj 261 156 t b b;
+#X msg 59 96 print;
+#X obj 263 86 block~ 128;
+#X msg 261 178 adaptation 0;
+#X obj 341 38 inlet;
+#X obj 37 156 nlms3~ 10 0.01;
+#X connect 0 0 18 0;
+#X connect 1 0 18 2;
+#X connect 4 0 13 0;
+#X connect 5 0 18 0;
+#X connect 6 0 7 0;
+#X connect 7 0 18 0;
+#X connect 8 0 18 1;
+#X connect 12 0 18 0;
+#X connect 13 0 16 0;
+#X connect 13 1 12 0;
+#X connect 14 0 18 0;
+#X connect 16 0 18 0;
+#X connect 17 0 18 0;
+#X connect 18 0 3 0;
+#X restore 51 220 pd nlms3~;
+#X obj 66 94 expr if($f1==1 \, 1 \, 0);
+#X obj 66 74 r mode;
+#X obj 66 114 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
+;
+#X obj 50 132 *~;
+#X obj 282 205 expr if($f1==1 \, 1 \, 0);
+#X obj 282 185 r mode;
+#X obj 282 225 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+1;
+#X msg 282 244 adaptation \$1;
+#X obj 251 75 r mode;
+#X obj 251 115 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+1;
+#X obj 235 133 *~;
+#X obj 251 95 expr if($f1==2 \, 1 \, 0);
+#X obj 50 44 r~ channel;
+#X obj 235 45 r~ input;
+#X obj 147 184 catch~ in_delayed;
+#X connect 1 0 2 1;
+#X connect 2 0 0 0;
+#X connect 3 0 5 0;
+#X connect 4 0 3 0;
+#X connect 5 0 6 1;
+#X connect 6 0 2 0;
+#X connect 7 0 9 0;
+#X connect 8 0 7 0;
+#X connect 9 0 10 0;
+#X connect 10 0 2 3;
+#X connect 11 0 14 0;
+#X connect 12 0 13 1;
+#X connect 13 0 2 0;
+#X connect 14 0 12 0;
+#X connect 15 0 6 0;
+#X connect 16 0 13 0;
+#X connect 17 0 2 2;
+#X restore 201 356 pd adaptive_equalizer~;
+#X text 460 130 (1);
+#X text 460 338 (2);
+#X obj 46 161 vradio 20 1 0 4 mode moder empty 0 -6 0 8 -262144 -1
+-1 3;
+#X text 68 163 calculate latency of the channel;
+#X text 68 183 train to get the inverse system;
+#X text 69 202 use equalized system;
+#X text 41 144 mode:;
+#X text 517 520 training mode:;
+#X text 86 374 H_chan(z);
+#X text 252 376 H_eq(z);
+#X text 532 536 (1) H_chan(z) * H_eq(z);
+#X text 532 551 (2) H_chan(z) (= channel);
+#X text 516 572 using mode:;
+#X text 529 589 (1) H_eq(z) (= 1/H_chan(z) = equalizer);
+#X text 529 604 (2) H_chan(z) * H_eq(z);
+#N canvas 815 256 526 453 latency_measurement 0;
+#X obj 38 118 metro 500;
+#X msg 38 163 0.5;
+#X obj 72 142 del 3;
+#X msg 72 162 0;
+#X obj 289 231 timer;
+#X floatatom 319 260 9 0 0 0 - - -;
+#X obj 319 203 threshold~ 0.1 5 0.05 5;
+#X obj 38 186 vline~;
+#X obj 133 204 threshold~ 0.1 5 0.05 5;
+#X obj 38 55 r mode;
+#X obj 38 95 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
+;
+#X obj 38 75 expr if($f1==0 \, 1 \, 0);
+#X obj 38 277 throw~ channel_in;
+#X obj 318 179 catch~ channel_out;
+#X text 339 275 latency in ms;
+#X obj 289 376 s delay;
+#X text 157 25 measure latency of the channel;
+#X obj 289 295 spigot;
+#X obj 289 349 max 0;
+#X obj 289 322 - 1.6;
+#X connect 0 0 1 0;
+#X connect 0 0 2 0;
+#X connect 1 0 7 0;
+#X connect 2 0 3 0;
+#X connect 3 0 7 0;
+#X connect 4 0 5 0;
+#X connect 4 0 17 0;
+#X connect 6 0 4 1;
+#X connect 7 0 8 0;
+#X connect 7 0 12 0;
+#X connect 8 0 4 0;
+#X connect 9 0 11 0;
+#X connect 10 0 0 0;
+#X connect 10 0 17 1;
+#X connect 11 0 10 0;
+#X connect 13 0 6 0;
+#X connect 17 0 19 0;
+#X connect 18 0 15 0;
+#X connect 19 0 18 0;
+#X restore 611 449 pd latency_measurement;
+#X floatatom 292 317 5 0 2000 1 ms delay -;
+#X obj 44 476 hsl 128 15 0 127 0 0 empty empty empty -2 -6 0 8 -262144
+-1 -1 0 1;
+#N canvas 490 130 319 220 audio_out 0;
+#X obj 37 161 env~;
+#X obj 36 68 r~ vol_out;
+#X obj 37 136 *~;
+#X obj 119 80 dbtorms;
+#X obj 119 120 line~;
+#X msg 119 100 \$1 50;
+#X obj 119 58 inlet;
+#X obj 37 184 outlet;
+#X obj 119 147 s~ out_vol;
+#X connect 0 0 7 0;
+#X connect 1 0 2 0;
+#X connect 2 0 0 0;
+#X connect 3 0 5 0;
+#X connect 4 0 2 1;
+#X connect 4 0 8 0;
+#X connect 5 0 4 0;
+#X connect 6 0 3 0;
+#X restore 41 456 pd audio_out;
+#X floatatom 41 438 5 0 200 1 dB - -;
+#X obj 184 476 hsl 128 15 0 127 0 0 empty empty empty -2 -6 0 8 -262144
+-1 -1 0 1;
+#X floatatom 181 438 5 0 200 1 dB - -;
+#N canvas 490 130 319 220 audio_in 0;
+#X obj 37 161 env~;
+#X obj 37 136 *~;
+#X obj 119 80 dbtorms;
+#X obj 119 120 line~;
+#X msg 119 100 \$1 50;
+#X obj 119 58 inlet;
+#X obj 37 184 outlet;
+#X obj 36 68 adc~;
+#X obj 119 148 s~ in_vol;
+#X connect 0 0 6 0;
+#X connect 1 0 0 0;
+#X connect 2 0 4 0;
+#X connect 3 0 1 1;
+#X connect 3 0 8 0;
+#X connect 4 0 3 0;
+#X connect 5 0 2 0;
+#X connect 7 0 1 0;
+#X restore 181 456 pd audio_in;
+#X floatatom 181 491 5 0 200 1 dB - -;
+#X floatatom 41 491 5 0 200 1 dB - -;
+#X obj 78 322 vradio 15 1 0 2 channel channelr empty 0 -6 0 8 -262144
+-1 -1 0;
+#X text 96 322 dummy filter;
+#X text 96 336 a real room;
+#X text 40 416 adjust volumes to measure a room:;
+#X text 49 164 1;
+#X text 49 184 2;
+#X text 49 204 3;
+#X obj 144 261 vradio 15 1 0 2 insig insigr empty 0 -6 0 8 -262144
+-1 -1 0;
+#X text 162 261 noise;
+#X text 161 275 sample;
+#X obj 243 278 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X text 216 262 open sample;
+#X connect 6 0 5 2;
+#X connect 7 0 5 1;
+#X connect 10 0 9 2;
+#X connect 11 0 9 1;
+#X connect 22 0 5 0;
+#X connect 23 0 9 0;
+#X connect 42 0 0 0;
+#X connect 43 0 50 0;
+#X connect 44 0 43 0;
+#X connect 45 0 44 0;
+#X connect 46 0 49 0;
+#X connect 47 0 48 0;
+#X connect 48 0 46 0;
+#X connect 61 0 24 0;
diff --git a/adaptive/examples/08.decision-directed_equalization.pd b/adaptive/examples/08.decision-directed_equalization.pd
new file mode 100755
index 0000000..e81c5aa
--- /dev/null
+++ b/adaptive/examples/08.decision-directed_equalization.pd
@@ -0,0 +1,167 @@
+#N canvas 0 0 815 449 10;
+#N canvas 713 200 313 209 delay~ 0;
+#X obj 42 45 inlet~;
+#X obj 43 139 outlet~;
+#X obj 43 89 z~ 60;
+#X connect 0 0 2 0;
+#X connect 2 0 1 0;
+#X restore 176 261 pd delay~;
+#N canvas 684 469 305 289 channel~ 0;
+#X obj 39 120 bp~ 500 10;
+#X text 72 96 dummy filter + latency;
+#X obj 39 36 inlet~;
+#X obj 40 234 outlet~;
+#X obj 40 182 z~ 60;
+#X connect 0 0 4 0;
+#X connect 2 0 0 0;
+#X connect 4 0 3 0;
+#X restore 29 262 pd channel~;
+#N canvas 490 469 479 338 PROBLEM_DESCRIPTION 0;
+#X text 57 137 possible symbols: -1 \, 1;
+#X text 55 160 the decision device is implemented by d=sign(y);
+#X text 72 40 DECISION-DIRECTED CHANNEL EQUALIZATION;
+#X text 27 189 The adaptive equalizer tries to invert the channel \,
+so that the overal system has a flat frequency response and there are
+almost no bit errors.;
+#X text 28 280 We simulate the transmission with a simple bandpass
+filter and a delay (= the channel).;
+#X text 28 241 Bit errors are plotted over time for equalized and unequalized
+transmission.;
+#X text 27 83 This patch simulates the equalization of a baseband transmission
+of a binary signal (similar to the adaptation process in e.g. a modem).
+;
+#X restore 28 106 pd PROBLEM_DESCRIPTION;
+#N canvas 493 226 453 208 OBSERVATIONS 0;
+#X text 21 30 OBSERVATIONS;
+#X text 19 77 You can see that if you train the system long enough
+there are almost no bit errors.;
+#X text 20 126 A critical parameter is the delay: If you don't find
+the exact delay of the channel adaptation works very bad for uncorrelated
+training sequences.;
+#X restore 28 130 pd OBSERVATIONS;
+#X text 27 85 ReadMe:;
+#N canvas 752 62 617 174 init 0;
+#X obj 256 43 loadbang;
+#X obj 213 120 s mur;
+#X msg 515 103 \; pd dsp \$1;
+#X obj 515 78 r audio_io;
+#X msg 212 96 0.1;
+#X obj 125 118 s moder;
+#X msg 125 97 0;
+#X connect 0 0 4 0;
+#X connect 0 0 6 0;
+#X connect 3 0 2 0;
+#X connect 4 0 1 0;
+#X connect 6 0 5 0;
+#X restore 679 389 pd init;
+#X obj 708 108 tgl 20 0 audio_io empty empty 0 -6 0 8 -262144 -1 -1
+0 1;
+#X floatatom 684 139 6 0 0 0 - mur mu;
+#X text 546 138 learning rate (mu):;
+#N canvas 0 0 450 300 input_signal~ 0;
+#X obj 59 74 noise~;
+#X obj 60 120 expr~ if($v1>=0 \, 1 \, -1);
+#X text 75 104 signum:;
+#X obj 60 182 outlet~;
+#X connect 0 0 1 0;
+#X connect 1 0 3 0;
+#X restore 29 198 pd input_signal~;
+#N canvas 573 367 334 253 adaptive_equalizer~ 0;
+#X obj 164 64 r mode;
+#X obj 164 104 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+1;
+#X msg 164 123 adaptation \$1;
+#X obj 31 34 inlet~;
+#X obj 108 34 inlet~;
+#X obj 163 151 r mode;
+#X obj 163 191 sel 1;
+#X msg 163 212 init_unity;
+#X obj 30 205 outlet~;
+#N canvas 922 527 390 347 nlms~ 0;
+#X obj 37 35 inlet~;
+#X obj 155 44 inlet~;
+#X text 134 24 desired signal;
+#X obj 36 291 outlet~;
+#X obj 261 135 loadbang;
+#X msg 264 300 clear;
+#X obj 262 250 r mu;
+#X msg 262 272 mu \$1;
+#X text 36 313 outsig1;
+#X text 38 14 insig1;
+#X msg 274 201 init_unity;
+#X obj 261 156 t b b;
+#X msg 59 96 print;
+#X msg 261 178 adaptation 0;
+#X obj 341 38 inlet;
+#X obj 37 156 nlms~ 10 0.01;
+#X connect 0 0 15 0;
+#X connect 1 0 15 1;
+#X connect 4 0 11 0;
+#X connect 5 0 15 0;
+#X connect 6 0 7 0;
+#X connect 7 0 15 0;
+#X connect 10 0 15 0;
+#X connect 11 0 13 0;
+#X connect 11 1 10 0;
+#X connect 12 0 15 0;
+#X connect 13 0 15 0;
+#X connect 14 0 15 0;
+#X connect 15 0 3 0;
+#X restore 30 140 pd nlms~;
+#X obj 164 84 expr if($f1==1 \, 1 \, 0);
+#X obj 163 171 expr if($f1==0 \, 1 \, 0);
+#X connect 0 0 10 0;
+#X connect 1 0 2 0;
+#X connect 2 0 9 2;
+#X connect 3 0 9 0;
+#X connect 4 0 9 1;
+#X connect 5 0 11 0;
+#X connect 6 0 7 0;
+#X connect 7 0 9 2;
+#X connect 9 0 8 0;
+#X connect 10 0 1 0;
+#X connect 11 0 6 0;
+#X restore 28 337 pd adaptive_equalizer~;
+#X obj 297 108 vradio 20 1 0 3 mode moder empty 0 -6 0 8 -262144 -1
+-1 2;
+#X text 292 90 mode:;
+#X text 37 244 H_chan(z);
+#X text 37 319 H_eq(z);
+#X text 26 22 DECISION-DIRECTED CHANNEL EQUALIZATION;
+#X text 323 111 unequalized transmission;
+#N canvas 609 329 450 300 decision_device~ 0;
+#X obj 25 38 inlet~;
+#X obj 26 97 expr~ if($v1>=0 \, 1 \, -1);
+#X text 41 81 signum:;
+#X obj 270 38 inlet~;
+#X obj 59 202 tabsend~ biterrors;
+#X obj 59 173 expr~ if($v1==$v2 \, -1 \, 1);
+#X connect 0 0 1 0;
+#X connect 1 0 5 0;
+#X connect 3 0 5 1;
+#X connect 5 0 4 0;
+#X restore 124 387 pd decision_device~;
+#N canvas 0 0 450 300 graph3 0;
+#X array biterrors 64 float 2;
+#X coords 0 1.4 63 -1.4 350 140 1;
+#X restore 380 245 graph;
+#X text 734 257 error;
+#X text 734 357 no error;
+#X text 487 390 ---- 64 samples ----;
+#X text 382 228 biterrors over time:;
+#X text 624 110 Audio IO ->;
+#X text 322 131 training;
+#X text 323 150 equalized transmission;
+#X text 302 112 1;
+#X text 302 131 2;
+#X text 302 151 3;
+#N canvas 0 0 450 110 NEEDED_EXTERNALS 0;
+#X text 16 38 For this patch you will need the zexy external by IOhannes
+Zmoelnig: http://pd.iem.at;
+#X restore 659 16 pd NEEDED_EXTERNALS;
+#X connect 0 0 10 1;
+#X connect 0 0 17 1;
+#X connect 1 0 10 0;
+#X connect 9 0 1 0;
+#X connect 9 0 0 0;
+#X connect 10 0 17 0;
diff --git a/adaptive/examples/coef.dat b/adaptive/examples/coef.dat
new file mode 100755
index 0000000..35238a6
--- /dev/null
+++ b/adaptive/examples/coef.dat
@@ -0,0 +1,12 @@
+adaptivePD
+size: 9
+mu: 0.0001
+1
+1
+1
+1
+1
+1
+1
+1
+1
diff --git a/adaptive/examples/spectrum~.pd b/adaptive/examples/spectrum~.pd
new file mode 100755
index 0000000..9757e75
--- /dev/null
+++ b/adaptive/examples/spectrum~.pd
@@ -0,0 +1,243 @@
+#N canvas 265 153 333 190 10;
+#N canvas 88 49 872 789 FFT_Analyse 0;
+#X obj 101 102 inlet~;
+#X obj 101 332 *~;
+#X obj 132 331 *~;
+#X obj 110 356 +~;
+#X obj 111 377 powtodb~;
+#N canvas 0 0 346 535 init_input_window 0;
+#X obj 73 217 / 10;
+#X obj 55 278 line 0 0.1;
+#X msg 119 246 0;
+#X obj 54 176 t f f b;
+#X obj 54 239 pack;
+#X obj 55 301 t f f;
+#X obj 54 152 - 1;
+#X obj 74 114 t f f;
+#X obj 55 359 * 3.14159;
+#X obj 55 381 sin;
+#X msg 55 401 \$1 \$1;
+#X obj 55 423 *;
+#X text 119 334 0...0.99;
+#X text 128 359 0...pi;
+#X text 79 423 hanning;
+#X msg 55 88 4096;
+#X obj 100 88 f 4096;
+#X obj 99 60 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X obj 99 39 loadbang;
+#X obj 74 333 / 4096;
+#X obj 55 448 tabwrite \$0-window;
+#X text 86 381 half-sine;
+#X connect 0 0 4 1;
+#X connect 1 0 5 0;
+#X connect 2 0 1 0;
+#X connect 3 0 4 0;
+#X connect 3 1 0 0;
+#X connect 3 2 2 0;
+#X connect 4 0 1 0;
+#X connect 5 0 19 0;
+#X connect 5 1 20 1;
+#X connect 6 0 3 0;
+#X connect 7 0 6 0;
+#X connect 7 1 19 1;
+#X connect 8 0 9 0;
+#X connect 9 0 10 0;
+#X connect 10 0 11 0;
+#X connect 11 0 20 0;
+#X connect 15 0 7 0;
+#X connect 16 0 7 0;
+#X connect 17 0 16 0;
+#X connect 18 0 17 0;
+#X connect 19 0 8 0;
+#X restore 161 276 pd init_input_window;
+#N canvas 0 0 450 300 graph3 0;
+#X array \$0-lin_scope 2048 float 0;
+#X coords 0 100 2047 0 200 140 1;
+#X restore 110 596 graph;
+#N canvas 0 0 822 328 init_norm 0;
+#X obj 43 230 outlet;
+#X obj 43 187 - 100;
+#X floatatom 43 208 9 0 0 0 - - -;
+#X text 108 169 leistung -> techn. dB;
+#X msg 43 69 4096;
+#X obj 80 68 f 4096;
+#X obj 80 47 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X obj 80 26 loadbang;
+#X obj 43 167 rmstodb;
+#X obj 43 110 / 4;
+#X text 74 103 faktor 2 wegen hanning;
+#X text 74 114 weiterer faktor 2 \, weil wir nur die;
+#X text 73 124 erste haelfte des konjungiert komplexen spektrum sehen
+;
+#X text 108 135 bzw. bearbeiten \, somit nur die haelfte der spektralen
+energie;
+#X connect 1 0 2 0;
+#X connect 2 0 0 0;
+#X connect 4 0 9 0;
+#X connect 5 0 9 0;
+#X connect 6 0 5 0;
+#X connect 7 0 6 0;
+#X connect 8 0 1 0;
+#X connect 9 0 8 0;
+#X restore 126 401 pd init_norm;
+#X obj 100 231 *~;
+#X obj 110 425 -~ 60.206;
+#X obj 123 519 *~ 0.98;
+#X obj 110 541 +~;
+#X obj 111 475 *~ 0.02;
+#X msg 314 481 1 \$1;
+#X obj 314 502 -;
+#X obj 314 458 clip 0 1;
+#X obj 314 437 / 100;
+#X floatatom 314 413 5 0.5 100 0 - - -;
+#X obj 333 366 loadbang;
+#X obj 100 277 fft~;
+#X obj 463 557 line 0 0.1;
+#X obj 463 602 / 2;
+#X obj 463 622 mtof;
+#X msg 463 536 6 \, 273 26.7;
+#X obj 463 580 t f f;
+#X obj 494 602 - 6;
+#X obj 463 642 / 44100;
+#X obj 463 663 * 4096;
+#X msg 656 633 6;
+#X obj 656 653 / 2;
+#X obj 656 673 mtof;
+#X floatatom 656 693 9 0 0 0 - - -;
+#X text 723 694 Hz;
+#X obj 754 654 / 2;
+#X obj 754 673 mtof;
+#X floatatom 754 693 9 0 0 0 - - -;
+#X text 822 693 Hz;
+#X msg 754 634 273;
+#X obj 656 612 t b b;
+#X obj 463 516 metro 1000;
+#X obj 463 498 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1
+1;
+#X obj 463 458 loadbang;
+#X msg 463 478 1;
+#X obj 656 592 loadbang;
+#X obj 468 245 loadbang;
+#X obj 703 102 inlet;
+#X obj 130 253 table \$0-window 4096;
+#X obj 137 214 tabreceive~ \$0-window;
+#X text 353 403 temporal lowpass;
+#X text 355 415 parameter between 0 .. 100 %;
+#X text 23 23 spectrum~;
+#X text 120 23 draws the power of a spectrum in a logarithmic scale
+;
+#X text 118 36 (by Thomas Musil);
+#X obj 123 498 tabreceive~ \$0-lin_scope;
+#X obj 110 566 tabsend~ \$0-lin_scope;
+#X obj 463 685 tabread4 \$0-lin_scope;
+#X obj 468 267 f \$0;
+#X text 553 536 transformation to log scale;
+#X msg 333 385 100;
+#X obj 314 341 max 0.5;
+#X obj 314 319 min 100;
+#X obj 440 107 inlet;
+#X text 96 81 audio sig;
+#X text 700 81 ON/OFF;
+#X text 427 86 (0 .. 100);
+#X text 408 72 temporal lowpass;
+#X obj 703 125 switch~ 4096 2;
+#X obj 533 244 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X obj 463 707 tabwrite \$0-s;
+#X msg 468 296 \; \$1-s xticks 0 12 2;
+#X msg 491 330 \; \$1-s yticks 0 5 2;
+#X connect 0 0 8 0;
+#X connect 1 0 3 0;
+#X connect 2 0 3 1;
+#X connect 3 0 4 0;
+#X connect 4 0 9 0;
+#X connect 7 0 9 1;
+#X connect 8 0 19 0;
+#X connect 9 0 12 0;
+#X connect 10 0 11 1;
+#X connect 11 0 54 0;
+#X connect 12 0 11 0;
+#X connect 13 0 14 0;
+#X connect 14 0 10 1;
+#X connect 15 0 13 0;
+#X connect 15 0 12 1;
+#X connect 16 0 15 0;
+#X connect 17 0 16 0;
+#X connect 18 0 58 0;
+#X connect 19 0 1 0;
+#X connect 19 0 1 1;
+#X connect 19 1 2 0;
+#X connect 19 1 2 1;
+#X connect 20 0 24 0;
+#X connect 21 0 22 0;
+#X connect 22 0 26 0;
+#X connect 23 0 20 0;
+#X connect 24 0 21 0;
+#X connect 24 1 25 0;
+#X connect 25 0 68 1;
+#X connect 26 0 27 0;
+#X connect 27 0 55 0;
+#X connect 28 0 29 0;
+#X connect 29 0 30 0;
+#X connect 30 0 31 0;
+#X connect 33 0 34 0;
+#X connect 34 0 35 0;
+#X connect 37 0 33 0;
+#X connect 38 0 28 0;
+#X connect 38 1 37 0;
+#X connect 39 0 23 0;
+#X connect 40 0 39 0;
+#X connect 41 0 42 0;
+#X connect 42 0 40 0;
+#X connect 43 0 38 0;
+#X connect 44 0 56 0;
+#X connect 45 0 66 0;
+#X connect 47 0 8 1;
+#X connect 53 0 10 0;
+#X connect 55 0 68 0;
+#X connect 56 0 69 0;
+#X connect 56 0 70 0;
+#X connect 58 0 17 0;
+#X connect 59 0 17 0;
+#X connect 60 0 59 0;
+#X connect 61 0 60 0;
+#X connect 67 0 56 0;
+#X restore 17 270 pd FFT_Analyse;
+#X text 15 195 spectrum~.pd;
+#X obj 63 249 inlet;
+#X obj 17 249 inlet~;
+#X obj 110 249 inlet;
+#N canvas 0 0 450 300 graph3 0;
+#X array \$0-s 268 float 0;
+#X coords 0 100 267 0 267 140 1;
+#X restore 33 17 graph;
+#X obj 307 32 cnv 15 1 1 empty empty -10 0 0 0 10 -262144 -1 0;
+#X obj 307 144 cnv 15 1 1 empty empty -90 0 0 0 10 -262144 -1 0;
+#X obj 307 88 cnv 15 1 1 empty empty -50 0 0 0 10 -262144 -1 0;
+#X obj 307 60 cnv 15 1 1 empty empty -30 0 0 0 10 -262144 -1 0;
+#X obj 307 116 cnv 15 1 1 empty empty -70 0 0 0 10 -262144 -1 0;
+#X obj 28 161 cnv 15 1 1 empty empty 10 0 5 0 10 -262144 -1 0;
+#X obj 76 161 cnv 15 1 1 empty empty 40 0 5 0 10 -262144 -1 0;
+#X obj 125 161 cnv 15 1 1 empty empty 160 0 5 0 10 -262144 -1 0;
+#X obj 172 161 cnv 15 1 1 empty empty 640 0 5 0 10 -262144 -1 0;
+#X obj 220 161 cnv 15 1 1 empty empty 2k56 0 5 0 10 -262144 -1 0;
+#X obj 268 161 cnv 15 1 1 empty empty 10k2 0 5 0 10 -262144 -1 0;
+#X obj 148 174 cnv 15 1 1 empty empty 320 0 5 0 10 -262144 -1 0;
+#X obj 292 174 cnv 15 1 1 empty empty 20k5 0 5 0 10 -262144 -1 0;
+#X obj 52 171 cnv 15 1 1 empty empty 20 0 9 0 10 -262144 -1 0;
+#X obj 100 174 cnv 15 1 1 empty empty 80 0 5 0 10 -262144 -1 0;
+#X obj 196 174 cnv 15 1 1 empty empty 1k28 0 5 0 10 -262144 -1 0;
+#X obj 244 174 cnv 15 1 1 empty empty 5k12 0 5 0 10 -262144 -1 0;
+#X obj 56 158 cnv 15 1 1 empty empty | 0 7 0 10 -262144 -1 0;
+#X obj 104 158 cnv 15 1 1 empty empty | 0 7 0 10 -262144 -1 0;
+#X obj 152 158 cnv 15 1 1 empty empty | 0 7 0 10 -262144 -1 0;
+#X obj 200 158 cnv 15 1 1 empty empty | 0 7 0 10 -262144 -1 0;
+#X obj 248 158 cnv 15 1 1 empty empty | 0 7 0 10 -262144 -1 0;
+#X obj 296 158 cnv 15 1 1 empty empty | 0 7 0 10 -262144 -1 0;
+#X text 16 220 draws the power of the spectrum (log);
+#X connect 2 0 0 1;
+#X connect 3 0 0 0;
+#X connect 4 0 0 2;
+#X coords 0 0 1 1 330 190 1;
diff --git a/adaptive/src/adaptive.c b/adaptive/src/adaptive.c
new file mode 100755
index 0000000..223bb0a
--- /dev/null
+++ b/adaptive/src/adaptive.c
@@ -0,0 +1,158 @@
+/******************************************************
+ *
+ * Adaptive Systems for PD
+ *
+ * copyleft (c) Gerda Strobl, Georg Holzmann
+ * 2005
+ *
+ * for complaints, suggestions: grh@mur.at
+ *
+ ******************************************************
+ *
+ * license: GNU General Public License v.2
+ *
+ ******************************************************/
+
+#include "adaptive.h"
+
+typedef struct _adaptive
+{
+ t_object x_obj;
+} t_adaptive;
+
+t_class *adaptive_class;
+
+static void adaptive_help(void)
+{
+ post("\n-----------------------------------------------");
+ post("adaptive systems for PD");
+ post("copyleft (c) Gerda Strobl, Georg Holzmann, 2005");
+ post("");
+ post("for more info look at the help patches!");
+ post("-----------------------------------------------\n");
+}
+
+void *adaptive_new(void)
+{
+ t_adaptive *x = (t_adaptive *)pd_new(adaptive_class);
+ return (void *)x;
+}
+
+//-----------------------------------------------------
+// declaration of the setup functions:
+void lms_tilde_setup();
+void lms2_tilde_setup();
+void nlms_tilde_setup();
+void nlms2_tilde_setup();
+void nlms3_tilde_setup();
+//-end-of-declaration----------------------------------
+
+void adaptive_setup(void)
+{
+ //---------------------------------------------------
+ // call all the setup functions:
+ lms_tilde_setup();
+ lms2_tilde_setup();
+ nlms_tilde_setup();
+ nlms2_tilde_setup();
+ nlms3_tilde_setup();
+ //-end-----------------------------------------------
+
+ post("\nadaptive: 2005 by Gerda Strobl and Georg Holzmann");
+
+ adaptive_class = class_new(gensym("adaptive"), adaptive_new, 0, sizeof(t_adaptive), 0, 0);
+ class_addmethod(adaptive_class, (t_method)adaptive_help, gensym("help"), 0);
+}
+
+
+/* ---------------------- helpers ----------------------- */
+
+void adaptation_write(const char *filename, t_int N, t_float mu, t_float *c)
+{
+ FILE *f=0;
+ int i;
+
+ // open file
+ f = fopen(filename, "w");
+ if(!f)
+ {
+ post("adaptive, save: error open file");
+ return;
+ }
+
+ // write little header, number of coefficients and mu
+ fprintf(f, "adaptivePD\n");
+ fprintf(f, "size: %d\n", N);
+ fprintf(f, "mu: %.30f\n", mu);
+
+ // write coefficients
+ for(i=0; i<N; i++)
+ fprintf(f, "%.30f\n", c[i]);
+
+ // close file
+ if (f) fclose(f);
+ post("adaptive, save: coefficients written to file");
+}
+
+void adaptation_read(const char *filename, t_int *N, t_float *mu,
+ t_float *c, t_float *buf)
+{
+ FILE *f=0;
+ int i, n=0;
+
+ // open file
+ f = fopen(filename, "r");
+ if(!f)
+ {
+ post("adaptive, open: error open file");
+ return;
+ }
+
+ // read header and nr of coefficients
+ if ( fscanf(f,"adaptivePD\n") != 0)
+ {
+ post("adaptive, open: error in reading file");
+ return;
+ }
+ if ( fscanf(f,"size: %d\n",&n) != 1)
+ {
+ post("adaptive, open: error in reading file");
+ return;
+ };
+
+ // change size of the filter if needed
+ if(n != *N)
+ {
+ if(c) freebytes(c, sizeof(t_float) * (*N));
+ if(buf) freebytes(buf, sizeof(t_sample) * (*N-1));
+
+ *N = (n<=0) ? 1 : n;
+
+ post("WARNING (adaptive): Nr. of coefficients is changed to %d!",*N);
+
+ // allocate mem and init coefficients
+ c = (t_float *)getbytes(sizeof(t_float) * (*N));
+
+ // allocate mem for temp buffer
+ buf = (t_sample *)getbytes(sizeof(t_sample) * (*N-1));
+ for(i=0; i<(*N-1); i++)
+ buf[i] = 0;
+ }
+
+ // read mu
+ if ( fscanf(f,"mu: %f\n",mu) != 1)
+ {
+ post("adaptive, open: error in reading file");
+ return;
+ };
+
+ // get coefficients:
+ for(i=0; i<(*N); i++)
+ if( fscanf(f, "%f\n", c+i) != 1)
+ {
+ post("adaptive, open: error in reading file");
+ return;
+ }
+ //post("c_inside: %d",c);
+ post("adaptive, read: coefficients readed from file");
+}
diff --git a/adaptive/src/adaptive.h b/adaptive/src/adaptive.h
new file mode 100755
index 0000000..209a51a
--- /dev/null
+++ b/adaptive/src/adaptive.h
@@ -0,0 +1,34 @@
+/******************************************************
+ *
+ * Adaptive Systems for PD
+ *
+ * copyleft (c) Gerda Strobl, Georg Holzmann
+ * 2005
+ *
+ * for complaints, suggestions: grh@mur.at
+ *
+ ******************************************************
+ *
+ * license: GNU General Public License v.2
+ *
+ ******************************************************/
+
+#ifndef __ADAPTIVE_H__
+#define __ADAPTIVE_H__
+
+#include "m_pd.h"
+#include <stdio.h>
+
+
+
+/* ---------------------- helpers ----------------------- */
+
+// save all data to file
+void adaptation_write(const char *filename, t_int N, t_float mu, t_float *c);
+
+// read data from file
+void adaptation_read(const char *filename, t_int *N, t_float *mu,
+ t_float *c, t_float *buf);
+
+
+#endif //__ADAPTIVE_H__
diff --git a/adaptive/src/lms2~.c b/adaptive/src/lms2~.c
new file mode 100755
index 0000000..c3c3d3c
--- /dev/null
+++ b/adaptive/src/lms2~.c
@@ -0,0 +1,332 @@
+/******************************************************
+ *
+ * Adaptive Systems for PD
+ *
+ * copyleft (c) Gerda Strobl, Georg Holzmann
+ * 2005
+ *
+ * for complaints, suggestions: grh@mur.at
+ *
+ ******************************************************
+ *
+ * license: GNU General Public License v.2
+ *
+ ******************************************************/
+
+#include "adaptive.h"
+
+
+/* ------------------------ lms2~ ------------------------- */
+
+static t_class *lms2_tilde_class;
+
+typedef struct _lms2
+{
+ t_object x_obj;
+ t_float f;
+ t_atom *coef;
+ t_sample *buf;
+ t_sample *y_tmp;
+ t_sample *e_tmp;
+ t_int bufsize;
+ t_outlet *c_out;
+ int adapt; // enable/disable adaptation
+
+ t_int N; //number of coefficients of the adaptive system
+ t_float *c; // coefficients of the system
+ t_float mu; // step-size parameter (learning rate)
+
+ t_canvas *x_canvas;
+} t_lms2_tilde;
+
+static void lms2_tilde_a(t_lms2_tilde *x, t_floatarg f)
+{
+ x->adapt = (f==0) ? 0 : 1;
+}
+
+static void lms2_tilde_geta(t_lms2_tilde *x)
+{
+ if(x->adapt==0)
+ post("lms2~: adaptation is currently OFF");
+ else
+ post("lms2~: adaptation is currently ON");
+}
+
+static void lms2_tilde_mu(t_lms2_tilde *x, t_floatarg f)
+{
+ x->mu = f;
+}
+
+static void lms2_tilde_getmu(t_lms2_tilde *x)
+{
+ post("mu (step-size parameter): %f", x->mu);
+}
+
+static void lms2_tilde_getN(t_lms2_tilde *x)
+{
+ post("N (number of coefficients): %d", x->N);
+}
+
+static void lms2_tilde_clear(t_lms2_tilde *x)
+{
+ int i;
+
+ // clear coefficients
+ for(i=0; i<x->N; i++)
+ x->c[i] = 0;
+
+ // clear temp buffer
+ for(i=0; i<x->N-1; i++)
+ x->buf[i] = 0;
+}
+
+static void lms2_tilde_init(t_lms2_tilde *x)
+{
+ int i;
+
+ // set the first coefficient to 1, all others to 0
+ // so this is a delay free transmission
+ x->c[0] = 1;
+ for(i=1; i<x->N; i++)
+ x->c[i] = 0;
+
+ // clear temp buffers
+ for(i=0; i<x->N-1; i++)
+ x->buf[i] = 0;
+}
+
+static void lms2_tilde_print(t_lms2_tilde *x)
+{
+ int i;
+
+ // print coefficients
+ post("\nNr. of coefficients: %d",x->N);
+ post("coefficients:");
+ for(i=0; i<x->N; i++)
+ post("\t%d: %f",i,x->c[i]);
+}
+
+static void lms2_tilde_write(t_lms2_tilde *x, t_symbol *s)
+{
+ // make correct path
+ char filnam[MAXPDSTRING];
+ char filename[MAXPDSTRING];
+ canvas_makefilename(x->x_canvas, s->s_name, filnam, MAXPDSTRING);
+ sys_bashfilename(filnam, filename);
+
+ // save to file
+ adaptation_write(filename, x->N, x->mu, x->c);
+}
+
+static void lms2_tilde_read(t_lms2_tilde *x, t_symbol *s)
+{
+ // make correct path
+ char filnam[MAXPDSTRING];
+ char filename[MAXPDSTRING];
+ int n = x->N;
+ canvas_makefilename(x->x_canvas, s->s_name, filnam, MAXPDSTRING);
+ sys_bashfilename(filnam, filename);
+
+ // read file
+ adaptation_read(filename, &x->N, &x->mu, x->c, x->buf);
+
+ // if length changes:
+ if(x->N != n)
+ {
+ if(x->coef) freebytes(x->coef, sizeof(t_atom) * x->N);
+ x->coef = (t_atom *)getbytes(sizeof(t_atom) * x->N);
+ }
+}
+
+static t_int *lms2_tilde_perform(t_int *w)
+{
+ t_sample *x_ = (t_sample *)(w[1]);
+ t_sample *d_ = (t_sample *)(w[2]);
+ t_sample *y_ = (t_sample *)(w[3]);
+ t_sample *e_ = (t_sample *)(w[4]);
+ int n = (int)(w[5]);
+ t_lms2_tilde *x = (t_lms2_tilde *)(w[6]);
+ int i, j, tmp;
+
+
+ for(i=0; i<n; i++)
+ {
+ // calc output (filter)
+
+ x->y_tmp[i]=0;
+
+ // y_[i] += x->c[j] * x_[i-j];
+ // so lets split in two halfs, so that
+ // negative indezes get samples from the
+ // last audioblock (x->buf) ...
+
+ tmp = (i+1 - x->N)*(-1);
+ tmp = tmp<0 ? 0 : tmp;
+
+ for(j=0; j<x->N-tmp; j++)
+ x->y_tmp[i] += x->c[j] * x_[i-j];
+
+ for(j=x->N-tmp; j<x->N; j++)
+ x->y_tmp[i] += x->c[j] * x->buf[(i-j)*(-1)-1];
+
+ if(x->adapt)
+ {
+ // error computation
+ x->e_tmp[i] = d_[i] - x->y_tmp[i];
+
+ // coefficient adaptation
+ // (split in the same way as above)
+
+ for(j=0; j<x->N-tmp; j++)
+ x->c[j] = x->c[j] + x->mu * x_[i-j] * x->e_tmp[i];
+
+ for(j=x->N-tmp; j<x->N; j++)
+ x->c[j] = x->c[j] + x->mu * x->buf[(i-j)*(-1)-1] * x->e_tmp[i];
+ }
+ else x->e_tmp[i] = 0;
+
+ //post("%d: in %f, d: %f, out: %f, e: %f, c1:%f, c2:%f", i, x_[i], d_[i], x->y_tmp[i], x->e_tmp[i], x->c[0], x->c[1]);
+ }
+
+ // outlet coefficients
+ for(i=0; i<x->N; i++)
+ SETFLOAT(&x->coef[i],x->c[i]);
+
+ outlet_list(x->c_out, &s_list, x->N, x->coef);
+
+ // store last samples for next audiobuffer
+ for(i=0; i<x->N-1; i++)
+ x->buf[i] = x_[n-1-i];
+
+ // now write tmps to outlets
+ while(n--)
+ {
+ y_[n] = x->y_tmp[n];
+ e_[n] = x->e_tmp[n];
+ }
+
+ return (w+7);
+}
+
+static void lms2_tilde_dsp(t_lms2_tilde *x, t_signal **sp)
+{
+ // allocate new temp buffer if buffersize changes
+ if(x->bufsize != sp[0]->s_n)
+ {
+ if(sp[0]->s_n < x->N)
+ post("lms2~ WARNING: buffersize must be bigger than N, you will get wrong results !!!");
+
+ if(x->y_tmp) freebytes(x->y_tmp, sizeof(t_sample) * x->bufsize);
+ x->y_tmp = (t_sample *)getbytes(sizeof(t_sample) * sp[0]->s_n);
+
+ if(x->e_tmp) freebytes(x->e_tmp, sizeof(t_sample) * x->bufsize);
+ x->e_tmp = (t_sample *)getbytes(sizeof(t_sample) * sp[0]->s_n);
+
+ x->bufsize = sp[0]->s_n;
+ }
+
+ dsp_add(lms2_tilde_perform, 6, sp[0]->s_vec, sp[1]->s_vec,
+ sp[2]->s_vec, sp[3]->s_vec, sp[0]->s_n, x);
+}
+
+static void lms2_tilde_helper(void)
+{
+ post("\nlms2~: Adaptive transversal filter using LMS (for algorithm analysis)");
+ post("INPUT:");
+ post("\tinlet1: input signal x[n]");
+ post("\tinlet2: desired output signal d[n]");
+ post("\tinit_arg1: number of coefficients of the adaptive system");
+ post("\tinit_arg2, mu: step-size parameter (learning rate)");
+ post("OUTPUT:");
+ post("\toutlet1: output signal y[n]");
+ post("\toutlet2: error signal e[n]");
+ post("\toutlet3: coefficients c[n] (only per block)\n");
+}
+
+static void *lms2_tilde_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_lms2_tilde *x = (t_lms2_tilde *)pd_new(lms2_tilde_class);
+ int i;
+
+ // default values:
+ x->N = 8;
+ x->mu = 0.05;
+ x->adapt = 0;
+ x->y_tmp = NULL;
+ x->e_tmp = NULL;
+ x->bufsize = 0;
+
+ switch(argc)
+ {
+ case 2:
+ x->mu = atom_getfloat(argv+1);
+ case 1:
+ x->N = atom_getint(argv);
+ x->N = (x->N<=0) ? 1 : x->N;
+ }
+
+ // allocate mem and init coefficients
+ x->c = (t_float *)getbytes(sizeof(t_float) * x->N);
+ for(i=0; i<x->N; i++)
+ x->c[i] = 0;
+
+ // allocate mem for temp buffer
+ x->buf = (t_float *)getbytes(sizeof(t_float) * x->N-1);
+ for(i=0; i<x->N-1; i++)
+ x->buf[i] = 0;
+
+ // for output atoms (coefficients):
+ x->coef = (t_atom *)getbytes(sizeof(t_atom) * x->N);
+
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+ outlet_new(&x->x_obj, &s_signal);
+ outlet_new(&x->x_obj, &s_signal);
+ x->c_out = outlet_new(&x->x_obj, 0);
+
+ x->x_canvas = canvas_getcurrent();
+
+
+ return (x);
+}
+
+static void lms2_tilde_free(t_lms2_tilde *x)
+{
+ if(x->c) freebytes(x->c, sizeof(t_float) * x->N);
+ if(x->buf) freebytes(x->buf, sizeof(t_sample) * x->N-1);
+ if(x->y_tmp) freebytes(x->y_tmp, sizeof(t_sample) * x->bufsize);
+ if(x->e_tmp) freebytes(x->e_tmp, sizeof(t_sample) * x->bufsize);
+ if(x->coef) freebytes(x->coef, sizeof(t_atom) * x->N);
+}
+
+void lms2_tilde_setup(void)
+{
+ lms2_tilde_class = class_new(gensym("lms2~"), (t_newmethod)lms2_tilde_new,
+ (t_method)lms2_tilde_free, sizeof(t_lms2_tilde),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addmethod(lms2_tilde_class, (t_method)lms2_tilde_a,
+ gensym("adaptation"), A_DEFFLOAT, 0);
+ class_addmethod(lms2_tilde_class, (t_method)lms2_tilde_geta,
+ gensym("getadaptation"), 0);
+ class_addmethod(lms2_tilde_class, (t_method)lms2_tilde_mu,
+ gensym("mu"), A_DEFFLOAT, 0);
+ class_addmethod(lms2_tilde_class, (t_method)lms2_tilde_getmu,
+ gensym("getmu"), 0);
+ class_addmethod(lms2_tilde_class, (t_method)lms2_tilde_getN,
+ gensym("getN"), 0);
+ class_addmethod(lms2_tilde_class, (t_method)lms2_tilde_init,
+ gensym("init_unity"), 0);
+ class_addmethod(lms2_tilde_class, (t_method)lms2_tilde_clear,
+ gensym("clear"), 0);
+ class_addmethod(lms2_tilde_class, (t_method)lms2_tilde_print,
+ gensym("print"), 0);
+ class_addmethod(lms2_tilde_class, (t_method)lms2_tilde_write,
+ gensym("write"), A_DEFSYMBOL, 0);
+ class_addmethod(lms2_tilde_class, (t_method)lms2_tilde_read,
+ gensym("read"), A_DEFSYMBOL, 0);
+
+ class_addmethod(lms2_tilde_class, (t_method)lms2_tilde_dsp, gensym("dsp"), 0);
+ CLASS_MAINSIGNALIN(lms2_tilde_class, t_lms2_tilde, f);
+
+ class_addmethod(lms2_tilde_class, (t_method)lms2_tilde_helper, gensym("help"), 0);
+}
diff --git a/adaptive/src/lms~.c b/adaptive/src/lms~.c
new file mode 100755
index 0000000..d39ccb7
--- /dev/null
+++ b/adaptive/src/lms~.c
@@ -0,0 +1,295 @@
+/******************************************************
+ *
+ * Adaptive Systems for PD
+ *
+ * copyleft (c) Gerda Strobl, Georg Holzmann
+ * 2005
+ *
+ * for complaints, suggestions: grh@mur.at
+ *
+ ******************************************************
+ *
+ * license: GNU General Public License v.2
+ *
+ ******************************************************/
+
+#include "adaptive.h"
+
+
+/* ------------------------ lms~ ------------------------- */
+
+static t_class *lms_tilde_class;
+
+typedef struct _lms
+{
+ t_object x_obj;
+ t_float f;
+ t_sample *buf;
+ t_sample *tmp;
+ t_int bufsize;
+ int adapt; // enable/disable adaptation
+
+ t_int N; //number of coefficients of the adaptive system
+ t_float *c; // coefficients of the system
+ t_float mu; // step-size parameter (learning rate)
+
+ t_canvas *x_canvas;
+} t_lms_tilde;
+
+static void lms_tilde_a(t_lms_tilde *x, t_floatarg f)
+{
+ x->adapt = (f==0) ? 0 : 1;
+}
+
+static void lms_tilde_geta(t_lms_tilde *x)
+{
+ if(x->adapt==0)
+ post("lms~: adaptation is currently OFF");
+ else
+ post("lms~: adaptation is currently ON");
+}
+
+static void lms_tilde_mu(t_lms_tilde *x, t_floatarg f)
+{
+ x->mu = f;
+}
+
+static void lms_tilde_getmu(t_lms_tilde *x)
+{
+ post("mu (step-size parameter): %f", x->mu);
+}
+
+static void lms_tilde_getN(t_lms_tilde *x)
+{
+ post("N (number of coefficients): %d", x->N);
+}
+
+static void lms_tilde_clear(t_lms_tilde *x)
+{
+ int i;
+
+ // clear coefficients
+ for(i=0; i<x->N; i++)
+ x->c[i] = 0;
+
+ // clear temp buffer
+ for(i=0; i<x->N-1; i++)
+ x->buf[i] = 0;
+}
+
+static void lms_tilde_init(t_lms_tilde *x)
+{
+ int i;
+
+ // set the first coefficient to 1, all others to 0
+ // so this is a delay free transmission
+ x->c[0] = 1;
+ for(i=1; i<x->N; i++)
+ x->c[i] = 0;
+
+ // clear temp buffers
+ for(i=0; i<x->N-1; i++)
+ x->buf[i] = 0;
+}
+
+static void lms_tilde_print(t_lms_tilde *x)
+{
+ int i;
+
+ // print coefficients
+ post("\nNr. of coefficients: %d",x->N);
+ post("coefficients:");
+ for(i=0; i<x->N; i++)
+ post("\t%d: %f",i,x->c[i]);
+}
+
+static void lms_tilde_write(t_lms_tilde *x, t_symbol *s)
+{
+ // make correct path
+ char filnam[MAXPDSTRING];
+ char filename[MAXPDSTRING];
+ canvas_makefilename(x->x_canvas, s->s_name, filnam, MAXPDSTRING);
+ sys_bashfilename(filnam, filename);
+
+ // save to file
+ adaptation_write(filename, x->N, x->mu, x->c);
+}
+
+static void lms_tilde_read(t_lms_tilde *x, t_symbol *s)
+{
+ // make correct path
+ char filnam[MAXPDSTRING];
+ char filename[MAXPDSTRING];
+ canvas_makefilename(x->x_canvas, s->s_name, filnam, MAXPDSTRING);
+ sys_bashfilename(filnam, filename);
+
+ // read file
+ adaptation_read(filename, &x->N, &x->mu, x->c, x->buf);
+}
+
+static t_int *lms_tilde_perform(t_int *w)
+{
+ t_lms_tilde *x = (t_lms_tilde *)(w[1]);
+ t_sample *x_ = (t_sample *)(w[2]);
+ t_sample *d_ = (t_sample *)(w[3]);
+ t_sample *y_ = (t_sample *)(w[4]);
+ int n = (int)(w[5]);
+ int i, j, tmp;
+ t_sample e=0;
+
+
+ for(i=0; i<n; i++)
+ {
+ // calc output (filter)
+
+ x->tmp[i]=0;
+
+ // y_[i] += x->c[j] * x_[i-j];
+ // so lets split in two halfs, so that
+ // negative indezes get samples from the
+ // last audioblock (x->buf) ...
+ tmp = (i+1 - x->N)*(-1);
+ tmp = tmp<0 ? 0 : tmp;
+
+ for(j=0; j<x->N-tmp; j++)
+ x->tmp[i] += x->c[j] * x_[i-j];
+
+ for(j=x->N-tmp; j<x->N; j++)
+ x->tmp[i] += x->c[j] * x->buf[(i-j)*(-1)-1];
+
+ if(x->adapt)
+ {
+ // error computation
+ e = d_[i] - x->tmp[i];
+
+ // coefficient adaptation
+ // (split in the same way as above)
+
+ for(j=0; j<x->N-tmp; j++)
+ x->c[j] = x->c[j] + x->mu * x_[i-j] * e;
+
+ for(j=x->N-tmp; j<x->N; j++)
+ x->c[j] = x->c[j] + x->mu * x->buf[(i-j)*(-1)-1] * e;
+ }
+
+ //post("%d: in %f, d: %f, out: %f, error: %f, c1:%f, c2:%f", i, x_[i], d_[i], x->tmp[i], e, x->c[0], x->c[1]);
+ }
+
+ // store last samples for next audiobuffer
+ for(i=0; i<x->N-1; i++)
+ x->buf[i] = x_[n-1-i];
+
+ // now write tmp to outlet
+ while(n--)
+ y_[n] = x->tmp[n];
+
+ return (w+6);
+}
+
+static void lms_tilde_dsp(t_lms_tilde *x, t_signal **sp)
+{
+ // allocate new temp buffer if buffersize changes
+ if(x->bufsize != sp[0]->s_n)
+ {
+ if(sp[0]->s_n < x->N)
+ post("lms~ WARNING: buffersize must be bigger than N, you will get wrong results !!!");
+
+ if(x->tmp) freebytes(x->tmp, sizeof(t_sample) * x->bufsize);
+ x->tmp = (t_sample *)getbytes(sizeof(t_sample) * sp[0]->s_n);
+
+ x->bufsize = sp[0]->s_n;
+ }
+
+ dsp_add(lms_tilde_perform, 5, x, sp[0]->s_vec, sp[1]->s_vec,
+ sp[2]->s_vec, sp[0]->s_n);
+}
+
+static void lms_tilde_helper(void)
+{
+ post("\nlms~: Adaptive transversal filter using LMS");
+ post("INPUT:");
+ post("\tinlet1: input signal x[n]");
+ post("\tinlet2: desired output signal d[n]");
+ post("\tinit_arg1: number of coefficients of the adaptive system");
+ post("\tinit_arg2, mu: step-size parameter (learning rate)");
+ post("OUTPUT:");
+ post("\toutlet1: output signal\n");
+}
+
+static void *lms_tilde_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_lms_tilde *x = (t_lms_tilde *)pd_new(lms_tilde_class);
+ int i;
+
+ // default values:
+ x->N = 8;
+ x->mu = 0.05;
+ x->adapt = 0;
+ x->tmp = NULL;
+ x->bufsize = 0;
+
+ switch(argc)
+ {
+ case 2:
+ x->mu = atom_getfloat(argv+1);
+ case 1:
+ x->N = atom_getint(argv);
+ x->N = (x->N<=0) ? 1 : x->N;
+ }
+
+ // allocate mem and init coefficients
+ x->c = (t_float *)getbytes(sizeof(t_float) * x->N);
+ for(i=0; i<x->N; i++)
+ x->c[i] = 0;
+
+ // allocate mem for temp buffer
+ x->buf = (t_sample *)getbytes(sizeof(t_sample) * x->N-1);
+ for(i=0; i<x->N-1; i++)
+ x->buf[i] = 0;
+
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+ outlet_new(&x->x_obj, &s_signal);
+ x->x_canvas = canvas_getcurrent();
+
+ return (x);
+}
+
+static void lms_tilde_free(t_lms_tilde *x)
+{
+ if(x->c) freebytes(x->c, sizeof(t_float) * x->N);
+ if(x->buf) freebytes(x->buf, sizeof(t_sample) * x->N-1);
+ if(x->tmp) freebytes(x->tmp, sizeof(t_sample) * x->bufsize);
+}
+
+void lms_tilde_setup(void)
+{
+ lms_tilde_class = class_new(gensym("lms~"), (t_newmethod)lms_tilde_new,
+ (t_method)lms_tilde_free, sizeof(t_lms_tilde),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addmethod(lms_tilde_class, (t_method)lms_tilde_a,
+ gensym("adaptation"), A_DEFFLOAT, 0);
+ class_addmethod(lms_tilde_class, (t_method)lms_tilde_geta,
+ gensym("getadaptation"), 0);
+ class_addmethod(lms_tilde_class, (t_method)lms_tilde_mu,
+ gensym("mu"), A_DEFFLOAT, 0);
+ class_addmethod(lms_tilde_class, (t_method)lms_tilde_getmu,
+ gensym("getmu"), 0);
+ class_addmethod(lms_tilde_class, (t_method)lms_tilde_getN,
+ gensym("getN"), 0);
+ class_addmethod(lms_tilde_class, (t_method)lms_tilde_init,
+ gensym("init_unity"), 0);
+ class_addmethod(lms_tilde_class, (t_method)lms_tilde_clear,
+ gensym("clear"), 0);
+ class_addmethod(lms_tilde_class, (t_method)lms_tilde_print,
+ gensym("print"), 0);
+ class_addmethod(lms_tilde_class, (t_method)lms_tilde_write,
+ gensym("write"), A_DEFSYMBOL, 0);
+ class_addmethod(lms_tilde_class, (t_method)lms_tilde_read,
+ gensym("read"), A_DEFSYMBOL, 0);
+
+ class_addmethod(lms_tilde_class, (t_method)lms_tilde_dsp, gensym("dsp"), 0);
+ CLASS_MAINSIGNALIN(lms_tilde_class, t_lms_tilde, f);
+
+ class_addmethod(lms_tilde_class, (t_method)lms_tilde_helper, gensym("help"), 0);
+}
diff --git a/adaptive/src/makefile b/adaptive/src/makefile
new file mode 100755
index 0000000..9a3f09b
--- /dev/null
+++ b/adaptive/src/makefile
@@ -0,0 +1,48 @@
+current: all
+
+.SUFFIXES: .pd_linux
+
+# make sure that the "m_pd.h" is somehow available either by putting it into this
+# directory, by adding it's path to the INCLUDE-path or by putting it into an
+# already included path, e.g. "/usr/include/"
+INCLUDE = -I. -I/usr/include/
+
+PDPATH = /usr/lib/pd
+
+LDFLAGS = -export-dynamic -shared
+
+#select either the DBG and OPT compiler flags below:
+
+CFLAGS = -DPD -DUNIX -W -Wno-unused \
+ -Wno-parentheses -Wno-switch -O6 -funroll-loops -fomit-frame-pointer
+
+SYSTEM = $(shell uname -m)
+
+# the sources:
+
+SRC = adaptive.c lms~.c lms2~.c nlms~.c nlms2~.c nlms3~.c
+
+TARGET = adaptive.pd_linux
+
+
+OBJ = $(SRC:.c=.o)
+
+
+# ------------------ targets ------------------------------------
+
+
+clean:
+ rm -f *.o *.pd_linux
+
+all: $(OBJ)
+ @echo :: $(OBJ)
+ ld $(LDFLAGS) -o $(TARGET) $(OBJ)
+ strip --strip-unneeded $(TARGET)
+
+$(OBJ) : %.o : %.c
+ touch $*.c
+ cc $(CFLAGS) $(INCLUDE) -c -o $*.o $*.c
+
+install:
+ cp $(TARGET) $(PDPATH)/externs
+ cp ../doc/help-*.pd $(PDPATH)/doc/5.reference
diff --git a/adaptive/src/makefile_mingw b/adaptive/src/makefile_mingw
new file mode 100755
index 0000000..4f9d617
--- /dev/null
+++ b/adaptive/src/makefile_mingw
@@ -0,0 +1,46 @@
+current: all
+
+.SUFFIXES: .dll
+
+PDPATH = "c:/pd"
+
+INCLUDE = -I. -I$(PDPATH)/src
+
+LDFLAGS = --export-dynamic -shared
+
+#select either the DBG and OPT compiler flags below:
+
+CFLAGS = -DPD -DNT -W -Wno-unused -mms-bitfields\
+ -Wno-parentheses -Wno-switch -O6 -funroll-loops -fomit-frame-pointer
+
+SYSTEM = $(shell uname -m)
+
+# the sources:
+
+SRC = adaptive.c lms~.c lms2~.c nlms~.c nlms2~.c nlms3~.c
+
+TARGET = adaptive.dll
+
+
+OBJ = $(SRC:.c=.o)
+
+
+# ------------------ targets ------------------------------------
+
+
+clean:
+ rm -f *.a *.def *.o *.dll
+
+all: $(OBJ)
+ @echo :: $(OBJ)
+ g++ $(LDFLAGS) -o $(TARGET) $(OBJ) $(PDPATH)/bin/pd.dll -libc
+ strip --strip-unneeded $(TARGET)
+ chmod 755 $(TARGET)
+
+$(OBJ) : %.o : %.c
+ touch $*.c
+ gcc $(CFLAGS) $(INCLUDE) -c -o $*.o $*.c
+
+install:
+ cp $(TARGET) $(PDPATH)/externs
+ cp ../doc/help-*.pd $(PDPATH)/doc/5.reference
diff --git a/adaptive/src/makefile_msvc b/adaptive/src/makefile_msvc
new file mode 100755
index 0000000..dc104c3
--- /dev/null
+++ b/adaptive/src/makefile_msvc
@@ -0,0 +1,39 @@
+
+current: all
+
+TARGET = adaptive.dll
+
+VIS_CPP_PATH = "C:\Programme\Microsoft Visual Studio\Vc98"
+
+PD_INST_PATH = "C:\pd"
+
+SRC = adaptive.c lms~.c lms2~.c nlms~.c nlms2~.c nlms3~.c
+
+PD_WIN_INCLUDE_PATH = /I. /I$(PD_INST_PATH)\src /I$(VIS_CPP_PATH)\include
+
+PD_WIN_C_FLAGS = /W3 /WX /DNT /DPD /nologo
+
+PD_WIN_L_FLAGS = /nologo
+
+PD_WIN_LIB = $(VIS_CPP_PATH)\lib\libc.lib \
+ $(VIS_CPP_PATH)\lib\oldnames.lib \
+ $(VIS_CPP_PATH)\lib\kernel32.lib \
+ $(PD_INST_PATH)\bin\pd.lib
+
+
+OBJ = $(SRC:.c=.obj)
+
+.c.obj:
+ cl $(PD_WIN_C_FLAGS) $(PD_WIN_INCLUDE_PATH) /c $*.c
+
+all: $(OBJ)
+ link $(PD_WIN_L_FLAGS) /dll /export:adaptive_setup \
+ /out:$(TARGET) $(OBJ) $(PD_WIN_LIB)
+ del *.obj *.lib *.exp
+
+clean:
+ del *.obj *.dll *.lib *.exp
+
+install:
+ copy *.dll $(PD_INST_PATH)\externs
+ copy ..\doc\*.pd $(PD_INST_PATH)\doc\5.reference
diff --git a/adaptive/src/nlms2~.c b/adaptive/src/nlms2~.c
new file mode 100755
index 0000000..c967641
--- /dev/null
+++ b/adaptive/src/nlms2~.c
@@ -0,0 +1,359 @@
+/******************************************************
+ *
+ * Adaptive Systems for PD
+ *
+ * copyleft (c) Gerda Strobl, Georg Holzmann
+ * 2005
+ *
+ * for complaints, suggestions: grh@mur.at
+ *
+ ******************************************************
+ *
+ * license: GNU General Public License v.2
+ *
+ ******************************************************/
+
+#include "adaptive.h"
+
+
+/* ------------------------ nlms2~ ------------------------- */
+
+static t_class *nlms2_tilde_class;
+
+typedef struct _nlms2
+{
+ t_object x_obj;
+ t_float f;
+ t_atom *coef;
+ t_sample *buf;
+ t_sample *y_tmp;
+ t_sample *e_tmp;
+ t_int bufsize;
+ t_outlet *c_out;
+ int adapt; // enable/disable adaptation
+
+ t_int N; //number of coefficients of the adaptive system
+ t_float *c; // coefficients of the system
+ t_float mu; // step-size parameter (learning rate)
+ t_float alpha; // small constant to avoid division by zero
+
+ t_canvas *x_canvas;
+} t_nlms2_tilde;
+
+static void nlms2_tilde_a(t_nlms2_tilde *x, t_floatarg f)
+{
+ x->adapt = (f==0) ? 0 : 1;
+}
+
+static void nlms2_tilde_geta(t_nlms2_tilde *x)
+{
+ if(x->adapt==0)
+ post("nlms2~: adaptation is currently OFF");
+ else
+ post("nlms2~: adaptation is currently ON");
+}
+
+static void nlms2_tilde_mu(t_nlms2_tilde *x, t_floatarg f)
+{
+ x->mu = f;
+}
+
+static void nlms2_tilde_getmu(t_nlms2_tilde *x)
+{
+ post("mu (step-size parameter): %f", x->mu);
+}
+
+static void nlms2_tilde_alpha(t_nlms2_tilde *x, t_floatarg f)
+{
+ x->alpha = f;
+}
+
+static void nlms2_tilde_getalpha(t_nlms2_tilde *x)
+{
+ post("alpha: %f", x->alpha);
+}
+
+static void nlms2_tilde_getN(t_nlms2_tilde *x)
+{
+ post("N (number of coefficients): %d", x->N);
+}
+
+static void nlms2_tilde_clear(t_nlms2_tilde *x)
+{
+ int i;
+
+ // clear coefficients
+ for(i=0; i<x->N; i++)
+ x->c[i] = 0;
+
+ // clear temp buffer
+ for(i=0; i<x->N-1; i++)
+ x->buf[i] = 0;
+}
+
+static void nlms2_tilde_init(t_nlms2_tilde *x)
+{
+ int i;
+
+ // set the first coefficient to 1, all others to 0
+ // so this is a delay free transmission
+ x->c[0] = 1;
+ for(i=1; i<x->N; i++)
+ x->c[i] = 0;
+
+ // clear temp buffers
+ for(i=0; i<x->N-1; i++)
+ x->buf[i] = 0;
+}
+
+static void nlms2_tilde_print(t_nlms2_tilde *x)
+{
+ int i;
+
+ // print coefficients
+ post("\nNr. of coefficients: %d",x->N);
+ post("coefficients:");
+ for(i=0; i<x->N; i++)
+ post("\t%d: %f",i,x->c[i]);
+}
+
+static void nlms2_tilde_write(t_nlms2_tilde *x, t_symbol *s)
+{
+ // make correct path
+ char filnam[MAXPDSTRING];
+ char filename[MAXPDSTRING];
+ canvas_makefilename(x->x_canvas, s->s_name, filnam, MAXPDSTRING);
+ sys_bashfilename(filnam, filename);
+
+ // save to file
+ adaptation_write(filename, x->N, x->mu, x->c);
+}
+
+static void nlms2_tilde_read(t_nlms2_tilde *x, t_symbol *s)
+{
+ // make correct path
+ char filnam[MAXPDSTRING];
+ char filename[MAXPDSTRING];
+ int n = x->N;
+ canvas_makefilename(x->x_canvas, s->s_name, filnam, MAXPDSTRING);
+ sys_bashfilename(filnam, filename);
+
+ // read file
+ adaptation_read(filename, &x->N, &x->mu, x->c, x->buf);
+
+ // if length changes:
+ if(x->N != n)
+ {
+ if(x->coef) freebytes(x->coef, sizeof(t_atom) * x->N);
+ x->coef = (t_atom *)getbytes(sizeof(t_atom) * x->N);
+ }
+}
+
+static t_int *nlms2_tilde_perform(t_int *w)
+{
+ t_sample *x_ = (t_sample *)(w[1]);
+ t_sample *d_ = (t_sample *)(w[2]);
+ t_sample *y_ = (t_sample *)(w[3]);
+ t_sample *e_ = (t_sample *)(w[4]);
+ int n = (int)(w[5]);
+ t_nlms2_tilde *x = (t_nlms2_tilde *)(w[6]);
+ int i, j, tmp;
+ t_sample x_2;
+
+
+ for(i=0; i<n; i++)
+ {
+ // calc output (filter)
+
+ x->y_tmp[i]=0;
+
+ // y_[i] += x->c[j] * x_[i-j];
+ // so lets split in two halfs, so that
+ // negative indezes get samples from the
+ // last audioblock (x->buf) ...
+ tmp = (i+1 - x->N)*(-1);
+ tmp = tmp<0 ? 0 : tmp;
+
+ for(j=0; j<x->N-tmp; j++)
+ x->y_tmp[i] += x->c[j] * x_[i-j];
+
+ for(j=x->N-tmp; j<x->N; j++)
+ x->y_tmp[i] += x->c[j] * x->buf[(i-j)*(-1)-1];
+
+ if(x->adapt)
+ {
+ x_2=0;
+
+ // error computation
+ x->e_tmp[i] = d_[i] - x->y_tmp[i];
+
+ // Normalized LMS Adaptmsation Algorithm
+ // (split in the same way as above)
+ //
+ // c[n] = c[n-1] + mu/(alpha + x'[n]*x[n])*e[n]*x[n]
+
+ // calc x'[n]*x[n]
+
+ for(j=0; j<x->N-tmp; j++)
+ x_2 += x_[i-j] * x_[i-j];
+ for(j=x->N-tmp; j<x->N; j++)
+ x_2 += x->buf[(i-j)*(-1)-1] * x->buf[(i-j)*(-1)-1];
+
+
+ for(j=0; j<x->N-tmp; j++)
+ x->c[j] = x->c[j] + x->mu/(x->alpha+x_2) * x_[i-j] * x->e_tmp[i];
+
+ for(j=x->N-tmp; j<x->N; j++)
+ x->c[j] = x->c[j] + x->mu/(x->alpha+x_2) * x->buf[(i-j)*(-1)-1] * x->e_tmp[i];
+ }
+ else x->e_tmp[i] = 0;
+
+ //post("%d: in %f, d: %f, out: %f, e: %f, c1:%f, c2:%f", i, x_[i], d_[i], x->y_tmp[i], x->e_tmp[i], x->c[0], x->c[1]);
+ }
+
+ // outlet coefficients
+ for(i=0; i<x->N; i++)
+ SETFLOAT(&x->coef[i],x->c[i]);
+
+ outlet_list(x->c_out, &s_list, x->N, x->coef);
+
+ // store last samples for next audiobuffer
+ for(i=0; i<x->N-1; i++)
+ x->buf[i] = x_[n-1-i];
+
+ // now write to outlets
+ while(n--)
+ {
+ y_[n] = x->y_tmp[n];
+ e_[n] = x->e_tmp[n];
+ }
+
+ return (w+7);
+}
+
+static void nlms2_tilde_dsp(t_nlms2_tilde *x, t_signal **sp)
+{
+ // allocate new temp buffer if buffersize changes
+ if(x->bufsize != sp[0]->s_n)
+ {
+ if(sp[0]->s_n < x->N)
+ post("nlms2~ WARNING: buffersize must be bigger than N, you will get wrong results !!!");
+
+ if(x->y_tmp) freebytes(x->y_tmp, sizeof(t_sample) * x->bufsize);
+ x->y_tmp = (t_sample *)getbytes(sizeof(t_sample) * sp[0]->s_n);
+
+ if(x->e_tmp) freebytes(x->e_tmp, sizeof(t_sample) * x->bufsize);
+ x->e_tmp = (t_sample *)getbytes(sizeof(t_sample) * sp[0]->s_n);
+
+ x->bufsize = sp[0]->s_n;
+ }
+
+ dsp_add(nlms2_tilde_perform, 6, sp[0]->s_vec, sp[1]->s_vec,
+ sp[2]->s_vec, sp[3]->s_vec, sp[0]->s_n, x);
+}
+
+static void nlms2_tilde_helper(void)
+{
+ post("\nnlms2~: Adaptive transversal filter using normalized LMS");
+ post("INPUT:");
+ post("\tinlet1: input signal x[n]");
+ post("\tinlet2: desired output signal d[n]");
+ post("\tinit_arg1: number of coefficients of the adaptive system");
+ post("\tinit_arg2, mu: step-size parameter (learning rate)");
+ post("OUTPUT:");
+ post("\toutlet1: output signal");
+ post("\toutlet2: error signal e[n]");
+ post("\toutlet3: coefficients c[n] (only per block)\n");
+}
+
+static void *nlms2_tilde_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_nlms2_tilde *x = (t_nlms2_tilde *)pd_new(nlms2_tilde_class);
+ int i;
+
+ // default values:
+ x->N = 8;
+ x->mu = 0.05;
+ x->alpha = 0.0001;
+ x->adapt = 0;
+ x->y_tmp = NULL;
+ x->e_tmp = NULL;
+ x->bufsize = 0;
+
+ switch(argc)
+ {
+ case 2:
+ x->mu = atom_getfloat(argv+1);
+ case 1:
+ x->N = atom_getint(argv);
+ x->N = (x->N<=0) ? 1 : x->N;
+ }
+
+ // allocate mem and init coefficients
+ x->c = (t_float *)getbytes(sizeof(t_float) * x->N);
+ for(i=0; i<x->N; i++)
+ x->c[i] = 0;
+
+ // allocate mem for temp buffer
+ x->buf = (t_sample *)getbytes(sizeof(t_sample) * x->N-1);
+ for(i=0; i<x->N-1; i++)
+ x->buf[i] = 0;
+
+ // for output atoms (coefficients):
+ x->coef = (t_atom *)getbytes(sizeof(t_atom) * x->N);
+
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+ outlet_new(&x->x_obj, &s_signal);
+ outlet_new(&x->x_obj, &s_signal);
+ x->c_out = outlet_new(&x->x_obj, 0);
+
+ x->x_canvas = canvas_getcurrent();
+
+ return (x);
+}
+
+static void nlms2_tilde_free(t_nlms2_tilde *x)
+{
+ if(x->c) freebytes(x->c, sizeof(t_float) * x->N);
+ if(x->buf) freebytes(x->buf, sizeof(t_sample) * x->N-1);
+ if(x->y_tmp) freebytes(x->y_tmp, sizeof(t_sample) * x->bufsize);
+ if(x->e_tmp) freebytes(x->e_tmp, sizeof(t_sample) * x->bufsize);
+ if(x->coef) freebytes(x->coef, sizeof(t_atom) * x->N);
+}
+
+void nlms2_tilde_setup(void)
+{
+ nlms2_tilde_class = class_new(gensym("nlms2~"), (t_newmethod)nlms2_tilde_new,
+ (t_method)nlms2_tilde_free, sizeof(t_nlms2_tilde),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addmethod(nlms2_tilde_class, (t_method)nlms2_tilde_a,
+ gensym("adaptation"), A_DEFFLOAT, 0);
+ class_addmethod(nlms2_tilde_class, (t_method)nlms2_tilde_geta,
+ gensym("getadaptation"), 0);
+ class_addmethod(nlms2_tilde_class, (t_method)nlms2_tilde_mu,
+ gensym("mu"), A_DEFFLOAT, 0);
+ class_addmethod(nlms2_tilde_class, (t_method)nlms2_tilde_getmu,
+ gensym("getmu"), 0);
+ class_addmethod(nlms2_tilde_class, (t_method)nlms2_tilde_alpha,
+ gensym("alpha"), A_DEFFLOAT, 0);
+ class_addmethod(nlms2_tilde_class, (t_method)nlms2_tilde_getalpha,
+ gensym("getalpha"), 0);
+ class_addmethod(nlms2_tilde_class, (t_method)nlms2_tilde_getN,
+ gensym("getN"), 0);
+ class_addmethod(nlms2_tilde_class, (t_method)nlms2_tilde_init,
+ gensym("init_unity"), 0);
+ class_addmethod(nlms2_tilde_class, (t_method)nlms2_tilde_clear,
+ gensym("clear"), 0);
+ class_addmethod(nlms2_tilde_class, (t_method)nlms2_tilde_print,
+ gensym("print"), 0);
+ class_addmethod(nlms2_tilde_class, (t_method)nlms2_tilde_write,
+ gensym("write"), A_DEFSYMBOL, 0);
+ class_addmethod(nlms2_tilde_class, (t_method)nlms2_tilde_read,
+ gensym("read"), A_DEFSYMBOL, 0);
+
+ class_addmethod(nlms2_tilde_class, (t_method)nlms2_tilde_dsp, gensym("dsp"), 0);
+ CLASS_MAINSIGNALIN(nlms2_tilde_class, t_nlms2_tilde, f);
+
+ class_addmethod(nlms2_tilde_class, (t_method)nlms2_tilde_helper, gensym("help"), 0);
+}
diff --git a/adaptive/src/nlms3~.c b/adaptive/src/nlms3~.c
new file mode 100755
index 0000000..a1857a2
--- /dev/null
+++ b/adaptive/src/nlms3~.c
@@ -0,0 +1,423 @@
+/******************************************************
+ *
+ * Adaptive Systems for PD
+ *
+ * copyleft (c) Gerda Strobl, Georg Holzmann
+ * 2005
+ *
+ * for complaints, suggestions: grh@mur.at
+ *
+ ******************************************************
+ *
+ * license: GNU General Public License v.2
+ *
+ ******************************************************/
+
+#include "adaptive.h"
+
+
+/* ------------------------ nlms3~ ------------------------- */
+
+static t_class *nlms3_tilde_class;
+
+typedef struct _nlms3
+{
+ t_object x_obj;
+ t_float f;
+ t_atom *coef;
+ t_sample *buf;
+ t_sample *xbuf;
+ t_sample *in_tmp;
+ t_sample *y_tmp;
+ t_sample *e_tmp;
+ t_int bufsize;
+ t_outlet *c_out;
+ int adapt; // enable/disable adaptation
+
+ t_int N; //number of coefficients of the adaptive system
+ t_float *c; // coefficients of the system
+ t_float mu; // step-size parameter (learning rate)
+ t_float alpha; // small constant to avoid division by zero
+
+ t_canvas *x_canvas;
+} t_nlms3_tilde;
+
+static void nlms3_tilde_a(t_nlms3_tilde *x, t_floatarg f)
+{
+ x->adapt = (f==0) ? 0 : 1;
+
+ if(!x->adapt)
+ {
+ int i;
+
+ // clear temp buffers
+ for(i=0; i<x->N-1; i++)
+ x->buf[i] = 0;
+ for(i=0; i<x->N-1; i++)
+ x->xbuf[i] = 0;
+ }
+}
+
+static void nlms3_tilde_geta(t_nlms3_tilde *x)
+{
+ if(x->adapt==0)
+ post("nlms3~: adaptation is currently OFF");
+ else
+ post("nlms3~: adaptation is currently ON");
+}
+
+static void nlms3_tilde_mu(t_nlms3_tilde *x, t_floatarg f)
+{
+ x->mu = f;
+}
+
+static void nlms3_tilde_getmu(t_nlms3_tilde *x)
+{
+ post("mu (step-size parameter): %f", x->mu);
+}
+
+static void nlms3_tilde_alpha(t_nlms3_tilde *x, t_floatarg f)
+{
+ x->alpha = f;
+}
+
+static void nlms3_tilde_getalpha(t_nlms3_tilde *x)
+{
+ post("alpha: %f", x->alpha);
+}
+
+static void nlms3_tilde_getN(t_nlms3_tilde *x)
+{
+ post("N (number of coefficients): %d", x->N);
+}
+
+static void nlms3_tilde_clear(t_nlms3_tilde *x)
+{
+ int i;
+
+ // clear coefficients
+ for(i=0; i<x->N; i++)
+ x->c[i] = 0;
+
+ // clear temp buffers
+ for(i=0; i<x->N-1; i++)
+ x->buf[i] = 0;
+ for(i=0; i<x->N-1; i++)
+ x->xbuf[i] = 0;
+}
+
+static void nlms3_tilde_init(t_nlms3_tilde *x)
+{
+ int i;
+
+ // set the first coefficient to 1, all others to 0
+ // so this is a delay free transmission
+ x->c[0] = 1;
+ for(i=1; i<x->N; i++)
+ x->c[i] = 0;
+
+ // clear temp buffers
+ for(i=0; i<x->N-1; i++)
+ x->buf[i] = 0;
+ for(i=0; i<x->N-1; i++)
+ x->xbuf[i] = 0;
+}
+
+static void nlms3_tilde_print(t_nlms3_tilde *x)
+{
+ int i;
+
+ // print coefficients
+ post("\nNr. of coefficients: %d",x->N);
+ post("coefficients:");
+ for(i=0; i<x->N; i++)
+ post("\t%d: %f",i,x->c[i]);
+}
+
+static void nlms3_tilde_write(t_nlms3_tilde *x, t_symbol *s)
+{
+ // make correct path
+ char filnam[MAXPDSTRING];
+ char filename[MAXPDSTRING];
+ canvas_makefilename(x->x_canvas, s->s_name, filnam, MAXPDSTRING);
+ sys_bashfilename(filnam, filename);
+
+ // save to file
+ adaptation_write(filename, x->N, x->mu, x->c);
+}
+
+static void nlms3_tilde_read(t_nlms3_tilde *x, t_symbol *s)
+{
+ // make correct path
+ char filnam[MAXPDSTRING];
+ char filename[MAXPDSTRING];
+ int n = x->N;
+ canvas_makefilename(x->x_canvas, s->s_name, filnam, MAXPDSTRING);
+ sys_bashfilename(filnam, filename);
+
+ // read file
+ adaptation_read(filename, &x->N, &x->mu, x->c, x->buf);
+
+ // if length changes:
+ if(x->N != n)
+ {
+ if(x->coef) freebytes(x->coef, sizeof(t_atom) * x->N);
+ x->coef = (t_atom *)getbytes(sizeof(t_atom) * x->N);
+ }
+}
+
+static t_int *nlms3_tilde_perform(t_int *w)
+{
+ t_sample *in_ = (t_sample *)(w[1]);
+ t_sample *x_ = (t_sample *)(w[2]);
+ t_sample *d_ = (t_sample *)(w[3]);
+ t_sample *out_= (t_sample *)(w[4]);
+ t_sample *y_ = (t_sample *)(w[5]);
+ t_sample *e_ = (t_sample *)(w[6]);
+ int n = (int)(w[7]);
+ t_nlms3_tilde *x = (t_nlms3_tilde *)(w[8]);
+ int i, j, tmp;
+ t_sample x_2;
+
+
+ // calculate inlet2 (filter+adaptation)
+ if(x->adapt)
+ {
+ for(i=0; i<n; i++)
+ {
+ x->y_tmp[i]=0;
+ x_2=0;
+
+ // y_[i] += x->c[j] * x_[i-j];
+ // so lets split in two halfs, so that
+ // negative indezes get samples from the
+ // last audioblock (x->buf) ...
+ tmp = (i+1 - x->N)*(-1);
+ tmp = tmp<0 ? 0 : tmp;
+
+ for(j=0; j<x->N-tmp; j++)
+ x->y_tmp[i] += x->c[j] * x_[i-j];
+
+ for(j=x->N-tmp; j<x->N; j++)
+ x->y_tmp[i] += x->c[j] * x->xbuf[(i-j)*(-1)-1];
+
+ // error computation
+ x->e_tmp[i] = d_[i] - x->y_tmp[i];
+
+ // Normalized LMS Adaptmsation Algorithm
+ // (split in the same way as above)
+ //
+ // c[n] = c[n-1] + mu/(alpha + x'[n]*x[n])*e[n]*x[n]
+
+ // calc x'[n]*x[n]
+
+ for(j=0; j<x->N-tmp; j++)
+ x_2 += x_[i-j] * x_[i-j];
+ for(j=x->N-tmp; j<x->N; j++)
+ x_2 += x->xbuf[(i-j)*(-1)-1] * x->xbuf[(i-j)*(-1)-1];
+
+ for(j=0; j<x->N-tmp; j++)
+ x->c[j] = x->c[j] + x->mu/(x->alpha+x_2) * x_[i-j] * x->e_tmp[i];
+ for(j=x->N-tmp; j<x->N; j++)
+ x->c[j] = x->c[j] + x->mu/(x->alpha+x_2) * x->xbuf[(i-j)*(-1)-1] * x->e_tmp[i];
+ }
+
+ // outlet coefficients
+ for(i=0; i<x->N; i++)
+ SETFLOAT(&x->coef[i],x->c[i]);
+
+ outlet_list(x->c_out, &s_list, x->N, x->coef);
+
+ // store last samples for next audiobuffer
+ for(i=0; i<x->N-1; i++)
+ x->xbuf[i] = x_[n-1-i];
+ }
+
+
+ // calculate filter output (inlet 1)
+ for(i=0; i<n; i++)
+ {
+ x->in_tmp[i]=0;
+
+ // y_[i] += x->c[j] * x_[i-j];
+ // so lets split in two halfs, so that
+ // negative indezes get samples from the
+ // last audioblock (x->buf) ...
+ tmp = (i+1 - x->N)*(-1);
+ tmp = tmp<0 ? 0 : tmp;
+
+ for(j=0; j<x->N-tmp; j++)
+ x->in_tmp[i] += x->c[j] * in_[i-j];
+
+ for(j=x->N-tmp; j<x->N; j++)
+ x->in_tmp[i] += x->c[j] * x->buf[(i-j)*(-1)-1];
+ }
+ // store last samples for next audiobuffer
+ for(i=0; i<x->N-1; i++)
+ x->buf[i] = in_[n-1-i];
+
+
+ // write to the outlets
+ if(x->adapt)
+ {
+ while(n--)
+ {
+ out_[n] = x->in_tmp[n];
+ y_[n] = x->y_tmp[n];
+ e_[n] = x->e_tmp[n];
+ }
+ }
+ else
+ {
+ while(n--)
+ {
+ out_[n] = x->in_tmp[n];
+ y_[n] = 0;
+ e_[n] = 0;
+ }
+ }
+
+
+ return (w+9);
+}
+
+static void nlms3_tilde_dsp(t_nlms3_tilde *x, t_signal **sp)
+{
+ // allocate new temp buffer if buffersize changes
+ if(x->bufsize != sp[0]->s_n)
+ {
+ if(sp[0]->s_n < x->N)
+ post("nlms3~ WARNING: buffersize must be bigger than N, you will get wrong results !!!");
+
+ if(x->in_tmp) freebytes(x->in_tmp, sizeof(t_sample) * x->bufsize);
+ x->in_tmp = (t_sample *)getbytes(sizeof(t_sample) * sp[0]->s_n);
+
+ if(x->y_tmp) freebytes(x->y_tmp, sizeof(t_sample) * x->bufsize);
+ x->y_tmp = (t_sample *)getbytes(sizeof(t_sample) * sp[0]->s_n);
+
+ if(x->e_tmp) freebytes(x->e_tmp, sizeof(t_sample) * x->bufsize);
+ x->e_tmp = (t_sample *)getbytes(sizeof(t_sample) * sp[0]->s_n);
+
+ x->bufsize = sp[0]->s_n;
+ }
+
+ dsp_add(nlms3_tilde_perform, 8, sp[0]->s_vec, sp[1]->s_vec,
+ sp[2]->s_vec, sp[3]->s_vec, sp[4]->s_vec,
+ sp[5]->s_vec, sp[0]->s_n, x);
+}
+
+static void nlms3_tilde_helper(void)
+{
+ post("\nnlms3~: Adaptive transversal filter using normalized LMS");
+ post("INPUT:");
+ post("\tinlet1: input signal without adaptation, only filter");
+ post("\tinlet2: input signal for adaptation x[n]");
+ post("\tinlet3: desired output signal d[n]");
+ post("\tinit_arg1: number of coefficients of the adaptive system");
+ post("\tinit_arg2, mu: step-size parameter (learning rate)");
+ post("OUTPUT:");
+ post("\toutlet1: output signal from inlet1");
+ post("\toutlet2: output signal from inlet2");
+ post("\toutlet3: error signal e[n]");
+ post("\toutlet4: coefficients c[n] (only per block)\n");
+}
+
+static void *nlms3_tilde_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_nlms3_tilde *x = (t_nlms3_tilde *)pd_new(nlms3_tilde_class);
+ int i;
+
+ // default values:
+ x->N = 8;
+ x->mu = 0.05;
+ x->alpha = 0.000001;
+ x->adapt = 0;
+ x->in_tmp = NULL;
+ x->y_tmp = NULL;
+ x->e_tmp = NULL;
+ x->bufsize = 0;
+
+ switch(argc)
+ {
+ case 2:
+ x->mu = atom_getfloat(argv+1);
+ case 1:
+ x->N = atom_getint(argv);
+ x->N = (x->N<=0) ? 1 : x->N;
+ }
+
+ // allocate mem and init coefficients
+ x->c = (t_float *)getbytes(sizeof(t_float) * x->N);
+ for(i=0; i<x->N; i++)
+ x->c[i] = 0;
+
+ // allocate mem for temp buffers
+ x->buf = (t_sample *)getbytes(sizeof(t_sample) * x->N-1);
+ for(i=0; i<x->N-1; i++)
+ x->buf[i] = 0;
+ x->xbuf = (t_sample *)getbytes(sizeof(t_sample) * x->N-1);
+ for(i=0; i<x->N-1; i++)
+ x->xbuf[i] = 0;
+
+ // for output atoms (coefficients):
+ x->coef = (t_atom *)getbytes(sizeof(t_atom) * x->N);
+
+ 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);
+ outlet_new(&x->x_obj, &s_signal);
+ outlet_new(&x->x_obj, &s_signal);
+ x->c_out = outlet_new(&x->x_obj, 0);
+
+ x->x_canvas = canvas_getcurrent();
+
+ return (x);
+}
+
+static void nlms3_tilde_free(t_nlms3_tilde *x)
+{
+ if(x->c) freebytes(x->c, sizeof(t_float) * x->N);
+ if(x->buf) freebytes(x->buf, sizeof(t_sample) * x->N-1);
+ if(x->xbuf) freebytes(x->xbuf, sizeof(t_sample) * x->N-1);
+ if(x->in_tmp) freebytes(x->y_tmp, sizeof(t_sample) * x->bufsize);
+ if(x->y_tmp) freebytes(x->y_tmp, sizeof(t_sample) * x->bufsize);
+ if(x->e_tmp) freebytes(x->e_tmp, sizeof(t_sample) * x->bufsize);
+ if(x->coef) freebytes(x->coef, sizeof(t_atom) * x->N);
+}
+
+void nlms3_tilde_setup(void)
+{
+ nlms3_tilde_class = class_new(gensym("nlms3~"), (t_newmethod)nlms3_tilde_new,
+ (t_method)nlms3_tilde_free, sizeof(t_nlms3_tilde),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addmethod(nlms3_tilde_class, (t_method)nlms3_tilde_a,
+ gensym("adaptation"), A_DEFFLOAT, 0);
+ class_addmethod(nlms3_tilde_class, (t_method)nlms3_tilde_geta,
+ gensym("getadaptation"), 0);
+ class_addmethod(nlms3_tilde_class, (t_method)nlms3_tilde_mu,
+ gensym("mu"), A_DEFFLOAT, 0);
+ class_addmethod(nlms3_tilde_class, (t_method)nlms3_tilde_getmu,
+ gensym("getmu"), 0);
+ class_addmethod(nlms3_tilde_class, (t_method)nlms3_tilde_alpha,
+ gensym("alpha"), A_DEFFLOAT, 0);
+ class_addmethod(nlms3_tilde_class, (t_method)nlms3_tilde_getalpha,
+ gensym("getalpha"), 0);
+ class_addmethod(nlms3_tilde_class, (t_method)nlms3_tilde_getN,
+ gensym("getN"), 0);
+ class_addmethod(nlms3_tilde_class, (t_method)nlms3_tilde_init,
+ gensym("init_unity"), 0);
+ class_addmethod(nlms3_tilde_class, (t_method)nlms3_tilde_clear,
+ gensym("clear"), 0);
+ class_addmethod(nlms3_tilde_class, (t_method)nlms3_tilde_print,
+ gensym("print"), 0);
+ class_addmethod(nlms3_tilde_class, (t_method)nlms3_tilde_write,
+ gensym("write"), A_DEFSYMBOL, 0);
+ class_addmethod(nlms3_tilde_class, (t_method)nlms3_tilde_read,
+ gensym("read"), A_DEFSYMBOL, 0);
+
+ class_addmethod(nlms3_tilde_class, (t_method)nlms3_tilde_dsp, gensym("dsp"), 0);
+ CLASS_MAINSIGNALIN(nlms3_tilde_class, t_nlms3_tilde, f);
+
+ class_addmethod(nlms3_tilde_class, (t_method)nlms3_tilde_helper, gensym("help"), 0);
+}
diff --git a/adaptive/src/nlms~.c b/adaptive/src/nlms~.c
new file mode 100755
index 0000000..5ebc4f5
--- /dev/null
+++ b/adaptive/src/nlms~.c
@@ -0,0 +1,324 @@
+/******************************************************
+ *
+ * Adaptive Systems for PD
+ *
+ * copyleft (c) Gerda Strobl, Georg Holzmann
+ * 2005
+ *
+ * for complaints, suggestions: grh@mur.at
+ *
+ ******************************************************
+ *
+ * license: GNU General Public License v.2
+ *
+ ******************************************************/
+
+#include "adaptive.h"
+
+
+/* ------------------------ nlms~ ------------------------- */
+
+static t_class *nlms_tilde_class;
+
+typedef struct _nlms
+{
+ t_object x_obj;
+ t_float f;
+ t_sample *buf;
+ t_sample *tmp;
+ t_int bufsize;
+ int adapt; // enable/disable adaptation
+
+ t_int N; //number of coefficients of the adaptive system
+ t_float *c; // coefficients of the system
+ t_float mu; // step-size parameter (learning rate)
+ t_float alpha; // small constant to avoid division by zero
+
+ t_canvas *x_canvas;
+} t_nlms_tilde;
+
+static void nlms_tilde_a(t_nlms_tilde *x, t_floatarg f)
+{
+ x->adapt = (f==0) ? 0 : 1;
+}
+
+static void nlms_tilde_geta(t_nlms_tilde *x)
+{
+ if(x->adapt==0)
+ post("nlms~: adaptation is currently OFF");
+ else
+ post("nlms~: adaptation is currently ON");
+}
+
+static void nlms_tilde_mu(t_nlms_tilde *x, t_floatarg f)
+{
+ x->mu = f;
+}
+
+static void nlms_tilde_getmu(t_nlms_tilde *x)
+{
+ post("mu (step-size parameter): %f", x->mu);
+}
+
+static void nlms_tilde_alpha(t_nlms_tilde *x, t_floatarg f)
+{
+ x->alpha = f;
+}
+
+static void nlms_tilde_getalpha(t_nlms_tilde *x)
+{
+ post("alpha: %f", x->alpha);
+}
+
+static void nlms_tilde_getN(t_nlms_tilde *x)
+{
+ post("N (number of coefficients): %d", x->N);
+}
+
+static void nlms_tilde_clear(t_nlms_tilde *x)
+{
+ int i;
+
+ // clear coefficients
+ for(i=0; i<x->N; i++)
+ x->c[i] = 0;
+
+ // clear temp buffer
+ for(i=0; i<x->N-1; i++)
+ x->buf[i] = 0;
+}
+
+static void nlms_tilde_init(t_nlms_tilde *x)
+{
+ int i;
+
+ // set the first coefficient to 1, all others to 0
+ // so this is a delay free transmission
+ x->c[0] = 1;
+ for(i=1; i<x->N; i++)
+ x->c[i] = 0;
+
+ // clear temp buffers
+ for(i=0; i<x->N-1; i++)
+ x->buf[i] = 0;
+}
+
+static void nlms_tilde_print(t_nlms_tilde *x)
+{
+ int i;
+
+ // print coefficients
+ post("\nNr. of coefficients: %d",x->N);
+ post("coefficients:");
+ for(i=0; i<x->N; i++)
+ post("\t%d: %f",i,x->c[i]);
+}
+
+static void nlms_tilde_write(t_nlms_tilde *x, t_symbol *s)
+{
+ // make correct path
+ char filnam[MAXPDSTRING];
+ char filename[MAXPDSTRING];
+ canvas_makefilename(x->x_canvas, s->s_name, filnam, MAXPDSTRING);
+ sys_bashfilename(filnam, filename);
+
+ // save to file
+ adaptation_write(filename, x->N, x->mu, x->c);
+}
+
+static void nlms_tilde_read(t_nlms_tilde *x, t_symbol *s)
+{
+ // make correct path
+ char filnam[MAXPDSTRING];
+ char filename[MAXPDSTRING];
+ canvas_makefilename(x->x_canvas, s->s_name, filnam, MAXPDSTRING);
+ sys_bashfilename(filnam, filename);
+
+ // read file
+ adaptation_read(filename, &x->N, &x->mu, x->c, x->buf);
+}
+
+static t_int *nlms_tilde_perform(t_int *w)
+{
+ t_nlms_tilde *x = (t_nlms_tilde *)(w[1]);
+ t_sample *x_ = (t_sample *)(w[2]);
+ t_sample *d_ = (t_sample *)(w[3]);
+ t_sample *y_ = (t_sample *)(w[4]);
+ int n = (int)(w[5]);
+ int i, j, tmp;
+ t_sample e=0, x_2;
+
+
+ for(i=0; i<n; i++)
+ {
+ // calc output (filter)
+
+ x->tmp[i]=0;
+
+ // y_[i] += x->c[j] * x_[i-j];
+ // so lets split in two halfs, so that
+ // negative indezes get samples from the
+ // last audioblock (x->buf) ...
+ tmp = (i+1 - x->N)*(-1);
+ tmp = tmp<0 ? 0 : tmp;
+
+ for(j=0; j<x->N-tmp; j++)
+ x->tmp[i] += x->c[j] * x_[i-j];
+
+ for(j=x->N-tmp; j<x->N; j++)
+ x->tmp[i] += x->c[j] * x->buf[(i-j)*(-1)-1];
+
+ if(x->adapt)
+ {
+ x_2=0;
+
+ // error computation
+ e =d_[i] - x->tmp[i];
+
+ // Normalized LMS Adaptmsation Algorithm
+ // (split in the same way as above)
+ //
+ // c[n] = c[n-1] + mu/(alpha + x'[n]*x[n])*e[n]*x[n]
+
+ // calc x'[n]*x[n]
+ // TODO: Performance Optimization: save results from the past
+ // so that this for loop should be obsolet ...
+ for(j=0; j<x->N-tmp; j++)
+ x_2 += x_[i-j] * x_[i-j];
+ for(j=x->N-tmp; j<x->N; j++)
+ x_2 += x->buf[(i-j)*(-1)-1] * x->buf[(i-j)*(-1)-1];
+
+
+ for(j=0; j<x->N-tmp; j++)
+ x->c[j] = x->c[j] + x->mu/(x->alpha+x_2) * x_[i-j] * e;
+
+ for(j=x->N-tmp; j<x->N; j++)
+ x->c[j] = x->c[j] + x->mu/(x->alpha+x_2) * x->buf[(i-j)*(-1)-1] * e;
+ }
+
+ //post("%d: in %f, d: %f, out: %f, error: %f, c1:%f, c2:%f", i, x_[i], d_[i], x->tmp[i], e, x->c[0], x->c[1]);
+ }
+
+ // store last samples for next audiobuffer
+ for(i=0; i<x->N-1; i++)
+ x->buf[i] = x_[n-1-i];
+
+ // now write tmp to outlet
+ while(n--)
+ y_[n] = x->tmp[n];
+
+ return (w+6);
+}
+
+static void nlms_tilde_dsp(t_nlms_tilde *x, t_signal **sp)
+{
+ // allocate new temp buffer if buffersize changes
+ if(x->bufsize != sp[0]->s_n)
+ {
+ if(sp[0]->s_n < x->N)
+ post("nlms~ WARNING: buffersize must be bigger than N, you will get wrong results !!!");
+
+ if(x->tmp) freebytes(x->tmp, sizeof(t_sample) * x->bufsize);
+ x->tmp = (t_sample *)getbytes(sizeof(t_sample) * sp[0]->s_n);
+
+ x->bufsize = sp[0]->s_n;
+ }
+
+ dsp_add(nlms_tilde_perform, 5, x, sp[0]->s_vec, sp[1]->s_vec,
+ sp[2]->s_vec, sp[0]->s_n);
+}
+
+static void nlms_tilde_helper(void)
+{
+ post("\nnlms~: Adaptive transversal filter using normalized LMS");
+ post("INPUT:");
+ post("\tinlet1: input signal x[n]");
+ post("\tinlet2: desired output signal d[n]");
+ post("\tinit_arg1: number of coefficients of the adaptive system");
+ post("\tinit_arg2, mu: step-size parameter (learning rate)");
+ post("OUTPUT:");
+ post("\toutlet1: output signal\n");
+}
+
+static void *nlms_tilde_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_nlms_tilde *x = (t_nlms_tilde *)pd_new(nlms_tilde_class);
+ int i;
+
+ // default values:
+ x->N = 8;
+ x->mu = 0.05;
+ x->alpha = 0.0001;
+ x->adapt = 0;
+ x->tmp = NULL;
+ x->bufsize = 0;
+
+ switch(argc)
+ {
+ case 2:
+ x->mu = atom_getfloat(argv+1);
+ case 1:
+ x->N = atom_getint(argv);
+ x->N = (x->N<=0) ? 1 : x->N;
+ }
+
+ // allocate mem and init coefficients
+ x->c = (t_float *)getbytes(sizeof(t_float) * x->N);
+ for(i=0; i<x->N; i++)
+ x->c[i] = 0;
+
+ // allocate mem for temp buffer
+ x->buf = (t_sample *)getbytes(sizeof(t_sample) * x->N-1);
+ for(i=0; i<x->N-1; i++)
+ x->buf[i] = 0;
+
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+ outlet_new(&x->x_obj, &s_signal);
+ x->x_canvas = canvas_getcurrent();
+
+ return (x);
+}
+
+static void nlms_tilde_free(t_nlms_tilde *x)
+{
+ if(x->c) freebytes(x->c, sizeof(t_float) * x->N);
+ if(x->buf) freebytes(x->buf, sizeof(t_sample) * x->N-1);
+ if(x->tmp) freebytes(x->tmp, sizeof(t_sample) * x->bufsize);
+}
+
+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),
+ CLASS_DEFAULT, A_GIMME, 0);
+
+ class_addmethod(nlms_tilde_class, (t_method)nlms_tilde_a,
+ gensym("adaptation"), A_DEFFLOAT, 0);
+ class_addmethod(nlms_tilde_class, (t_method)nlms_tilde_geta,
+ gensym("getadaptation"), 0);
+ class_addmethod(nlms_tilde_class, (t_method)nlms_tilde_mu,
+ gensym("mu"), A_DEFFLOAT, 0);
+ class_addmethod(nlms_tilde_class, (t_method)nlms_tilde_getmu,
+ gensym("getmu"), 0);
+ class_addmethod(nlms_tilde_class, (t_method)nlms_tilde_alpha,
+ gensym("alpha"), A_DEFFLOAT, 0);
+ class_addmethod(nlms_tilde_class, (t_method)nlms_tilde_getalpha,
+ gensym("getalpha"), 0);
+ class_addmethod(nlms_tilde_class, (t_method)nlms_tilde_getN,
+ gensym("getN"), 0);
+ class_addmethod(nlms_tilde_class, (t_method)nlms_tilde_init,
+ gensym("init_unity"), 0);
+ class_addmethod(nlms_tilde_class, (t_method)nlms_tilde_clear,
+ gensym("clear"), 0);
+ class_addmethod(nlms_tilde_class, (t_method)nlms_tilde_print,
+ gensym("print"), 0);
+ class_addmethod(nlms_tilde_class, (t_method)nlms_tilde_write,
+ gensym("write"), A_DEFSYMBOL, 0);
+ class_addmethod(nlms_tilde_class, (t_method)nlms_tilde_read,
+ gensym("read"), A_DEFSYMBOL, 0);
+
+ class_addmethod(nlms_tilde_class, (t_method)nlms_tilde_dsp, gensym("dsp"), 0);
+ CLASS_MAINSIGNALIN(nlms_tilde_class, t_nlms_tilde, f);
+
+ class_addmethod(nlms_tilde_class, (t_method)nlms_tilde_helper, gensym("help"), 0);
+}