aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJamie Bullock <jamie@postlude.co.uk>2007-09-03 14:31:58 +0000
committerJamie Bullock <jamie@postlude.co.uk>2007-09-03 14:31:58 +0000
commitf8eed0713059b5c4e8e56ba98b8a33fe2a472d84 (patch)
tree3d77ea00cb55394fce82811fad29aaa258bdf776 /examples
parentff80e419ed5ce6291eefa90dc01b22939d15b0d0 (diff)
downloadLibXtract-f8eed0713059b5c4e8e56ba98b8a33fe2a472d84.tar.gz
LibXtract-f8eed0713059b5c4e8e56ba98b8a33fe2a472d84.tar.bz2
LibXtract-f8eed0713059b5c4e8e56ba98b8a33fe2a472d84.zip
Checked ANSI C89 compliance (basically a few ifndefs for the C99 math functions: powf, roundf etc). Added a few PD examples/tests.
Diffstat (limited to 'examples')
-rw-r--r--examples/puredata/harmonic_spectrum.pd108
-rw-r--r--examples/puredata/regression-test.pd84
-rw-r--r--examples/puredata/simple-example.pd8
-rw-r--r--examples/puredata/xtract~.c14
4 files changed, 212 insertions, 2 deletions
diff --git a/examples/puredata/harmonic_spectrum.pd b/examples/puredata/harmonic_spectrum.pd
new file mode 100644
index 0000000..9522217
--- /dev/null
+++ b/examples/puredata/harmonic_spectrum.pd
@@ -0,0 +1,108 @@
+#N canvas 621 238 587 354 10;
+#X obj 82 127 xtract~ spectrum;
+#N canvas 6 48 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.0212162 0.0317487 0.0195466 0.00561563 0.0177077 0.0476304 0.0567499
+0.0474959 0.0970338 0.464764 0.096619 0.0562304 0.0238859 0.0221252
+0.0281975 0.0124481 0.0234213 0.0308018 0.0182565 0.0118857 0.0086735
+0.0188852 0.0119291 0.0237176 0.00864544 0.00273517 0.0113407 0.0100331
+0.0382518 0.0213396 0.0296342 0.034342 0.0171451 0.00243189 0.0301973
+0.00739387 0.0278942 0.0198999 0.0173251 0.0225384 0.0042204 0.0186626
+0.0191895 0.0116634 0.00931694 0.00501582 0.012182 0.0301927 0.0167377
+0.0194199 0.0254657 0.0208484 0.0438904 0.030928 0.0123733 0.0220734
+0.0199979 0.028819 0.00481497 0.0136932 0.00975227 0.0256796 0.0157346
+0.040834 0.0247319 0.0333543 0.00981976 0.00128905 0.0108467 0.00859555
+0.00120924 0.0198812 0.00942567 0.0179 0.021585 0.0144289 0.0138407
+0.0259725 0.0088767 0.0189066 0.0241189 0.0123437 0.0110563 0.0110612
+0.0135812 0.0295776 0.00935764 0.00530153 0.0136921 0.00645618 0.00677527
+0.018981 0.00559285 0.0423402 0.012537 0.0196257 0.0107362 0.0244728
+0.0169689 0.00800423 0.0106661 0.00580486 0.00123392 0.0318564 0.00313052
+0.00918496 0.0148799 0.0215053 0.0103284 0.0101435 0.0159162 0.0265488
+0.0149968 0.0144774 0.0127121 0.0210075 0.0136251 0.0246422 0.0150687
+0.0125131 0.0238336 0.0144661 0.00459801 0.0176529 0.0196158 0.00860441
+0.02399 0.0125216 0.0132359 0.0217819 0.0122651 0.0233058 0.00750471
+0.0162637 0.00563749 0.0107775 0.021111 0.0161979 0.00453912 0.0148774
+0.000913515 0.0250208 0.0255661 0.0349255 0.0140773 0.0264259 0.00978363
+0.0128433 0.017953 0.0123747 0.000980419 0.0202137 0.0111122 0.0122572
+0.0150218 0.0198538 0.00786684 0.0152549 0.00976639 0.00464054 0.0141998
+0.00772205 0.016834 0.0153422 0.00997133 0.00674112 0.0190689 0.0255067
+0.0107735 0.0116028 0.0145695 0.0243072 0.0254179 0.00474025 0.00489552
+0.0260339 0.025168 0.0067304 0.0217401 0.00904745 0.0146951 0.0182503
+0.0392981 0.00691688 0.00454291 0.0212321 0.00856008 0.00406878 0.0208133
+0.0184339 0.0295088 0.0299841 0.0114197 0.00718674 0.00452769 0.0230214
+0.00951422 0.0362591 0.011827 0.0228309 0.0272509 0.0168917 0.0301141
+0.0192356 0.0161379 0.0236251 0.0141769 0.0320988 0.0151104 0.0143148
+0.0313421 0.0272517 0.0313192 0.0226451 0.0218267 0.0183534 0.00742306
+0.0236084 0.0220338 0.00740086 0.0283414 0.0325231 0.0465779 0.027643
+0.0240922 0.0164632 0.0113228 0.0164433 0.0194295 0.0161885 0.0152107
+0.0173802 0.024051 0.0108911 0.0118482 0.0144843 0.0158265 0.0159634
+0.0105952 0.0106542 0.0124575 0.0159426 0.0126567 0.00726532 0.0130271
+0.011397 0.00576796 0.0219027 0.0120067 0.0112131 0.0217665 0.028283
+0.00556188 0.0172272 0.0156255 0.00790093 0.00810658 0.0129488 0.0178136
+0.0131554 0.0221222 0.00680469 0.0248362 0.019694 0.00703206 0.0339999
+0.0136595 0.00676699 0.0151537 0.0263812 0.0226784 0.00493732 0.0295971
+0.0212905 0.0360165 0.0220007 0.0306554 0.0132068 0.0143121 0.0110527
+0.00200652 0.0119865 0.029585 0.0195924 0.00423938 0.0292942 0.0235783
+0.0149287 0.0091102 0.0132163 0.00536295 0.0112099 0.0160713 0.0266621
+0.0049689 0.0151439 0.0168654 0.0132658 0.0118611 0.0180696 0.0176023
+0.00712655 0.0239444 0.00829241 0.016034 0.00839455 0.0132304 0.0193391
+0.00969501 0.0108692 0.01659 0.026616 0.029016 0.00760763 0.00869712
+0.013781 0.0124679 0.0153336 0.0169436 0.0151282 0.00582287 0.0252088
+0.010132 0.0144077 0.0172376 0.0138607 0.0192887 0.0162585 0.0250082
+0.0124786 0.0213438 0.0185502 0.00461736 0.0107252 0.0246183 0.0199021
+0.0213024 0.0325369 0.0128834 0.0297772 0.0139391 0.0290136 0.00977331
+0.0293352 0.0223587 0.00683776 0.00774782 0.00868099 0.0177819 0.0501341
+0.0168349 0.0122174 0.0045685 0.00933541 0.0153631 0.0120776 0.0136674
+0.0110695 0.00526424 0.0223792 0.0189218 0.0324813 0.0175627 0.0103907
+0.00722242 0.0192809 0.0222755 0.0144299 0.0189361 0.00997853 0.0065123
+0.0109085 0.00674032 0.0146737 0.0185307 0.0158343 0.0202681 0.00576984
+0.0147357 0.0204028 0.00339465 0.020232 0.00719163 0.0106671 0.0111035
+0.0214937 0.0121637 0.0168017 0.00981358 0.0179859 0.0189836 0.00543421
+0.0183689 0.0268019 0.0143586 0.0221351 0.00688864 0.0237894 0.0253554
+0.02866 0.00769269 0.015072 0.00734027 0.020403 0.0248997 0.0108569
+0.0154023 0.00941389 0.0291191 0.00872522 0.0223672 0.00639403 0.021712
+0.0246656 0.00448177 0.0050129 0.0137407 0.0122352 0.0130276 0.0181434
+0.0239518 0.0052326 0.0193361 0.0226996 0.0202401 0.0208808 0.030179
+0.00866272 0.0413012 0.0268073 0.0105023 0.0168644 0.00408668 0.00292807
+0.0134017 0.0205693 0.0173767 0.0117562 0.00719525 0.00927211 0.027002
+0.0271098 0.0216011 0.00717236 0.0138263 0.00271252 0.0143244 0.00397278
+0.0219117 0.0104727 0.0199572 0.0140881 0.00060853 0.0142593 0.0227859
+0.0109915 0.0209464 0.0273022 0.0140469 0.0104995 0.00597412 0.00458115
+0.0301041 0.00698568 0.0164327 0.0147746 0.0181867 0.0160428 0.00350695
+0.0073609 0.016644 0.0147995 0.014512 0.0058076 0.0198532 0.0114418
+0.0141326 0.0116806 0.0179014 0.0186733 0.0171869 0.0219169 0.0151714
+0.00699651 0.023865 0.0292064 0.00678898 0.0329386 0.0143645 0.0170765
+0.0206896 0.0111348 0.0100621 0.0115056 0.015144 0.00661284 0.00584966
+0.0215877 0.0121954 0.0291166 0.0302916 0.0354529 0.0102541 0.00448918
+0.0112287 0.0154816 0.00960475 0.035809 0.0276429 0.0209137 0.0209784
+300.821;
+#X coords 0 1 511 0 200 140 1;
+#X restore 125 121 graph;
+#X restore 245 43 pd mag_spectrum;
+#X obj 82 162 tabsend~ mag_spectrum;
+#X obj 244 15 block~ 1024;
+#X obj 278 253 xtract~ peak_spectrum;
+#X obj 255 277 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
+-1 -1;
+#X obj 279 224 tabreceive~ mag_spectrum;
+#X msg 453 223 list \$1;
+#X obj 453 178 samplerate~;
+#X obj 58 71 noise~;
+#X obj 113 70 osc~ 440;
+#X obj 453 198 / 1024;
+#X obj 278 277 xtract~ harmonic_spectrum;
+#X obj 278 307 print~;
+#X obj 453 151 loadbang;
+#X connect 0 0 2 0;
+#X connect 4 0 12 0;
+#X connect 5 0 13 0;
+#X connect 6 0 4 0;
+#X connect 7 0 4 1;
+#X connect 8 0 11 0;
+#X connect 9 0 0 0;
+#X connect 10 0 0 0;
+#X connect 11 0 7 0;
+#X connect 12 0 13 0;
+#X connect 14 0 8 0;
diff --git a/examples/puredata/regression-test.pd b/examples/puredata/regression-test.pd
new file mode 100644
index 0000000..c269ca0
--- /dev/null
+++ b/examples/puredata/regression-test.pd
@@ -0,0 +1,84 @@
+#N canvas 534 223 894 462 10;
+#X obj 168 31 noise~;
+#X obj 168 61 xtract~ spectrum;
+#X obj 72 106 xtract~ irregularity_j;
+#X obj 95 142 xtract~ irregularity_k;
+#X obj 112 206 xtract~ tristimulus_1;
+#X obj 145 269 xtract~ tristimulus_2;
+#X obj 166 327 xtract~ tristimulus_3;
+#X obj 315 87 xtract~ spectral_mean;
+#X obj 311 140 xtract~ spectral_variance;
+#X obj 326 194 xtract~ spectral_standard_deviation;
+#X obj 375 245 xtract~ spectral_kurtosis;
+#X floatatom 378 281 5 0 0 0 - - -;
+#X floatatom 88 252 5 0 0 0 - - -;
+#X floatatom 116 317 5 0 0 0 - - -;
+#X floatatom 156 376 5 0 0 0 - - -;
+#X floatatom 57 197 5 0 0 0 - - -;
+#X floatatom 107 179 5 0 0 0 - - -;
+#X floatatom 666 292 5 0 0 0 - - -;
+#X obj 603 98 xtract~ mean;
+#X obj 599 151 xtract~ variance;
+#X obj 614 205 xtract~ standard_deviation;
+#X obj 663 256 xtract~ kurtosis;
+#X obj 430 365 xtract~ smoothness;
+#X floatatom 436 400 5 0 0 0 - - -;
+#X msg 696 129 list \$1;
+#X msg 762 172 list \$1;
+#X msg 728 230 list \$1;
+#X msg 505 214 list \$1;
+#X msg 375 168 list \$1;
+#X msg 465 116 list \$1;
+#X obj 611 406 xtract~ loudness;
+#X floatatom 612 430 5 0 0 0 - - -;
+#X obj 649 360 xtract~ inharmonicity;
+#X floatatom 658 385 5 0 0 0 - - -;
+#X floatatom 750 327 5 0 0 0 - - -;
+#X obj 195 404 xtract~ autocorrelation;
+#X obj 257 445 xtract~ bark_coefficients;
+#X obj 49 437 xtract~ peak_spectrum;
+#X obj 486 438 xtract~ mfcc;
+#X obj 28 24 block~ 512;
+#X connect 0 0 1 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 1 0 2 0;
+#X connect 1 0 3 0;
+#X connect 1 0 4 0;
+#X connect 1 0 7 0;
+#X connect 1 0 8 0;
+#X connect 1 0 9 0;
+#X connect 1 0 10 0;
+#X connect 1 0 5 0;
+#X connect 1 0 6 0;
+#X connect 1 0 22 0;
+#X connect 1 0 30 0;
+#X connect 1 0 32 0;
+#X connect 1 0 35 0;
+#X connect 1 0 36 0;
+#X connect 1 0 37 0;
+#X connect 1 0 38 0;
+#X connect 2 0 15 0;
+#X connect 3 0 16 0;
+#X connect 4 0 12 0;
+#X connect 5 0 13 0;
+#X connect 6 0 14 0;
+#X connect 7 0 29 0;
+#X connect 8 0 28 0;
+#X connect 9 0 27 0;
+#X connect 10 0 11 0;
+#X connect 18 0 24 0;
+#X connect 19 0 25 0;
+#X connect 20 0 26 0;
+#X connect 21 0 17 0;
+#X connect 22 0 23 0;
+#X connect 24 0 19 1;
+#X connect 25 0 20 1;
+#X connect 26 0 21 1;
+#X connect 27 0 10 1;
+#X connect 28 0 9 1;
+#X connect 29 0 8 1;
+#X connect 30 0 31 0;
+#X connect 32 0 33 0;
diff --git a/examples/puredata/simple-example.pd b/examples/puredata/simple-example.pd
new file mode 100644
index 0000000..510fb2f
--- /dev/null
+++ b/examples/puredata/simple-example.pd
@@ -0,0 +1,8 @@
+#N canvas 0 0 450 300 10;
+#X obj 144 80 xtract~ spectrum;
+#X obj 154 26 osc~ 440;
+#X obj 145 129 xtract~ spectral_mean;
+#X floatatom 146 184 5 0 0 0 - - -;
+#X connect 0 0 2 0;
+#X connect 1 0 0 0;
+#X connect 2 0 3 0;
diff --git a/examples/puredata/xtract~.c b/examples/puredata/xtract~.c
index 26d349b..3f07cd3 100644
--- a/examples/puredata/xtract~.c
+++ b/examples/puredata/xtract~.c
@@ -27,6 +27,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define BLOCKSIZE 1024 /* FIX: this should be dynamic - somehow */
#define NYQUIST 22050.0f
+#ifndef isnan
+ /* FIX: should probably try to handle signalling NaNs */
+ int isnan(x){ if(x == x) return 0; else return 1;}
+#endif
+
+#ifndef isinf
+ int isinf(x) {if(x == 1.0 / 0. || x == -1.0 / 0.) return 1; else return 0;}
+#endif
+
static t_class *xtract_class;
/* Struct for keeping track of memory allocations */
@@ -143,7 +152,7 @@ static void *xtract_new(t_symbol *me, t_int argc, t_atom *argv) {
if(n_args){
for(n = 0; n < n_args; n++){
argv_max = &fd[f].argv.max[n];
- //post("Argument %d, max: %.2f", n, *argv_max);
+ /*post("Argument %d, max: %.2f", n, *argv_max); */
}
if(type == XTRACT_MEL_FILTER){
x->memory.argv = (size_t)(n_args * sizeof(xtract_mel_filter));
@@ -249,9 +258,10 @@ static void xtract_tilde_show_help(t_xtract_tilde *x, t_symbol *s){
int i;
- i = XTRACT_FEATURES;
xtract_function_descriptor_t *fd, *d;
+ i = XTRACT_FEATURES;
+
fd = (xtract_function_descriptor_t *)xtract_make_descriptors();
post("\nxtract~: Feature List\n");