aboutsummaryrefslogtreecommitdiff
path: root/desiredata/doc/3.audio.examples/I09.sheep.from.goats.pd
blob: 87a779eda989e11f7aa4ad9e55cfbd6493f70971 (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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
#N canvas -6 5 609 588 12;
#N canvas 300 81 867 775 fft-analysis 0;
#X obj 85 664 *~;
#X obj 35 712 *~;
#X obj 316 148 *~;
#X obj 34 58 *~;
#X obj 34 35 inlet~;
#X obj 34 82 rfft~;
#X obj 35 688 rifft~;
#X obj 35 737 outlet~;
#X obj 277 147 *~;
#X obj 277 198 rsqrt~;
#X obj 105 421 -~;
#X obj 34 663 *~;
#X obj 68 58 tabreceive~ \$0-hann;
#X obj 644 51 loadbang;
#X obj 644 133 r window-size;
#X obj 69 711 tabreceive~ \$0-hann;
#X obj 131 327 *~;
#X msg 644 155 set \$1 4;
#X obj 644 179 block~;
#X msg 643 75 \; pd dsp 1 \; window-size 1024;
#X obj 125 616 /~ 1000;
#X obj 197 616 r window-size;
#X obj 254 229 *~;
#X obj 113 220 *~;
#X obj 277 171 +~ 1e-20;
#X obj 152 246 lrshift~ 1;
#X obj 313 254 lrshift~ 1;
#X obj 152 272 lrshift~ -1;
#X obj 314 281 lrshift~ -1;
#X obj 292 335 *~;
#X obj 105 475 clip~ 0 1;
#X obj 106 448 *~ 1e+20;
#X obj 105 392 +~;
#X obj 105 508 *~;
#X obj 144 508 lrshift~ 1;
#X obj 251 508 lrshift~ -1;
#X obj 125 540 *~;
#X obj 410 411 -~;
#X obj 410 459 clip~ 0 1;
#X obj 411 435 *~ 1e+20;
#X obj 410 488 *~;
#X obj 449 488 lrshift~ 1;
#X obj 553 487 lrshift~ -1;
#X obj 430 517 *~;
#X obj 430 540 *~ -1;
#X obj 430 563 +~ 1;
#X obj 125 582 +~;
#X obj 255 335 *~;
#X obj 98 327 *~;
#X text 195 476 0 if clean;
#X text 170 541 0 if a neighbor is clean;
#X obj 97 301 +~;
#X obj 130 300 +~;
#X obj 255 309 +~;
#X obj 292 308 +~;
#X text 169 558 1 if all neighbors dirty;
#X text 470 584 1 if a neighbor dirty;
#X text 472 568 0 if all neighbors clean;
#X obj 224 679 lrshift~ -1;
#X obj 224 655 sig~ 1;
#X obj 125 638 *~;
#X obj 220 442 expr $f1*$f1/1250;
#X obj 432 385 expr $f1*$f1/1250;
#X obj 220 417 r dirty;
#X obj 432 360 r clean;
#X text 362 148 normalize the amplitudes;
#X text 439 253 add neighboring amplitude to this one;
#X text 437 269 and take squared magnitude of result -;
#X text 437 286 do this for both the left neightbor and;
#X text 436 303 the right one;
#X text 94 82 forward real Hann-windowed FT;
#X text 284 658 I had trouble with the DC bin - this zeros it.;
#X text 594 366 adjust threshold to quadratic;
#X text 594 382 units and scale;
#X text 142 389 total incoherence;
#X text 496 414 compare incoherence with the threshold;
#X text 532 511 multiply by left and right;
#X text 531 529 neighbors \, so 0 if any of;
#X text 531 546 the 3 is "clean".;
#X text 497 429 If greater (dirty) \, the "clip" outputs;
#X text 498 444 1 \, otherwise (if clean) \, zero.;
#X text 161 583 add to let in channels;
#X text 159 597 for either criterion;
#X connect 0 0 6 1;
#X connect 1 0 7 0;
#X connect 2 0 24 0;
#X connect 3 0 5 0;
#X connect 4 0 3 0;
#X connect 5 0 11 0;
#X connect 5 0 8 0;
#X connect 5 0 8 1;
#X connect 5 0 23 0;
#X connect 5 1 0 0;
#X connect 5 1 2 0;
#X connect 5 1 2 1;
#X connect 5 1 22 0;
#X connect 6 0 1 0;
#X connect 8 0 24 0;
#X connect 9 0 23 1;
#X connect 9 0 22 1;
#X connect 10 0 31 0;
#X connect 11 0 6 0;
#X connect 12 0 3 1;
#X connect 13 0 19 0;
#X connect 14 0 17 0;
#X connect 15 0 1 1;
#X connect 16 0 32 0;
#X connect 17 0 18 0;
#X connect 20 0 60 0;
#X connect 21 0 20 1;
#X connect 22 0 26 0;
#X connect 22 0 28 0;
#X connect 22 0 53 0;
#X connect 22 0 54 0;
#X connect 23 0 25 0;
#X connect 23 0 27 0;
#X connect 23 0 51 0;
#X connect 23 0 52 0;
#X connect 24 0 9 0;
#X connect 25 0 51 1;
#X connect 26 0 53 1;
#X connect 27 0 52 1;
#X connect 28 0 54 1;
#X connect 29 0 32 1;
#X connect 30 0 33 0;
#X connect 30 0 35 0;
#X connect 30 0 34 0;
#X connect 31 0 30 0;
#X connect 32 0 10 0;
#X connect 32 0 37 0;
#X connect 33 0 36 0;
#X connect 34 0 33 1;
#X connect 35 0 36 1;
#X connect 36 0 46 0;
#X connect 37 0 39 0;
#X connect 38 0 40 0;
#X connect 38 0 42 0;
#X connect 38 0 41 0;
#X connect 39 0 38 0;
#X connect 40 0 43 0;
#X connect 41 0 40 1;
#X connect 42 0 43 1;
#X connect 43 0 44 0;
#X connect 44 0 45 0;
#X connect 45 0 46 1;
#X connect 46 0 20 0;
#X connect 47 0 32 1;
#X connect 48 0 32 0;
#X connect 51 0 48 0;
#X connect 51 0 48 1;
#X connect 52 0 16 0;
#X connect 52 0 16 1;
#X connect 53 0 47 0;
#X connect 53 0 47 1;
#X connect 54 0 29 0;
#X connect 54 0 29 1;
#X connect 58 0 60 1;
#X connect 59 0 58 0;
#X connect 60 0 11 1;
#X connect 60 0 0 1;
#X connect 61 0 10 1;
#X connect 62 0 37 1;
#X connect 63 0 61 0;
#X connect 64 0 62 0;
#X restore 49 410 pd fft-analysis;
#X floatatom 355 287 0 0 100 0 - - -;
#X text 138 10 PITCHED/UNPITCHED SEPARATION;
#X obj 48 443 output~;
#X floatatom 48 356 0 0 100 0 - - -;
#X text 105 337 noise;
#X floatatom 108 356 0 0 100 0 - - -;
#N canvas 214 193 769 642 test-signal 0;
#X obj 75 328 line~;
#X obj 75 250 f;
#X obj 517 236 *~;
#X obj 76 442 *~;
#X obj 517 127 noise~;
#X obj 371 494 +~;
#X obj 98 415 dbtorms;
#X obj 539 210 dbtorms;
#X obj 98 390 inlet;
#X obj 539 186 inlet;
#X obj 373 568 outlet~;
#X msg 75 304 0 \, \$1 \$2;
#X obj 75 276 pack 0 0;
#X obj 236 248 /;
#X obj 251 190 * 0.001;
#X obj 251 219 t b f;
#X obj 372 543 hip~ 5;
#X obj 75 136 loadbang;
#X obj 75 182 metro 1000;
#X obj 517 152 bp~ 10000 3;
#X obj 75 161 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1
;
#X text 270 247 sample duration \, msec;
#X text 126 84 looped sample playback;
#X obj 75 356 tabread4~ \$0-sample;
#X text 514 100 filtered noise;
#X text 105 15 TEST SIGNAL: looped sample plus noise. The inlets control
amplitude of each in dB.;
#X obj 236 139 r \$0-samplength;
#X obj 251 164 r \$0-insamprate;
#X obj 658 244 *~;
#X obj 680 218 dbtorms;
#X obj 680 194 inlet;
#X text 655 108 osc;
#X obj 658 134 osc~ 440;
#X obj 372 519 *~ 3;
#X connect 0 0 23 0;
#X connect 1 0 12 0;
#X connect 2 0 5 1;
#X connect 3 0 5 0;
#X connect 4 0 19 0;
#X connect 5 0 33 0;
#X connect 6 0 3 1;
#X connect 7 0 2 1;
#X connect 8 0 6 0;
#X connect 9 0 7 0;
#X connect 11 0 0 0;
#X connect 12 0 11 0;
#X connect 13 0 12 1;
#X connect 13 0 18 1;
#X connect 14 0 15 0;
#X connect 15 0 13 0;
#X connect 15 1 13 1;
#X connect 16 0 10 0;
#X connect 17 0 20 0;
#X connect 18 0 1 0;
#X connect 19 0 2 0;
#X connect 20 0 18 0;
#X connect 23 0 3 0;
#X connect 26 0 1 1;
#X connect 26 0 13 0;
#X connect 27 0 14 0;
#X connect 28 0 5 1;
#X connect 29 0 28 1;
#X connect 30 0 29 0;
#X connect 32 0 28 0;
#X connect 33 0 16 0;
#X restore 48 380 pd test-signal;
#X text 32 334 sampler;
#X text 56 314 amplitudes (dB);
#N canvas 0 110 565 454 hann-window 0;
#N canvas 0 0 450 300 graph1 0;
#X array \$0-hann 1024 float 0;
#X coords 0 1 1023 0 300 100 1;
#X restore 82 311 graph;
#X obj 378 165 osc~;
#X obj 378 190 *~ -0.5;
#X obj 378 214 +~ 0.5;
#X obj 331 247 tabwrite~ \$0-hann;
#X obj 37 88 r window-size;
#X obj 38 173 /;
#X obj 127 142 samplerate~;
#X obj 38 251 s window-sec;
#X obj 177 204 swap;
#X obj 177 228 /;
#X obj 177 252 s window-hz;
#X obj 49 201 * 1000;
#X obj 49 228 s window-msec;
#X obj 38 115 t f b f;
#X msg 173 92 resize \$1;
#X obj 173 116 s \$0-hann;
#X obj 330 105 r window-hz;
#X msg 382 130 0;
#X obj 330 131 t f b;
#X text 15 8 calculate Hann window table (variable window size) and
constants window-hz (fundamental frequency of analysis) \, window-sec
and window-msec (analysis window size in seconds and msec).;
#X connect 1 0 2 0;
#X connect 2 0 3 0;
#X connect 3 0 4 0;
#X connect 5 0 14 0;
#X connect 6 0 8 0;
#X connect 6 0 12 0;
#X connect 7 0 6 1;
#X connect 7 0 9 1;
#X connect 9 0 10 0;
#X connect 9 1 10 1;
#X connect 10 0 11 0;
#X connect 12 0 13 0;
#X connect 14 0 6 0;
#X connect 14 0 9 0;
#X connect 14 1 7 0;
#X connect 14 2 15 0;
#X connect 15 0 16 0;
#X connect 17 0 19 0;
#X connect 18 0 1 1;
#X connect 19 0 1 0;
#X connect 19 1 4 0;
#X connect 19 1 18 0;
#X restore 457 458 pd hann-window;
#N canvas 52 71 774 520 tables 0;
#N canvas 0 0 450 300 graph1 0;
#X array \$0-last-real 2048 float 0;
#X coords 0 500 2048 -500 200 150 1;
#X restore 103 15 graph;
#N canvas 0 0 450 300 graph2 0;
#X array \$0-last-imag 2048 float 0;
#X coords 0 500 2048 500 200 150 1;
#X restore 497 6 graph;
#N canvas 0 0 450 300 graph1 0;
#X array \$0-precess-real 2048 float 0;
#X coords 0 500 2048 -500 200 150 1;
#X restore 105 185 graph;
#N canvas 0 0 450 300 graph2 0;
#X array \$0-precess-imag 2048 float 0;
#X coords 0 500 2048 -500 200 150 1;
#X restore 501 178 graph;
#N canvas 0 0 450 300 graph1 0;
#X array \$0-inc-real 2048 float 0;
#X coords 0 1 2048 -1 200 150 1;
#X restore 105 357 graph;
#N canvas 0 0 450 300 graph2 0;
#X array \$0-inc-imag 2048 float 0;
#X coords 0 1 2048 -1 200 150 1;
#X restore 503 342 graph;
#X restore 457 479 pd tables;
#N canvas 388 86 722 350 insample 0;
#N canvas 0 0 450 300 graph1 0;
#X array \$0-sample 62079 float 0;
#X coords 0 1 62078 -1 400 150 1;
#X restore 259 24 graph;
#X obj 19 23 r read-sample;
#X obj 19 74 unpack s f;
#X obj 19 184 soundfiler;
#X text 356 250 read a sample;
#X obj 276 249 loadbang;
#X obj 19 100 t s b;
#X obj 75 99 symbol \$0-sample;
#X obj 19 135 pack s s;
#X msg 19 160 read -resize \$1 \$2;
#X obj 74 46 44100;
#X obj 19 47 t a b;
#X msg 276 273 \; read-sample ../sound/bell.aiff;
#X obj 29 208 s \$0-samplength;
#X obj 116 74 s \$0-insamprate;
#X obj 19 247 /;
#X obj 19 271 * 1000;
#X obj 19 294 s \$0-samp-msec;
#X obj 57 247 r \$0-insamprate;
#X connect 1 0 11 0;
#X connect 2 0 6 0;
#X connect 2 1 14 0;
#X connect 3 0 13 0;
#X connect 3 0 15 0;
#X connect 5 0 12 0;
#X connect 6 0 8 0;
#X connect 6 1 7 0;
#X connect 7 0 8 1;
#X connect 8 0 9 0;
#X connect 9 0 3 0;
#X connect 10 0 14 0;
#X connect 11 0 2 0;
#X connect 11 1 10 0;
#X connect 15 0 16 0;
#X connect 16 0 17 0;
#X connect 18 0 15 1;
#X restore 233 501 pd insample;
#X msg 233 403 ../sound/bell.aiff;
#X msg 233 426 ../sound/voice.wav;
#X msg 233 449 ../sound/voice2.wav;
#X text 236 383 change input sound;
#X obj 233 473 s read-sample;
#X floatatom 233 523 5 0 0 0 - #0-samp-msec -;
#X text 286 522 sample length \, msec;
#X floatatom 233 285 0 0 100 0 - - -;
#X floatatom 169 356 0 0 100 0 - - -;
#X text 167 336 osc;
#X msg 471 325 512;
#X msg 471 346 1024;
#X msg 471 368 2048;
#X obj 471 413 s window-size;
#X msg 471 390 4096;
#X obj 233 308 s clean;
#X text 233 331 0=silent;
#X text 231 351 100=all;
#X obj 355 310 s dirty;
#X text 351 331 100=silent;
#X text 353 348 0=all;
#X text 354 563 updated for Pd version 0.39;
#X text 11 212 Two separate thresholds may be adjusted to listen to
the "clean" or "dirty" part of the signal. You'll hear anything less
incoherent than the clean threshold \, OR more incoherent than the
dirty one.;
#X text 13 35 This patch applies a very simple coherence test to distinguish
between sinusoids and noise in an input signal. It works very imperfectly
(since noise is random \, no matter what test we place on it it will
sometimes spoof its way in.) Here we just test that neighboring channels
are 180 degrees (pi radians) out of phase \, as they should be in the
main lobe in response to a sinusoid. If any three channels are so arranged
\, all three are considered as contributing to a sinusoid. To do this
we make an "incoherence" measure which is zero if the phase relationship
is perfect and progressively larger otherwise.;
#X connect 0 0 3 0;
#X connect 0 0 3 1;
#X connect 1 0 31 0;
#X connect 4 0 7 0;
#X connect 6 0 7 1;
#X connect 7 0 0 0;
#X connect 13 0 17 0;
#X connect 14 0 17 0;
#X connect 15 0 17 0;
#X connect 20 0 28 0;
#X connect 21 0 7 2;
#X connect 23 0 26 0;
#X connect 24 0 26 0;
#X connect 25 0 26 0;
#X connect 27 0 26 0;