aboutsummaryrefslogtreecommitdiff
path: root/adaptive/examples/01.system_identification.pd
diff options
context:
space:
mode:
Diffstat (limited to 'adaptive/examples/01.system_identification.pd')
-rwxr-xr-xadaptive/examples/01.system_identification.pd318
1 files changed, 318 insertions, 0 deletions
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;