From da1f0065d07250b86b9a761b012987e4825f491f Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 28 Nov 2005 16:53:25 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r4068, which included commits to RCS files with non-trunk default branches. svn path=/trunk/externals/smlib/; revision=4069 --- examples/beattracker.pd | 123 +++++++++++++++++++++ examples/normalizer.pd | 94 ++++++++++++++++ examples/resonate-beat.pd | 239 ++++++++++++++++++++++++++++++++++++++++ help/SMLib-help.pd | 103 +++++++++++++++++ help/bp-help.pd | 35 ++++++ help/deltas-help.pd | 34 ++++++ help/hip-help.pd | 32 ++++++ help/hist-help.pd | 44 ++++++++ help/itov-help.pd | 44 ++++++++ help/lavg-help.pd | 22 ++++ help/lhist-help.pd | 40 +++++++ help/lhisti-help.pd | 41 +++++++ help/linspace-help.pd | 20 ++++ help/lmax-help.pd | 22 ++++ help/lmin-help.pd | 22 ++++ help/lrange-help.pd | 22 ++++ help/prevl-help.pd | 34 ++++++ help/threshold-help.pd | 50 +++++++++ help/vabs-help.pd | 6 + help/vclip-help.pd | 17 +++ help/vcog-help.pd | 21 ++++ help/vdbtorms-help.pd | 9 ++ help/vdelta-help.pd | 29 +++++ help/vfmod-help.pd | 17 +++ help/vftom-help.pd | 9 ++ help/vlavg-help.pd | 29 +++++ help/vlmax-help.pd | 29 +++++ help/vlmin-help.pd | 29 +++++ help/vmax-help.pd | 21 ++++ help/vmin-help.pd | 21 ++++ help/vmtof-help.pd | 9 ++ help/vpow-help.pd | 15 +++ help/vrms-help.pd | 15 +++ help/vrmstodb-help.pd | 9 ++ help/vstd-help.pd | 15 +++ help/vsum-help.pd | 13 +++ help/vv+-help.pd | 25 +++++ help/vv--help.pd | 23 ++++ help/vvconv-help.pd | 35 ++++++ readme.txt | 127 +++++++++++++++++++++ source/SMLib.c | 230 ++++++++++++++++++++++++++++++++++++++ source/SMLib.dsp | 275 ++++++++++++++++++++++++++++++++++++++++++++++ source/SMLib.dsw | 29 +++++ source/SMLib.opt | Bin 0 -> 48640 bytes source/SMLib.plg | 153 ++++++++++++++++++++++++++ source/bp.c | 123 +++++++++++++++++++++ source/decimator.c | 66 +++++++++++ source/defines.h | 18 +++ source/deltas.c | 181 ++++++++++++++++++++++++++++++ source/hip.c | 77 +++++++++++++ source/hist.c | 155 ++++++++++++++++++++++++++ source/itov.c | 86 +++++++++++++++ source/lavg.c | 55 ++++++++++ source/lhist.c | 174 +++++++++++++++++++++++++++++ source/lhisti.c | 174 +++++++++++++++++++++++++++++ source/linspace.c | 74 +++++++++++++ source/lmax.c | 57 ++++++++++ source/lmin.c | 57 ++++++++++ source/lrange.c | 60 ++++++++++ source/lstd.c | 60 ++++++++++ source/prevl.c | 161 +++++++++++++++++++++++++++ source/threshold.c | 112 +++++++++++++++++++ source/vabs.c | 48 ++++++++ source/vclip.c | 58 ++++++++++ source/vcog.c | 43 ++++++++ source/vdbtorms.c | 56 ++++++++++ source/vdelta.c | 75 +++++++++++++ source/vfmod.c | 57 ++++++++++ source/vftom.c | 49 +++++++++ source/vlavg.c | 86 +++++++++++++++ source/vlmax.c | 86 +++++++++++++++ source/vlmin.c | 86 +++++++++++++++ source/vlrange.c | 99 +++++++++++++++++ source/vmax.c | 52 +++++++++ source/vmin.c | 52 +++++++++ source/vmtof.c | 51 +++++++++ source/vnmax.c | 55 ++++++++++ source/vpow.c | 60 ++++++++++ source/vrms.c | 41 +++++++ source/vrmstodb.c | 54 +++++++++ source/vstd.c | 45 ++++++++ source/vsum.c | 40 +++++++ source/vthreshold.c | 106 ++++++++++++++++++ source/vvconv.c | 151 +++++++++++++++++++++++++ source/vvminus.c | 141 ++++++++++++++++++++++++ source/vvplus.c | 141 ++++++++++++++++++++++++ 86 files changed, 5653 insertions(+) create mode 100644 examples/beattracker.pd create mode 100644 examples/normalizer.pd create mode 100644 examples/resonate-beat.pd create mode 100644 help/SMLib-help.pd create mode 100644 help/bp-help.pd create mode 100644 help/deltas-help.pd create mode 100644 help/hip-help.pd create mode 100644 help/hist-help.pd create mode 100644 help/itov-help.pd create mode 100644 help/lavg-help.pd create mode 100644 help/lhist-help.pd create mode 100644 help/lhisti-help.pd create mode 100644 help/linspace-help.pd create mode 100644 help/lmax-help.pd create mode 100644 help/lmin-help.pd create mode 100644 help/lrange-help.pd create mode 100644 help/prevl-help.pd create mode 100644 help/threshold-help.pd create mode 100644 help/vabs-help.pd create mode 100644 help/vclip-help.pd create mode 100644 help/vcog-help.pd create mode 100644 help/vdbtorms-help.pd create mode 100644 help/vdelta-help.pd create mode 100644 help/vfmod-help.pd create mode 100644 help/vftom-help.pd create mode 100644 help/vlavg-help.pd create mode 100644 help/vlmax-help.pd create mode 100644 help/vlmin-help.pd create mode 100644 help/vmax-help.pd create mode 100644 help/vmin-help.pd create mode 100644 help/vmtof-help.pd create mode 100644 help/vpow-help.pd create mode 100644 help/vrms-help.pd create mode 100644 help/vrmstodb-help.pd create mode 100644 help/vstd-help.pd create mode 100644 help/vsum-help.pd create mode 100644 help/vv+-help.pd create mode 100644 help/vv--help.pd create mode 100644 help/vvconv-help.pd create mode 100644 readme.txt create mode 100644 source/SMLib.c create mode 100755 source/SMLib.dsp create mode 100755 source/SMLib.dsw create mode 100755 source/SMLib.opt create mode 100755 source/SMLib.plg create mode 100644 source/bp.c create mode 100644 source/decimator.c create mode 100644 source/defines.h create mode 100644 source/deltas.c create mode 100644 source/hip.c create mode 100644 source/hist.c create mode 100644 source/itov.c create mode 100644 source/lavg.c create mode 100644 source/lhist.c create mode 100644 source/lhisti.c create mode 100644 source/linspace.c create mode 100644 source/lmax.c create mode 100644 source/lmin.c create mode 100644 source/lrange.c create mode 100644 source/lstd.c create mode 100644 source/prevl.c create mode 100644 source/threshold.c create mode 100644 source/vabs.c create mode 100644 source/vclip.c create mode 100644 source/vcog.c create mode 100644 source/vdbtorms.c create mode 100644 source/vdelta.c create mode 100644 source/vfmod.c create mode 100644 source/vftom.c create mode 100644 source/vlavg.c create mode 100644 source/vlmax.c create mode 100644 source/vlmin.c create mode 100644 source/vlrange.c create mode 100644 source/vmax.c create mode 100644 source/vmin.c create mode 100644 source/vmtof.c create mode 100644 source/vnmax.c create mode 100644 source/vpow.c create mode 100644 source/vrms.c create mode 100644 source/vrmstodb.c create mode 100644 source/vstd.c create mode 100644 source/vsum.c create mode 100644 source/vthreshold.c create mode 100644 source/vvconv.c create mode 100644 source/vvminus.c create mode 100644 source/vvplus.c diff --git a/examples/beattracker.pd b/examples/beattracker.pd new file mode 100644 index 0000000..44c4749 --- /dev/null +++ b/examples/beattracker.pd @@ -0,0 +1,123 @@ +#N canvas 145 39 541 656 12; +#X obj 28 22 adc~; +#X obj 20 330 vmin; +#X floatatom 69 348 5 0 0; +#X obj 10 127 bang; +#X obj 58 473 /; +#X floatatom 59 526 5 0 0; +#X floatatom 1 361 5 0 0; +#N canvas 0 0 450 300 graph2 0; +#X array arrayP 140 float 1; +#A 0 12.745 12.6021 12.4917 12.4624 12.4428 12.4083 12.357 12.3169 +12.2838 12.3642 12.4992 12.6125 12.8334 13.1195 13.2091 13.3636 13.427 +13.3262 13.1274 13.0323 12.8959 12.4778 12.1279 11.7467 11.1084 10.6082 +10.4762 10.5106 10.7249 11.0192 11.4685 11.8969 12.1991 12.4113 12.6745 +12.9505 13.0786 13.2169 13.2771 13.2021 12.9841 12.5133 12.0669 11.549 +11.0624 10.5936 10.3689 10.1306 10.1064 10.2099 10.1462 10.0187 10.1388 +10.2314 10.366 10.447 10.7786 11.1631 11.4977 11.6852 11.9644 12.0264 +11.8789 11.6583 11.5462 11.2125 10.9489 10.555 10.1705 9.70149 9.28413 +9.1935 9.21485 9.45742 9.79504 10.2243 10.7402 11.2532 11.698 12.1547 +12.5026 12.7131 12.8981 12.8903 12.784 12.7157 12.6072 12.4176 12.101 +11.7283 11.4631 11.1951 10.8678 10.6743 10.553 10.5304 10.5276 10.6795 +10.932 11.0555 11.1699 11.4492 11.7819 12.0798 12.2656 12.2123 12.1171 +11.9876 11.7143 11.5564 11.2613 10.9105 10.6654 10.5599 10.4874 10.6588 +10.8811 11.2697 11.5855 12.0241 12.4281 12.8351 13.1598 13.4953 13.6783 +13.6874 13.5532 13.2183 12.8892 12.5378 12.0966 11.7289 11.3947 11.0228 +10.7229 10.5954 10.4147 10.2329 10.1179 10.0109; +#X coords 0 100 139 0 200 140 1; +#X restore 324 155 graph; +#X obj 292 486 tabset arrayP; +#X obj 291 454 spigot; +#X msg 347 454 0; +#X msg 330 427 1; +#X obj 292 380 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 +1; +#X obj 109 208 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 194 189 loadbang; +#X obj 133 281 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 107 252 vpow 2; +#X obj 129 321 vpow 2; +#X obj 69 315 vv+; +#X msg 85 102 0; +#X obj 26 56 ear~ 256; +#X obj 107 228 linspace 1 0.1 140; +#X obj 130 299 linspace 0.1 1 140; +#X obj 20 171 deltas 60 200 200; +#X obj 56 421 + 60; +#X obj 20 196 vabs; +#X obj 121 49 env~ 256; +#X floatatom 206 55 5 0 0; +#X obj 57 375 moses 2; +#X obj 55 400 moses 138; +#X obj 324 297 hsl 200 15 0 140 0 0 empty empty empty -2 -6 0 8 -262144 +-1 -1 10376 1; +#X text 11 75 samplerate = 44100/256 = 172.26 Hz = 0.348 BPM resolution +; +#X obj 57 500 * 172.26; +#X obj 291 398 metro 200; +#X obj 19 245 vlavg 100; +#X text 102 122 172.26Hz/60 = 172 BPM; +#X text 103 138 172.26Hz/200 = 51.6 BPM; +#X obj 39 95 vsum; +#X obj 20 300 vv+; +#X obj 55 138 * 0.1; +#X obj 59 572 ftom; +#X floatatom 169 574 5 0 0; +#X obj 96 573 vfmod 12; +#X text 109 524 BPM; +#X msg 56 451 60; +#X text 3 -31 beattracker based on average mean difference funtion +(amdf); +#X obj 1 395 vmax; +#X obj 1 431 -; +#X obj 1 470 vsl 15 128 0 127 0 0 empty empty empty 0 -8 0 8 -262144 +-1 -1 493 1; +#X text 441 593 j#|@2002; +#X connect 0 0 20 0; +#X connect 0 0 26 0; +#X connect 1 0 6 0; +#X connect 1 0 47 1; +#X connect 1 1 2 0; +#X connect 1 1 28 0; +#X connect 2 0 30 0; +#X connect 3 0 23 0; +#X connect 4 0 32 0; +#X connect 5 0 40 0; +#X connect 9 0 10 0; +#X connect 9 0 8 0; +#X connect 10 0 9 1; +#X connect 11 0 9 1; +#X connect 12 0 33 0; +#X connect 13 0 21 0; +#X connect 14 0 22 0; +#X connect 14 0 21 0; +#X connect 15 0 22 0; +#X connect 16 0 18 0; +#X connect 17 0 18 1; +#X connect 20 0 37 0; +#X connect 21 0 16 0; +#X connect 22 0 17 0; +#X connect 23 0 25 0; +#X connect 24 0 4 1; +#X connect 24 0 44 0; +#X connect 25 0 34 0; +#X connect 26 0 27 0; +#X connect 28 1 29 0; +#X connect 29 0 24 0; +#X connect 32 0 5 0; +#X connect 33 0 11 0; +#X connect 34 0 38 0; +#X connect 37 0 3 0; +#X connect 37 0 19 0; +#X connect 37 0 39 0; +#X connect 38 0 1 0; +#X connect 38 0 9 0; +#X connect 38 0 46 0; +#X connect 39 0 23 0; +#X connect 40 0 42 0; +#X connect 42 0 41 0; +#X connect 44 0 4 0; +#X connect 46 0 47 0; +#X connect 47 0 48 0; diff --git a/examples/normalizer.pd b/examples/normalizer.pd new file mode 100644 index 0000000..71cd102 --- /dev/null +++ b/examples/normalizer.pd @@ -0,0 +1,94 @@ +#N canvas 161 407 512 338 12; +#X obj 410 270 SMLib; +#X obj -14 54 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1 +; +#X obj -14 94 random 10; +#X obj -14 72 metro 10; +#X obj 13 272 hsl 128 15 -3 3 0 0 empty empty empty -2 -6 0 8 -262144 +-1 -1 7495 1; +#X floatatom 34 224 5 0 0; +#X obj 60 143 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1 +; +#X obj 126 143 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 34 202 lstd 50; +#X obj -14 117 + 7; +#X floatatom 21 250 5 0 0; +#X text 45 121 adapt; +#X text 119 123 store; +#N canvas 0 0 456 343 normalizer 0; +#X obj 83 171 -; +#X obj 37 2 inlet; +#X obj 101 81 spigot; +#X obj 131 0 inlet; +#X msg 256 108 set \$1; +#X obj 167 108 spigot; +#X msg 220 108 0; +#X msg 255 132 11.0646; +#X msg 222 39 1; +#X text 253 39 set; +#X msg 294 42 bang; +#X text 335 42 recall; +#X obj 294 18 loadbang; +#X obj 139 190 spigot; +#X msg 294 217 set \$1; +#X obj 205 217 spigot; +#X msg 258 217 0; +#X msg 293 241 3.10129; +#X obj 90 292 outlet; +#X text 178 0 learn; +#X obj 231 -1 inlet; +#X obj 102 107 lavg 500; +#X obj 140 216 lstd 500; +#X obj 92 261 *; +#X obj 135 241 pow -1; +#X connect 0 0 13 0; +#X connect 0 0 23 0; +#X connect 1 0 0 0; +#X connect 1 0 2 0; +#X connect 2 0 21 0; +#X connect 3 0 2 1; +#X connect 3 0 13 1; +#X connect 4 0 7 0; +#X connect 5 0 4 0; +#X connect 5 0 6 0; +#X connect 6 0 5 1; +#X connect 7 0 0 1; +#X connect 8 0 5 1; +#X connect 8 0 15 1; +#X connect 10 0 7 0; +#X connect 10 0 17 0; +#X connect 12 0 10 0; +#X connect 13 0 22 0; +#X connect 14 0 17 0; +#X connect 15 0 14 0; +#X connect 15 0 16 0; +#X connect 16 0 15 1; +#X connect 20 0 8 0; +#X connect 21 0 0 1; +#X connect 21 0 5 0; +#X connect 22 0 15 0; +#X connect 22 0 24 0; +#X connect 23 0 18 0; +#X connect 24 0 23 1; +#X restore 14 173 pd normalizer; +#X text -17 -8 normalizer : rescales a float stream so that its average +approximates zero \, and its standard deviation approximates unity. +; +#X text 153 143 using store changes the patch; +#X text 153 160 not usefull for use in an abstraction; +#X text 389 290 j#|@2002; +#X floatatom 96 223 5 0 0; +#X obj 96 201 lavg 50; +#X connect 1 0 3 0; +#X connect 2 0 9 0; +#X connect 3 0 2 0; +#X connect 6 0 13 1; +#X connect 7 0 13 2; +#X connect 8 0 5 0; +#X connect 9 0 13 0; +#X connect 13 0 4 0; +#X connect 13 0 8 0; +#X connect 13 0 10 0; +#X connect 13 0 19 0; +#X connect 19 0 18 0; diff --git a/examples/resonate-beat.pd b/examples/resonate-beat.pd new file mode 100644 index 0000000..00b2043 --- /dev/null +++ b/examples/resonate-beat.pd @@ -0,0 +1,239 @@ +#N canvas 35 57 1126 761 12; +#X floatatom 35 282 5 0 0; +#X obj 35 259 float; +#X obj 35 195 loadbang; +#X obj 35 219 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1 +; +#X floatatom 161 312 0 0 0; +#X msg 129 289 clear; +#X text 179 288 <-- reinitialize internal state; +#X text 193 313 <-- center frequency; +#X floatatom 210 334 0 0 0; +#X text 242 335 <-- Q; +#X obj 111 412 hsl 128 15 -256 256 0 0 empty empty empty -2 -6 0 8 +-262144 -1 -1 6350 1; +#X floatatom 108 430 5 0 0; +#X obj 35 7 key; +#X obj 35 30 select 32; +#X msg 80 260 0; +#X obj 40 527 line~; +#X obj 40 549 osc~; +#X obj 40 571 hip~ 30; +#X msg 40 505 200 \, 0 100; +#X obj 40 597 *~; +#X obj 163 508 lrange 30; +#X floatatom 164 533 5 0 0; +#X obj 41 453 threshold 1 1 -1 1; +#X floatatom 478 314 0 0 0; +#X msg 446 291 clear; +#X floatatom 527 336 0 0 0; +#X obj 428 414 hsl 128 15 -256 256 0 0 empty empty empty -2 -6 0 8 +-262144 -1 -1 6350 1; +#X floatatom 425 432 5 0 0; +#X obj 357 529 line~; +#X obj 357 551 osc~; +#X obj 357 573 hip~ 30; +#X obj 350 600 *~; +#X obj 480 503 lrange 30; +#X floatatom 481 535 5 0 0; +#X obj 358 455 threshold 1 1 -1 1; +#X obj 354 383 bp 0.02 10; +#X obj 35 236 metro 20; +#X obj 164 553 * 0.01; +#X obj 481 554 * 0.01; +#X obj 37 381 bp 0.04 10; +#X text 74 9 rock your spacebar!; +#X floatatom 786 308 0 0 0; +#X msg 754 285 clear; +#X floatatom 835 330 0 0 0; +#X obj 736 408 hsl 128 15 -256 256 0 0 empty empty empty -2 -6 0 8 +-262144 -1 -1 6350 1; +#X floatatom 733 426 5 0 0; +#X obj 706 523 line~; +#X obj 706 545 osc~; +#X obj 649 663 hip~ 30; +#X obj 658 694 *~; +#X obj 812 499 lrange 30; +#X floatatom 813 531 5 0 0; +#X obj 666 449 threshold 1 1 -1 1; +#X msg 356 503 10000 \, 0 20; +#X obj 648 587 *~; +#X obj 583 561 clip~ -0.1 0.1; +#X msg 702 499 0 \, 110 200; +#X obj 582 539 osc~ 55; +#X text 112 237 generate sampled stream; +#X text 122 380 resonate; +#X text 192 454 detect; +#X text 46 486 bass drum synth; +#X text 364 483 electro clap synth; +#X obj 583 517 line~; +#X obj 663 378 bp 0.01 10; +#X obj 649 638 clip~ -0.2 0.1; +#X obj 649 611 *~ 5; +#X obj 1018 527 line~; +#X obj 1018 549 osc~; +#X obj 961 667 hip~ 30; +#X obj 970 698 *~; +#X obj 1103 503 lrange 30; +#X floatatom 1104 535 5 0 0; +#X obj 960 591 *~; +#X obj 894 543 osc~ 55; +#X obj 895 521 line~; +#X obj 961 642 clip~ -0.2 0.1; +#X obj 961 615 *~ 5; +#X msg 1012 503 0 \, 175 200; +#X obj 1103 554 * 0.02; +#X obj 812 550 * 0.02; +#X obj 362 110 delay; +#X floatatom 339 43 5 0 0; +#X obj 306 87 moses 50; +#X obj 537 164 line~; +#X obj 537 186 osc~; +#X obj 536 230 *~ 0.2; +#X obj 536 208 hip~ 300; +#X text 528 120 electro tom synth; +#X msg 536 141 2000 \, 0 10; +#X obj 306 65 float; +#X obj 423 67 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X msg 342 16 753; +#X msg 386 16 520; +#X obj 536 254 throw~ mix; +#X obj 39 623 throw~ mix; +#X obj 348 626 throw~ mix; +#X obj 655 718 throw~ mix; +#X obj 969 723 throw~ mix; +#X text 750 377 resonate; +#X text 510 452 detect; +#X text 821 450 detect; +#X obj 810 143 catch~ mix; +#X obj 802 171 dac~; +#X text 282 -8 or use this metronome; +#X text 992 8 j#|@2002; +#X text 395 44 pulse period in ms; +#X text 444 66 start; +#X obj 488 24 line 100; +#X msg 489 1 2000 \, 200 240000; +#X text 664 474 electro bass synths; +#X text 948 476 electro bass synths; +#X obj 895 565 clip~ -0.1 0.2; +#X msg 896 497 87 \, 86 2000; +#X msg 583 493 55 \, 54 2000; +#X msg 35 164 1000; +#X obj 165 577 moses 0.3; +#X obj 482 579 moses 0.3; +#X obj 1105 579 moses 0.4; +#X obj 814 575 moses 0.4; +#X text 443 385 resonate; +#X msg 421 87 0; +#X text 453 88 stop; +#X connect 1 0 0 0; +#X connect 1 0 14 0; +#X connect 1 0 35 0; +#X connect 1 0 39 0; +#X connect 1 0 64 0; +#X connect 2 0 3 0; +#X connect 3 0 36 0; +#X connect 4 0 39 1; +#X connect 5 0 39 0; +#X connect 8 0 39 2; +#X connect 10 0 11 0; +#X connect 12 0 13 0; +#X connect 13 0 115 0; +#X connect 13 0 89 0; +#X connect 14 0 1 1; +#X connect 15 0 16 0; +#X connect 16 0 17 0; +#X connect 17 0 19 0; +#X connect 18 0 15 0; +#X connect 19 0 95 0; +#X connect 20 0 21 0; +#X connect 21 0 37 0; +#X connect 22 0 18 0; +#X connect 23 0 35 1; +#X connect 24 0 35 0; +#X connect 25 0 35 2; +#X connect 26 0 27 0; +#X connect 28 0 29 0; +#X connect 29 0 30 0; +#X connect 30 0 31 0; +#X connect 31 0 96 0; +#X connect 32 0 33 0; +#X connect 33 0 38 0; +#X connect 34 0 53 0; +#X connect 35 0 26 0; +#X connect 35 0 32 0; +#X connect 35 0 34 0; +#X connect 36 0 1 0; +#X connect 37 0 116 0; +#X connect 38 0 117 0; +#X connect 39 0 10 0; +#X connect 39 0 20 0; +#X connect 39 0 22 0; +#X connect 41 0 64 1; +#X connect 42 0 64 0; +#X connect 43 0 64 2; +#X connect 44 0 45 0; +#X connect 46 0 47 0; +#X connect 47 0 54 1; +#X connect 48 0 49 0; +#X connect 49 0 97 0; +#X connect 50 0 51 0; +#X connect 51 0 80 0; +#X connect 52 0 56 0; +#X connect 52 0 114 0; +#X connect 52 1 113 0; +#X connect 52 1 78 0; +#X connect 53 0 28 0; +#X connect 54 0 66 0; +#X connect 55 0 54 0; +#X connect 56 0 46 0; +#X connect 57 0 55 0; +#X connect 63 0 57 0; +#X connect 64 0 44 0; +#X connect 64 0 50 0; +#X connect 64 0 52 0; +#X connect 64 0 71 0; +#X connect 65 0 48 0; +#X connect 66 0 65 0; +#X connect 67 0 68 0; +#X connect 68 0 73 1; +#X connect 69 0 70 0; +#X connect 70 0 98 0; +#X connect 71 0 72 0; +#X connect 72 0 79 0; +#X connect 73 0 77 0; +#X connect 74 0 112 0; +#X connect 75 0 74 0; +#X connect 76 0 69 0; +#X connect 77 0 76 0; +#X connect 78 0 67 0; +#X connect 79 0 118 0; +#X connect 80 0 119 0; +#X connect 81 0 115 0; +#X connect 81 0 89 0; +#X connect 81 0 90 0; +#X connect 82 0 90 1; +#X connect 83 1 81 0; +#X connect 84 0 85 0; +#X connect 85 0 87 0; +#X connect 86 0 94 0; +#X connect 87 0 86 0; +#X connect 89 0 84 0; +#X connect 90 0 83 0; +#X connect 91 0 90 0; +#X connect 92 0 82 0; +#X connect 93 0 82 0; +#X connect 102 0 103 0; +#X connect 102 0 103 1; +#X connect 108 0 82 0; +#X connect 109 0 108 0; +#X connect 112 0 73 0; +#X connect 113 0 75 0; +#X connect 114 0 63 0; +#X connect 115 0 1 1; +#X connect 116 0 19 1; +#X connect 117 0 31 1; +#X connect 118 0 70 1; +#X connect 119 0 49 1; +#X connect 121 0 108 0; diff --git a/help/SMLib-help.pd b/help/SMLib-help.pd new file mode 100644 index 0000000..028dbc4 --- /dev/null +++ b/help/SMLib-help.pd @@ -0,0 +1,103 @@ +#N canvas 97 25 525 422 12; +#X obj 31 188 lmax; +#X obj 31 211 lmin; +#X obj 31 234 lrange; +#X obj 31 165 lavg; +#X obj 9 317 threshold; +#X text 89 188 leaky maximum; +#X text 89 213 leaky minimum; +#X text 90 237 leaky range; +#X text 89 164 leaky average; +#X text 92 316 hysteresis; +#X obj 31 257 lstd; +#X text 90 260 leaky standard deviation; +#X obj 26 421 hist; +#X text 88 421 histogram; +#X obj 26 444 lhist; +#X text 88 445 leaky histogram; +#X obj 9 293 decimator; +#X text 94 291 decimator; +#X obj 32 352 hip; +#X obj 32 375 bp; +#X obj 25 751 vv+; +#X text 83 751 vector addition; +#X text 83 774 vector substraction; +#X obj 25 797 vvconv; +#X text 83 797 vector convolution; +#X obj 24 590 vsum; +#X text 85 592 sum of elements; +#X obj 24 613 vcog; +#X text 85 613 center of gravity; +#X obj 24 636 vmax; +#X text 86 637 maximum and its location; +#X text 86 659 minimum and its location; +#X obj 24 659 vmin; +#X obj 27 1129 vlavg; +#X text 87 1131 leaky averages; +#X text 3 4 SMLib means Signal processing for Mapping; +#X text 435 1264 j#|@2002; +#X text 249 121 johannes.taelman@rug.ac.be; +#X text 283 102 enjoy!; +#X obj 27 1152 vlmax; +#X text 87 1154 leaky maxima; +#X obj 27 1175 vlmin; +#X text 87 1177 leaky minima; +#X obj 27 1198 vlrange; +#X text 87 1200 leaky ranges; +#X obj 27 1221 vdelta; +#X text 88 1223 differences between succesive vectors; +#X obj 25 820 vclip; +#X text 84 821 clip elements; +#X text 96 352 high pass filter; +#X text 97 375 band pass filter; +#X text 3 29 Its a collection of objects for the analysis of float +streams (for taking temporal context into account) \, vectors (lists +of floats) and vector streams (temporal context...). It is complementary +to the zexy and gem/markex library \, so have a look at those too. +; +#X obj 25 774 vv-; +#X obj 24 683 vrms; +#X text 84 686 root mean square; +#X obj 24 706 vstd; +#X text 83 708 standard deviation; +#X text 22 1044 there is also a [Clip] in cyclone (identical to vclip) +; +#X text 0 398 analyzing stream of floats (context) (vector output) +; +#X text 1 142 processing stream of floats (context) (float output) +; +#X text -3 567 immediate vector analysis (float output); +#X text -6 730 immediate vector processing (vector output); +#X text 22 1010 cfr. [.] in zexy; +#X text 22 1027 cfr. [v+] \, [v-] \, [v*] \, [v/] \, [vabs] in GEM/MarkEx +; +#X text -2 1108 vector stream processing (context) (vector output) +; +#X obj 25 843 vfmod; +#X text 83 845 floating point modulo; +#X obj 23 918 vmtof; +#X text 81 918 midi to frequency; +#X text 21 897 unit conversions; +#X obj 23 941 vftom; +#X text 81 941 frequency to midi; +#X obj 23 964 vdbtorms; +#X text 99 964 db to rms; +#X obj 23 987 vrmstodb; +#X text 99 987 rms to db; +#X obj 25 866 vpow; +#X obj 25 546 deltas; +#X text 83 867 power; +#X obj 26 466 lhisti; +#X text 88 467 leaky histogram without clipping input; +#X text 88 546 difference between current input and past inputs; +#X obj 455 1243 SMLib; +#X obj 472 1224 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 +-1 -1; +#X obj 26 520 prevl; +#X text 89 520 previous input values in a list; +#X text -3 1064 vector synthesis; +#X obj 23 1085 linspace; +#X text 98 1085 generates a vector with linear spaced floats; +#X obj 44 492 itov; +#X text 90 491 index to value (for histogram bins); +#X connect 83 0 82 0; diff --git a/help/bp-help.pd b/help/bp-help.pd new file mode 100644 index 0000000..cb88dcb --- /dev/null +++ b/help/bp-help.pd @@ -0,0 +1,35 @@ +#N canvas 114 43 428 284 12; +#X floatatom 12 141 5 0 0; +#X obj 12 118 float; +#X obj 12 95 metro 100; +#X obj 12 54 loadbang; +#X obj 12 78 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1 +; +#X obj 124 77 hsl 128 15 -127 127 0 0 empty empty empty -2 -6 0 8 -262144 +-1 -1 12700 1; +#X text 349 255 j#|@2002; +#X obj 367 233 SMLib; +#X text 13 7 bp: bandpass filter on float stream; +#X floatatom 138 133 0 0 0; +#X msg 106 110 clear; +#X text 156 109 <-- reinitialize internal state; +#X text 170 134 <-- center frequency; +#X floatatom 187 155 0 0 0; +#X text 219 156 <-- Q; +#X obj 21 211 hsl 128 15 -256 256 0 0 empty empty empty -2 -6 0 8 -262144 +-1 -1 7974 1; +#X floatatom 17 237 5 0 0; +#X text 11 25 the non-audio version of bp~; +#X text 262 76 <-- swing!; +#X obj 19 182 bp 0.07 5; +#X connect 1 0 0 0; +#X connect 1 0 19 0; +#X connect 2 0 1 0; +#X connect 3 0 4 0; +#X connect 4 0 2 0; +#X connect 5 0 1 1; +#X connect 9 0 19 1; +#X connect 10 0 19 0; +#X connect 13 0 19 2; +#X connect 15 0 16 0; +#X connect 19 0 15 0; diff --git a/help/deltas-help.pd b/help/deltas-help.pd new file mode 100644 index 0000000..9988a85 --- /dev/null +++ b/help/deltas-help.pd @@ -0,0 +1,34 @@ +#N canvas 553 310 489 262 12; +#X text 390 239 j#|@2002; +#X obj 412 217 SMLib; +#X floatatom 14 74 5 0 0; +#X obj 12 165 print deltas; +#X floatatom 68 108 5 0 0; +#X floatatom 120 107 5 0 0; +#X obj 24 104 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 12 138 deltas 1 10 10; +#X obj 14 54 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X text 9 4 deltas: generates vector with differences between last +input and past inputs; +#X text 9 186 x(i)-x(i-a); +#X text 9 200 x(i)-x(i-(a+1)); +#X text 9 214 x(i)-x(i-(a+2)); +#X text 9 240 x(i)-x(i-(b)); +#X text 7 225 ...; +#X text 153 137 [deltas a b c]; +#X text 120 86 b; +#X text 66 87 a; +#X text 152 183 requires b<=c; +#X text 152 167 c = buffer size; +#X text 35 50 x(i); +#X msg 79 57 clear; +#X connect 2 0 6 0; +#X connect 2 0 7 0; +#X connect 4 0 7 1; +#X connect 5 0 7 2; +#X connect 6 0 7 0; +#X connect 7 0 3 0; +#X connect 8 0 2 0; +#X connect 21 0 7 0; diff --git a/help/hip-help.pd b/help/hip-help.pd new file mode 100644 index 0000000..c8f8e14 --- /dev/null +++ b/help/hip-help.pd @@ -0,0 +1,32 @@ +#N canvas 114 43 430 286 12; +#X floatatom 12 141 5 0 0; +#X obj 12 118 float; +#X obj 12 95 metro 100; +#X obj 12 54 loadbang; +#X obj 12 78 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1 +; +#X obj 124 77 hsl 128 15 -127 127 0 0 empty empty empty -2 -6 0 8 -262144 +-1 -1 12700 1; +#X text 349 255 j#|@2002; +#X obj 367 233 SMLib; +#X floatatom 138 133 0 0 0; +#X msg 106 110 clear; +#X text 156 109 <-- reinitialize internal state; +#X obj 21 211 hsl 128 15 -256 256 0 0 empty empty empty -2 -6 0 8 -262144 +-1 -1 6350 1; +#X floatatom 17 237 5 0 0; +#X text 262 76 <-- swing!; +#X text 13 7 hip: highpass filter on float stream; +#X text 11 25 the non-audio version of hip~; +#X obj 19 182 hip 0.05; +#X text 170 134 <-- cutoff frequency; +#X connect 1 0 0 0; +#X connect 1 0 16 0; +#X connect 2 0 1 0; +#X connect 3 0 4 0; +#X connect 4 0 2 0; +#X connect 5 0 1 1; +#X connect 8 0 16 1; +#X connect 9 0 16 0; +#X connect 11 0 12 0; +#X connect 16 0 11 0; diff --git a/help/hist-help.pd b/help/hist-help.pd new file mode 100644 index 0000000..f17850c --- /dev/null +++ b/help/hist-help.pd @@ -0,0 +1,44 @@ +#N canvas 678 207 414 422 12; +#X text 331 381 j#|@2002; +#X text 351 362 SMLib; +#X text 14 7 hist: histograms; +#X obj 2 354 print; +#X obj 11 181 random 10; +#X obj 11 162 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X msg 129 177 absolute; +#X msg 129 205 relative; +#X msg 276 177 clear; +#X text 128 156 generate output; +#X text 275 159 reinit; +#X text 31 160 feed data; +#X obj 2 317 hist 0 10 10; +#X obj 62 347 vsum; +#X floatatom 62 370 5 0 0; +#X msg 11 208 1 3 5 7 9; +#X text 14 50 - value of first class; +#X text 14 77 - number of classes; +#X text 14 64 - value of last class; +#X text 13 35 arguments:; +#X text 14 112 - array of samples in classes; +#X text 12 97 output:; +#X text 12 133 out-of-range inputs are clipped (cfr lhisti); +#X msg 11 233 1.4 3.4 5.4 7.4 9.4; +#X msg 87 292 -10; +#X msg 11 259 0.6 2.6 4.6 6.6 8.6; +#X obj 42 396 itov; +#X text 4 399 cfr.; +#X obj 79 396 lhist; +#X obj 124 396 lhisti; +#X connect 4 0 12 0; +#X connect 5 0 4 0; +#X connect 6 0 12 0; +#X connect 7 0 12 0; +#X connect 8 0 12 0; +#X connect 12 0 3 0; +#X connect 12 0 13 0; +#X connect 13 0 14 0; +#X connect 15 0 12 0; +#X connect 23 0 12 0; +#X connect 24 0 12 0; +#X connect 25 0 12 0; diff --git a/help/itov-help.pd b/help/itov-help.pd new file mode 100644 index 0000000..1ce4e7f --- /dev/null +++ b/help/itov-help.pd @@ -0,0 +1,44 @@ +#N canvas 436 204 416 478 12; +#X text 327 442 j#|@2002; +#X text 347 423 SMLib; +#X msg 275 239 clear; +#X text 277 219 reinit; +#X text 11 81 - value of first class; +#X text 11 108 - number of classes; +#X text 11 95 - value of last class; +#X text 10 66 arguments:; +#X text 10 128 output:; +#X floatatom 93 445 5 0 0; +#X floatatom 45 446 5 0 0; +#X floatatom 144 445 5 0 0; +#X text 14 7 itov: intex to value; +#X text 11 36 input:; +#X text 12 52 - class index; +#X msg 134 248 absolute; +#X floatatom 94 353 5 0 0; +#X msg 16 228 4.6; +#X msg 52 228 5.4; +#X obj 37 293 hist 0 10 10; +#X obj 45 419 itov 0 10 10; +#X obj 45 324 vcog; +#X msg 86 228 5.6; +#X text 7 191 out-of-range input is clipped; +#X floatatom 69 394 5 0 0; +#X text 11 157 - center value of class i; +#X text 11 143 - lower value of class i; +#X text 11 171 - upper value of class i; +#X connect 2 0 19 0; +#X connect 15 0 19 0; +#X connect 17 0 19 0; +#X connect 17 0 15 0; +#X connect 18 0 19 0; +#X connect 18 0 15 0; +#X connect 19 0 21 0; +#X connect 20 0 10 0; +#X connect 20 1 9 0; +#X connect 20 2 11 0; +#X connect 21 0 16 0; +#X connect 21 0 20 0; +#X connect 22 0 19 0; +#X connect 22 0 15 0; +#X connect 24 0 20 0; diff --git a/help/lavg-help.pd b/help/lavg-help.pd new file mode 100644 index 0000000..9ba5e0f --- /dev/null +++ b/help/lavg-help.pd @@ -0,0 +1,22 @@ +#N canvas 553 310 441 199 12; +#X text 351 171 j#|@2002; +#X obj 373 149 SMLib; +#X floatatom 53 75 5 0 0; +#X obj 9 58 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 -1 +; +#X text 53 55 x(i); +#X text 6 7 lavg: leaky average; +#X obj 9 141 lavg 10; +#X floatatom 9 171 5 0 0; +#X obj 9 101 float; +#X text 5 24 argument: half-decay time (in number of activations); +#X msg 118 101 clear; +#X text 116 79 clear accumulator; +#X msg 244 106 decay 5; +#X text 243 90 set half-decay time; +#X connect 2 0 8 1; +#X connect 3 0 8 0; +#X connect 6 0 7 0; +#X connect 8 0 6 0; +#X connect 10 0 6 0; +#X connect 12 0 6 0; diff --git a/help/lhist-help.pd b/help/lhist-help.pd new file mode 100644 index 0000000..d0648ca --- /dev/null +++ b/help/lhist-help.pd @@ -0,0 +1,40 @@ +#N canvas 133 245 443 412 12; +#X text 360 376 j#|@2002; +#X text 380 357 SMLib; +#X obj 51 362 print; +#X obj 11 193 random 10; +#X obj 11 174 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X msg 236 193 absolute; +#X msg 236 221 relative; +#X msg 372 192 clear; +#X text 235 172 generate output; +#X text 371 173 reinit; +#X text 31 172 feed data; +#X obj 111 355 vsum; +#X floatatom 111 378 5 0 0 0 - - -; +#X msg 11 220 1 3 5 7 9; +#X text 14 50 - value of first class; +#X text 14 77 - number of classes; +#X text 14 64 - value of last class; +#X text 13 35 arguments:; +#X text 14 124 - array of samples in classes; +#X text 12 109 output:; +#X text 12 145 out-of-range inputs are clipped (cfr lhisti); +#X text 14 7 lhist: "leaky" histograms; +#X text 13 91 - half-decay time; +#X obj 51 325 lhist 0 10 10 5; +#X msg 118 194 leak; +#X text 118 172 perform leak; +#X msg 10 246 -5; +#X connect 3 0 23 0; +#X connect 4 0 3 0; +#X connect 5 0 23 0; +#X connect 6 0 23 0; +#X connect 7 0 23 0; +#X connect 11 0 12 0; +#X connect 13 0 23 0; +#X connect 23 0 2 0; +#X connect 23 0 11 0; +#X connect 24 0 23 0; +#X connect 26 0 23 0; diff --git a/help/lhisti-help.pd b/help/lhisti-help.pd new file mode 100644 index 0000000..601845f --- /dev/null +++ b/help/lhisti-help.pd @@ -0,0 +1,41 @@ +#N canvas 645 245 441 405 12; +#X text 360 376 j#|@2002; +#X text 380 357 SMLib; +#X obj 51 362 print; +#X obj 11 193 random 10; +#X obj 11 174 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X msg 236 193 absolute; +#X msg 236 221 relative; +#X msg 372 192 clear; +#X text 235 172 generate output; +#X text 371 173 reinit; +#X text 31 172 feed data; +#X obj 111 355 vsum; +#X floatatom 111 378 5 0 0 0 - - -; +#X msg 11 220 1 3 5 7 9; +#X text 14 50 - value of first class; +#X text 14 77 - number of classes; +#X text 14 64 - value of last class; +#X text 13 35 arguments:; +#X text 14 124 - array of samples in classes; +#X text 12 109 output:; +#X text 12 145 out-of-range inputs are clipped (cfr lhisti); +#X text 13 91 - half-decay time; +#X obj 51 325 lhist 0 10 10 5; +#X msg 118 194 leak; +#X text 118 172 perform leak; +#X text 13 4 lhisti: "leaky" histograms without clipping the input +; +#X msg 11 245 -5; +#X connect 3 0 22 0; +#X connect 4 0 3 0; +#X connect 5 0 22 0; +#X connect 6 0 22 0; +#X connect 7 0 22 0; +#X connect 11 0 12 0; +#X connect 13 0 22 0; +#X connect 22 0 2 0; +#X connect 22 0 11 0; +#X connect 23 0 22 0; +#X connect 26 0 22 0; diff --git a/help/linspace-help.pd b/help/linspace-help.pd new file mode 100644 index 0000000..cbd7732 --- /dev/null +++ b/help/linspace-help.pd @@ -0,0 +1,20 @@ +#N canvas 488 507 396 195 12; +#X text 303 159 j#|@2002; +#X obj 325 139 SMLib; +#X obj 29 147 print linspace; +#X floatatom 136 101 5 0 0; +#X floatatom 82 80 5 0 0; +#X floatatom 29 58 5 0 0; +#X obj 11 38 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X text 29 36 generate; +#X text 132 80 set b; +#X text 187 101 set n; +#X text 79 56 set a and generate; +#X obj 29 124 linspace 0 1 4; +#X text 9 6 generates a vector with linear spaced floats; +#X connect 3 0 11 2; +#X connect 4 0 11 1; +#X connect 5 0 11 0; +#X connect 6 0 11 0; +#X connect 11 0 2 0; diff --git a/help/lmax-help.pd b/help/lmax-help.pd new file mode 100644 index 0000000..e704957 --- /dev/null +++ b/help/lmax-help.pd @@ -0,0 +1,22 @@ +#N canvas 553 310 441 199 12; +#X text 353 169 j#|@2002; +#X obj 375 147 SMLib; +#X floatatom 55 73 5 0 0; +#X obj 11 56 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X text 55 53 x(i); +#X floatatom 11 169 5 0 0; +#X obj 11 99 float; +#X text 7 22 argument: half-decay time (in number of activations); +#X msg 119 95 clear; +#X text 118 77 clear accumulator; +#X text 8 5 lmax: leaky maximum; +#X obj 11 139 lmax 10; +#X msg 244 106 decay 5; +#X text 243 90 set half-decay time; +#X connect 2 0 6 1; +#X connect 3 0 6 0; +#X connect 6 0 11 0; +#X connect 8 0 11 0; +#X connect 11 0 5 0; +#X connect 12 0 11 0; diff --git a/help/lmin-help.pd b/help/lmin-help.pd new file mode 100644 index 0000000..c17e984 --- /dev/null +++ b/help/lmin-help.pd @@ -0,0 +1,22 @@ +#N canvas 553 310 444 200 12; +#X text 351 168 j#|@2002; +#X obj 373 146 SMLib; +#X floatatom 53 72 5 0 0; +#X obj 9 55 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 -1 +; +#X text 53 52 x(i); +#X floatatom 9 168 5 0 0; +#X obj 9 98 float; +#X text 5 21 argument: half-decay time (in number of activations); +#X text 6 4 lmin: leaky minimum; +#X obj 9 138 lmin 10; +#X msg 112 92 clear; +#X text 111 73 clear accumulator; +#X msg 244 106 decay 5; +#X text 243 90 set half-decay time; +#X connect 2 0 6 1; +#X connect 3 0 6 0; +#X connect 6 0 9 0; +#X connect 9 0 5 0; +#X connect 10 0 9 0; +#X connect 12 0 9 0; diff --git a/help/lrange-help.pd b/help/lrange-help.pd new file mode 100644 index 0000000..3d2102a --- /dev/null +++ b/help/lrange-help.pd @@ -0,0 +1,22 @@ +#N canvas 553 310 441 199 12; +#X text 352 168 j#|@2002; +#X obj 374 146 SMLib; +#X floatatom 54 72 5 0 0; +#X obj 10 55 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X text 54 52 x(i); +#X floatatom 10 168 5 0 0; +#X obj 10 98 float; +#X text 6 21 argument: half-decay time (in number of activations); +#X msg 119 98 clear; +#X text 117 76 clear accumulator; +#X text 7 4 lrange: leaky maximum minus leaky minimum; +#X obj 10 138 lrange 10; +#X msg 244 106 decay 5; +#X text 243 90 set half-decay time; +#X connect 2 0 6 1; +#X connect 3 0 6 0; +#X connect 6 0 11 0; +#X connect 8 0 11 0; +#X connect 11 0 5 0; +#X connect 12 0 11 0; diff --git a/help/prevl-help.pd b/help/prevl-help.pd new file mode 100644 index 0000000..cf7f8d5 --- /dev/null +++ b/help/prevl-help.pd @@ -0,0 +1,34 @@ +#N canvas 410 463 489 262 12; +#X text 364 181 j#|@2002; +#X obj 386 159 SMLib; +#X floatatom -12 16 5 0 0; +#X floatatom 42 50 5 0 0; +#X floatatom 94 49 5 0 0; +#X obj -2 46 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj -12 -4 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X text -19 167 ...; +#X text 127 79 [deltas a b c]; +#X text 94 28 b; +#X text 40 29 a; +#X text 126 125 requires b<=c; +#X text 126 109 c = buffer size; +#X text 9 -8 x(i); +#X obj -14 107 print prevl; +#X text -17 -54 prevl: generates vector with past input values (float) +; +#X text -17 128 x(i-a); +#X text -17 142 x(i-(a+1)); +#X text -17 156 x(i-(a+2)); +#X text -17 182 x(i-(b)); +#X obj -14 80 prevl 0 10 10; +#X msg 71 2 clear; +#X connect 2 0 20 0; +#X connect 2 0 5 0; +#X connect 3 0 20 1; +#X connect 4 0 20 2; +#X connect 5 0 20 0; +#X connect 6 0 2 0; +#X connect 20 0 14 0; +#X connect 21 0 20 0; diff --git a/help/threshold-help.pd b/help/threshold-help.pd new file mode 100644 index 0000000..e9b5a5d --- /dev/null +++ b/help/threshold-help.pd @@ -0,0 +1,50 @@ +#N canvas 114 43 708 422 12; +#X text 221 309 Arguments:; +#X text 310 310 1 trigger threshold; +#X floatatom 20 235 5 0 0; +#X obj 42 363 print trigger; +#X obj 183 363 print rest; +#X text 310 341 3 rest threshold; +#X msg 172 268 1; +#X msg 208 268 0; +#X text 249 209 "set" to change the parameters; +#X text 245 263 zero or nonszero in inlet to set the state to "high" +or "low". There is no debounce period after this.; +#X text 208 12 - TRIGGER FROM FLOAT STREAM; +#X obj 124 11 threshold; +#X text 26 48 threshold monitors its input float stream and outputs +bangs when the signal exceeds a specified "trigger" value \, and also +when the input value recedes below a "rest" value. You can specify +debounce in number of floats received \, for the threshold~ to wait +after the two event types before triggering again.; +#X text 310 326 2 trigger debounce number; +#X text 309 358 4 rest debounce number; +#X obj 20 212 float; +#X obj 20 189 metro 100; +#X obj 20 148 loadbang; +#X obj 20 170 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1 +; +#X obj 132 171 hsl 128 15 0 127 0 0 empty empty empty -2 -6 0 8 -262144 +-1 -1 1200 1; +#X msg 129 208 set 50 0 10 0; +#X msg 130 231 set 50 15 10 15; +#X text 12 393 see also threshold~; +#X obj 164 363 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 20 363 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 20 332 threshold 70 10 30 10; +#X text 620 398 j#|@2002; +#X obj 638 376 SMLib; +#X connect 2 0 25 0; +#X connect 15 0 2 0; +#X connect 16 0 15 0; +#X connect 17 0 18 0; +#X connect 18 0 16 0; +#X connect 19 0 15 1; +#X connect 20 0 25 0; +#X connect 21 0 25 0; +#X connect 25 0 3 0; +#X connect 25 0 24 0; +#X connect 25 1 4 0; +#X connect 25 1 23 0; diff --git a/help/vabs-help.pd b/help/vabs-help.pd new file mode 100644 index 0000000..8fea847 --- /dev/null +++ b/help/vabs-help.pd @@ -0,0 +1,6 @@ +#N canvas 490 308 452 302 12; +#X obj 106 129 vabs; +#X msg 105 95 1 2 3 -4 -5 -6; +#X obj 105 165 print; +#X connect 0 0 2 0; +#X connect 1 0 0 0; diff --git a/help/vclip-help.pd b/help/vclip-help.pd new file mode 100644 index 0000000..9b12fdd --- /dev/null +++ b/help/vclip-help.pd @@ -0,0 +1,17 @@ +#N canvas 588 327 324 246 12; +#X obj 11 141 vclip -1 1; +#X obj 11 196 print; +#X msg 11 30 -4 -3 -2 -1 0 1 2 3 4; +#X floatatom 73 64 5 0 0; +#X floatatom 118 103 5 0 0; +#X text 10 6 vclip clips each element in a vector; +#X text 23 166 arguments: lower bound \, upper bound; +#X text 20 52 input; +#X text 79 81 lower bound; +#X text 121 120 upper bound; +#X text 252 220 j#|@2002; +#X obj 274 200 SMLib; +#X connect 0 0 1 0; +#X connect 2 0 0 0; +#X connect 3 0 0 1; +#X connect 4 0 0 2; diff --git a/help/vcog-help.pd b/help/vcog-help.pd new file mode 100644 index 0000000..3f62651 --- /dev/null +++ b/help/vcog-help.pd @@ -0,0 +1,21 @@ +#N canvas 480 472 471 125 12; +#X msg 18 40 1 2 3 4; +#X floatatom 50 96 5 0 0; +#X msg 84 40 3 4 5; +#X text 387 99 j#|@2002; +#X obj 409 77 SMLib; +#X obj 52 69 vcog; +#X text 16 14 vcog computes the center of gravity of a list of floats +; +#X msg 134 40 0 1 0 1; +#X msg 199 40 0 0 1 1; +#X msg 263 40 8; +#X msg 144 74 1 -1; +#X text 142 94 zero sum causes no output; +#X connect 0 0 5 0; +#X connect 2 0 5 0; +#X connect 5 0 1 0; +#X connect 7 0 5 0; +#X connect 8 0 5 0; +#X connect 9 0 5 0; +#X connect 10 0 5 0; diff --git a/help/vdbtorms-help.pd b/help/vdbtorms-help.pd new file mode 100644 index 0000000..bb72563 --- /dev/null +++ b/help/vdbtorms-help.pd @@ -0,0 +1,9 @@ +#N canvas 606 355 283 118 12; +#X text 194 88 j#|@2002; +#X obj 216 68 SMLib; +#X msg 15 33 100 97 94; +#X text 10 6 db to rms on a vector; +#X obj 15 56 vdbtorms; +#X obj 15 80 print vdbtorms; +#X connect 2 0 4 0; +#X connect 4 0 5 0; diff --git a/help/vdelta-help.pd b/help/vdelta-help.pd new file mode 100644 index 0000000..3e0c082 --- /dev/null +++ b/help/vdelta-help.pd @@ -0,0 +1,29 @@ +#N canvas 619 449 433 228 12; +#X msg 5 30 1 1 1 1 1 1 1 1 1 1; +#X msg 5 52 1 0 1 0 1 0 1 0 1 0; +#X msg 5 74 0 1 0 1 0 1 0 1 0 1; +#X msg 5 96 0 0 0 0 0 0 0 0 0 0; +#X msg 5 118 -1 -1 0 0 -1 -1 0 0 -1 -1; +#X msg 5 140 0 0 0 0 0 1 1 1 1 1; +#X text 352 205 j#|@2002; +#X obj 373 184 SMLib; +#X text 7 3 vdelta: difference between consecutive vectors; +#X obj 5 193 print vdelta; +#X msg 221 31 0; +#X text 111 162 sending a vector of a different; +#X text 111 178 length resets its state; +#X obj 5 170 vdelta; +#X msg 221 57 0 0 0; +#X msg 221 79 1 2 3; +#X msg 221 101 3 2 1; +#X connect 0 0 13 0; +#X connect 1 0 13 0; +#X connect 2 0 13 0; +#X connect 3 0 13 0; +#X connect 4 0 13 0; +#X connect 5 0 13 0; +#X connect 10 0 13 0; +#X connect 13 0 9 0; +#X connect 14 0 13 0; +#X connect 15 0 13 0; +#X connect 16 0 13 0; diff --git a/help/vfmod-help.pd b/help/vfmod-help.pd new file mode 100644 index 0000000..e4ccbb2 --- /dev/null +++ b/help/vfmod-help.pd @@ -0,0 +1,17 @@ +#N canvas 163 334 442 175 12; +#X text 364 147 j#|@2002; +#X obj 386 127 SMLib; +#X text 10 6 vfmod computes the modulo of each element in a vector +; +#X obj 15 127 print; +#X floatatom 66 81 5 0 0; +#X text 79 103 base; +#X text 78 119 base zero becomes one; +#X msg 15 33 0 0.5 1 1.5 2 2.5 3 3.5; +#X msg 26 58 0 -0.5 -1 -1.5 -2 -2.5 -3 -3.5; +#X obj 15 101 vfmod 2; +#X text 78 134 default argument is 1; +#X connect 4 0 9 1; +#X connect 7 0 9 0; +#X connect 8 0 9 0; +#X connect 9 0 3 0; diff --git a/help/vftom-help.pd b/help/vftom-help.pd new file mode 100644 index 0000000..6b3a17f --- /dev/null +++ b/help/vftom-help.pd @@ -0,0 +1,9 @@ +#N canvas 606 355 281 116 12; +#X text 194 88 j#|@2002; +#X obj 216 68 SMLib; +#X text 10 6 frequency to midi on a vector; +#X msg 15 33 440 446.164 880; +#X obj 15 56 vftom; +#X obj 15 80 print vftom; +#X connect 3 0 4 0; +#X connect 4 0 5 0; diff --git a/help/vlavg-help.pd b/help/vlavg-help.pd new file mode 100644 index 0000000..4fc0bef --- /dev/null +++ b/help/vlavg-help.pd @@ -0,0 +1,29 @@ +#N canvas 448 299 464 314 12; +#X obj 8 249 prepend 0; +#N canvas 0 0 450 300 graph1 0; +#X array array_vlavg 10 float 0; +#X coords 0 1 9 -1 200 140 1; +#X restore 239 102 graph; +#X msg 8 58 1 1 1 1 1 1 1 1 1 1; +#X msg 8 80 1 0 1 0 1 0 1 0 1 0; +#X msg 8 102 0 1 0 1 0 1 0 1 0 1; +#X msg 8 124 0 0 0 0 0 0 0 0 0 0; +#X obj 8 224 vlavg 6; +#X msg 8 146 -1 -1 0 0 -1 -1 0 0 -1 -1; +#X msg 8 168 0 0 0 0 0 1 1 1 1 1; +#X text 376 285 j#|@2002; +#X text 7 3 vlavg: vector leaky average; +#X text 8 22 the argument is the half-decay expressed in number of +activations; +#X obj 8 275 s array_vlavg; +#X obj 397 264 SMLib; +#X msg 27 201 decay 20; +#X connect 0 0 12 0; +#X connect 2 0 6 0; +#X connect 3 0 6 0; +#X connect 4 0 6 0; +#X connect 5 0 6 0; +#X connect 6 0 0 0; +#X connect 7 0 6 0; +#X connect 8 0 6 0; +#X connect 14 0 6 0; diff --git a/help/vlmax-help.pd b/help/vlmax-help.pd new file mode 100644 index 0000000..bb1063c --- /dev/null +++ b/help/vlmax-help.pd @@ -0,0 +1,29 @@ +#N canvas 448 299 466 316 12; +#X obj 8 249 prepend 0; +#N canvas 0 0 450 300 graph1 0; +#X array array_vlmax 10 float 0; +#X coords 0 1 9 -1 200 140 1; +#X restore 239 102 graph; +#X msg 8 58 1 1 1 1 1 1 1 1 1 1; +#X msg 8 80 1 0 1 0 1 0 1 0 1 0; +#X msg 8 102 0 1 0 1 0 1 0 1 0 1; +#X msg 8 124 0 0 0 0 0 0 0 0 0 0; +#X msg 8 146 -1 -1 0 0 -1 -1 0 0 -1 -1; +#X msg 8 168 0 0 0 0 0 1 1 1 1 1; +#X text 376 285 j#|@2002; +#X text 8 22 the argument is the half-decay expressed in number of +activations; +#X obj 397 264 SMLib; +#X obj 8 224 vlmax 6; +#X obj 8 275 s array_vlmax; +#X msg 27 201 decay 20; +#X text 9 4 vlmax: vector leaky maximum; +#X connect 0 0 12 0; +#X connect 2 0 11 0; +#X connect 3 0 11 0; +#X connect 4 0 11 0; +#X connect 5 0 11 0; +#X connect 6 0 11 0; +#X connect 7 0 11 0; +#X connect 11 0 0 0; +#X connect 13 0 11 0; diff --git a/help/vlmin-help.pd b/help/vlmin-help.pd new file mode 100644 index 0000000..2aa6ae1 --- /dev/null +++ b/help/vlmin-help.pd @@ -0,0 +1,29 @@ +#N canvas 448 299 466 316 12; +#X obj 8 249 prepend 0; +#N canvas 0 0 450 300 graph1 0; +#X array array_vlmin 10 float 0; +#X coords 0 1 9 -1 200 140 1; +#X restore 239 102 graph; +#X msg 8 58 1 1 1 1 1 1 1 1 1 1; +#X msg 8 80 1 0 1 0 1 0 1 0 1 0; +#X msg 8 102 0 1 0 1 0 1 0 1 0 1; +#X msg 8 124 0 0 0 0 0 0 0 0 0 0; +#X msg 8 146 -1 -1 0 0 -1 -1 0 0 -1 -1; +#X msg 8 168 0 0 0 0 0 1 1 1 1 1; +#X text 376 285 j#|@2002; +#X text 8 22 the argument is the half-decay expressed in number of +activations; +#X obj 397 264 SMLib; +#X obj 8 275 s array_vlmax; +#X msg 27 201 decay 20; +#X text 7 3 vlmin: vector leaky minimum; +#X obj 8 224 vlmin 6; +#X connect 0 0 11 0; +#X connect 2 0 14 0; +#X connect 3 0 14 0; +#X connect 4 0 14 0; +#X connect 5 0 14 0; +#X connect 6 0 14 0; +#X connect 7 0 14 0; +#X connect 12 0 14 0; +#X connect 14 0 0 0; diff --git a/help/vmax-help.pd b/help/vmax-help.pd new file mode 100644 index 0000000..b9d7947 --- /dev/null +++ b/help/vmax-help.pd @@ -0,0 +1,21 @@ +#N canvas 480 472 473 127 12; +#X floatatom 35 104 5 0 0; +#X text 387 99 j#|@2002; +#X obj 409 77 SMLib; +#X msg 133 47 0; +#X msg 168 47 0 1 0 1; +#X msg 243 48 0 0 1 1; +#X text 14 3 vcog computes maximum of a list of floats; +#X obj 49 76 vmax; +#X floatatom 86 104 5 0 0; +#X msg 15 47 1 2 3 1; +#X msg 81 47 3 4 1; +#X text 13 21 and the location of the first occurance of the maximum +; +#X connect 3 0 7 0; +#X connect 4 0 7 0; +#X connect 5 0 7 0; +#X connect 7 0 0 0; +#X connect 7 1 8 0; +#X connect 9 0 7 0; +#X connect 10 0 7 0; diff --git a/help/vmin-help.pd b/help/vmin-help.pd new file mode 100644 index 0000000..9a99c5e --- /dev/null +++ b/help/vmin-help.pd @@ -0,0 +1,21 @@ +#N canvas 480 472 473 127 12; +#X floatatom 35 104 5 0 0; +#X text 387 99 j#|@2002; +#X obj 409 77 SMLib; +#X msg 133 47 0; +#X msg 168 47 0 1 0 1; +#X msg 236 47 0 0 1 1; +#X floatatom 86 104 5 0 0; +#X msg 15 47 1 2 3 1; +#X msg 81 47 3 4 1; +#X text 14 3 vcog computes minimum of a list of floats; +#X text 13 21 and the location of the first occurance of the minimum +; +#X obj 49 76 vmin; +#X connect 3 0 11 0; +#X connect 4 0 11 0; +#X connect 5 0 11 0; +#X connect 7 0 11 0; +#X connect 8 0 11 0; +#X connect 11 0 0 0; +#X connect 11 1 6 0; diff --git a/help/vmtof-help.pd b/help/vmtof-help.pd new file mode 100644 index 0000000..dc3ba47 --- /dev/null +++ b/help/vmtof-help.pd @@ -0,0 +1,9 @@ +#N canvas 606 355 279 114 12; +#X text 192 79 j#|@2002; +#X obj 214 59 SMLib; +#X obj 15 57 vmtof; +#X text 10 6 midi to frequency on a vector; +#X msg 15 33 69 70 81; +#X obj 15 80 print vmtof; +#X connect 2 0 5 0; +#X connect 4 0 2 0; diff --git a/help/vpow-help.pd b/help/vpow-help.pd new file mode 100644 index 0000000..d8df50b --- /dev/null +++ b/help/vpow-help.pd @@ -0,0 +1,15 @@ +#N canvas 163 334 444 177 12; +#X text 364 147 j#|@2002; +#X obj 386 127 SMLib; +#X obj 15 127 print; +#X floatatom 66 81 5 0 0 0 - - -; +#X text 78 134 default argument is 1; +#X text 10 6 vpow computes y(i)=x(i)^a; +#X text 79 103 a; +#X text 79 117 a zero becomes one; +#X obj 15 101 vpow 2; +#X msg 15 33 0.01 0.5 1 1.5 2 2.5 3 3.5 0; +#X text 27 56 if (x(i)<=0) then y(i)=-1000; +#X connect 3 0 8 1; +#X connect 8 0 2 0; +#X connect 9 0 8 0; diff --git a/help/vrms-help.pd b/help/vrms-help.pd new file mode 100644 index 0000000..43b063f --- /dev/null +++ b/help/vrms-help.pd @@ -0,0 +1,15 @@ +#N canvas 381 509 392 123 12; +#X msg 17 39 1 2 3 4; +#X floatatom 50 96 5 0 0; +#X msg 84 40 3 4 5; +#X text 315 100 j#|@2002; +#X obj 337 78 SMLib; +#X obj 52 69 vrms; +#X text 16 14 vrms computes the root-mean-square of a vector; +#X msg 134 40 1 1 1 1; +#X msg 200 40 1 -1 1 -1; +#X connect 0 0 5 0; +#X connect 2 0 5 0; +#X connect 5 0 1 0; +#X connect 7 0 5 0; +#X connect 8 0 5 0; diff --git a/help/vrmstodb-help.pd b/help/vrmstodb-help.pd new file mode 100644 index 0000000..f971964 --- /dev/null +++ b/help/vrmstodb-help.pd @@ -0,0 +1,9 @@ +#N canvas 606 355 283 118 12; +#X text 194 88 j#|@2002; +#X obj 216 68 SMLib; +#X text 10 6 frequency to midi on a vector; +#X obj 15 56 vrmstodb; +#X msg 15 33 100 97 94; +#X obj 15 80 print vrmstodb; +#X connect 3 0 5 0; +#X connect 4 0 3 0; diff --git a/help/vstd-help.pd b/help/vstd-help.pd new file mode 100644 index 0000000..025dfa7 --- /dev/null +++ b/help/vstd-help.pd @@ -0,0 +1,15 @@ +#N canvas 381 509 394 125 12; +#X msg 17 39 1 2 3 4; +#X floatatom 51 95 5 0 0; +#X msg 84 40 3 4 5; +#X text 315 100 j#|@2002; +#X obj 337 78 SMLib; +#X msg 134 40 1 1 1 1; +#X obj 51 70 vstd; +#X msg 200 40 1 -1 1 -1 1; +#X text 16 14 vstd computes the standard deviation of a vector; +#X connect 0 0 6 0; +#X connect 2 0 6 0; +#X connect 5 0 6 0; +#X connect 6 0 1 0; +#X connect 7 0 6 0; diff --git a/help/vsum-help.pd b/help/vsum-help.pd new file mode 100644 index 0000000..2aee90d --- /dev/null +++ b/help/vsum-help.pd @@ -0,0 +1,13 @@ +#N canvas 468 275 355 125 12; +#X text 16 14 vsum computes the sum of a list of floats; +#X msg 17 39 1 2 3 4; +#X obj 52 69 vsum; +#X floatatom 50 96 5 0 0; +#X msg 84 40 3 4 5; +#X text 275 102 j#|@2002; +#X obj 297 80 SMLib; +#X msg 136 40 0; +#X connect 1 0 2 0; +#X connect 2 0 3 0; +#X connect 4 0 2 0; +#X connect 7 0 2 0; diff --git a/help/vv+-help.pd b/help/vv+-help.pd new file mode 100644 index 0000000..2974208 --- /dev/null +++ b/help/vv+-help.pd @@ -0,0 +1,25 @@ +#N canvas 561 440 313 218 12; +#X obj 40 115 vv+; +#X msg 16 81 1 2 3; +#X msg 73 85 4 5 6; +#X msg 159 86 1 2 3; +#X msg 219 86 4; +#X obj 180 116 vv+ 0; +#X msg 16 57 1; +#X msg 159 62 1; +#X text 18 10 vv+ adds two lists of floats; +#X text 17 25 or a float to a list of floats; +#X msg 73 60 3 2 1; +#X obj 252 159 SMLib; +#X text 230 184 j#|@2002; +#X obj 40 139 print vv+; +#X obj 180 140 print vv+; +#X connect 0 0 13 0; +#X connect 1 0 0 0; +#X connect 2 0 0 1; +#X connect 3 0 5 0; +#X connect 4 0 5 1; +#X connect 5 0 14 0; +#X connect 6 0 0 0; +#X connect 7 0 5 0; +#X connect 10 0 0 1; diff --git a/help/vv--help.pd b/help/vv--help.pd new file mode 100644 index 0000000..184e744 --- /dev/null +++ b/help/vv--help.pd @@ -0,0 +1,23 @@ +#N canvas 561 440 326 219 12; +#X msg 25 90 1 2 3; +#X msg 82 94 4 5 6; +#X msg 168 95 1 2 3; +#X msg 228 95 4; +#X msg 25 66 1; +#X msg 168 71 1; +#X text 248 191 j#|@2002; +#X text 18 10 vv- substracts two lists of floats; +#X text 18 26 or a float from a list of floats; +#X obj 49 124 vv-; +#X obj 189 125 vv- 0; +#X obj 268 170 SMLib; +#X obj 49 148 print vv-; +#X obj 189 149 print vv-; +#X connect 0 0 9 0; +#X connect 1 0 9 1; +#X connect 2 0 10 0; +#X connect 3 0 10 1; +#X connect 4 0 9 0; +#X connect 5 0 10 0; +#X connect 9 0 12 0; +#X connect 10 0 13 0; diff --git a/help/vvconv-help.pd b/help/vvconv-help.pd new file mode 100644 index 0000000..f7cc8a8 --- /dev/null +++ b/help/vvconv-help.pd @@ -0,0 +1,35 @@ +#N canvas 482 447 441 276 12; +#X msg 132 78 1 2 1; +#X msg 132 53 1 0 1; +#X text 26 18 vvconv: convolution of 2 vectors; +#X text 357 244 j#|@2002; +#X msg 30 43 1; +#X obj 48 130 vvconv; +#X msg 331 80 1 2 1; +#X msg 229 68 1 0 0; +#X msg 331 55 1 0 1; +#X msg 229 45 1; +#X obj 247 132 vvconv -1 2 -1; +#X msg 230 92 1 0 1 0 0 1; +#X msg 31 90 1 0 1 0 0 1; +#X text 177 178 arguments: convolution kernel; +#X obj 377 225 SMLib; +#X obj 48 154 print vvconv; +#X obj 247 156 print vvconv; +#X text 2 202 length of output is the sum of input lengths minus one +; +#X msg 30 66 2 0 1; +#X msg 132 103 1 0 2; +#X connect 0 0 5 1; +#X connect 1 0 5 1; +#X connect 4 0 5 0; +#X connect 5 0 15 0; +#X connect 6 0 10 1; +#X connect 7 0 10 0; +#X connect 8 0 10 1; +#X connect 9 0 10 0; +#X connect 10 0 16 0; +#X connect 11 0 10 0; +#X connect 12 0 5 0; +#X connect 18 0 5 0; +#X connect 19 0 5 1; diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..12da712 --- /dev/null +++ b/readme.txt @@ -0,0 +1,127 @@ + ----------------------------------------- + - SMLib : Signal processing for Mapping - + ----------------------------------------- + + v0.12 date 20021125 + +1. Introduction +--------------- + +SMLib is an external objects library for PD (pure data). It complements PD +with a set of objects for vector processing, vector analysis, vector +synthesis, number stream analysis, number stream filters. + +I was missing objects that could do dsp-like operations on control signals. +PD is event-driven by nature (except the dsp-objects and [delay], [metro], +...). A slider that does not change does not transmit anything. Event-driven +events can be sampled by eg. using a [float] with a [metro] on its main input, +and a slider on its right inlet. SMLib has objects designed to process such +streams. Eg. [lavg] is a leaky integrator, it smoothes abrupt changes. Leaky +processes are interesting in mapping because our attention is also leaky. +Eg. [hp] is a high-pass filter (just like [hp~]), and it only passes changes, +and decays to zero when there are no changes. Likewise our attention shifts +towards remarkable changes in our environment. You can detect 'events' in +float streams with [threshold]. A vector is a list of floats. + +These objects are suitable for gesture and high-level music analysis +prototyping. + +This library is written by Johannes Taelman (johannes.taelman@rug.ac.be). The +code is free+open (GNU GPL license). I have only tested/compiled the code on +win32, but porting to linux or macOs should be easy. + +2. List of objects +------------------ + +processing stream of floats (context) (float output) + + lavg leaky average + lmax leaky maximum + lmin leaky minimum + lrange leaky range + lstd leaky standard deviation + decimator passes 1 in n input values + threshold detection with hysteresis + hip first order high-pass filter + bp second order (resonant) high-pass filter + +analyzing stream of floats (vector output) + + hist histogram + lhist leaky histogram, clips samples + lhisti leaky histogram, ignore samples + outside bins + itov bin index to value (for the histograms + prevl previous floats in a list + deltas difference between last float and + previous floats + +immediate vector analysis (float output) + + vsum sum of vector elements + vcog center of gravity + vmax maximum and its location + vmin minimum and its location + vrms root mean square + vstd standard deviation + +vector processors (vector output) + + vv+ vector addition + vv- vector substraction + vvconv vector convolution + vclip clip elements + vfmod floating point modulo + vpow power + vthreshold detections with hysteresises + +unit conversions on vectors + + vftom frequency to midi + vmtof midi to frequency + vdbtorms dB to rms + vrmstodb rms to dB + +vector synthesis (vector output) + + linspace linearly spaced vector + +vector stream processing (vector output) (context) + + vlavg leaky averages + vlmax leaky maxima + vlmin leaky minima + vlrange leaky ranges + vdelta difference between successive vectors + + +3. Installation +--------------- + +Requires PD on the win32 platform (for now). Put SMLib.dll in a directory in +your PD path. Put the help patches in pd\doc\5.reference. + +Start PD with "-lib SMLib" + +4. Getting started +------------------ + +Start PD. + +Create a new patch. + +Create an object [SMLib] + +Right-click on this object after creation. Choose help. + +This gives you the main SMLib patch with all objects and a brief explanation +of them. Choose help for the objects to get details. Have a look at the +example patches for design ideas. + +5. References +------------- + +PD headquarters: +http://crca.ucsd.edu/~msp/software.html +http://iem.kug.ac.at/pd/ +http://www.pure-data.org diff --git a/source/SMLib.c b/source/SMLib.c new file mode 100644 index 0000000..1771395 --- /dev/null +++ b/source/SMLib.c @@ -0,0 +1,230 @@ +/* --------------------- SMLib ----------------------------- */ +/* + + Signal processing for Mapping + objects: + + float stream + - pid controller? + - deltas (generate difference vector between current values and values of the past) + vector + - vquant (quantizer with hysteresis) + - vv/ + - vv> + - vv< + - s2v (stream to vector, incl ola) + - v2s (vector to stream, incl ola) + + vector math + - vreverse + + - delread + - delwrite + - upsample + - fir + - autorescale +*/ + +#include "defines.h" + + +// in alphabetical order +extern void bp_setup(); +extern void decimator_setup(); +extern void deltas_setup(); +extern void hip_setup(); +extern void hist_setup(); +extern void itov_setup(); +extern void lavg_setup(); +extern void lhist_setup(); +extern void lhisti_setup(); +extern void linspace_setup(); +extern void lmax_setup(); +extern void lmin_setup(); +extern void lrange_setup(); +extern void lstd_setup(); +extern void prevl_setup(); +extern void threshold_setup(); +extern void vabs_setup(); +extern void vclip_setup(); +extern void vcog_setup(); +extern void vdbtorms_setup(); +extern void vdelta_setup(); +extern void vfmod_setup(); +extern void vftom_setup(); +extern void vlavg_setup(); +extern void vlmax_setup(); +extern void vlmin_setup(); +extern void vlrange_setup(); +extern void vmax_setup(); +extern void vmin_setup(); +extern void vmtof_setup(); +extern void vpow_setup(); +extern void vrms_setup(); +extern void vrmstodb_setup(); +extern void vstd_setup(); +extern void vsum_setup(); +extern void vthreshold_setup(); +extern void vvconv_setup(); +extern void vvminus_setup(); +extern void vvplus_setup(); + +static t_class *SMLib_class; + +typedef struct _lstd +{ + t_object x_obj; +} t_SMLib; + +static void SMLib_help(t_SMLib *x) +{ + /* + */ + post(""); + post(""); + post(" .........................................................."); + post(" . SMLib ."); + post(" . Signal processing for Mapping ."); + post(" . v0.12 24/11/2002 ."); + post(" .........................................................."); + post(" . processing stream of floats (context) (float output) ."); + post(" . ."); + post(" . lavg leaky average ."); + post(" . lmax leaky maximum ."); + post(" . lmin leaky minimum ."); + post(" . lrange leaky range ."); + post(" u lstd leaky standard deviation ."); + post(" u decimator passes 1 in n input values ."); + post(" . threshold detection with hysteresis ."); + post(" . hip first order high-pass filter ."); + post(" . bp second order (resonant) high-pass filter ."); + post(" .........................................................."); + post(" . analyzing stream of floats (vector output) ."); + post(" . ."); + post(" . hist histogram ."); + post(" . lhist leaky histogram, clips samples ."); + post(" . lhisti leaky histogram, ignore samples ."); + post(" . outside bins ."); + post(" . itov bin index to value (for the histograms ."); + post(" . prevl previous floats in a list ."); + post(" . deltas difference between last float and ."); + post(" . previous floats ."); +// post(" o filterbank lineairly spaced set of bandpass filters ."); + post(" .........................................................."); + post(" . immediate vector analysis (float output) ."); + post(" . ."); + post(" . vsum sum of vector elements ."); + post(" . vcog center of gravity ."); + post(" . vmax maximum and its location ."); + post(" . vmin minimum and its location ."); + post(" . vrms root mean square ."); + post(" . vstd standard deviation ."); + post(" .........................................................."); + post(" . vector processors (vector output) ."); + post(" . ."); + post(" . vv+ vector addition ."); + post(" . vv- vector substraction ."); + post(" . vvconv vector convolution ."); + post(" . vclip clip elements ."); + post(" . vfmod floating point modulo ."); + post(" . vpow power ."); + post(" . vthreshold detections with hysteresises ."); + post(" . ."); + post(" . unit conversions on vectors ."); + post(" . ."); + post(" . vftom frequency to midi ."); + post(" . vmtof midi to frequency ."); + post(" . vdbtorms dB to rms ."); + post(" . vrmstodb rms to dB ."); + post(" .........................................................."); + post(" . vector synthesis (vector output) ."); + post(" . ."); + post(" . linspace linearly spaced vector ."); +// post(" o logspace logarithmically spaced vector ."); +// post(" o rand uniformly distributed random vector ."); +// post(" o randn normally distributed random vector ."); + post(" .........................................................."); + post(" . vector stream processing (vector output) (context) ."); + post(" . ."); + post(" . vlavg leaky averages ."); + post(" . vlmax leaky maxima ."); + post(" . vlmin leaky minima ."); + post(" . vlrange leaky ranges ."); + post(" . vdelta difference between successive vectors ."); + post(" .........................................................."); +// post(" . o = future additions ."); +// post(" . e = experimental ."); + post(" . u = undocumented ."); + post(" . j#|@ = johannes.taelman@rug.ac.be ."); + post(" .........................................................."); + post(""); + post(""); +} + +static void *SMLib_new() +{ + t_SMLib *x=(t_SMLib *)pd_new(SMLib_class); + return (void *)x; +} + +__declspec(dllexport) void __cdecl SMLib_setup( void) +{ + // dummy object for help-system + SMLib_class = class_new(gensym("SMLib"), + (t_newmethod)SMLib_new, 0, + sizeof(t_SMLib), + CLASS_DEFAULT, + 0); + class_addbang(SMLib_class, (t_method)SMLib_help); + class_addmethod(SMLib_class, (t_method)SMLib_help, gensym("help"),0); + + // real objects in alphabetical order + bp_setup(); + decimator_setup(); + deltas_setup(); + hip_setup(); + hist_setup(); + itov_setup(); + lavg_setup(); + lhist_setup(); + lhisti_setup(); + linspace_setup(); + lmax_setup(); + lmin_setup(); + lrange_setup(); + lstd_setup(); + prevl_setup(); + threshold_setup(); + vabs_setup(); + vclip_setup(); + vcog_setup(); + vdbtorms_setup(); + vdelta_setup(); + vfmod_setup(); + vftom_setup(); + vlavg_setup(); + vlmax_setup(); + vlmin_setup(); + vlrange_setup(); + vmax_setup(); + vmin_setup(); + vmtof_setup(); + vpow_setup(); + vrms_setup(); + vrmstodb_setup(); + vstd_setup(); + vsum_setup(); + vthreshold_setup(); + vvconv_setup(); + vvminus_setup(); + vvplus_setup(); + + post(""); + post(" .........................................................."); + post(" . SMLib ."); + post(" . Signal processing for Mapping ."); + post(" . v0.12 24/11/2002 ."); + post(" .........................................................."); + post(""); + +} diff --git a/source/SMLib.dsp b/source/SMLib.dsp new file mode 100755 index 0000000..35c2ab8 --- /dev/null +++ b/source/SMLib.dsp @@ -0,0 +1,275 @@ +# Microsoft Developer Studio Project File - Name="SMLib" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=SMLib - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "SMLib.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "SMLib.mak" CFG="SMLib - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "SMLib - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "SMLib - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "SMLib - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SMLIB_EXPORTS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SMLIB_EXPORTS" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x813 /d "NDEBUG" +# ADD RSC /l 0x813 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pd.lib /nologo /dll /machine:I386 + +!ELSEIF "$(CFG)" == "SMLib - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SMLIB_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SMLIB_EXPORTS" /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x813 /d "_DEBUG" +# ADD RSC /l 0x813 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pd.lib /nologo /dll /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "SMLib - Win32 Release" +# Name "SMLib - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\bp.c +# End Source File +# Begin Source File + +SOURCE=.\decimator.c +# End Source File +# Begin Source File + +SOURCE=.\deltas.c +# End Source File +# Begin Source File + +SOURCE=.\hip.c +# End Source File +# Begin Source File + +SOURCE=.\hist.c +# End Source File +# Begin Source File + +SOURCE=.\itov.c +# End Source File +# Begin Source File + +SOURCE=.\lavg.c +# End Source File +# Begin Source File + +SOURCE=.\lhist.c +# End Source File +# Begin Source File + +SOURCE=.\lhisti.c +# End Source File +# Begin Source File + +SOURCE=.\linspace.c +# End Source File +# Begin Source File + +SOURCE=.\lmax.c +# End Source File +# Begin Source File + +SOURCE=.\lmin.c +# End Source File +# Begin Source File + +SOURCE=.\lrange.c +# End Source File +# Begin Source File + +SOURCE=.\lstd.c +# End Source File +# Begin Source File + +SOURCE=.\prevl.c +# End Source File +# Begin Source File + +SOURCE=.\SMLib.c +# End Source File +# Begin Source File + +SOURCE=.\threshold.c +# End Source File +# Begin Source File + +SOURCE=.\vabs.c +# End Source File +# Begin Source File + +SOURCE=.\vclip.c +# End Source File +# Begin Source File + +SOURCE=.\vcog.c +# End Source File +# Begin Source File + +SOURCE=.\vdbtorms.c +# End Source File +# Begin Source File + +SOURCE=.\vdelta.c +# End Source File +# Begin Source File + +SOURCE=.\vfmod.c +# End Source File +# Begin Source File + +SOURCE=.\vftom.c +# End Source File +# Begin Source File + +SOURCE=.\vlavg.c +# End Source File +# Begin Source File + +SOURCE=.\vlmax.c +# End Source File +# Begin Source File + +SOURCE=.\vlmin.c +# End Source File +# Begin Source File + +SOURCE=.\vlrange.c +# End Source File +# Begin Source File + +SOURCE=.\vmax.c +# End Source File +# Begin Source File + +SOURCE=.\vmin.c +# End Source File +# Begin Source File + +SOURCE=.\vmtof.c +# End Source File +# Begin Source File + +SOURCE=.\vnmax.c +# End Source File +# Begin Source File + +SOURCE=.\vpow.c +# End Source File +# Begin Source File + +SOURCE=.\vrms.c +# End Source File +# Begin Source File + +SOURCE=.\vrmstodb.c +# End Source File +# Begin Source File + +SOURCE=.\vstd.c +# End Source File +# Begin Source File + +SOURCE=.\vsum.c +# End Source File +# Begin Source File + +SOURCE=.\vthreshold.c +# End Source File +# Begin Source File + +SOURCE=.\vvconv.c +# End Source File +# Begin Source File + +SOURCE=.\vvminus.c +# End Source File +# Begin Source File + +SOURCE=.\vvplus.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\defines.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\readme.txt +# End Source File +# End Target +# End Project diff --git a/source/SMLib.dsw b/source/SMLib.dsw new file mode 100755 index 0000000..0428bd3 --- /dev/null +++ b/source/SMLib.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "SMLib"=.\SMLib.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/source/SMLib.opt b/source/SMLib.opt new file mode 100755 index 0000000..685315a Binary files /dev/null and b/source/SMLib.opt differ diff --git a/source/SMLib.plg b/source/SMLib.plg new file mode 100755 index 0000000..c75a641 --- /dev/null +++ b/source/SMLib.plg @@ -0,0 +1,153 @@ + + +
+

