aboutsummaryrefslogtreecommitdiff
path: root/adaptive/examples/06.interference_cancelation.pd
blob: 622b6463a8117eef07c573ced0c35877e11fad88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
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;