diff options
author | Jamie Bullock <jamie@postlude.co.uk> | 2007-03-12 18:20:43 +0000 |
---|---|---|
committer | Jamie Bullock <jamie@postlude.co.uk> | 2007-03-12 18:20:43 +0000 |
commit | b82f0373c5c7bed95b7c7612db9c051bb37ea36e (patch) | |
tree | ef43ed783bed471ea2ae600cfc7788672b2b7768 /examples | |
parent | cadf1d65ff8f2679b2e394ef1843a3a6f7232c54 (diff) | |
download | LibXtract-b82f0373c5c7bed95b7c7612db9c051bb37ea36e.tar.gz LibXtract-b82f0373c5c7bed95b7c7612db9c051bb37ea36e.tar.bz2 LibXtract-b82f0373c5c7bed95b7c7612db9c051bb37ea36e.zip |
Improvements an fixes to PD example and help files
Diffstat (limited to 'examples')
-rw-r--r-- | examples/puredata/xtract/a_hann.pd | 48 | ||||
-rw-r--r-- | examples/puredata/xtract/f0.pd | 120 | ||||
-rw-r--r-- | examples/puredata/xtract/mfcc.pd | 181 | ||||
-rw-r--r-- | examples/puredata/xtract/xtract-help.pd | 18 | ||||
-rw-r--r-- | examples/puredata/xtract~.c | 47 |
5 files changed, 266 insertions, 148 deletions
diff --git a/examples/puredata/xtract/a_hann.pd b/examples/puredata/xtract/a_hann.pd index bc150b0..fbc7af4 100644 --- a/examples/puredata/xtract/a_hann.pd +++ b/examples/puredata/xtract/a_hann.pd @@ -1,30 +1,30 @@ #N canvas 379 192 709 463 10; -#X obj 368 85 samplerate~; -#X obj 371 153 phasor~; -#X msg 457 83 0; -#X obj 371 182 expr~ 0.5 - cos($v1 * 6.28) * 0.5; -#X obj 618 10 block~ \$1; -#X obj 368 107 /~ \$1; +#X obj 381 119 samplerate~; +#X obj 384 187 phasor~; +#X msg 470 117 0; +#X obj 384 216 expr~ 0.5 - cos($v1 * 6.28) * 0.5; +#X obj 381 141 /~ \$1; #X text 43 20 Creation arg gives window size; #X obj 346 38 t b b b b; -#X obj 490 58 float \$1; +#X obj 504 92 float \$1; #X obj 346 10 inlet; -#X obj 40 268 tabreceive~ \$0-hann; -#X obj 40 307 outlet~; -#X msg 491 80 resize \$1; -#X obj 493 104 s \$0-hann; -#X obj 373 308 table \$0-hann; -#X obj 371 207 tabwrite~ \$0-hann; -#X connect 0 0 5 0; +#X msg 504 114 resize \$1; +#X obj 504 139 s \$0-hann; +#X obj 589 37 table \$0-hann; +#X obj 318 296 tabwrite~ \$0-hann; +#X obj 58 186 tabreceive~ \$0-hann; +#X obj 59 229 outlet~; +#X obj 589 11 block~ \$1; +#X connect 0 0 4 0; #X connect 1 0 3 0; #X connect 2 0 1 1; -#X connect 3 0 15 0; -#X connect 5 0 1 0; -#X connect 7 0 15 0; -#X connect 7 1 2 0; -#X connect 7 2 0 0; -#X connect 7 3 8 0; -#X connect 8 0 12 0; -#X connect 9 0 7 0; -#X connect 10 0 11 0; -#X connect 12 0 13 0; +#X connect 3 0 12 0; +#X connect 4 0 1 0; +#X connect 6 0 12 0; +#X connect 6 1 2 0; +#X connect 6 2 0 0; +#X connect 6 3 7 0; +#X connect 7 0 9 0; +#X connect 8 0 6 0; +#X connect 9 0 10 0; +#X connect 13 0 14 0; diff --git a/examples/puredata/xtract/f0.pd b/examples/puredata/xtract/f0.pd index d178c82..47dc649 100644 --- a/examples/puredata/xtract/f0.pd +++ b/examples/puredata/xtract/f0.pd @@ -1,4 +1,4 @@ -#N canvas 814 127 584 590 10; +#N canvas 730 93 584 590 10; #N canvas 162 173 901 522 guts 0; #X obj 205 48 osc~; #X obj 338 70 a_spigot~; @@ -53,18 +53,15 @@ #X connect 4 0 3 0; #X connect 4 0 1 1; #X restore 587 66 pd noise; -#N canvas 604 77 496 580 pda 0; +#N canvas 135 136 496 580 pda 0; #X obj 99 100 xtract~ f0; #X obj 197 6 inlet~; -#X obj 147 195 xtract~ magnitude_spectrum; -#X obj 149 299 xtract~ lowest_match; #X msg 361 203 list \$1; #X obj 244 115 *~; #X obj 59 25 r sr; -#X obj 148 222 xtract~ peaks; -#X obj 148 245 tabsend~ freqs; +#X obj 149 267 tabsend~ freqs; #X obj 401 30 table freqs; -#X obj 148 276 tabreceive~ freqs; +#X obj 148 292 tabreceive~ freqs; #X obj 6 220 != 0; #X obj 4 331 spigot; #X obj 57 331 spigot; @@ -80,36 +77,49 @@ #X obj 402 8 block~ 2048; #X obj 200 51 hip~ 20; #X msg 60 48 list \$1; -#X obj 274 80 a_hann 2048; #X obj 274 59 r \$0-window-gen; -#X connect 0 0 4 0; +#X obj 274 80 a_hann 2048; +#X obj 147 195 xtract~ spectrum; +#X obj 148 222 xtract~ peak_spectrum; +#X obj 149 315 xtract~ lowest_value; +#X obj 150 243 a_blockswap~ 2048; +#X obj 359 127 samplerate~; +#X obj 358 150 / 2048; +#X msg 358 171 \$1 10; +#X obj 356 105 r \$0-peak-args; +#X connect 0 0 2 0; +#X connect 0 0 8 0; +#X connect 0 0 9 0; #X connect 0 0 11 0; -#X connect 0 0 12 0; -#X connect 0 0 14 0; -#X connect 1 0 22 0; -#X connect 2 0 7 0; -#X connect 3 0 13 0; -#X connect 4 0 3 1; -#X connect 5 0 2 0; -#X connect 6 0 25 0; -#X connect 7 0 8 0; -#X connect 10 0 3 0; -#X connect 11 0 12 1; -#X connect 12 0 15 0; +#X connect 1 0 19 0; +#X connect 2 0 27 1; +#X connect 3 0 25 0; +#X connect 4 0 22 0; +#X connect 7 0 27 0; +#X connect 8 0 9 1; +#X connect 9 0 12 0; +#X connect 10 0 12 0; +#X connect 11 0 10 1; +#X connect 12 0 14 0; #X connect 13 0 15 0; -#X connect 14 0 13 1; -#X connect 15 0 17 0; -#X connect 16 0 18 0; -#X connect 17 0 16 0; -#X connect 18 0 21 0; -#X connect 19 0 18 0; -#X connect 21 0 20 0; -#X connect 22 0 24 0; -#X connect 24 0 0 0; -#X connect 24 0 5 0; -#X connect 25 0 0 1; -#X connect 26 0 5 1; -#X connect 27 0 26 0; +#X connect 14 0 13 0; +#X connect 15 0 18 0; +#X connect 16 0 15 0; +#X connect 18 0 17 0; +#X connect 19 0 21 0; +#X connect 21 0 0 0; +#X connect 21 0 3 0; +#X connect 22 0 0 1; +#X connect 23 0 24 0; +#X connect 24 0 3 1; +#X connect 25 0 26 0; +#X connect 26 0 28 0; +#X connect 27 0 10 0; +#X connect 28 0 5 0; +#X connect 29 0 30 0; +#X connect 30 0 31 0; +#X connect 31 0 26 1; +#X connect 32 0 29 0; #X restore 357 262 pd pda; #N canvas 0 0 596 417 d_saw 0; #X obj 382 176 phasor~; @@ -160,7 +170,7 @@ #X obj 733 -70 loadbang; #X obj 68 241 loadbang; #X msg 67 263 symbol; -#X text 411 283 <-The magic happens in here; +#X text 411 263 <-The magic happens in here; #X obj 660 323 a_output~; #X msg 747 271 0; #X obj 263 46 r \$0-sine; @@ -179,14 +189,14 @@ #X obj 745 230 r \$0-master-lvl-stereo; #X obj 747 252 r \$0-master-lvl-mute; #X obj 747 291 s \$0-master-lvl-stereo; -#X msg 733 -20 \; pd dsp 1 \; \; \$1-window-gen bang \; sr 44100 \; -\; \$1-master-lvl-stereo 50; #X obj 733 -45 f \$0; #X obj 38 357 s \$0-f0_cent; #X obj 19 378 s \$0-f0_8ve; #X obj 0 406 s \$0-f0_note; #X obj 254 261 s~ \$0-dacs; #X obj 670 281 r~ \$0-dacs; +#X msg 732 -19 \; pd dsp 1 \; \; \$1-window-gen bang \; sr 44100 \; +\; \$1-master-lvl-stereo 50 \; \$1-peak-args bang; #X connect 0 0 2 0; #X connect 1 0 9 0; #X connect 2 0 9 0; @@ -201,27 +211,27 @@ #X connect 8 0 9 0; #X connect 9 0 11 0; #X connect 9 0 13 0; -#X connect 9 0 46 0; +#X connect 9 0 45 0; #X connect 10 0 9 1; #X connect 11 0 5 0; #X connect 12 0 8 0; #X connect 13 0 17 0; #X connect 14 0 15 0; #X connect 15 0 9 0; -#X connect 16 0 45 0; -#X connect 16 1 44 0; -#X connect 16 2 43 0; +#X connect 16 0 44 0; +#X connect 16 1 43 0; +#X connect 16 2 42 0; #X connect 17 0 31 0; #X connect 17 1 32 0; #X connect 17 2 33 0; #X connect 18 0 34 0; #X connect 18 1 36 0; #X connect 18 2 37 0; -#X connect 19 0 42 0; +#X connect 19 0 41 0; #X connect 20 0 21 0; #X connect 21 0 31 0; #X connect 21 0 34 0; -#X connect 21 0 45 0; +#X connect 21 0 44 0; #X connect 24 0 23 2; #X connect 24 0 40 0; #X connect 25 0 2 1; @@ -233,21 +243,21 @@ #X connect 35 0 4 0; #X connect 38 0 23 2; #X connect 39 0 24 0; -#X connect 42 0 41 0; -#X connect 47 0 23 0; -#X connect 47 0 23 1; +#X connect 41 0 47 0; +#X connect 46 0 23 0; +#X connect 46 0 23 1; #X restore 519 -226 pd guts; #X obj 11 -226 cnv 15 500 200 empty empty PDA_comparison 20 12 0 14 -261681 -66577 0; #X obj 34 -94 hsl 128 15 2 2.05 0 0 \$0-inharmonicity empty fm-inharmonicity --2 -6 0 8 -225271 -1 -1 0 1; +-2 -6 0 8 -225271 -1 -1 800 1; #X obj 34 -50 hsl 128 15 0 0.5 0 0 \$0-noisiness empty noisiness -2 -6 0 8 -225271 -1 -1 0 1; #X obj 33 -135 hsl 128 15 30 3000 0 0 \$0-fund empty f0 -2 -6 0 8 -225271 --1 -1 0 1; +-1 -1 300 1; #X obj 32 -172 tgl 15 0 \$0-sine empty sine 0 -6 0 8 -225280 -1 -1 0 1; -#X obj 73 -172 tgl 15 0 \$0-fm empty fm 0 -6 0 8 -225280 -1 -1 0 1 +#X obj 73 -172 tgl 15 0 \$0-fm empty fm 0 -6 0 8 -225280 -1 -1 1 1 ; #X obj 110 -172 tgl 15 0 \$0-saw empty saw 0 -6 0 8 -225280 -1 -1 0 1; @@ -260,7 +270,7 @@ #X symbolatom 245 -112 5 0 0 0 f0 #0-fidd_f0_note -; #X floatatom 313 -112 5 0 0 0 8ve #0-fidd_f0_8ve -; #X text 304 -200 Input; -#X text 308 -93 xtract~; +#X text 308 -84 xtract~; #X text 305 -134 fiddle~; #X floatatom 315 -62 5 0 0 0 8ve #0-pda_f0_8ve -; #X symbolatom 247 -62 5 0 0 0 f0 #0-pda_f0_note -; @@ -276,11 +286,6 @@ but with a larger block size it could go lower!; \, with centre and peak clipping used to provide noise robustness. This could be further improved \, as could the efficiency of the algorithm. ; -#X text 26 154 If [xtract~ f0] is unable to find a fundamental (i.e. -its output is 0 \, the lowest frequency in the peak spectrum is used. -In general this happens for very low frequencies. [xtract~ magnitude_spectrum] -\, [xtract~ peaks] \, and [xtract~ lowest_match] are used to achieve -this.; #X obj 147 -172 tgl 15 0 \$0-adc empty adc~ 0 -6 0 8 -257472 -1 -1 0 1; #X floatatom 386 -171 5 0 0 0 cent #0-f0_cent -; @@ -290,3 +295,8 @@ this.; out -4 -8 0 8 -262131 -1 -1 3898 1; #X obj 465 -77 bng 10 250 50 0 \$0-master-lvl-mute empty mute -6 16 0 8 -262131 -1 -1; +#X text 26 154 If [xtract~ f0] is unable to find a fundamental (i.e. +its output is 0 \, the lowest frequency in the peak spectrum is used. +In general this happens for very low frequencies. [xtract~ spectrum] +\, [xtract~ peak_spectrum] \, and [xtract~ lowest_value] are used to +achieve this.; diff --git a/examples/puredata/xtract/mfcc.pd b/examples/puredata/xtract/mfcc.pd index 7721a77..2310c7f 100644 --- a/examples/puredata/xtract/mfcc.pd +++ b/examples/puredata/xtract/mfcc.pd @@ -1,5 +1,5 @@ -#N canvas 667 28 576 568 10; -#N canvas 397 309 590 228 guts 0; +#N canvas 737 25 578 583 10; +#N canvas 116 214 598 221 guts 0; #X obj 318 37 loadbang; #X obj 318 64 f \$0; #N canvas 0 0 450 300 dacs 0; @@ -16,22 +16,6 @@ #X connect 5 0 0 0; #X connect 5 0 0 1; #X restore 85 126 pd dacs; -#N canvas 0 0 450 300 analysis 0; -#X obj 191 201 xtract~ mfcc; -#X obj 195 176 xtract~ magnitude_spectrum; -#X obj 194 153 *~; -#X obj 219 104 r \$0-window-gen; -#X obj 190 225 tabsend~ \$0-mfcc; -#X obj 181 69 inlet~; -#X obj 299 45 block~ 1024 2 1; -#X obj 219 125 a_hann 1024; -#X connect 0 0 4 0; -#X connect 1 0 0 0; -#X connect 2 0 1 0; -#X connect 3 0 7 0; -#X connect 5 0 2 0; -#X connect 7 0 2 1; -#X restore 32 167 pd analysis; #X obj 16 24 r \$0-fund; #X msg 318 88 \; pd dsp 1 \; \$1-master-lvl-stereo 60 \; \$1-window-gen bang \; \$1-mfcc xticks 0 5 5 \; \$1-mfcc yticks 0 50 1 \; \$1-mfcc @@ -130,50 +114,163 @@ xlabel -120 0 5 10 15 20; #X restore 35 80 pd paf; #X obj 85 25 r \$0-cf; #X obj 140 23 r \$0-bw; +#X obj 145 127 r \$0-window-gen; +#X obj 145 148 a_hann 1024; +#N canvas 34 54 723 391 spectrum 0; +#X obj 194 153 *~; +#X obj 181 69 inlet~; +#X obj 252 68 inlet~; +#X obj 195 176 xtract~ spectrum; +#N canvas 0 0 450 300 mag_spectrum 0; +#X obj 260 64 block~ 512; +#N canvas 0 0 450 300 (subpatch) 0; +#X array mag_spectrum 512 float 3; +#A 0 0.0347679 0.0238386 0.0342933 0.0362505 0.0295941 0.0500627 0.0356107 +0.0419818 0.0507073 0.0290984 0.0416723 0.0321575 0.0192698 0.0252058 +0.0116167 0.00836482 0.00784646 0.00138145 0.00132721 0.000381971 0.000573959 +0.000406984 0.000280216 0.000179901 0.000186049 0.000268997 0.000263714 +0.000155282 0.000139129 0.000167519 0.000124361 0.000180699 0.000142076 +0.000144225 0.000119736 0.000148186 0.000111046 0.000121504 0.000107089 +0.000121003 9.47739e-05 0.000125579 0.000100434 0.000104701 9.41711e-05 +0.000104671 8.29275e-05 9.69602e-05 8.842e-05 9.28634e-05 8.08756e-05 +9.55736e-05 7.85888e-05 8.25423e-05 7.83809e-05 8.18489e-05 7.07095e-05 +8.02309e-05 7.42804e-05 7.48963e-05 6.96933e-05 7.65881e-05 6.52446e-05 +6.90523e-05 6.72559e-05 6.77385e-05 6.22041e-05 6.80202e-05 6.33565e-05 +6.27514e-05 6.09007e-05 6.3778e-05 5.64576e-05 5.99506e-05 5.87628e-05 +5.80413e-05 5.54242e-05 5.86565e-05 5.49603e-05 5.42429e-05 5.4014e-05 +5.47262e-05 5.03136e-05 5.31452e-05 5.20179e-05 5.08749e-05 4.98008e-05 +5.13611e-05 4.85163e-05 4.80735e-05 4.85478e-05 4.80833e-05 4.56452e-05 +4.77271e-05 4.64662e-05 4.53934e-05 4.50956e-05 4.56013e-05 4.35624e-05 +4.34772e-05 4.40007e-05 4.30346e-05 4.18994e-05 4.31475e-05 4.18919e-05 +4.11025e-05 4.11284e-05 4.10175e-05 3.97421e-05 3.98145e-05 4.01797e-05 +3.90583e-05 3.87068e-05 3.92256e-05 3.81535e-05 3.76564e-05 3.77768e-05 +3.73499e-05 3.66974e-05 3.67557e-05 3.68833e-05 3.58508e-05 3.59041e-05 +3.58715e-05 3.51094e-05 3.48463e-05 3.49077e-05 3.43984e-05 3.41789e-05 +3.40861e-05 3.40455e-05 3.32054e-05 3.34367e-05 3.30168e-05 3.26526e-05 +3.24827e-05 3.24396e-05 3.19881e-05 3.19942e-05 3.17211e-05 3.16122e-05 +3.10021e-05 3.12408e-05 3.06344e-05 3.06429e-05 3.04321e-05 3.03029e-05 +2.99668e-05 3.00742e-05 2.95874e-05 2.95749e-05 2.91166e-05 2.92872e-05 +2.87315e-05 2.88123e-05 2.86934e-05 2.84017e-05 2.82494e-05 2.83481e-05 +2.76694e-05 2.7905e-05 2.74856e-05 2.7595e-05 2.70659e-05 2.73785e-05 +2.70175e-05 2.68042e-05 2.67559e-05 2.67275e-05 2.61115e-05 2.64444e-05 +2.60253e-05 2.6143e-05 2.56633e-05 2.59967e-05 2.55765e-05 2.54011e-05 +2.54205e-05 2.52767e-05 2.48309e-05 2.51035e-05 2.48111e-05 2.47337e-05 +2.44776e-05 2.47857e-05 2.41466e-05 2.42557e-05 2.41419e-05 2.40363e-05 +2.36974e-05 2.39439e-05 2.36521e-05 2.35678e-05 2.34062e-05 2.3597e-05 +2.29854e-05 2.32039e-05 2.30333e-05 2.29341e-05 2.27001e-05 2.29057e-05 +2.25917e-05 2.25413e-05 2.24169e-05 2.25144e-05 2.1993e-05 2.22539e-05 +2.20491e-05 2.19648e-05 2.18146e-05 2.19472e-05 2.16342e-05 2.16211e-05 +2.15227e-05 2.15229e-05 2.11552e-05 2.13981e-05 2.1145e-05 2.11307e-05 +2.10028e-05 2.10558e-05 2.07771e-05 2.08104e-05 2.06922e-05 2.06572e-05 +2.0421e-05 2.06044e-05 2.03378e-05 2.03852e-05 2.0236e-05 2.02428e-05 +2.00298e-05 2.00682e-05 1.99341e-05 1.99055e-05 1.9766e-05 1.98595e-05 +1.96149e-05 1.9708e-05 1.95175e-05 1.951e-05 1.93652e-05 1.93882e-05 +1.9253e-05 1.92475e-05 1.91492e-05 1.91725e-05 1.89653e-05 1.90797e-05 +1.88526e-05 1.88553e-05 1.87737e-05 1.87674e-05 1.86322e-05 1.86603e-05 +1.85738e-05 1.8523e-05 1.84042e-05 1.84821e-05 1.82465e-05 1.82856e-05 +1.82333e-05 1.81908e-05 1.80772e-05 1.81247e-05 1.80205e-05 1.79422e-05 +1.78919e-05 1.79356e-05 1.76952e-05 1.77907e-05 1.77256e-05 1.76545e-05 +1.75951e-05 1.76011e-05 1.75059e-05 1.74307e-05 1.74315e-05 1.73783e-05 +1.72885e-05 1.72999e-05 1.72644e-05 1.71807e-05 1.71397e-05 1.71261e-05 +1.70455e-05 1.6948e-05 1.70073e-05 1.6948e-05 1.6794e-05 1.69151e-05 +1.68262e-05 1.6732e-05 1.67057e-05 1.67527e-05 1.65599e-05 1.65856e-05 +1.65865e-05 1.65142e-05 1.64285e-05 1.65163e-05 1.63755e-05 1.63693e-05 +1.63267e-05 1.62936e-05 1.62273e-05 1.6209e-05 1.62148e-05 1.61265e-05 +1.61024e-05 1.61131e-05 1.60167e-05 1.60016e-05 1.59628e-05 1.59332e-05 +1.58903e-05 1.58553e-05 1.58772e-05 1.57569e-05 1.57924e-05 1.57572e-05 +1.56537e-05 1.56966e-05 1.56074e-05 1.56212e-05 1.55779e-05 1.5539e-05 +1.55494e-05 1.5449e-05 1.5495e-05 1.54081e-05 1.53711e-05 1.53932e-05 +1.52964e-05 1.53376e-05 1.52897e-05 1.52396e-05 1.52538e-05 1.51629e-05 +1.52182e-05 1.50957e-05 1.51177e-05 1.51097e-05 1.50368e-05 1.50477e-05 +1.50399e-05 1.49629e-05 1.49619e-05 1.4934e-05 1.49109e-05 1.48107e-05 +1.49298e-05 1.48269e-05 1.47474e-05 1.48734e-05 1.47248e-05 1.47904e-05 +1.46943e-05 1.47132e-05 1.46267e-05 1.47303e-05 1.44649e-05 1.46803e-05 +1.45807e-05 1.45165e-05 1.45321e-05 1.45863e-05 1.44389e-05 1.44883e-05 +1.45138e-05 1.43366e-05 1.45488e-05 1.42999e-05 1.43532e-05 1.43481e-05 +1.44012e-05 1.40856e-05 1.4473e-05 1.42298e-05 1.42492e-05 1.42315e-05 +1.43224e-05 1.40978e-05 1.42317e-05 1.41411e-05 1.41222e-05 1.41452e-05 +1.40687e-05 1.4097e-05 1.40772e-05 1.40533e-05 1.4062e-05 1.39999e-05 +1.40167e-05 1.39786e-05 1.39683e-05 1.39479e-05 1.39503e-05 1.39196e-05 +1.39185e-05 1.3891e-05 1.38968e-05 1.38385e-05 1.38591e-05 1.38226e-05 +1.3823e-05 1.37987e-05 1.38058e-05 1.37687e-05 1.37731e-05 1.37467e-05 +1.3741e-05 1.37012e-05 1.37238e-05 1.36772e-05 1.36989e-05 1.36648e-05 +1.36677e-05 1.36383e-05 1.36465e-05 1.36082e-05 1.36107e-05 1.35828e-05 +1.36001e-05 1.35517e-05 1.35862e-05 1.35436e-05 1.3545e-05 1.35258e-05 +1.35259e-05 1.34894e-05 1.35036e-05 1.34777e-05 1.34856e-05 1.34502e-05 +1.34863e-05 1.34282e-05 1.34469e-05 1.34125e-05 1.34237e-05 1.34026e-05 +1.33887e-05 1.34055e-05 1.33624e-05 1.33684e-05 1.34108e-05 1.32959e-05 +1.33875e-05 1.32811e-05 1.33619e-05 1.33219e-05 1.3276e-05 1.33497e-05 +1.32483e-05 1.33257e-05 1.3305e-05 1.32275e-05 1.33069e-05 1.32249e-05 +1.32866e-05 1.32339e-05 1.32487e-05 1.3251e-05 1.32172e-05 1.32353e-05 +1.323e-05 1.31875e-05 1.32223e-05 1.319e-05 1.32038e-05 1.31846e-05 +1.31983e-05 1.31761e-05 1.31802e-05 1.31635e-05 1.31737e-05 1.31439e-05 +1.31682e-05 1.31427e-05 1.31617e-05 1.31332e-05 1.31547e-05 1.3133e-05 +1.31335e-05 1.31252e-05 1.31203e-05 1.31178e-05 1.313e-05 1.31048e-05 +1.31309e-05 1.30961e-05 1.31287e-05 1.30943e-05 1.31076e-05 1.3093e-05 +1.30996e-05 1.30943e-05 1.3103e-05 1.30871e-05 1.31077e-05 1.30727e-05 +1.31072e-05 1.30737e-05 1.3094e-05 1.30748e-05 1.30877e-05 1.30874e-05 +1.30868e-05 1.30789e-05 1.30949e-05 1.30709e-05 1.30856e-05; +#X coords 0 1 511 0 200 140 1; +#X restore 125 121 graph; +#X restore 358 92 pd mag_spectrum; +#X obj 195 211 tabsend~ mag_spectrum; +#X obj 357 64 block~ 1024; +#X obj 197 301 xtract~ mfcc; +#X obj 196 274 tabreceive~ mag_spectrum; +#X obj 197 333 tabsend~ \$0-mfcc; +#X connect 0 0 3 0; +#X connect 1 0 0 0; +#X connect 2 0 0 1; +#X connect 3 0 5 0; +#X connect 7 0 9 0; +#X connect 8 0 7 0; +#X restore 32 167 pd spectrum; #X connect 0 0 1 0; -#X connect 1 0 5 0; -#X connect 4 0 6 0; -#X connect 6 0 2 0; -#X connect 6 0 3 0; -#X connect 7 0 6 1; -#X connect 8 0 6 2; +#X connect 1 0 4 0; +#X connect 3 0 5 0; +#X connect 5 0 2 0; +#X connect 5 0 10 0; +#X connect 6 0 5 1; +#X connect 7 0 5 2; +#X connect 8 0 9 0; +#X connect 9 0 10 1; #X restore 516 -222 pd guts; #X obj 6 -225 cnv 15 500 200 empty empty MFCC 20 12 0 14 -261681 -66577 0; #X obj 184 -202 cnv 15 250 150 empty empty empty 20 12 0 14 -262131 -66577 0; #X obj 465 -187 vsl 10 100 0 127 0 0 \$0-master-lvl-stereo \$0-master-lvl-stereo -out -4 -8 0 8 -262131 -1 -1 6100 1; +out -4 -8 0 8 -262131 -1 -1 0 1; #X obj 465 -77 bng 10 250 50 0 \$0-master-lvl-mute empty mute -6 16 0 8 -262131 -1 -1; #X obj 32 -114 hsl 128 15 20 150 0 0 \$0-cf empty centre_frequency --2 -6 0 8 -225271 -1 -1 1000 1; +-2 -6 0 8 -225271 -1 -1 700 1; #X obj 33 -153 hsl 128 15 80 2000 0 0 \$0-fund empty fundamental -2 --6 0 8 -225271 -1 -1 400 1; +-6 0 8 -225271 -1 -1 200 1; #X text 19 7 Notes:; -#X text 20 36 In this patch [xtract~ magnitude_spectrum] is first used -to extract the magnitude spectrum from an audio signal in overlapping -blocks of 1024 samples.; #X text 20 87 [xtract~ mfcc] outputs a series 20 Mel-Frequency Cepstral Coefficients. When it is instantiated \, an initialisation function creates a bank of 20 mel-spaced filters \, between 80Hz and 1800Hz on a linear scale. All filters have the same gain; -#X text 23 165 Whilst DSP is running the input vector (magnitude spectrum) -is filtered by this filterbank \, and the total energy output from -each filter is appended to a new vector. This new vector (mel-filtered -spectrum) is then subjected to a fast cosine transfor. The output can -be visualised in the graph labelled \$0-mfcc.; #X text 23 255 With LibXtract it is possible to change the number of Mel filters as well as the range of frequencies over which they operate \, and the filter scaling (equal area/equal gain). With this PD example \, sensible defaults have been chosen to improve usability; -#N canvas 0 0 450 300 graph2 0; -#X array \$0-mfcc 20 float 5; -#A 0 -241.398 87.462 -6.0369 -7.30858 -8.26749 0.337816 1.44736 0.73507 --2.33864 -1.38718 -0.545284 -0.269468 -0.985905 -0.89323 -1.33766 -1.09721 --0.614915 -0.242816 -0.894777 -1.20686; -#X coords 0 50 19 -100 200 100 1; +#N canvas 0 0 450 300 (subpatch) 0; +#X array \$0-mfcc 20 float 1; +#A 0 -226.816 39.0179 27.0649 13.3895 3.18296 -4.35309 -6.98078 -6.73432 +-4.09373 -1.24401 0.693745 0.961352 0.393719 -0.854615 -1.49734 -1.75847 +-1.32051 -0.652124 0.00802549 0.234184; +#X coords 0 50 19 -500 200 100 1; #X restore 212 -178 graph; #X text 28 -188 PAF synthesiser; #X obj 34 -71 hsl 128 15 1 10 0 0 \$0-bw empty formant_bandwidth -2 --6 0 8 -225271 -1 -1 4400 1; +-6 0 8 -225271 -1 -1 600 1; +#X text 20 36 In this patch [xtract~ spectrum] is first used to extract +the magnitude spectrum from an audio signal in overlapping blocks of +1024 samples.; +#X text 23 165 Whilst DSP is running the input vector (magnitude spectrum) +is filtered by this filterbank \, and the total energy output from +each filter is appended to a new vector. This new vector (mel-filtered +spectrum) is then subjected to a fast cosine transform. The output +can be visualised in the graph labelled \$0-mfcc.; diff --git a/examples/puredata/xtract/xtract-help.pd b/examples/puredata/xtract/xtract-help.pd index da96a07..6a7435b 100644 --- a/examples/puredata/xtract/xtract-help.pd +++ b/examples/puredata/xtract/xtract-help.pd @@ -15,9 +15,6 @@ may be obtained by sending the external a |help( message:; #X text 26 298 Other than this help message \, the data sent to the left inlet should always be a 'signal' (i.e. audio rate). This is the data from a which a given feature will be extracted.; -#X text 27 405 Any additional arguments that need to be passed to the -feature extraction funtion must be provided as a list to the right -inlet \, e.g.; #X obj 182 490 xtract~ mean; #X floatatom 132 586 10 0 0 0 - - -; #X floatatom 253 523 5 0 0 0 - - -; @@ -30,10 +27,13 @@ inlet \, e.g.; extracted.; #X obj 42 665 f0; #X obj 83 665 mfcc; +#X text 27 405 Any additional arguments that need to be passed to the +feature extraction function must be provided as a list to the right +inlet \, e.g.; #X connect 5 0 4 0; -#X connect 8 0 10 0; -#X connect 8 0 11 0; -#X connect 11 0 12 1; -#X connect 12 0 9 0; -#X connect 13 0 8 0; -#X connect 13 0 12 0; +#X connect 7 0 9 0; +#X connect 7 0 10 0; +#X connect 10 0 11 1; +#X connect 11 0 8 0; +#X connect 12 0 7 0; +#X connect 12 0 11 0; diff --git a/examples/puredata/xtract~.c b/examples/puredata/xtract~.c index a769bdc..26d349b 100644 --- a/examples/puredata/xtract~.c +++ b/examples/puredata/xtract~.c @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "xtract/libxtract.h" -#define BLOCKSIZE 1024 +#define BLOCKSIZE 1024 /* FIX: this should be dynamic - somehow */ #define NYQUIST 22050.0f static t_class *xtract_class; @@ -70,15 +70,18 @@ static t_int *xtract_perform_vector(t_int *w) { t_int N = (t_int)(w[4]), n; t_int return_code = 0; + n = N; + tmp_in = copybytes(in, N * sizeof(t_float)); tmp_out = getbytes(N * sizeof(t_float)); + + if(x->feature == XTRACT_PEAK_SPECTRUM) + N >>= 1; return_code = xtract[x->feature](tmp_in, N, x->argv, tmp_out); if(return_code == XTRACT_FEATURE_NOT_IMPLEMENTED) pd_error(x, "Feature not implemented"); - - n = N; while(n--) out[n] = tmp_out[n]; @@ -107,7 +110,7 @@ static void *xtract_new(t_symbol *me, t_int argc, t_atom *argv) { t_float *argv_max; xtract_function_descriptor_t *fd; char *p_name, *p_desc, *author; - int *year; + int year; p_name = p_desc = author = NULL; @@ -162,7 +165,7 @@ static void *xtract_new(t_symbol *me, t_int argc, t_atom *argv) { p_name = fd[f].algo.p_name; p_desc = fd[f].algo.p_desc; author = fd[f].algo.author; - year = &fd[f].algo.year; + year = fd[f].algo.year; if(argc){ if(strcmp(p_name, "")) @@ -170,7 +173,7 @@ static void *xtract_new(t_symbol *me, t_int argc, t_atom *argv) { if(strcmp(p_desc, "")) post("xtract~: %s", p_desc ); if(strcmp(author, "") && year) - post("xtract~: %s(%d)", author, *year); + post("xtract~: %s(%d)", author, year); } else post("xtract~: No arguments given"); @@ -190,18 +193,21 @@ static void *xtract_new(t_symbol *me, t_int argc, t_atom *argv) { for(n = 0; n < mf->n_filters; n++) mf->filters[n] = (float *)getbytes(N * sizeof(float)); - xtract_init_mfcc(N, NYQUIST, XTRACT_EQUAL_GAIN, 18000.0f, - 80.0f, mf->n_filters, mf->filters); + xtract_init_mfcc(N, NYQUIST, XTRACT_EQUAL_GAIN, 80.0f, + 18000.0f, mf->n_filters, mf->filters); } else if(x->feature == XTRACT_BARK_COEFFICIENTS) xtract_init_bark(N, NYQUIST, x->argv); - if(x->feature == XTRACT_AUTOCORRELATION || x->feature == XTRACT_AUTOCORRELATION_FFT || - x->feature == XTRACT_MFCC || x->feature == XTRACT_AMDF || x->feature == XTRACT_ASDF|| - x->feature == XTRACT_DCT || x->feature == XTRACT_BARK_COEFFICIENTS || - x->feature == XTRACT_SPECTRUM || x->feature == XTRACT_PEAK_SPECTRUM || - x->feature == XTRACT_HARMONIC_SPECTRUM) - x->feature_type = XTRACT_VECTOR; + if(x->feature == XTRACT_AUTOCORRELATION || + x->feature == XTRACT_AUTOCORRELATION_FFT || + x->feature == XTRACT_MFCC || x->feature == XTRACT_AMDF || + x->feature == XTRACT_ASDF|| x->feature == XTRACT_DCT || + x->feature == XTRACT_BARK_COEFFICIENTS || + x->feature == XTRACT_SPECTRUM || + x->feature == XTRACT_PEAK_SPECTRUM || + x->feature == XTRACT_HARMONIC_SPECTRUM) + x->feature_type = XTRACT_VECTOR; else if (x->feature == XTRACT_FLUX || x->feature == XTRACT_ATTACK_TIME || x->feature == XTRACT_DECAY_TIME || x->feature == XTRACT_DELTA) @@ -244,12 +250,17 @@ static void xtract_tilde_show_help(t_xtract_tilde *x, t_symbol *s){ int i; i = XTRACT_FEATURES; + xtract_function_descriptor_t *fd, *d; - post("\n\txtract~: Feature List\n"); - /* + fd = (xtract_function_descriptor_t *)xtract_make_descriptors(); + post("\nxtract~: Feature List\n"); + while(i--){ - post("\t%s", xtract_help_strings[i]+7); - }*/ + d = &fd[i]; + post("\t%s", d->algo.name); + } + + xtract_free_descriptors(fd); } static void xtract_tilde_free(t_xtract_tilde *x) { |