Build Log

+

+--------------------Configuration: SMLib - Win32 Release-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP6B.tmp" with contents +[ +/nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SMLIB_EXPORTS" /Fp"Release/SMLib.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c +"D:\devel\SMLib\bp.c" +"D:\devel\SMLib\decimator.c" +"D:\devel\SMLib\deltas.c" +"D:\devel\SMLib\hip.c" +"D:\devel\SMLib\hist.c" +"D:\devel\SMLib\itov.c" +"D:\devel\SMLib\lavg.c" +"D:\devel\SMLib\lhist.c" +"D:\devel\SMLib\lhisti.c" +"D:\devel\SMLib\linspace.c" +"D:\devel\SMLib\lmax.c" +"D:\devel\SMLib\lmin.c" +"D:\devel\SMLib\lrange.c" +"D:\devel\SMLib\lstd.c" +"D:\devel\SMLib\prevl.c" +"D:\devel\SMLib\SMLib.c" +"D:\devel\SMLib\threshold.c" +"D:\devel\SMLib\vabs.c" +"D:\devel\SMLib\vclip.c" +"D:\devel\SMLib\vcog.c" +"D:\devel\SMLib\vdbtorms.c" +"D:\devel\SMLib\vdelta.c" +"D:\devel\SMLib\vfmod.c" +"D:\devel\SMLib\vftom.c" +"D:\devel\SMLib\vlavg.c" +"D:\devel\SMLib\vlmax.c" +"D:\devel\SMLib\vlmin.c" +"D:\devel\SMLib\vlrange.c" +"D:\devel\SMLib\vmax.c" +"D:\devel\SMLib\vmin.c" +"D:\devel\SMLib\vmtof.c" +"D:\devel\SMLib\vnmax.c" +"D:\devel\SMLib\vpow.c" +"D:\devel\SMLib\vrms.c" +"D:\devel\SMLib\vrmstodb.c" +"D:\devel\SMLib\vstd.c" +"D:\devel\SMLib\vsum.c" +"D:\devel\SMLib\vthreshold.c" +"D:\devel\SMLib\vvconv.c" +"D:\devel\SMLib\vvminus.c" +"D:\devel\SMLib\vvplus.c" +] +Creating command line "cl.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP6B.tmp" +Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP6C.tmp" with contents +[ +kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pd.lib /nologo /dll /incremental:no /pdb:"Release/SMLib.pdb" /machine:I386 /out:"Release/SMLib.dll" /implib:"Release/SMLib.lib" +.\Release\bp.obj +.\Release\decimator.obj +.\Release\deltas.obj +.\Release\hip.obj +.\Release\hist.obj +.\Release\itov.obj +.\Release\lavg.obj +.\Release\lhist.obj +.\Release\lhisti.obj +.\Release\linspace.obj +.\Release\lmax.obj +.\Release\lmin.obj +.\Release\lrange.obj +.\Release\lstd.obj +.\Release\prevl.obj +.\Release\SMLib.obj +.\Release\threshold.obj +.\Release\vabs.obj +.\Release\vclip.obj +.\Release\vcog.obj +.\Release\vdbtorms.obj +.\Release\vdelta.obj +.\Release\vfmod.obj +.\Release\vftom.obj +.\Release\vlavg.obj +.\Release\vlmax.obj +.\Release\vlmin.obj +.\Release\vlrange.obj +.\Release\vmax.obj +.\Release\vmin.obj +.\Release\vmtof.obj +.\Release\vnmax.obj +.\Release\vpow.obj +.\Release\vrms.obj +.\Release\vrmstodb.obj +.\Release\vstd.obj +.\Release\vsum.obj +.\Release\vthreshold.obj +.\Release\vvconv.obj +.\Release\vvminus.obj +.\Release\vvplus.obj +] +Creating command line "link.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP6C.tmp" +

Output Window

+Compiling... +bp.c +decimator.c +deltas.c +hip.c +hist.c +itov.c +lavg.c +lhist.c +lhisti.c +linspace.c +lmax.c +lmin.c +lrange.c +lstd.c +prevl.c +SMLib.c +threshold.c +vabs.c +vclip.c +vcog.c +vdbtorms.c +vdelta.c +vfmod.c +vftom.c +vlavg.c +vlmax.c +vlmin.c +vlrange.c +vmax.c +vmin.c +vmtof.c +vnmax.c +vpow.c +vrms.c +vrmstodb.c +vstd.c +vsum.c +vthreshold.c +vvconv.c +vvminus.c +vvplus.c +Linking... + Creating library Release/SMLib.lib and object Release/SMLib.exp + + + +

Results

+SMLib.dll - 0 error(s), 0 warning(s) +
+ + diff --git a/source/bp.c b/source/bp.c new file mode 100644 index 0000000..d21bc19 --- /dev/null +++ b/source/bp.c @@ -0,0 +1,123 @@ +#include "defines.h" + +/*--------------- bp ---------------*/ + +typedef struct bpctl +{ + float c_x1; + float c_x2; + float c_coef1; + float c_coef2; + float c_gain; +} t_bpctl; + +typedef struct bp +{ + t_object x_obj; + float x_freq; + float x_q; + t_bpctl x_cspace; + t_bpctl *x_ctl; + float x_f; +} t_bp; + +t_class *bp_class; + +static void bp_docoef(t_bp *x, t_floatarg f, t_floatarg q); + +static void *bp_new(t_floatarg f, t_floatarg q) +{ + t_bp *x = (t_bp *)pd_new(bp_class); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft2")); + outlet_new(&x->x_obj, gensym("float")); + x->x_ctl = &x->x_cspace; + x->x_cspace.c_x1 = 0; + x->x_cspace.c_x2 = 0; + bp_docoef(x, f, q); + x->x_f = 0; + return (x); +} + +static float bp_qcos(float f) +{ + if (f >= -(0.5f*3.14159f) && f <= 0.5f*3.14159f) + { + float g = f*f; + return (((g*g*g * (-1.0f/720.0f) + g*g*(1.0f/24.0f)) - g*0.5f) + 1); + } + else return (0); +} + +static void bp_docoef(t_bp *x, t_floatarg f, t_floatarg q) +{ + float r, oneminusr, omega; + if (f < 0.0001f) f = 0.0001f; + if (q < 0) q = 0; + x->x_freq = f; + x->x_q = q; + omega = f * (2.0f * 3.14159f); + if (q < 0.001) oneminusr = 1.0f; + else oneminusr = omega/q; + if (oneminusr > 1.0f) oneminusr = 1.0f; + r = 1.0f - oneminusr; + x->x_ctl->c_coef1 = 2.0f * bp_qcos(omega) * r; + x->x_ctl->c_coef2 = - r * r; + x->x_ctl->c_gain = 2 * oneminusr * (oneminusr + r * omega); + /* post("r %f, omega %f, coef1 %f, coef2 %f", + r, omega, x->x_ctl->c_coef1, x->x_ctl->c_coef2); */ +} + +static void bp_ft1(t_bp *x, t_floatarg f) +{ + bp_docoef(x, f, x->x_q); +} + +static void bp_ft2(t_bp *x, t_floatarg q) +{ + bp_docoef(x, x->x_freq, q); +} + +static void bp_clear(t_bp *x, t_floatarg q) +{ + x->x_ctl->c_x1 = x->x_ctl->c_x2 = 0; +} + +static void bp_perform(t_bp *x, t_float in) +{ + float out; + t_bpctl *c = x->x_ctl; + float last = c->c_x1; + float prev = c->c_x2; + float coef1 = c->c_coef1; + float coef2 = c->c_coef2; + float gain = c->c_gain; + + float output = in + coef1 * last + coef2 * prev; + out = gain * output; + + prev = last; + last = output; + + /* NAN protect */ + if (!((last <= 0) || (last >= 0))) + last = 0; + if (!((prev <= 0) || (prev >= 0))) + prev = 0; + c->c_x1 = last; + c->c_x2 = prev; + + outlet_float(x->x_obj.ob_outlet, out); +} + +void bp_setup(void) +{ + bp_class = class_new(gensym("bp"), (t_newmethod)bp_new, 0, + sizeof(t_bp), 0, A_DEFFLOAT, A_DEFFLOAT, 0); + class_addfloat(bp_class, (t_method)bp_perform); + class_addmethod(bp_class, (t_method)bp_ft1, + gensym("ft1"), A_FLOAT, 0); + class_addmethod(bp_class, (t_method)bp_ft2, + gensym("ft2"), A_FLOAT, 0); + class_addmethod(bp_class, (t_method)bp_clear, gensym("clear"), 0); +} diff --git a/source/decimator.c b/source/decimator.c new file mode 100644 index 0000000..d7f93f3 --- /dev/null +++ b/source/decimator.c @@ -0,0 +1,66 @@ +#include "defines.h" + +/*--------------- decimator ---------------*/ + +static t_class *decimator_class; + +typedef struct _decimator +{ + t_object x_obj; + int m_state; + int m_factor; +} t_decimator; + +static void decimator_perform(t_decimator *x, t_float in) +{ + if (!x->m_state) + { + outlet_float(x->x_obj.ob_outlet, in); + x->m_state=x->m_factor; + } + else + { + x->m_state--; + } + +} + +static void decimator_setFactor(t_decimator *x, t_float factor) +{ + x->m_factor=(int)factor - 1; +} + +static void decimator_clear(t_decimator *x) +{ + x->m_state=0; +} + + +static void *decimator_new(t_float factor) +{ + + t_decimator *x=(t_decimator *)pd_new(decimator_class); + outlet_new(&x->x_obj, gensym("float")); + + if (factor<1) factor=2; + + decimator_setFactor(x, factor); + decimator_clear(x); + return (void *)x; +} + + +void decimator_setup(void) +{ + decimator_class = class_new(gensym("decimator"), + (t_newmethod)decimator_new, 0, + sizeof(t_decimator), + CLASS_DEFAULT, + A_DEFFLOAT, 0); + class_addfloat(decimator_class, (t_method)decimator_perform); + class_addmethod(decimator_class, (t_method)decimator_clear, + gensym("clear"), A_GIMME, NULL); + class_addmethod(decimator_class, (t_method)decimator_setFactor, + gensym("factor"), A_DEFFLOAT, NULL); +} + diff --git a/source/defines.h b/source/defines.h new file mode 100644 index 0000000..e819f88 --- /dev/null +++ b/source/defines.h @@ -0,0 +1,18 @@ +//#include +#include "m_imp.h" +#include +#define MAXFLOAT 1e18f; +#define LOGTEN 2.302585092994 + +/* NT and OSX don't appear to have single-precision ANSI math */ +#if defined(WIN32) || defined(MACOSX) +#define sinf sin +#define cosf cos +#define atanf atan +#define atan2f atan2 +#define sqrtf sqrt +#define logf log +#define expf exp +#define fabsf fabs +#define powf pow +#endif diff --git a/source/deltas.c b/source/deltas.c new file mode 100644 index 0000000..edc3cb0 --- /dev/null +++ b/source/deltas.c @@ -0,0 +1,181 @@ +#include "defines.h" + +/*--------------- deltas ---------------*/ + +static t_class *deltas_class; + +typedef struct _deltas +{ + t_object x_obj; + float m_lo; + float m_hi; + int m_buffer_size; + int m_buffer_index; + float *m_buffer; // circular buffer +} t_deltas; + + +static void deltas_perform_float(t_deltas *x, t_float f) +{ + int index; + index=x->m_buffer_index+1; + index=(index==x->m_buffer_size)?0:index; + x->m_buffer_index=index; + x->m_buffer[index]=f; +} + +static void deltas_bang(t_deltas *x) +{ + int lo,hi,n,index,size; + t_atom *ap,*app; + float last; + float *buffer, *bp; + + lo=(int)x->m_lo; + hi=(int)x->m_hi; + + n=hi-lo; + size=x->m_buffer_size; + index=x->m_buffer_index; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + app=ap; + buffer=x->m_buffer; + last=buffer[index]; + bp=buffer+index-lo; + bp=(bp>=buffer)?bp:bp+size; // wrap + + if (bp-buffer>=n) + { // no wrap-around needed + index=n; + while(index--){ + SETFLOAT(app, last-*bp--); + app++; + } +// post("not wrapped, app-ap=%i",app-ap); + } + else // need to wrap + { + int ps, nn; + ps = bp-buffer; + nn=n; +// post(" nn=%i",nn); + for(;ps>=0;ps--) // don't we miss one sample in signal??? + { +// post("ps=%i",ps); + SETFLOAT(app, last-buffer[ps]); + app++; + nn--; + } + ps=size-1; +// post(" nn=%i",nn); + for(;nn>0;nn--) + { +// post("ps=%i",ps); + SETFLOAT(app, last-buffer[ps--]); + app++; + } + +/* + int i2; + index=bp-buffer; + i2=index; + post("first part %i",index); + while(index--){ + SETFLOAT(app, last-*bp--); + app++; + } + index=n-i2; + post("2nd part %i",index); + bp=buffer+size-1; + while(index--){ + SETFLOAT(app, last-*bp--); + app++; + } +*/ +// post("wrapped, app-ap=%i",app-ap); + } + + outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); + freebytes(ap, sizeof(t_atom)*n); +} + +static void deltas_clear(t_deltas *x) +{ + int i,s; + float *f; + f=x->m_buffer; + s=x->m_buffer_size; + for (i=0;isize) + { + post("deltas: higher bound cannot be higher than the buffer size..."); + hi=size; + } + if (lo<0) + { + post("deltas: lower bound cannot be negative..."); + lo=0; + } + if (hi<1) + { + post("deltas: higher bound cannot be smaller than one..."); + hi=1; + } + if (hi<=lo) + { + post("deltas: higher bound must be higher than lower bound..."); + lo=hi-1.0f; + } + + freebytes(x->m_buffer, x->m_buffer_size); + + x->m_hi=(float)((int)hi); + x->m_lo=(float)((int)lo); + x->m_buffer_size=(int)size; + x->m_buffer = (float*)getbytes(sizeof(float)*x->m_buffer_size); + deltas_clear(x); + x->m_buffer_index=0; +} + +static void *deltas_new(t_float lo, t_float hi, t_float size) +{ + t_deltas *x=(t_deltas *)pd_new(deltas_class); + outlet_new(&x->x_obj, gensym("list")); + x->m_buffer_size=0; + x->m_buffer=0; + deltas_set(x, lo, hi, size); + + floatinlet_new(&x->x_obj, &x->m_lo); + floatinlet_new(&x->x_obj, &x->m_hi); + + return (void *)x; +} + +static void deltas_free(t_deltas *x) +{ + freebytes(x->m_buffer, x->m_buffer_size); +} + +void deltas_setup(void) +{ + deltas_class = class_new(gensym("deltas"), + (t_newmethod)deltas_new, (t_method)deltas_free, + sizeof(t_deltas), + CLASS_DEFAULT, + A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT,0); + + class_addmethod(deltas_class, (t_method)deltas_clear, gensym("clear"),0); + class_addfloat(deltas_class, (t_method)deltas_perform_float); + class_addbang(deltas_class, (t_method)deltas_bang); +} + diff --git a/source/hip.c b/source/hip.c new file mode 100644 index 0000000..b1425c1 --- /dev/null +++ b/source/hip.c @@ -0,0 +1,77 @@ +#include "defines.h" + +/*--------------- hip ---------------*/ + +typedef struct hipctl +{ + float c_x; + float c_coef; +} t_hipctl; + +typedef struct hip +{ + t_object x_obj; + float x_sr; + float x_hz; + t_hipctl x_cspace; + t_hipctl *x_ctl; + float x_f; +} t_hip; + +t_class *hip_class; + +static void hip_ft1(t_hip *x, t_floatarg f); + +static void *hip_new(t_floatarg f) +{ + t_hip *x = (t_hip *)pd_new(hip_class); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1")); + outlet_new(&x->x_obj, gensym("float")); + x->x_ctl = &x->x_cspace; + x->x_cspace.c_x = 0; + hip_ft1(x, f); + x->x_f = 0; + return (x); +} + +static void hip_ft1(t_hip *x, t_floatarg f) +{ + if (f < 0.001) f = 10; + x->x_hz = f; + x->x_ctl->c_coef = 1 - f * (2 * 3.14159f); + if (x->x_ctl->c_coef < 0) x->x_ctl->c_coef = 0; +} + +static void hip_perform(t_hip *x, t_float in) +{ + t_hipctl *c = x->x_ctl; + float last = c->c_x; + float coef = c->c_coef; + float out; + + float new = in + coef * last; + out = new - last; + last = new; + + /* NAN protect */ + if (!((last <= 0) || (last >= 0))) + last = 0; + c->c_x = last; + + outlet_float(x->x_obj.ob_outlet, out); +} + +static void hip_clear(t_hip *x, t_floatarg q) +{ + x->x_cspace.c_x = 0; +} + +void hip_setup(void) +{ + hip_class = class_new(gensym("hip"), (t_newmethod)hip_new, 0, + sizeof(t_hip), 0, A_DEFFLOAT, 0); + class_addfloat(hip_class, (t_method)hip_perform); + class_addmethod(hip_class, (t_method)hip_ft1, + gensym("ft1"), A_FLOAT, 0); + class_addmethod(hip_class, (t_method)hip_clear, gensym("clear"), 0); +} \ No newline at end of file diff --git a/source/hist.c b/source/hist.c new file mode 100644 index 0000000..ba492f2 --- /dev/null +++ b/source/hist.c @@ -0,0 +1,155 @@ +#include "defines.h" + +/*--------------- hist ---------------*/ + + +static t_class *hist_class; + +typedef struct _hist +{ + t_object x_obj; + float m_lo; + float m_hi; + float m_scale; + int m_nbins; + int m_n_observations; + float *m_hist; +} t_hist; + + +static void hist_perform_float(t_hist *x, t_float f) +{ + int j; + j=(int)(.5+(f-x->m_lo)*x->m_scale); + j=(j>0)?(jm_nbins?j:x->m_nbins-1):0; // limit without IF + x->m_hist[j]++; + x->m_n_observations++; +} + +static void hist_perform_list(t_hist *x, t_symbol *s, int argc, t_atom *argv) +{ + int i,j; + for (i = 0; i < argc; i++) + { + j=(int)(.5f+(atom_getfloat(&argv[i])-x->m_lo)*x->m_scale); + j=(j>0)?(jm_nbins?j:x->m_nbins-1):0; // limit without IF + x->m_hist[j]++; + } + x->m_n_observations+=argc; +} + +static void hist_bang(t_hist *x) +{ + int i,n; + float *f; + t_atom *ap,*app; + + n=x->m_nbins; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + app=ap; + + i=x->m_nbins; + f=x->m_hist; + + while(i--){ + SETFLOAT(app, *f); + f++; + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); + freebytes(ap, sizeof(t_atom)*n); +} + +static void hist_relative(t_hist *x) +{ + int i,n; + float *f; + float invn; + t_atom *ap,*app; + n=x->m_nbins; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + app=ap; + + invn=1.0f/(1e-10f+x->m_n_observations); + + i=n; + f=x->m_hist; + + while(i--){ + SETFLOAT(app, (*f*invn)); + f++; + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); + freebytes(ap, sizeof(t_atom)*n); +} + +static void hist_clear(t_hist *x) +{ + int i; + float *f; + f=x->m_hist; + for (i=0;im_nbins;i++) + *f++=0.0f; + x->m_n_observations=0; +} + + +static void hist_set(t_hist *x, t_float lo, t_float hi, t_float nbins) +{ + if (nbins<1) + { + nbins=1; + post("hist: number of bins is minimum 1..."); + } + if (hi<=lo) + { + post("hist: higher bound must be higher than lower bound..."); + hi=lo+1.0f; + } + + freebytes(x->m_hist, x->m_nbins); + + x->m_hi=hi; + x->m_lo=lo; + x->m_nbins=(int)nbins; + x->m_scale=(float)x->m_nbins/(hi-lo); + x->m_hist = (float*)getbytes(sizeof(float)*x->m_nbins); + + hist_clear(x); +} + +static void *hist_new(t_float lo, t_float hi, t_float nbins) +{ + t_hist *x=(t_hist *)pd_new(hist_class); + outlet_new(&x->x_obj, gensym("list")); + x->m_hist=0; + x->m_nbins=0; + hist_set(x, lo, hi, nbins); + return (void *)x; +} + +static void hist_free(t_hist *x) +{ + freebytes(x->m_hist, x->m_nbins); +} + +void hist_setup(void) +{ + hist_class = class_new(gensym("hist"), + (t_newmethod)hist_new, (t_method)hist_free, + sizeof(t_hist), + CLASS_DEFAULT, + A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT,0); + + class_addmethod(hist_class, (t_method)hist_clear, gensym("clear"),0); + class_addmethod(hist_class, (t_method)hist_bang, gensym("absolute"),0); + class_addmethod(hist_class, (t_method)hist_relative, gensym("relative"),0); + + class_addmethod(hist_class, (t_method)hist_set, gensym("set"),A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT,0); + + class_addlist(hist_class, (t_method)hist_perform_list); + class_addfloat(hist_class, (t_method)hist_perform_float); + class_addbang(hist_class, (t_method)hist_bang); +} + diff --git a/source/itov.c b/source/itov.c new file mode 100644 index 0000000..fa68a90 --- /dev/null +++ b/source/itov.c @@ -0,0 +1,86 @@ +#include "defines.h" + +/*--------------- itov ---------------*/ + + +static t_class *itov_class; + +typedef struct _itov +{ + t_object x_obj; + t_outlet *f_out1; + t_outlet *f_out2; + t_outlet *f_out3; + float m_lo; + float m_hi; + float m_scale; + int m_nbins; +} t_itov; + + +static void itov_perform_float(t_itov *x, t_float j) +{ + float i; + j-=1.0f; + j=(j>0)?(jm_nbins?j:x->m_nbins-1):0; // limit without IF + +// j=(int)((f-x->m_lo)*x->m_scale); + i=(j/x->m_scale)-x->m_lo; + + outlet_float(x->f_out2, i); + +} + +static void itov_perform_list(t_itov *x, t_symbol *s, int argc, t_atom *argv) +{ + + +} + +static void itov_set(t_itov *x, t_float lo, t_float hi, t_float nbins) +{ + if (nbins<1) + { + nbins=1; + post("itov: number of bins is minimum 1..."); + } + if (hi<=lo) + { + post("itov: higher bound must be higher than lower bound..."); + hi=lo+1.0f; + } + + x->m_hi=hi; + x->m_lo=lo; + x->m_nbins=(int)nbins; + x->m_scale=(float)x->m_nbins/(hi-lo); +} + +static void *itov_new(t_float lo, t_float hi, t_float nbins) +{ + t_itov *x=(t_itov *)pd_new(itov_class); + x->f_out1=outlet_new(&x->x_obj, gensym("float")); + x->f_out2=outlet_new(&x->x_obj, gensym("float")); + x->f_out3=outlet_new(&x->x_obj, gensym("float")); + + x->m_nbins=0; + itov_set(x, lo, hi, nbins); + return (void *)x; +} + +static void itov_free(t_itov *x) +{ +} + +void itov_setup(void) +{ + itov_class = class_new(gensym("itov"), + (t_newmethod)itov_new, (t_method)itov_free, + sizeof(t_itov), + CLASS_DEFAULT, + A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT,0); + +// class_addlist(itov_class, (t_method)itov_perform_list); + class_addfloat(itov_class, (t_method)itov_perform_float); +} + diff --git a/source/lavg.c b/source/lavg.c new file mode 100644 index 0000000..fce0015 --- /dev/null +++ b/source/lavg.c @@ -0,0 +1,55 @@ +#include "defines.h" + +/*--------------- lavg ---------------*/ + +static t_class *lavg_class; + +typedef struct _lavg +{ + t_object x_obj; + float m_avg; + float m_c_leak; + float m_leak; +} t_lavg; + + +static void lavg_perform(t_lavg *x, t_float in) +{ + x->m_avg= x->m_avg * x->m_c_leak + in * x->m_leak; + outlet_float(x->x_obj.ob_outlet, x->m_avg); +} + +static void lavg_clear(t_lavg *x) +{ + x->m_avg=0.0f; +} + +static void lavg_setHalfDecay(t_lavg *x, t_float halfDecayTime) +{ + x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_leak=1.0f-x->m_c_leak; +} + +static void *lavg_new( t_float halfDecayTime) +{ + t_lavg *x=(t_lavg *)pd_new(lavg_class); + outlet_new(&x->x_obj, gensym("float")); + + lavg_setHalfDecay(x, halfDecayTime); + return (void *)x; +} + +void lavg_setup(void) +{ + lavg_class = class_new(gensym("lavg"), + (t_newmethod)lavg_new, 0, + sizeof(t_lavg), + CLASS_DEFAULT, + A_DEFFLOAT, 0); + class_addfloat(lavg_class, (t_method)lavg_perform); + class_addmethod(lavg_class, (t_method)lavg_setHalfDecay, + gensym("decay"), A_DEFFLOAT, NULL); + class_addmethod(lavg_class, (t_method)lavg_clear, + gensym("clear"), 0); +} + diff --git a/source/lhist.c b/source/lhist.c new file mode 100644 index 0000000..ea20edc --- /dev/null +++ b/source/lhist.c @@ -0,0 +1,174 @@ +#include "defines.h" + +/*--------------- lhist ---------------*/ + +static t_class *lhist_class; + +typedef struct _lhist +{ + t_object x_obj; + float m_lo; + float m_hi; + float m_scale; + float m_c_leak; + float m_leak; + int m_nbins; +// int m_n_observations; + float *m_lhist; +} t_lhist; + +static void lhist_setHalfDecay(t_lhist *x, t_float halfDecayTime) +{ + x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_leak=1.0f-x->m_c_leak; +} + +static void lhist_perform_float(t_lhist *x, t_float f) +{ + int j; + j=(int)(.5+(f-x->m_lo)*x->m_scale); + j=(j>0)?(jm_nbins?j:x->m_nbins-1):0; // limit without IF + x->m_lhist[j]++; +// x->m_n_observations++; +} + +static void lhist_perform_list(t_lhist *x, t_symbol *s, int argc, t_atom *argv) +{ + int i,j; + for (i = 0; i < argc; i++) + { + j=(int)(.5f+(atom_getfloat(&argv[i])-x->m_lo)*x->m_scale); + j=(j>0)?(jm_nbins?j:x->m_nbins-1):0; // limit without IF + x->m_lhist[j]++; + } +// x->m_n_observations+=argc; +} + +static void lhist_leak(t_lhist *x) +{ + int i; + float *f; + float sc; + f=x->m_lhist; + sc=x->m_c_leak; + i=x->m_nbins; + while(i--) + *f++*=sc; +} + +static void lhist_bang(t_lhist *x) +{ + int i,n; + float *f; + t_atom *ap,*app; + n=x->m_nbins; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + app=ap; + i=n; + f=x->m_lhist; + + while(i--){ + SETFLOAT(app, *f); + f++; + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); + freebytes(ap,n); +} + +static void lhist_relative(t_lhist *x) +{ + int i,n; + float *f; + float invn,sum; + t_atom *ap,*app; + + n=x->m_nbins; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + app=ap; + i=x->m_nbins; + f=x->m_lhist; + sum=0.0f; + while(i--) sum+=*f++; + invn=1.0f/(1e-10f+sum); + + i=x->m_nbins; + f=x->m_lhist; + + while(i--){ + SETFLOAT(app, (*f*invn)); + f++; + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); + freebytes(ap,n); +} + +static void lhist_clear(t_lhist *x) +{ + int i; + float *f; + f=x->m_lhist; + for (i=0;im_nbins;i++) + *f++=0.0f; +// x->m_n_observations=0; +} + +static void lhist_set(t_lhist *x, t_float lo, t_float hi, t_float nbins) +{ + if (nbins<1) + { + nbins=1; + post("lhist: number of bins is minimum 1..."); + } + if (hi<=lo) + { + post("lhist: higher bound must be higher than lower bound..."); + hi=lo+1.0f; + } + freebytes(x->m_lhist, x->m_nbins); + x->m_hi=hi; + x->m_lo=lo; + x->m_nbins=(int)nbins; + x->m_scale=(float)x->m_nbins/(hi-lo); + x->m_lhist = (float*)getbytes(sizeof(float)*x->m_nbins); + + lhist_clear(x); +} + +static void *lhist_new(t_float lo, t_float hi, t_float nbins, t_float decay) +{ + t_lhist *x=(t_lhist *)pd_new(lhist_class); + outlet_new(&x->x_obj, gensym("list")); + lhist_setHalfDecay(x,decay); + x->m_nbins=0; + x->m_lhist=0; + lhist_set(x, lo, hi, nbins); + return (void *)x; +} + +static void lhist_free(t_lhist *x) +{ + freebytes(x->m_lhist, x->m_nbins); +} + +void lhist_setup(void) +{ + lhist_class = class_new(gensym("lhist"), + (t_newmethod)lhist_new, (t_method)lhist_free, + sizeof(t_lhist), + CLASS_DEFAULT, + A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT,A_DEFFLOAT,0); + + class_addmethod(lhist_class, (t_method)lhist_clear, gensym("clear"),0); + class_addmethod(lhist_class, (t_method)lhist_bang, gensym("absolute"),0); + class_addmethod(lhist_class, (t_method)lhist_relative, gensym("relative"),0); + class_addmethod(lhist_class, (t_method)lhist_leak, gensym("leak"),0); + class_addmethod(lhist_class, (t_method)lhist_setHalfDecay, + gensym("decay"), A_DEFFLOAT, NULL); + + class_addlist(lhist_class, (t_method)lhist_perform_list); + class_addfloat(lhist_class, (t_method)lhist_perform_float); + class_addbang(lhist_class, (t_method)lhist_bang); +} + diff --git a/source/lhisti.c b/source/lhisti.c new file mode 100644 index 0000000..826cce4 --- /dev/null +++ b/source/lhisti.c @@ -0,0 +1,174 @@ +#include "defines.h" + +/*--------------- lhisti ---------------*/ +// ignores samples outside bins + +static t_class *lhisti_class; + +typedef struct _lhisti +{ + t_object x_obj; + float m_lo; + float m_hi; + float m_scale; + float m_c_leak; + float m_leak; + int m_nbins; +// int m_n_observations; + float *m_lhisti; +} t_lhisti; + +static void lhisti_setHalfDecay(t_lhisti *x, t_float halfDecayTime) +{ + x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_leak=1.0f-x->m_c_leak; +} + +static void lhisti_perform_float(t_lhisti *x, t_float f) +{ + int j; + j=(int)(.5+(f-x->m_lo)*x->m_scale); + if ((j>=0)&&(jm_nbins)) + x->m_lhisti[j]++; +} + +static void lhisti_perform_list(t_lhisti *x, t_symbol *s, int argc, t_atom *argv) +{ + int i,j; + for (i = 0; i < argc; i++) + { + j=(int)(.5f+(atom_getfloat(&argv[i])-x->m_lo)*x->m_scale); + if ((j>=0)&&(jm_nbins)) + x->m_lhisti[j]++; + } +// x->m_n_observations+=argc; +} + +static void lhisti_leak(t_lhisti *x) +{ + int i; + float *f; + float sc; + f=x->m_lhisti; + sc=x->m_c_leak; + i=x->m_nbins; + while(i--) + *f++*=sc; +} + +static void lhisti_bang(t_lhisti *x) +{ + int i,n; + float *f; + t_atom *ap,*app; + n=x->m_nbins; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + app=ap; + i=n; + f=x->m_lhisti; + + while(i--){ + SETFLOAT(app, *f); + f++; + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); + freebytes(ap,n); +} + +static void lhisti_relative(t_lhisti *x) +{ + int i,n; + float *f; + float invn,sum; + t_atom *ap,*app; + + n=x->m_nbins; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + app=ap; + i=x->m_nbins; + f=x->m_lhisti; + sum=0.0f; + while(i--) sum+=*f++; + invn=1.0f/(1e-10f+sum); + + i=x->m_nbins; + f=x->m_lhisti; + + while(i--){ + SETFLOAT(app, (*f*invn)); + f++; + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); + freebytes(ap,n); +} + +static void lhisti_clear(t_lhisti *x) +{ + int i; + float *f; + f=x->m_lhisti; + for (i=0;im_nbins;i++) + *f++=0.0f; +// x->m_n_observations=0; +} + +static void lhisti_set(t_lhisti *x, t_float lo, t_float hi, t_float nbins) +{ + if (nbins<1) + { + nbins=1; + post("lhisti: number of bins is minimum 1..."); + } + if (hi<=lo) + { + post("lhisti: higher bound must be higher than lower bound..."); + hi=lo+1.0f; + } + freebytes(x->m_lhisti, x->m_nbins); + x->m_hi=hi; + x->m_lo=lo; + x->m_nbins=(int)nbins; + x->m_scale=(float)x->m_nbins/(hi-lo); + x->m_lhisti = (float*)getbytes(sizeof(float)*x->m_nbins); + + lhisti_clear(x); +} + +static void *lhisti_new(t_float lo, t_float hi, t_float nbins, t_float decay) +{ + t_lhisti *x=(t_lhisti *)pd_new(lhisti_class); + outlet_new(&x->x_obj, gensym("list")); + lhisti_setHalfDecay(x,decay); + x->m_nbins=0; + x->m_lhisti=0; + lhisti_set(x, lo, hi, nbins); + return (void *)x; +} + +static void lhisti_free(t_lhisti *x) +{ + freebytes(x->m_lhisti, x->m_nbins); +} + +void lhisti_setup(void) +{ + lhisti_class = class_new(gensym("lhisti"), + (t_newmethod)lhisti_new, (t_method)lhisti_free, + sizeof(t_lhisti), + CLASS_DEFAULT, + A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT,A_DEFFLOAT,0); + + class_addmethod(lhisti_class, (t_method)lhisti_clear, gensym("clear"),0); + class_addmethod(lhisti_class, (t_method)lhisti_bang, gensym("absolute"),0); + class_addmethod(lhisti_class, (t_method)lhisti_relative, gensym("relative"),0); + class_addmethod(lhisti_class, (t_method)lhisti_leak, gensym("leak"),0); + class_addmethod(lhisti_class, (t_method)lhisti_setHalfDecay, + gensym("decay"), A_DEFFLOAT, NULL); + + class_addlist(lhisti_class, (t_method)lhisti_perform_list); + class_addfloat(lhisti_class, (t_method)lhisti_perform_float); + class_addbang(lhisti_class, (t_method)lhisti_bang); +} + diff --git a/source/linspace.c b/source/linspace.c new file mode 100644 index 0000000..c3af9c2 --- /dev/null +++ b/source/linspace.c @@ -0,0 +1,74 @@ +#include "defines.h" + +/*--------------- linspace ----------------*/ +/* clips a vector */ + + +static t_class *linspace_class; + +typedef struct _linspace +{ + t_object x_obj; + float m_lo; + float m_hi; + float m_n; +} t_linspace; + + +static void linspace_bang(t_linspace *x) +{ + int n; + n=(int)x->m_n; + if ((n<256)&&(n>1)) + { + int i; + float lo,step; + t_atom *ap,*app; + + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + app=ap; + lo=x->m_lo; + step=(x->m_hi-lo)/(n-1); + for (i = 0; i < n; i++) + { + + SETFLOAT(app, lo); + app++; + lo+=step; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); + freebytes(ap,n); + } +} + +static void linspace_float(t_linspace *x, t_float lo) +{ + x->m_lo=lo; + linspace_bang(x); +} + +static void *linspace_new(t_float lo, t_float hi, t_float n) +{ + t_linspace *x=(t_linspace *)pd_new(linspace_class); + + floatinlet_new(&x->x_obj, &x->m_hi); + floatinlet_new(&x->x_obj, &x->m_n); + + outlet_new(&x->x_obj, gensym("list")); + x->m_lo=lo; + x->m_hi=hi; + x->m_n=n; + return (void *)x; +} + +void linspace_setup(void) +{ + linspace_class = class_new(gensym("linspace"), + (t_newmethod)linspace_new, 0, + sizeof(t_linspace), + CLASS_DEFAULT, + A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0); + class_addfloat(linspace_class, (t_method)linspace_float); + class_addbang(linspace_class, (t_method)linspace_bang); +} + diff --git a/source/lmax.c b/source/lmax.c new file mode 100644 index 0000000..911304f --- /dev/null +++ b/source/lmax.c @@ -0,0 +1,57 @@ +#include "defines.h" + +/*--------------- lmax ---------------*/ + +static t_class *lmax_class; + +typedef struct _lmax +{ + t_object x_obj; + float m_max; + float m_leak; + float m_c_leak; +} t_lmax; + + +static void lmax_perform(t_lmax *x, t_float in) +{ + x->m_max=(in > x->m_max) ? in : x->m_max * x->m_c_leak + in * x->m_leak; + outlet_float(x->x_obj.ob_outlet, x->m_max); +} + +static void lmax_setHalfDecay(t_lmax *x, t_float halfDecayTime) +{ + x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_leak=1.0f-x->m_c_leak; +} + +static void lmax_clear(t_lmax *x) +{ + x->m_max= - MAXFLOAT; +} + +static void *lmax_new( t_float halfDecayTime) +{ + t_lmax *x=(t_lmax *)pd_new(lmax_class); + outlet_new(&x->x_obj, gensym("float")); + + lmax_setHalfDecay(x, halfDecayTime); + lmax_clear(x); + return (void *)x; +} + + +void lmax_setup(void) +{ + lmax_class = class_new(gensym("lmax"), + (t_newmethod)lmax_new, 0, + sizeof(t_lmax), + CLASS_DEFAULT, + A_DEFFLOAT, 0); + class_addfloat(lmax_class, (t_method)lmax_perform); + class_addmethod(lmax_class, (t_method)lmax_clear, + gensym("clear"), A_GIMME, NULL); + class_addmethod(lmax_class, (t_method)lmax_setHalfDecay, + gensym("decay"), A_DEFFLOAT, NULL); +} + diff --git a/source/lmin.c b/source/lmin.c new file mode 100644 index 0000000..51b333a --- /dev/null +++ b/source/lmin.c @@ -0,0 +1,57 @@ +#include "defines.h" + +/*--------------- lmin ---------------*/ + +static t_class *lmin_class; + +typedef struct _lmin +{ + t_object x_obj; + float m_min; + float m_leak; + float m_c_leak; +} t_lmin; + + +static void lmin_perform(t_lmin *x, t_float in) +{ + x->m_min=(in < x->m_min) ? in : x->m_min * x->m_c_leak + in * x->m_leak; + outlet_float(x->x_obj.ob_outlet, x->m_min); +} + +static void lmin_setHalfDecay(t_lmin *x, t_float halfDecayTime) +{ + x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_leak=1.0f-x->m_c_leak; +} + +static void lmin_clear(t_lmin *x) +{ + x->m_min= MAXFLOAT; +} + +static void *lmin_new( t_float halfDecayTime) +{ + t_lmin *x=(t_lmin *)pd_new(lmin_class); + outlet_new(&x->x_obj, gensym("float")); + + lmin_setHalfDecay(x, halfDecayTime); + lmin_clear(x); + return (void *)x; +} + + +void lmin_setup(void) +{ + lmin_class = class_new(gensym("lmin"), + (t_newmethod)lmin_new, 0, + sizeof(t_lmin), + CLASS_DEFAULT, + A_DEFFLOAT, 0); + class_addfloat(lmin_class, (t_method)lmin_perform); + class_addmethod(lmin_class, (t_method)lmin_clear, + gensym("clear"), A_GIMME, NULL); + class_addmethod(lmin_class, (t_method)lmin_setHalfDecay, + gensym("decay"), A_DEFFLOAT, NULL); +} + diff --git a/source/lrange.c b/source/lrange.c new file mode 100644 index 0000000..8f5b296 --- /dev/null +++ b/source/lrange.c @@ -0,0 +1,60 @@ +#include "defines.h" + +/*--------------- lrange ---------------*/ + +static t_class *lrange_class; + +typedef struct _lrange +{ + t_object x_obj; + float m_min; + float m_max; + float m_c_leak; + float m_leak; +} t_lrange; + + +static void lrange_perform(t_lrange *x, t_float in) +{ + x->m_max=(in > x->m_max) ? in : x->m_max * x->m_c_leak + in * x->m_leak; + x->m_min=(in < x->m_min) ? in : x->m_min * x->m_c_leak + in * x->m_leak; + outlet_float(x->x_obj.ob_outlet, x->m_max-x->m_min); +} + +static void lrange_setHalfDecay(t_lrange *x, t_float halfDecayTime) +{ + x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_leak=1.0f-x->m_c_leak; +} + +static void lrange_clear(t_lrange *x) +{ + x->m_max = - MAXFLOAT; + x->m_min = MAXFLOAT; +} + +static void *lrange_new( t_float halfDecayTime) +{ + t_lrange *x=(t_lrange *)pd_new(lrange_class); + outlet_new(&x->x_obj, gensym("float")); + + lrange_setHalfDecay(x, halfDecayTime); + lrange_clear(x); + return (void *)x; +} + + +void lrange_setup(void) +{ + lrange_class = class_new(gensym("lrange"), + (t_newmethod)lrange_new, 0, + sizeof(t_lrange), + CLASS_DEFAULT, + A_DEFFLOAT, 0); + class_addfloat(lrange_class, (t_method)lrange_perform); + class_addmethod(lrange_class, (t_method)lrange_clear, + gensym("clear"), A_GIMME, NULL); + class_addmethod(lrange_class, (t_method)lrange_setHalfDecay, + gensym("decay"), A_DEFFLOAT, NULL); +} + diff --git a/source/lstd.c b/source/lstd.c new file mode 100644 index 0000000..1873bda --- /dev/null +++ b/source/lstd.c @@ -0,0 +1,60 @@ +#include "defines.h" + +/*--------------- lstd ---------------*/ + +static t_class *lstd_class; + +typedef struct _lstd +{ + t_object x_obj; + float m_avg; + float m_sum_squares; + float m_std; + float m_c_leak; + float m_leak; +} t_lstd; + + +static void lstd_perform(t_lstd *x, t_float in) +{ + float tmp=x->m_avg-in; + x->m_avg= x->m_avg * x->m_c_leak + in * x->m_leak; + x->m_sum_squares=x->m_sum_squares * x->m_c_leak + x->m_leak*tmp*tmp; + x->m_std=(float)sqrtf(x->m_sum_squares); + outlet_float(x->x_obj.ob_outlet, x->m_std); +} + +static void lstd_setHalfDecay(t_lstd *x, t_float halfDecayTime) +{ + x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_leak=1.0f-x->m_c_leak; +} + +static void lstd_clear(t_lstd *x) +{ + x->m_sum_squares=0.0f; + x->m_avg=0.0f; +} + +static void *lstd_new( t_float halfDecayTime) +{ + t_lstd *x=(t_lstd *)pd_new(lstd_class); + outlet_new(&x->x_obj, gensym("float")); + + lstd_setHalfDecay(x, halfDecayTime); + return (void *)x; +} + + +void lstd_setup(void) +{ + lstd_class = class_new(gensym("lstd"), + (t_newmethod)lstd_new, 0, + sizeof(t_lstd), + CLASS_DEFAULT, + A_DEFFLOAT, 0); + class_addfloat(lstd_class, (t_method)lstd_perform); + class_addmethod(lstd_class, (t_method)lstd_setHalfDecay, + gensym("decay"), A_DEFFLOAT, NULL); +} + diff --git a/source/prevl.c b/source/prevl.c new file mode 100644 index 0000000..2ba39ce --- /dev/null +++ b/source/prevl.c @@ -0,0 +1,161 @@ +#include "defines.h" + +/*--------------- prevl ---------------*/ + +static t_class *prevl_class; + +typedef struct _prevl +{ + t_object x_obj; + float m_lo; + float m_hi; + int m_buffer_size; + int m_buffer_index; + float *m_buffer; // circular buffer +} t_prevl; + + +static void prevl_perform_float(t_prevl *x, t_float f) +{ + int index; + index=x->m_buffer_index+1; + index=(index==x->m_buffer_size)?0:index; + x->m_buffer_index=index; + x->m_buffer[index]=f; +} + +static void prevl_bang(t_prevl *x) +{ + int lo,hi,n,index,size; + t_atom *ap,*app; + float *buffer, *bp; + + lo=(int)x->m_lo; + hi=(int)x->m_hi; + + n=hi-lo; + size=x->m_buffer_size; + index=x->m_buffer_index; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + app=ap; + buffer=x->m_buffer; + bp=buffer+index-lo; + bp=(bp>=buffer)?bp:bp+size; // wrap + + if (bp-buffer>=n) + { // no wrap-around needed + index=n; + while(index--){ + SETFLOAT(app, *bp--); + app++; + } +// post("not wrapped, app-ap=%i",app-ap); + } + else // need to wrap + { + int ps, nn; + ps = bp-buffer; + nn=n; +// post(" nn=%i",nn); + for(;ps>=0;ps--) // don't we miss one sample in signal??? + { +// post("ps=%i",ps); + SETFLOAT(app, buffer[ps]); + app++; + nn--; + } + ps=size-1; +// post(" nn=%i",nn); + for(;nn>0;nn--) + { +// post("ps=%i",ps); + SETFLOAT(app, buffer[ps--]); + app++; + } + + } + + outlet_list(x->x_obj.ob_outlet,gensym("list"),n,ap); + freebytes(ap, sizeof(t_atom)*n); +} + +static void prevl_clear(t_prevl *x) +{ + int i,s; + float *f; + f=x->m_buffer; + s=x->m_buffer_size; + for (i=0;isize) + { + post("prevl: higher bound cannot be higher than the buffer size..."); + hi=size; + } + if (lo<0) + { + post("prevl: lower bound cannot be negative..."); + lo=0; + } + if (hi<1) + { + post("prevl: higher bound cannot be smaller than one..."); + hi=1; + } + if (hi<=lo) + { + post("prevl: higher bound must be higher than lower bound..."); + lo=hi-1.0f; + } + + freebytes(x->m_buffer, x->m_buffer_size); + + x->m_hi=(float)((int)hi); + x->m_lo=(float)((int)lo); + x->m_buffer_size=(int)size; + x->m_buffer = (float*)getbytes(sizeof(float)*x->m_buffer_size); + prevl_clear(x); + x->m_buffer_index=0; +} + +static void *prevl_new(t_float lo, t_float hi, t_float size) +{ + t_prevl *x=(t_prevl *)pd_new(prevl_class); + outlet_new(&x->x_obj, gensym("list")); + x->m_buffer_size=0; + x->m_buffer=0; + prevl_set(x, lo, hi, size); + + floatinlet_new(&x->x_obj, &x->m_lo); + floatinlet_new(&x->x_obj, &x->m_hi); + + return (void *)x; +} + +static void prevl_free(t_prevl *x) +{ + freebytes(x->m_buffer, x->m_buffer_size); +} + +void prevl_setup(void) +{ + prevl_class = class_new(gensym("prevl"), + (t_newmethod)prevl_new, (t_method)prevl_free, + sizeof(t_prevl), + CLASS_DEFAULT, + A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT,0); + + class_addmethod(prevl_class, (t_method)prevl_clear, gensym("clear"),0); + class_addfloat(prevl_class, (t_method)prevl_perform_float); + class_addbang(prevl_class, (t_method)prevl_bang); +} + diff --git a/source/threshold.c b/source/threshold.c new file mode 100644 index 0000000..2d99e03 --- /dev/null +++ b/source/threshold.c @@ -0,0 +1,112 @@ +/* --------------------- threshold ----------------------------- */ + +#include "defines.h" + +static t_class *threshold_class; + +typedef struct _threshold +{ + t_object x_obj; + t_outlet *x_outlet1; /* bang out for high thresh */ + t_outlet *x_outlet2; /* bang out for low thresh */ + t_clock *x_clock; /* wakeup for message output */ + int x_state; /* 1 = high, 0 = low */ + float x_hithresh; /* value of high threshold */ + float x_lothresh; /* value of low threshold */ + float x_deadwait; /* msec remaining in dead period */ + float x_hideadtime; /* hi dead */ + float x_lodeadtime; /* lo dead */ +} t_threshold; + +static void threshold_tick(t_threshold *x); +static void threshold_set(t_threshold *x, + t_floatarg hithresh, t_floatarg hideadtime, + t_floatarg lothresh, t_floatarg lodeadtime); + +static t_threshold *threshold_new(t_floatarg hithresh, + t_floatarg hideadtime, t_floatarg lothresh, t_floatarg lodeadtime) +{ + t_threshold *x = (t_threshold *) + pd_new(threshold_class); + x->x_state = 0; /* low state */ + x->x_deadwait = 0; /* no dead time */ + x->x_clock = clock_new(x, (t_method)threshold_tick); + x->x_outlet1 = outlet_new(&x->x_obj, gensym("bang")); + x->x_outlet2 = outlet_new(&x->x_obj, gensym("bang")); + threshold_set(x, hithresh, hideadtime, lothresh, lodeadtime); + return (x); +} + + /* "set" message to specify thresholds and dead times */ +static void threshold_set(t_threshold *x, + t_floatarg hithresh, t_floatarg hideadtime, + t_floatarg lothresh, t_floatarg lodeadtime) +{ + if (lothresh > hithresh) + lothresh = hithresh; + x->x_hithresh = hithresh; + x->x_hideadtime = hideadtime; + x->x_lothresh = lothresh; + x->x_lodeadtime = lodeadtime; +} + + /* number in inlet sets state -- note incompatible with JMAX which used + "int" message for this, impossible here because of auto signal conversion */ +static void threshold_ft1(t_threshold *x, t_floatarg f) +{ + x->x_state = (f != 0); + x->x_deadwait = 0; +} + +static void threshold_tick(t_threshold *x) +{ + if (x->x_state) + outlet_bang(x->x_outlet1); + else outlet_bang(x->x_outlet2); +} + +static void threshold_perform(t_threshold *x, t_float in) +{ + if (x->x_deadwait > 0) + x->x_deadwait -= 1; + else if (x->x_state) + { + /* we're high; look for low sample */ + if (in < x->x_lothresh) + { + clock_delay(x->x_clock, 0L); + x->x_state = 0; + x->x_deadwait = x->x_lodeadtime; + } + } + else + { + /* we're low; look for high sample */ + if (in >= x->x_hithresh) + { + clock_delay(x->x_clock, 0L); + x->x_state = 1; + x->x_deadwait = x->x_hideadtime; + } + } +} + + +static void threshold_ff(t_threshold *x) +{ + clock_free(x->x_clock); +} + +void threshold_setup( void) +{ + threshold_class = class_new(gensym("threshold"), + (t_newmethod)threshold_new, (t_method)threshold_ff, + sizeof(t_threshold), 0, + A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); + + class_addfloat(threshold_class, (t_method)threshold_perform); + class_addmethod(threshold_class, (t_method)threshold_set, + gensym("set"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); + class_addmethod(threshold_class, (t_method)threshold_ft1, + gensym("ft1"), A_FLOAT, 0); +} diff --git a/source/vabs.c b/source/vabs.c new file mode 100644 index 0000000..c928c5e --- /dev/null +++ b/source/vabs.c @@ -0,0 +1,48 @@ +#include "defines.h" + +/*--------------- vabs ----------------*/ +/* absolute values of a list of floats */ + + +static t_class *vabs_class; + +typedef struct _vabs +{ + t_object x_obj; +} t_vabs; + + +static void vabs_perform(t_vabs *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + t_atom *ap,*app; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + + for (i = 0; i < argc; i++) + { + float f=atom_getfloat(argv++); + SETFLOAT(app, f>0?f:-f); + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void *vabs_new() +{ + t_vabs *x=(t_vabs *)pd_new(vabs_class); + outlet_new(&x->x_obj, gensym("list")); + return (void *)x; +} + +void vabs_setup(void) +{ + vabs_class = class_new(gensym("vabs"), + (t_newmethod)vabs_new, 0, + sizeof(t_vabs), + CLASS_DEFAULT, + 0); + class_addlist(vabs_class, (t_method)vabs_perform); +} + diff --git a/source/vclip.c b/source/vclip.c new file mode 100644 index 0000000..4a11ef5 --- /dev/null +++ b/source/vclip.c @@ -0,0 +1,58 @@ +#include "defines.h" + +/*--------------- vclip ----------------*/ +/* clips a vector */ + + +static t_class *vclip_class; + +typedef struct _vclip +{ + t_object x_obj; + float m_lo; + float m_hi; +} t_vclip; + + +static void vclip_perform(t_vclip *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + float lo,hi; + t_atom *ap,*app; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + lo=x->m_lo; + hi=x->m_hi; + for (i = 0; i < argc; i++) + { + float f=atom_getfloat(argv++); + SETFLOAT(app, (fhi?hi:f))); + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void *vclip_new(t_float lo, t_float hi) +{ + t_vclip *x=(t_vclip *)pd_new(vclip_class); + + floatinlet_new(&x->x_obj, &x->m_lo); + floatinlet_new(&x->x_obj, &x->m_hi); + + outlet_new(&x->x_obj, gensym("list")); + x->m_hi=hi; + x->m_lo=lo; + return (void *)x; +} + +void vclip_setup(void) +{ + vclip_class = class_new(gensym("vclip"), + (t_newmethod)vclip_new, 0, + sizeof(t_vclip), + CLASS_DEFAULT, + A_DEFFLOAT,A_DEFFLOAT,0); + class_addlist(vclip_class, (t_method)vclip_perform); +} + diff --git a/source/vcog.c b/source/vcog.c new file mode 100644 index 0000000..1dd68a4 --- /dev/null +++ b/source/vcog.c @@ -0,0 +1,43 @@ +#include "defines.h" + +/*--------------- vcog ---------------*/ + +static t_class *vcog_class; + +typedef struct _vcog +{ + t_object x_obj; +} t_vcog; + + +static void vcog_perform(t_vcog *x, t_symbol *s, int argc, t_atom *argv) +{ + float sum=0.f; + float wsum=0.0f; + int i; + for (i = 0; i < argc; i++) + { + float tmp=atom_getfloat(&argv[i]); + sum+= tmp; + wsum+= tmp*i; + } + if (sum!=0.0f) outlet_float(x->x_obj.ob_outlet, 1.0f+(wsum/sum)); +} + +static void *vcog_new( t_float halfDecayTime) +{ + t_vcog *x=(t_vcog *)pd_new(vcog_class); + outlet_new(&x->x_obj, gensym("float")); + return (void *)x; +} + +void vcog_setup(void) +{ + vcog_class = class_new(gensym("vcog"), + (t_newmethod)vcog_new, 0, + sizeof(t_vcog), + CLASS_DEFAULT, + 0); + class_addlist(vcog_class, (t_method)vcog_perform); +} + diff --git a/source/vdbtorms.c b/source/vdbtorms.c new file mode 100644 index 0000000..ab954f6 --- /dev/null +++ b/source/vdbtorms.c @@ -0,0 +1,56 @@ +#include "defines.h" + +/*--------------- vdbtorms ----------------*/ + +static t_class *vdbtorms_class; + +typedef struct _vdbtorms +{ + t_object x_obj; +} t_vdbtorms; + +float dbtorms(float f) +{ + if (f <= 0) + return(0); + else + { + if (f > 485) + f = 485; + } + return (float)(exp((LOGTEN * 0.05) * (f-100.))); +} + +static void vdbtorms_perform(t_vdbtorms *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + t_atom *ap,*app; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + + for (i = 0; i < argc; i++) + { + SETFLOAT(app, dbtorms(atom_getfloat(argv++))); + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void *vdbtorms_new() +{ + t_vdbtorms *x=(t_vdbtorms *)pd_new(vdbtorms_class); + outlet_new(&x->x_obj, gensym("list")); + return (void *)x; +} + +void vdbtorms_setup(void) +{ + vdbtorms_class = class_new(gensym("vdbtorms"), + (t_newmethod)vdbtorms_new, 0, + sizeof(t_vdbtorms), + CLASS_DEFAULT, + 0); + class_addlist(vdbtorms_class, (t_method)vdbtorms_perform); +} + diff --git a/source/vdelta.c b/source/vdelta.c new file mode 100644 index 0000000..cc809db --- /dev/null +++ b/source/vdelta.c @@ -0,0 +1,75 @@ +#include "defines.h" + +/*--------------- vdelta ----------------------------*/ +/* differences between element in succesive vectors */ + +static t_class *vdelta_class; + +typedef struct _vdelta +{ + t_object x_obj; + float m_c_leak; + float m_leak; + float *m_prev; + int m_n; +} t_vdelta; + + +static void vdelta_perform(t_vdelta *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + t_atom *ap,*app; + float *fp; + float m_leak; + float m_c_leak; + m_leak=x->m_leak; + m_c_leak=x->m_c_leak; + + if (argc!=x->m_n) + { + int i; + if (x->m_prev) + freebytes(x->m_prev,x->m_n); + x->m_prev=(float*)getbytes(argc*sizeof(float)); + for(i=0;im_prev[i]=0.0f; + x->m_n=argc; + } + + fp=x->m_prev; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + for (i = 0; i < argc; i++) + { + float f=atom_getfloat(argv++); + SETFLOAT(app, f-*fp); + app++; + *fp++=f; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void *vdelta_new() +{ + t_vdelta *x=(t_vdelta *)pd_new(vdelta_class); + outlet_new(&x->x_obj, gensym("list")); + x->m_n=0; + x->m_prev=0; + return (void *)x; +} + +static void vdelta_free(t_vdelta *x) +{ + freebytes(x->m_prev,x->m_n); +} + +void vdelta_setup(void) +{ + vdelta_class = class_new(gensym("vdelta"), + (t_newmethod)vdelta_new, (t_method)vdelta_free, + sizeof(t_vdelta), + CLASS_DEFAULT, + 0); + class_addlist(vdelta_class, (t_method)vdelta_perform); +} diff --git a/source/vfmod.c b/source/vfmod.c new file mode 100644 index 0000000..7b7d1af --- /dev/null +++ b/source/vfmod.c @@ -0,0 +1,57 @@ +#include "defines.h" + +/*--------------- vfmod ----------------*/ +/* floating point modulo of a vector */ + + +static t_class *vfmod_class; + +typedef struct _vfmod +{ + t_object x_obj; + float m_y; +} t_vfmod; + + +static void vfmod_perform(t_vfmod *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + float y; + t_atom *ap,*app; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + y=x->m_y; + if (y==0.0f) + y=1.0f; + for (i = 0; i < argc; i++) + { + SETFLOAT(app, (float)fmod(atom_getfloat(argv++),y)); + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void *vfmod_new(t_float y) +{ + t_vfmod *x=(t_vfmod *)pd_new(vfmod_class); + + floatinlet_new(&x->x_obj, &x->m_y); + + outlet_new(&x->x_obj, gensym("list")); + if (y==0.0f) + y=1.0f; + x->m_y=y; + return (void *)x; +} + +void vfmod_setup(void) +{ + vfmod_class = class_new(gensym("vfmod"), + (t_newmethod)vfmod_new, 0, + sizeof(t_vfmod), + CLASS_DEFAULT, + A_DEFFLOAT,A_DEFFLOAT,0); + class_addlist(vfmod_class, (t_method)vfmod_perform); +} + diff --git a/source/vftom.c b/source/vftom.c new file mode 100644 index 0000000..6355006 --- /dev/null +++ b/source/vftom.c @@ -0,0 +1,49 @@ +#include "defines.h" + +/*--------------- vftom ----------------*/ + +static t_class *vftom_class; + +typedef struct _vftom +{ + t_object x_obj; +} t_vftom; + +float ftom(float f) +{ + return (float)(f > 0 ? 17.3123405046 * log(.12231220585 * f) : -1500); +} + +static void vftom_perform(t_vftom *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + t_atom *ap,*app; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + + for (i = 0; i < argc; i++) + { + SETFLOAT(app, ftom(atom_getfloat(argv++))); + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void *vftom_new() +{ + t_vftom *x=(t_vftom *)pd_new(vftom_class); + outlet_new(&x->x_obj, gensym("list")); + return (void *)x; +} + +void vftom_setup(void) +{ + vftom_class = class_new(gensym("vftom"), + (t_newmethod)vftom_new, 0, + sizeof(t_vftom), + CLASS_DEFAULT, + 0); + class_addlist(vftom_class, (t_method)vftom_perform); +} + diff --git a/source/vlavg.c b/source/vlavg.c new file mode 100644 index 0000000..1e6ba98 --- /dev/null +++ b/source/vlavg.c @@ -0,0 +1,86 @@ +#include "defines.h" + +/*--------------- vlavg -----------------------*/ +/* leaky average of each element in a list */ +/* arguments: [halfdecay] */ + +static t_class *vlavg_class; + +typedef struct _vlavg +{ + t_object x_obj; + float m_c_leak; + float m_leak; + float *m_avg; + int m_n; +} t_vlavg; + + +static void vlavg_perform(t_vlavg *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + t_atom *ap,*app; + float *fp; + float m_leak; + float m_c_leak; + m_leak=x->m_leak; + m_c_leak=x->m_c_leak; + + if (argc!=x->m_n) + { + int i; + if (x->m_avg) + freebytes(x->m_avg,x->m_n); + x->m_avg=(float*)getbytes(argc*sizeof(float)); + for(i=0;im_avg[i]=0.0f; + x->m_n=argc; + } + + fp=x->m_avg; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + for (i = 0; i < argc; i++) + { + float f=atom_getfloat(argv++); + *fp = *fp * m_c_leak + f * m_leak; + SETFLOAT(app, *fp); + app++; + fp++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void vlavg_setHalfDecay(t_vlavg *x, t_floatarg halfDecayTime) +{ + x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_leak=1.0f-x->m_c_leak; +} + +static void *vlavg_new(t_float halfDecayTime) +{ + t_vlavg *x=(t_vlavg *)pd_new(vlavg_class); + outlet_new(&x->x_obj, gensym("list")); + vlavg_setHalfDecay(x, halfDecayTime); + x->m_n=0; + x->m_avg=0; + return (void *)x; +} + +static void vlavg_free(t_vlavg *x) +{ + freebytes(x->m_avg,x->m_n); +} + +void vlavg_setup(void) +{ + vlavg_class = class_new(gensym("vlavg"), + (t_newmethod)vlavg_new, (t_method)vlavg_free, + sizeof(t_vlavg), + CLASS_DEFAULT, + A_DEFFLOAT, 0); + class_addmethod(vlavg_class, (t_method)vlavg_setHalfDecay, + gensym("decay"), A_DEFFLOAT, NULL); + class_addlist(vlavg_class, (t_method)vlavg_perform); +} diff --git a/source/vlmax.c b/source/vlmax.c new file mode 100644 index 0000000..a566f49 --- /dev/null +++ b/source/vlmax.c @@ -0,0 +1,86 @@ +#include "defines.h" + +/*--------------- vlmax -----------------------*/ +/* leaky maximum of each element in a list */ +/* arguments: [halfdecay] */ + +static t_class *vlmax_class; + +typedef struct _vlmax +{ + t_object x_obj; + float m_c_leak; + float m_leak; + float *m_max; + int m_n; +} t_vlmax; + + +static void vlmax_perform(t_vlmax *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + t_atom *ap,*app; + float *fp; + float m_leak; + float m_c_leak; + m_leak=x->m_leak; + m_c_leak=x->m_c_leak; + + if (argc!=x->m_n) + { + int i; + if (x->m_max) + freebytes(x->m_max,x->m_n); + x->m_max=(float*)getbytes(argc*sizeof(float)); + for(i=0;im_max[i]=0.0f; + x->m_n=argc; + } + + fp=x->m_max; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + for (i = 0; i < argc; i++) + { + float f=atom_getfloat(argv++); + *fp =(f > *fp ) ? f : *fp *m_c_leak + f*m_leak; + SETFLOAT(app, *fp); + app++; + fp++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void vlmax_setHalfDecay(t_vlmax *x, t_floatarg halfDecayTime) +{ + x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_leak=1.0f-x->m_c_leak; +} + +static void *vlmax_new(t_float halfDecayTime) +{ + t_vlmax *x=(t_vlmax *)pd_new(vlmax_class); + outlet_new(&x->x_obj, gensym("list")); + vlmax_setHalfDecay(x, halfDecayTime); + x->m_n=0; + x->m_max=0; + return (void *)x; +} + +static void vlmax_free(t_vlmax *x) +{ + freebytes(x->m_max,x->m_n); +} + +void vlmax_setup(void) +{ + vlmax_class = class_new(gensym("vlmax"), + (t_newmethod)vlmax_new, (t_method)vlmax_free, + sizeof(t_vlmax), + CLASS_DEFAULT, + A_DEFFLOAT, 0); + class_addmethod(vlmax_class, (t_method)vlmax_setHalfDecay, + gensym("decay"), A_DEFFLOAT, NULL); + class_addlist(vlmax_class, (t_method)vlmax_perform); +} diff --git a/source/vlmin.c b/source/vlmin.c new file mode 100644 index 0000000..b839826 --- /dev/null +++ b/source/vlmin.c @@ -0,0 +1,86 @@ +#include "defines.h" + +/*--------------- vlmin -----------------------*/ +/* leaky minimum of each element in a list */ +/* arguments: [halfdecay] */ + +static t_class *vlmin_class; + +typedef struct _vlmin +{ + t_object x_obj; + float m_c_leak; + float m_leak; + float *m_min; + int m_n; +} t_vlmin; + + +static void vlmin_perform(t_vlmin *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + t_atom *ap,*app; + float *fp; + float m_leak; + float m_c_leak; + m_leak=x->m_leak; + m_c_leak=x->m_c_leak; + + if (argc!=x->m_n) + { + int i; + if (x->m_min) + freebytes(x->m_min,x->m_n); + x->m_min=(float*)getbytes(argc*sizeof(float)); + for(i=0;im_min[i]=0.0f; + x->m_n=argc; + } + + fp=x->m_min; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + for (i = 0; i < argc; i++) + { + float f=atom_getfloat(argv++); + *fp =(f < *fp ) ? f : *fp *m_c_leak + f*m_leak; + SETFLOAT(app, *fp); + app++; + fp++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void vlmin_setHalfDecay(t_vlmin *x, t_floatarg halfDecayTime) +{ + x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_leak=1.0f-x->m_c_leak; +} + +static void *vlmin_new(t_float halfDecayTime) +{ + t_vlmin *x=(t_vlmin *)pd_new(vlmin_class); + outlet_new(&x->x_obj, gensym("list")); + vlmin_setHalfDecay(x, halfDecayTime); + x->m_n=0; + x->m_min=0; + return (void *)x; +} + +static void vlmin_free(t_vlmin *x) +{ + freebytes(x->m_min,x->m_n); +} + +void vlmin_setup(void) +{ + vlmin_class = class_new(gensym("vlmin"), + (t_newmethod)vlmin_new, (t_method)vlmin_free, + sizeof(t_vlmin), + CLASS_DEFAULT, + A_DEFFLOAT, 0); + class_addmethod(vlmin_class, (t_method)vlmin_setHalfDecay, + gensym("decay"), A_DEFFLOAT, NULL); + class_addlist(vlmin_class, (t_method)vlmin_perform); +} diff --git a/source/vlrange.c b/source/vlrange.c new file mode 100644 index 0000000..07b383f --- /dev/null +++ b/source/vlrange.c @@ -0,0 +1,99 @@ +#include "defines.h" + +/*--------------- vlrange -----------------------*/ +/* leaky range of each element in a list */ +/* arguments: [halfdecay] */ + +static t_class *vlrange_class; + +typedef struct _vlrange +{ + t_object x_obj; + float m_c_leak; + float m_leak; + float *m_min; + float *m_max; + int m_n; +} t_vlrange; + + +static void vlrange_perform(t_vlrange *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + t_atom *ap,*app; + float *fmin, *fmax; + float m_leak; + float m_c_leak; + m_leak=x->m_leak; + m_c_leak=x->m_c_leak; + + if (argc!=x->m_n) + { + int i; + if (x->m_min) + { + freebytes(x->m_min,x->m_n); + freebytes(x->m_max,x->m_n); + } + x->m_min=(float*)getbytes(argc*sizeof(float)); + x->m_max=(float*)getbytes(argc*sizeof(float)); + for(i=0;im_min[i]=0.0f; + x->m_max[i]=0.0f; + } + x->m_n=argc; + } + + fmin=x->m_min; + fmax=x->m_max; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + for (i = 0; i < argc; i++) + { + float f=atom_getfloat(argv++); + *fmax =(f > *fmax ) ? f : *fmax *m_c_leak + f*m_leak; + *fmin =(f < *fmin ) ? f : *fmin *m_c_leak + f*m_leak; + SETFLOAT(app, *fmax-*fmin); + app++; + fmax++; + fmin++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void vlrange_setHalfDecay(t_vlrange *x, t_floatarg halfDecayTime) +{ + x->m_c_leak=(float)powf(.5,(1.0f/halfDecayTime)); + x->m_leak=1.0f-x->m_c_leak; +} + +static void *vlrange_new(t_float halfDecayTime) +{ + t_vlrange *x=(t_vlrange *)pd_new(vlrange_class); + outlet_new(&x->x_obj, gensym("list")); + vlrange_setHalfDecay(x, halfDecayTime); + x->m_n=0; + x->m_min=0; + x->m_max=0; + return (void *)x; +} + +static void vlrange_free(t_vlrange *x) +{ + freebytes(x->m_max,x->m_n); + freebytes(x->m_min,x->m_n); +} + +void vlrange_setup(void) +{ + vlrange_class = class_new(gensym("vlrange"), + (t_newmethod)vlrange_new, (t_method)vlrange_free, + sizeof(t_vlrange), + CLASS_DEFAULT, + A_DEFFLOAT, 0); + class_addmethod(vlrange_class, (t_method)vlrange_setHalfDecay, + gensym("decay"), A_DEFFLOAT, NULL); + class_addlist(vlrange_class, (t_method)vlrange_perform); +} diff --git a/source/vmax.c b/source/vmax.c new file mode 100644 index 0000000..ac56423 --- /dev/null +++ b/source/vmax.c @@ -0,0 +1,52 @@ +#include "defines.h" + +/*--------------- vmax ---------------*/ +/* maximum value in a list of float + and its location (index) +*/ + +static t_class *vmax_class; + +typedef struct _vmax +{ + t_object x_obj; + t_outlet *m_out_maxi; +} t_vmax; + + +static void vmax_perform(t_vmax *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + int maxi; + float max=-MAXFLOAT; + for (i = 0; i < argc; i++) + { + float f=atom_getfloat(&argv[i]); + if (f>max) + { + max=f; + maxi=i; + } + } + outlet_float(x->x_obj.ob_outlet, max); + outlet_float(x->m_out_maxi, (float)(maxi+1)); +} + +static void *vmax_new( t_float halfDecayTime) +{ + t_vmax *x=(t_vmax *)pd_new(vmax_class); + outlet_new(&x->x_obj, gensym("float")); + x->m_out_maxi=outlet_new(&x->x_obj, gensym("float")); + return (void *)x; +} + +void vmax_setup(void) +{ + vmax_class = class_new(gensym("vmax"), + (t_newmethod)vmax_new, 0, + sizeof(t_vmax), + CLASS_DEFAULT, + 0); + class_addlist(vmax_class, (t_method)vmax_perform); +} + diff --git a/source/vmin.c b/source/vmin.c new file mode 100644 index 0000000..a0b578e --- /dev/null +++ b/source/vmin.c @@ -0,0 +1,52 @@ +#include "defines.h" + +/*--------------- vmin ---------------*/ +/* maximum value in a list of float + and its location (index) +*/ + +static t_class *vmin_class; + +typedef struct _vmin +{ + t_object x_obj; + t_outlet *m_out_maxi; +} t_vmin; + + +static void vmin_perform(t_vmin *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + int mini; + float min=MAXFLOAT; + for (i = 0; i < argc; i++) + { + float f=atom_getfloat(&argv[i]); + if (fx_obj.ob_outlet, min); + outlet_float(x->m_out_maxi, (float)(mini+1)); +} + +static void *vmin_new( t_float halfDecayTime) +{ + t_vmin *x=(t_vmin *)pd_new(vmin_class); + outlet_new(&x->x_obj, gensym("float")); + x->m_out_maxi=outlet_new(&x->x_obj, gensym("float")); + return (void *)x; +} + +void vmin_setup(void) +{ + vmin_class = class_new(gensym("vmin"), + (t_newmethod)vmin_new, 0, + sizeof(t_vmin), + CLASS_DEFAULT, + 0); + class_addlist(vmin_class, (t_method)vmin_perform); +} + diff --git a/source/vmtof.c b/source/vmtof.c new file mode 100644 index 0000000..828dcb6 --- /dev/null +++ b/source/vmtof.c @@ -0,0 +1,51 @@ +#include "defines.h" + +/*--------------- vmtof ----------------*/ + +static t_class *vmtof_class; + +typedef struct _vmtof +{ + t_object x_obj; +} t_vmtof; + +float mtof(float f) +{ + if (f <= -1500) return(0); + else if (f > 1499) return(mtof(1499)); + else return (float)(8.17579891564 * exp(.0577622650 * f)); +} + +static void vmtof_perform(t_vmtof *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + t_atom *ap,*app; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + + for (i = 0; i < argc; i++) + { + SETFLOAT(app, mtof(atom_getfloat(argv++))); + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void *vmtof_new() +{ + t_vmtof *x=(t_vmtof *)pd_new(vmtof_class); + outlet_new(&x->x_obj, gensym("list")); + return (void *)x; +} + +void vmtof_setup(void) +{ + vmtof_class = class_new(gensym("vmtof"), + (t_newmethod)vmtof_new, 0, + sizeof(t_vmtof), + CLASS_DEFAULT, + 0); + class_addlist(vmtof_class, (t_method)vmtof_perform); +} + diff --git a/source/vnmax.c b/source/vnmax.c new file mode 100644 index 0000000..7003f6d --- /dev/null +++ b/source/vnmax.c @@ -0,0 +1,55 @@ +#include "defines.h" + +/*--------------- vnmax ---------------*/ +/* maximum n values in a list of float + and their locations (indices) +*/ + +//// UNCOMPLETE + + +static t_class *vnmax_class; + +typedef struct _vnmax +{ + t_object x_obj; + t_outlet *m_out_maxi; +} t_vnmax; + + +static void vnmax_perform(t_vnmax *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + int maxi; + float max=-MAXFLOAT; + for (i = 0; i < argc; i++) + { + float f=atom_getfloat(&argv[i]); + if (f>max) + { + max=f; + maxi=i; + } + } + outlet_float(x->x_obj.ob_outlet, max); + outlet_float(x->m_out_maxi, (float)(maxi+1)); +} + +static void *vnmax_new( t_float halfDecayTime) +{ + t_vnmax *x=(t_vnmax *)pd_new(vnmax_class); + outlet_new(&x->x_obj, gensym("list")); + x->m_out_maxi=outlet_new(&x->x_obj, gensym("list")); + return (void *)x; +} + +void vnmax_setup(void) +{ + vnmax_class = class_new(gensym("vnmax"), + (t_newmethod)vnmax_new, 0, + sizeof(t_vnmax), + CLASS_DEFAULT, + 0); + class_addlist(vnmax_class, (t_method)vnmax_perform); +} + diff --git a/source/vpow.c b/source/vpow.c new file mode 100644 index 0000000..6859859 --- /dev/null +++ b/source/vpow.c @@ -0,0 +1,60 @@ +#include "defines.h" + +/*--------------- vpow ----------------*/ + +static t_class *vpow_class; + +typedef struct _vpow +{ + t_object x_obj; + float m_y; +} t_vpow; + + +static void vpow_perform(t_vpow *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + float y; + t_atom *ap,*app; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + y=x->m_y; + if (y==0.0f) + y=1.0f; + for (i = 0; i < argc; i++) + { + float x=atom_getfloat(argv++); + if (x>0) + x=(float)powf(x,y); + else + x=-1000.; + SETFLOAT(app, x); + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void *vpow_new(t_float y) +{ + t_vpow *x=(t_vpow *)pd_new(vpow_class); + + floatinlet_new(&x->x_obj, &x->m_y); + + outlet_new(&x->x_obj, gensym("list")); + if (y==0.0f) + y=1.0f; + x->m_y=y; + return (void *)x; +} + +void vpow_setup(void) +{ + vpow_class = class_new(gensym("vpow"), + (t_newmethod)vpow_new, 0, + sizeof(t_vpow), + CLASS_DEFAULT, + A_DEFFLOAT,A_DEFFLOAT,0); + class_addlist(vpow_class, (t_method)vpow_perform); +} + diff --git a/source/vrms.c b/source/vrms.c new file mode 100644 index 0000000..52b8d6d --- /dev/null +++ b/source/vrms.c @@ -0,0 +1,41 @@ +#include "defines.h" + +/*--------------- vrms ---------------*/ + +static t_class *vrms_class; + +typedef struct _vrms +{ + t_object x_obj; +} t_vrms; + + +static void vrms_perform(t_vrms *x, t_symbol *s, int argc, t_atom *argv) +{ + float sum=0.f; + int i; + for (i = 0; i < argc; i++) + { + float tmp=atom_getfloat(&argv[i]); + sum+= tmp*tmp; + } + outlet_float(x->x_obj.ob_outlet, (float)sqrtf(sum/argc)); +} + +static void *vrms_new( t_float halfDecayTime) +{ + t_vrms *x=(t_vrms *)pd_new(vrms_class); + outlet_new(&x->x_obj, gensym("float")); + return (void *)x; +} + +void vrms_setup(void) +{ + vrms_class = class_new(gensym("vrms"), + (t_newmethod)vrms_new, 0, + sizeof(t_vrms), + CLASS_DEFAULT, + 0); + class_addlist(vrms_class, (t_method)vrms_perform); +} + diff --git a/source/vrmstodb.c b/source/vrmstodb.c new file mode 100644 index 0000000..d375bf9 --- /dev/null +++ b/source/vrmstodb.c @@ -0,0 +1,54 @@ +#include "defines.h" + +/*--------------- vrmstodb ----------------*/ + +static t_class *vrmstodb_class; + +typedef struct _vrmstodb +{ + t_object x_obj; +} t_vrmstodb; + +float rmstodb(float f) +{ + if (f <= 0) return (0); + else + { + float val = (float)(100 + 20./LOGTEN * log(f)); + return (val < 0 ? 0 : val); + } +} + +static void vrmstodb_perform(t_vrmstodb *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + t_atom *ap,*app; + ap = (t_atom *)getbytes(sizeof(t_atom)*argc); + app=ap; + + for (i = 0; i < argc; i++) + { + SETFLOAT(app, rmstodb(atom_getfloat(argv++))); + app++; + } + outlet_list(x->x_obj.ob_outlet,gensym("list"),argc,ap); + freebytes(ap,argc); +} + +static void *vrmstodb_new() +{ + t_vrmstodb *x=(t_vrmstodb *)pd_new(vrmstodb_class); + outlet_new(&x->x_obj, gensym("list")); + return (void *)x; +} + +void vrmstodb_setup(void) +{ + vrmstodb_class = class_new(gensym("vrmstodb"), + (t_newmethod)vrmstodb_new, 0, + sizeof(t_vrmstodb), + CLASS_DEFAULT, + 0); + class_addlist(vrmstodb_class, (t_method)vrmstodb_perform); +} + diff --git a/source/vstd.c b/source/vstd.c new file mode 100644 index 0000000..538cb94 --- /dev/null +++ b/source/vstd.c @@ -0,0 +1,45 @@ +#include "defines.h" + +/*--------------- vstd ---------------*/ + +static t_class *vstd_class; + +typedef struct _vstd +{ + t_object x_obj; +} t_vstd; + + +static void vstd_perform(t_vstd *x, t_symbol *s, int argc, t_atom *argv) +{ + float sumsq=0.0f; + float sum=0.0f; + int i; + for (i = 0; i < argc; i++) + { + float tmp=atom_getfloat(&argv[i]); + sumsq+= tmp*tmp; + sum+=tmp; + } + sumsq/=argc; + sum/=argc; + outlet_float(x->x_obj.ob_outlet, (float)sqrtf(sumsq-sum*sum)); +} + +static void *vstd_new( t_float halfDecayTime) +{ + t_vstd *x=(t_vstd *)pd_new(vstd_class); + outlet_new(&x->x_obj, gensym("float")); + return (void *)x; +} + +void vstd_setup(void) +{ + vstd_class = class_new(gensym("vstd"), + (t_newmethod)vstd_new, 0, + sizeof(t_vstd), + CLASS_DEFAULT, + 0); + class_addlist(vstd_class, (t_method)vstd_perform); +} + diff --git a/source/vsum.c b/source/vsum.c new file mode 100644 index 0000000..dd49f4c --- /dev/null +++ b/source/vsum.c @@ -0,0 +1,40 @@ +#include "defines.h" + +/*--------------- vsum ---------------*/ + +static t_class *vsum_class; + +typedef struct _vsum +{ + t_object x_obj; +} t_vsum; + + +static void vsum_perform(t_vsum *x, t_symbol *s, int argc, t_atom *argv) +{ + float sum=0.f; + int i; + for (i = 0; i < argc; i++) + { + sum+= atom_getfloat(&argv[i]); + } + outlet_float(x->x_obj.ob_outlet, sum); +} + +static void *vsum_new() +{ + t_vsum *x=(t_vsum *)pd_new(vsum_class); + outlet_new(&x->x_obj, gensym("float")); + return (void *)x; +} + +void vsum_setup(void) +{ + vsum_class = class_new(gensym("vsum"), + (t_newmethod)vsum_new, 0, + sizeof(t_vsum), + CLASS_DEFAULT, + 0); + class_addlist(vsum_class, (t_method)vsum_perform); +} + diff --git a/source/vthreshold.c b/source/vthreshold.c new file mode 100644 index 0000000..106cf72 --- /dev/null +++ b/source/vthreshold.c @@ -0,0 +1,106 @@ +/* --------------------- vthreshold ----------------------------- */ + +#include "defines.h" +#include "memory.h" + +static t_class *vthreshold_class; + +typedef struct _vthreshold +{ + t_object x_obj; + t_outlet *x_outlet1; /* bang out for high thresh */ + t_outlet *x_outlet2; /* bang out for low thresh */ + int *x_state; /* 1 = high, 0 = low */ + int x_n; + float x_hithresh; /* value of high vthreshold */ + float x_lothresh; /* value of low vthreshold */ + float x_hideadtime; /* hi dead */ + float x_lodeadtime; /* lo dead */ +} t_vthreshold; + + /* "set" message to specify vthresholds and dead times */ +static void vthreshold_set(t_vthreshold *x, + t_floatarg hithresh, t_floatarg hideadtime, + t_floatarg lothresh, t_floatarg lodeadtime, + t_floatarg nf) +{ + if (lothresh > hithresh) + lothresh = hithresh; + x->x_hithresh = hithresh; + x->x_hideadtime = hideadtime; + x->x_lothresh = lothresh; + x->x_lodeadtime = lodeadtime; + freebytes(x->x_state,x->x_n); + x->x_n=(int)nf; + x->x_state = (int *)getbytes(sizeof(int)*x->x_n); + memset(x->x_state , 0, x->x_n); +} + +static t_vthreshold *vthreshold_new(t_floatarg hithresh, + t_floatarg hideadtime, t_floatarg lothresh, t_floatarg lodeadtime, t_floatarg n) +{ + t_vthreshold *x = (t_vthreshold *) + pd_new(vthreshold_class); + x->x_state = 0; /* low state */ + x->x_outlet1 = outlet_new(&x->x_obj, gensym("float")); + x->x_outlet2 = outlet_new(&x->x_obj, gensym("float")); + vthreshold_set(x, hithresh, hideadtime, lothresh, lodeadtime, n); + return (x); +} + +static void vthreshold_free(t_vthreshold *x) +{ + freebytes(x->x_state,x->x_n); +} + +static void vthreshold_perform(t_vthreshold *x, t_symbol *s, int argc, t_atom *argv) +{ + int i; + int *state; + + state=x->x_state; + if (argc>x->x_n) argc=x->x_n; + for (i=0;ix->x_hithresh) + { + outlet_float(x->x_outlet1, (float)i); // on + *state=1; + } + } + else + { + if (fx_lothresh) + { + outlet_float(x->x_outlet2, (float)i); // off + *state=-1; + } + } + state++; + } +} + + +static void vthreshold_ff(t_vthreshold *x) +{ + freebytes(x->x_state,x->x_n); +} + +void vthreshold_setup( void) +{ + vthreshold_class = class_new(gensym("vthreshold"), + (t_newmethod)vthreshold_new, (t_method)vthreshold_free, + sizeof(t_vthreshold), 0, + A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); + + class_addlist(vthreshold_class, (t_method)vthreshold_perform); + class_addmethod(vthreshold_class, (t_method)vthreshold_set, + gensym("set"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); +// class_addmethod(vthreshold_class, (t_method)vthreshold_ft1, +// gensym("ft1"), A_FLOAT, 0); +} diff --git a/source/vvconv.c b/source/vvconv.c new file mode 100644 index 0000000..5541705 --- /dev/null +++ b/source/vvconv.c @@ -0,0 +1,151 @@ +#include "defines.h" + +/*--------------- vvconv ---------------*/ +/* vector convolution +*/ + +static t_class *vvconv_class; +static t_class *vvconv_scal_class; + +typedef struct _vvconv +{ + t_object x_obj; + + t_int n1, n2; + + t_float *buf1, *buf2; + + t_float f; +} t_vvconv; + + +static void vvconv_lst2(t_vvconv *x, t_symbol *s, int argc, t_atom *argv) +{ + t_float *fp; + if (x->n2 != argc) { + freebytes(x->buf2, x->n2 * sizeof(t_float)); + x->n2 = argc; + x->buf2=(t_float *)getbytes(sizeof(t_float)*x->n2); + }; + fp = x->buf2; + while(argc--)*fp++=atom_getfloat(argv++); +} + +static void vvconv_lst(t_vvconv *x, t_symbol *s, int argc, t_atom *argv) +{ + t_float *fp; + t_atom *ap; + int n; + + if (argc){ + if (x->n1 != argc) { + freebytes(x->buf1, x->n1 * sizeof(t_float)); + x->n1 = argc; + x->buf1=(t_float *)getbytes(sizeof(t_float)*x->n1); + }; + fp = x->buf1; + while(argc--)*fp++=atom_getfloat(argv++); + } + + if (x->n1*x->n2==1){ + outlet_float(x->x_obj.ob_outlet, *x->buf1**x->buf2); + return; + } + if (x->n1==1){ + t_atom *a; + int i = x->n2; + t_float f = *x->buf1; + fp = x->buf2; + n = x->n2; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + a = ap; + while(i--){ + SETFLOAT(a, *fp++*f); + a++; + } + } else if (x->n2==1){ + t_float f = *x->buf2; + t_atom *a; + int i = x->n1; + n = x->n1; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + a = ap; + fp = x->buf1; + while(i--){ + SETFLOAT(a, *fp++*f); + a++; + } + } else { + t_atom *a; + int i,j,n1,n2; + t_float *f; + t_float *g; + t_float *fp2=x->buf2; + fp = x->buf1; + n1=x->n1; + n2=x->n2; + n = n1 + n2 - 1; + f = (t_float *)getbytes(sizeof(t_float)*n); + g=f; + for(i=0;ix_obj.ob_outlet, gensym("list"), n, ap); + freebytes(ap, sizeof(t_atom)*n); +} +static void vvconv_free(t_vvconv *x) +{ + freebytes(x->buf1, sizeof(t_float)*x->n1); + freebytes(x->buf2, sizeof(t_float)*x->n2); +} + +static void *vvconv_new(t_symbol *s, int argc, t_atom *argv) +{ + t_vvconv *x; + + if (argc-1){ + x = (t_vvconv *)pd_new(vvconv_class); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("list"), gensym("")); + } else x = (t_vvconv *)pd_new(vvconv_scal_class); + + outlet_new(&x->x_obj, 0); + + x->n1 =1; + x->buf1 =(t_float*)getbytes(sizeof(t_float)); + *x->buf1=0; + + if (argc)vvconv_lst2(x, gensym("list"), argc, argv); + else { + x->n2 =1; + x->buf2 =(t_float*)getbytes(sizeof(t_float)); + *x->buf2=0; + } + + if (argc==1)floatinlet_new(&x->x_obj, x->buf2); + + return (x); +} + +void vvconv_setup(void) +{ + vvconv_class = class_new(gensym("vvconv"), (t_newmethod)vvconv_new, + (t_method)vvconv_free, sizeof(t_vvconv), 0, A_GIMME, 0); + class_addlist(vvconv_class, vvconv_lst); + class_addmethod (vvconv_class, (t_method)vvconv_lst2, gensym(""), A_GIMME, 0); + vvconv_scal_class = class_new(gensym("vv+"), 0, (t_method)vvconv_free, + sizeof(t_vvconv), 0, 0); + class_addlist(vvconv_scal_class, vvconv_lst); +} diff --git a/source/vvminus.c b/source/vvminus.c new file mode 100644 index 0000000..b6a8e1a --- /dev/null +++ b/source/vvminus.c @@ -0,0 +1,141 @@ +#include "defines.h" + +/*--------------- vvminus ---------------*/ +/* vector substraction +*/ + +static t_class *vvminus_class; +static t_class *vvminus_scal_class; + +typedef struct _vvminus +{ + t_object x_obj; + + t_int n1, n2; + + t_float *buf1, *buf2; + + t_float f; +} t_vvminus; + + +static void vvminus_lst2(t_vvminus *x, t_symbol *s, int argc, t_atom *argv) +{ + t_float *fp; + if (x->n2 != argc) { + freebytes(x->buf2, x->n2 * sizeof(t_float)); + x->n2 = argc; + x->buf2=(t_float *)getbytes(sizeof(t_float)*x->n2); + }; + fp = x->buf2; + while(argc--)*fp++=atom_getfloat(argv++); +} + +static void vvminus_lst(t_vvminus *x, t_symbol *s, int argc, t_atom *argv) +{ + t_float *fp; + t_atom *ap; + int n; + + if (argc){ + if (x->n1 != argc) { + freebytes(x->buf1, x->n1 * sizeof(t_float)); + x->n1 = argc; + x->buf1=(t_float *)getbytes(sizeof(t_float)*x->n1); + }; + fp = x->buf1; + while(argc--)*fp++=atom_getfloat(argv++); + } + + if (x->n1*x->n2==1){ + outlet_float(x->x_obj.ob_outlet, *x->buf1-*x->buf2); + return; + } + if (x->n1==1){ + t_atom *a; + int i = x->n2; + t_float f = *x->buf1; + fp = x->buf2; + n = x->n2; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + a = ap; + while(i--){ + SETFLOAT(a, f-*fp++); + a++; + } + } else if (x->n2==1){ + t_float f = *x->buf2; + t_atom *a; + int i = x->n1; + n = x->n1; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + a = ap; + fp = x->buf1; + while(i--){ + SETFLOAT(a, *fp++-f); + a++; + } + } else { + t_atom *a; + int i; + t_float *fp2=x->buf2; + fp = x->buf1; + n = x->n1; + if (x->n1!=x->n2){ + post("scalar multiplication: truncating vectors to the same length"); + if (x->n2n1)n=x->n2; + } + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + a = ap; + i=n; + while(i--){ + SETFLOAT(a, *fp++-*fp2++); + a++; + } + } + outlet_list(x->x_obj.ob_outlet, gensym("list"), n, ap); + freebytes(ap, sizeof(t_atom)*n); +} +static void vvminus_free(t_vvminus *x) +{ + freebytes(x->buf1, sizeof(t_float)*x->n1); + freebytes(x->buf2, sizeof(t_float)*x->n2); +} + +static void *vvminus_new(t_symbol *s, int argc, t_atom *argv) +{ + t_vvminus *x; + + if (argc-1){ + x = (t_vvminus *)pd_new(vvminus_class); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("list"), gensym("")); + } else x = (t_vvminus *)pd_new(vvminus_scal_class); + + outlet_new(&x->x_obj, 0); + + x->n1 =1; + x->buf1 =(t_float*)getbytes(sizeof(t_float)); + *x->buf1=0; + + if (argc)vvminus_lst2(x, gensym("list"), argc, argv); + else { + x->n2 =1; + x->buf2 =(t_float*)getbytes(sizeof(t_float)); + *x->buf2=0; + } + + if (argc==1)floatinlet_new(&x->x_obj, x->buf2); + + return (x); +} + +void vvminus_setup(void) +{ + vvminus_class = class_new(gensym("vv-"), (t_newmethod)vvminus_new, + (t_method)vvminus_free, sizeof(t_vvminus), 0, A_GIMME, 0); + class_addlist(vvminus_class, vvminus_lst); + class_addmethod (vvminus_class, (t_method)vvminus_lst2, gensym(""), A_GIMME, 0); + vvminus_scal_class = class_new(gensym("vv-"), 0, (t_method)vvminus_free, + sizeof(t_vvminus), 0, 0); + class_addlist(vvminus_scal_class, vvminus_lst); +} diff --git a/source/vvplus.c b/source/vvplus.c new file mode 100644 index 0000000..e2b323c --- /dev/null +++ b/source/vvplus.c @@ -0,0 +1,141 @@ +#include "defines.h" + +/*--------------- vvplus ---------------*/ +/* vector addition +*/ + +static t_class *vvplus_class; +static t_class *vvplus_scal_class; + +typedef struct _vvplus +{ + t_object x_obj; + + t_int n1, n2; + + t_float *buf1, *buf2; + + t_float f; +} t_vvplus; + + +static void vvplus_lst2(t_vvplus *x, t_symbol *s, int argc, t_atom *argv) +{ + t_float *fp; + if (x->n2 != argc) { + freebytes(x->buf2, x->n2 * sizeof(t_float)); + x->n2 = argc; + x->buf2=(t_float *)getbytes(sizeof(t_float)*x->n2); + }; + fp = x->buf2; + while(argc--)*fp++=atom_getfloat(argv++); +} + +static void vvplus_lst(t_vvplus *x, t_symbol *s, int argc, t_atom *argv) +{ + t_float *fp; + t_atom *ap; + int n; + + if (argc){ + if (x->n1 != argc) { + freebytes(x->buf1, x->n1 * sizeof(t_float)); + x->n1 = argc; + x->buf1=(t_float *)getbytes(sizeof(t_float)*x->n1); + }; + fp = x->buf1; + while(argc--)*fp++=atom_getfloat(argv++); + } + + if (x->n1*x->n2==1){ + outlet_float(x->x_obj.ob_outlet, *x->buf1+*x->buf2); + return; + } + if (x->n1==1){ + t_atom *a; + int i = x->n2; + t_float f = *x->buf1; + fp = x->buf2; + n = x->n2; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + a = ap; + while(i--){ + SETFLOAT(a, *fp+++f); + a++; + } + } else if (x->n2==1){ + t_float f = *x->buf2; + t_atom *a; + int i = x->n1; + n = x->n1; + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + a = ap; + fp = x->buf1; + while(i--){ + SETFLOAT(a, *fp+++f); + a++; + } + } else { + t_atom *a; + int i; + t_float *fp2=x->buf2; + fp = x->buf1; + n = x->n1; + if (x->n1!=x->n2){ + post("scalar multiplication: truncating vectors to the same length"); + if (x->n2n1)n=x->n2; + } + ap = (t_atom *)getbytes(sizeof(t_atom)*n); + a = ap; + i=n; + while(i--){ + SETFLOAT(a, *fp+++*fp2++); + a++; + } + } + outlet_list(x->x_obj.ob_outlet, gensym("list"), n, ap); + freebytes(ap, sizeof(t_atom)*n); +} +static void vvplus_free(t_vvplus *x) +{ + freebytes(x->buf1, sizeof(t_float)*x->n1); + freebytes(x->buf2, sizeof(t_float)*x->n2); +} + +static void *vvplus_new(t_symbol *s, int argc, t_atom *argv) +{ + t_vvplus *x; + + if (argc-1){ + x = (t_vvplus *)pd_new(vvplus_class); + inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("list"), gensym("")); + } else x = (t_vvplus *)pd_new(vvplus_scal_class); + + outlet_new(&x->x_obj, 0); + + x->n1 =1; + x->buf1 =(t_float*)getbytes(sizeof(t_float)); + *x->buf1=0; + + if (argc)vvplus_lst2(x, gensym("list"), argc, argv); + else { + x->n2 =1; + x->buf2 =(t_float*)getbytes(sizeof(t_float)); + *x->buf2=0; + } + + if (argc==1)floatinlet_new(&x->x_obj, x->buf2); + + return (x); +} + +void vvplus_setup(void) +{ + vvplus_class = class_new(gensym("vv+"), (t_newmethod)vvplus_new, + (t_method)vvplus_free, sizeof(t_vvplus), 0, A_GIMME, 0); + class_addlist(vvplus_class, vvplus_lst); + class_addmethod (vvplus_class, (t_method)vvplus_lst2, gensym(""), A_GIMME, 0); + vvplus_scal_class = class_new(gensym("vv+"), 0, (t_method)vvplus_free, + sizeof(t_vvplus), 0, 0); + class_addlist(vvplus_scal_class, vvplus_lst); +} -- cgit v1.2.1