From e728a5bc3db296b4b67c2d3e5b56558c42c566a8 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Mon, 21 Jun 2004 14:08:57 +0000 Subject: "" svn path=/trunk/; revision=1826 --- externals/grill/xsample/maxmsp/xsample.help | Bin 18871 -> 18907 bytes externals/grill/xsample/pd/xgroove~.pd | 77 ++++---------- externals/grill/xsample/pd/xrecord~.pd | 158 +++++++++++++++------------- externals/grill/xsample/readme.txt | 7 ++ externals/grill/xsample/source/groove.cpp | 67 +++++++++--- externals/grill/xsample/source/main.cpp | 98 ++++++++--------- externals/grill/xsample/source/main.h | 2 +- externals/grill/xsample/xsample.cw | Bin 399047 -> 399047 bytes 8 files changed, 218 insertions(+), 191 deletions(-) (limited to 'externals/grill/xsample') diff --git a/externals/grill/xsample/maxmsp/xsample.help b/externals/grill/xsample/maxmsp/xsample.help index bced9b5c..47fae9fb 100755 Binary files a/externals/grill/xsample/maxmsp/xsample.help and b/externals/grill/xsample/maxmsp/xsample.help differ diff --git a/externals/grill/xsample/pd/xgroove~.pd b/externals/grill/xsample/pd/xgroove~.pd index a12122af..86d879b5 100644 --- a/externals/grill/xsample/pd/xgroove~.pd +++ b/externals/grill/xsample/pd/xgroove~.pd @@ -1,55 +1,14 @@ -#N canvas 312 42 925 590 12; +#N canvas 69 62 929 594 12; #X obj 215 253 hsl 128 15 0.001 3 1 1 empty empty speed 0 -8 0 10 -225271 --1 -1 9500 1; +-1 -1 10800 1; #X floatatom 212 271 8 0 0 0 - - -; #X msg 603 169 loop \$1; #X obj 28 72 bng 15 250 50 0 empty empty empty 20 8 0 8 -258699 -1 -1; #X msg 27 92 stop; #N canvas 0 0 450 300 graph7 0; -#X array \$0-buf 300 float 1; -#A 0 -0.839747 -0.754139 -0.653263 -0.539126 -0.414078 -0.280635 -0.141504 -0.000492073 0.142479 0.281579 0.414975 0.539954 0.654004 0.754786 0.840279 -0.908753 0.958789 0.989418 0.999981 0.990281 0.960531 0.911285 0.843594 -0.758801 0.658626 0.545119 0.420547 0.287463 0.148552 0.00662906 -0.135428 --0.274738 -0.408483 -0.533953 -0.648592 -0.750102 -0.836398 -0.905748 --0.956757 -0.988351 -0.999937 -0.991251 -0.962473 -0.914213 -0.847394 --0.763422 -0.663977 -0.55107 -0.427008 -0.29428 -0.155594 -0.013755 -0.128363 0.267882 0.401968 0.527909 0.643161 0.745362 0.832475 0.902708 -0.954646 0.987258 0.999832 0.992166 0.964387 0.917059 0.851166 0.767999 -0.669283 0.557004 0.43343 0.301082 0.162624 0.0208751 -0.121299 -0.261011 --0.39544 -0.521849 -0.637684 -0.740608 -0.828501 -0.899623 -0.952507 --0.986084 -0.999701 -0.993024 -0.966246 -0.919884 -0.854871 -0.772553 --0.674559 -0.562905 -0.439846 -0.307865 -0.169653 -0.0279992 0.114221 -0.254129 0.38888 0.515759 0.632181 0.73579 0.824504 0.896483 0.950313 -0.984882 0.999483 0.993853 0.968051 0.92265 0.858553 0.777044 0.679806 -0.568776 0.446226 0.314637 0.176665 0.0351171 -0.107144 -0.247232 -0.382316 --0.509641 -0.626648 -0.730953 -0.82044 -0.89332 -0.948068 -0.983621 --0.999242 -0.9946 -0.969825 -0.925372 -0.862179 -0.781519 -0.685006 --0.574627 -0.452593 -0.32139 -0.183677 -0.0422376 0.100056 0.240322 -0.375716 0.503506 0.621075 0.72607 0.816351 0.890079 0.945791 0.982309 -0.998936 0.995323 0.971523 0.928057 0.865764 0.785935 0.690186 0.580434 -0.458934 0.328126 0.19067 0.0493521 -0.0929673 -0.233403 -0.369109 --0.497332 -0.615488 -0.721152 -0.812215 -0.886819 -0.94344 -0.980963 --0.998583 -0.995978 -0.973199 -0.930676 -0.869315 -0.790322 -0.695317 --0.586232 -0.465249 -0.33485 -0.197662 -0.0564676 0.0858711 0.226467 -0.362476 0.49114 0.609846 0.716207 0.808035 0.883498 0.941064 0.979541 -0.99819 0.99659 0.974801 0.933271 0.872803 0.794669 0.70042 0.591977 -0.471549 0.341549 0.204637 0.0635763 -0.0787726 -0.219528 -0.355829 --0.484923 -0.604193 -0.711208 -0.803828 -0.88014 -0.938624 -0.978096 --0.997725 -0.997158 -0.976368 -0.935795 -0.876273 -0.798968 -0.70549 --0.597709 -0.477813 -0.348244 -0.211606 -0.0706864 0.0716672 0.212567 -0.349164 0.478677 0.598495 0.706189 0.799558 0.876742 0.936143 0.976578 -0.997236 0.997659 0.977886 0.938285 0.879669 0.803244 0.710514 0.603402 -0.48406 0.354905 0.218564 0.0777877 -0.0645622 -0.205605 -0.342478 --0.472418 -0.592775 -0.701123 -0.795272 -0.873285 -0.933621 -0.975024 --0.996669 -0.998136 -0.979343 -0.940727 -0.88304 -0.807454 -0.715522 --0.609067 -0.490282 -0.361561 -0.225509 -0.0848913 0.0574491 0.198624 -0.335778 0.466119 0.587025 0.696025 0.790922 0.869805 0.931036 0.97342 -0.996069 0.998529 0.980775 0.943112 0.886359 0.811641 0.720466 0.614708 -0.496475 0.368189 0.232443 0.0919834 -0.0503387 -0.19164 -0.329058 --0.459814 -0.581239 -0.690897; -#X coords 0 1 299 -1 300 150 1; +#X array \$0-buf 10000 float 0; +#X coords 0 1 9999 -1 300 150 1; #X restore 573 269 graph; #X obj 44 529 dac~; #X msg 120 73 reset; @@ -80,18 +39,18 @@ #X restore 573 447 graph; #X obj 53 498 *~; #X obj 89 486 hsl 128 15 0.0001 1 1 0 empty empty volume -2 -6 0 8 --261689 -1 -1 0 1; +-261689 -1 -1 10900 1; #X obj 86 504 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0 -10 -261689 -1 -1 0 256; +10 -261689 -1 -1 0.271063 256; #X msg 25 249 pos \$1; #X msg 63 220 200; #X msg 25 221 100; #X obj 511 224 nbx 5 14 0 1e+037 0 1 empty empty frq 0 -6 0 10 -228992 --1 -1 1100 256; -#N canvas 83 212 407 313 loopzone 0; +-1 -1 144 256; +#N canvas 19 334 415 321 loopzone 0; #X msg 28 84 xzone \$1; #X obj 31 43 hsl 128 15 0 300 0 0 empty empty empty -2 -6 0 8 -262131 --1 -1 0 1; +-1 -1 12700 1; #X floatatom 28 64 5 0 0 0 - - -; #X msg 203 207 xfade \$1; #X obj 203 142 vdl 15 0 0 4 empty empty empty 0 -6 0 8 -262144 -1 -1 @@ -130,10 +89,10 @@ #X text 354 75 (pos message and position outlet); #X text 622 148 bidirectional; #X text 244 111 buffer size; -#X obj 574 419 hsl 300 15 0 300 0 0 empty bufpos empty -2 -6 0 8 -262144 --1 -1 0 1; +#X obj 574 419 hsl 300 15 0 10000 0 0 empty bufpos empty -2 -6 0 8 +-262144 -1 -1 20832 1; #X obj 236 527 nbx 5 14 -1e+037 1e+037 0 0 empty empty position 0 -6 -0 10 -228992 -1 -1 0 256; +0 10 -228992 -1 -1 6967.26 256; #N canvas 0 0 470 320 watch 0; #X obj 163 18 loadbang; #X obj 88 80 snapshot~; @@ -153,26 +112,28 @@ #X connect 6 0 1 0; #X restore 235 492 pd watch; #X text 377 111 units in loop; -#N canvas 0 0 842 609 genosc 0; +#N canvas 97 34 266 202 genosc 0; #X obj 38 29 inlet; #X obj 64 94 osc~ 1000; #X obj 38 54 route bang; #X obj 37 134 tabwrite~ \$0-buf; +#X obj 158 94 loadbang; #X connect 0 0 2 0; #X connect 1 0 3 0; #X connect 2 0 3 0; -#X connect 2 1 1 1; +#X connect 2 1 1 0; +#X connect 4 0 3 0; #X restore 491 244 pd genosc; #X text 600 97 loop mode; #X text 23 201 set position; #X obj 299 426 nbx 5 14 0 1e+037 0 1 empty empty min 0 -6 0 10 -262131 -1 -1 0 256; #X obj 356 426 nbx 5 14 0 1e+037 0 1 empty empty max 0 -6 0 10 -262131 --1 -1 300 256; +-1 -1 10000 256; #X obj 298 309 nbx 5 14 0 1e+037 0 1 empty empty min 0 -6 0 10 -225271 --1 -1 78 256; +-1 -1 0 256; #X obj 355 309 nbx 5 14 0 1e+037 0 1 empty empty max 0 -6 0 10 -225271 --1 -1 276 256; +-1 -1 30000 256; #X text 244 95 frames (def.); #X text 377 96 units in buffer (def.); #X text 622 132 forward (def.); diff --git a/externals/grill/xsample/pd/xrecord~.pd b/externals/grill/xsample/pd/xrecord~.pd index 595536b7..f1145fb8 100644 --- a/externals/grill/xsample/pd/xrecord~.pd +++ b/externals/grill/xsample/pd/xrecord~.pd @@ -1,11 +1,7 @@ -#N canvas 58 17 865 647 12; +#N canvas 58 17 869 651 12; #X obj 18 83 bng 15 250 50 0 empty empty empty 20 8 0 8 -258699 -1 -1; #X msg 17 103 stop; -#X floatatom 169 316 5 0 0 0 - - -; -#X floatatom 223 316 5 0 0 0 - - -; -#X floatatom 194 238 5 0 0 0 - - -; -#X floatatom 243 239 5 0 0 0 - - -; #N canvas 0 0 450 300 graph7 0; #X array \$0-buf 10000 float 0; #X coords 0 1 9999 -1 200 140 1; @@ -24,10 +20,6 @@ #X obj 427 332 bng 15 250 50 0 empty empty empty 20 8 0 8 -258699 -1 -1; #X msg 426 352 stop; -#X floatatom 581 542 5 0 0 0 - - -; -#X floatatom 635 542 5 0 0 0 - - -; -#X floatatom 584 484 5 0 0 0 - - -; -#X floatatom 633 485 5 0 0 0 - - -; #X msg 425 391 reset; #X obj 516 575 snapshot~; #X floatatom 516 605 7 0 0 0 - - -; @@ -58,8 +50,6 @@ #X obj 759 92 tgl 15 0 empty empty empty 20 8 0 8 -225271 -1 -1 0 1 ; #X obj 777 88 adc~; -#X text 202 217 min/max position; -#X text 170 335 min/max position; #X text 266 164 looping on/off; #X text 241 133 display refresh; #X text 56 81 start; @@ -73,12 +63,12 @@ #X text 509 242 click to activate auto update; #X text 448 328 start; #X text 466 352 stop; -#X msg 157 238 all; +#X msg 152 239 all; #X msg 504 263 100; -#X obj 537 483 line~; -#X msg 536 458 \$1 20; +#X obj 554 497 line~; +#X msg 554 472 \$1 20; #X msg 13 203 getattributes; -#X obj 224 279 print A; +#X obj 236 281 print A; #X msg 14 231 getbuffer; #X obj 583 116 *~ 1; #X obj 582 93 tgl 15 1 empty empty empty 20 8 0 8 -225271 -1 -1 0 1 @@ -90,67 +80,89 @@ #X text 582 396 by the trigger signal; #X text 581 383 the amount of mixing-in is given; #X obj 95 280 xrecord~ \$0-buf; -#X obj 516 515 xrecord~ \$0-buf; +#X obj 516 529 xrecord~ \$0-buf; #X obj 18 12 cnv 15 800 40 empty empty xrecord~ 10 22 0 24 -260818 -1 0; #X text 224 31 http://www.parasitaere-kapazitaeten.net; #X text 224 12 buffer-based signal recorder \, (C)2001-2004 Thomas Grill; -#X connect 0 0 77 0; -#X connect 1 0 77 0; -#X connect 4 0 77 2; -#X connect 5 0 77 3; -#X connect 7 0 77 0; +#X text 202 253 min/max points; +#X obj 201 241 nbx 5 14 0 1e+037 0 1 empty empty min 0 -6 0 10 -225271 +-1 -1 78 256; +#X obj 258 241 nbx 5 14 0 1e+037 0 1 empty empty max 0 -6 0 10 -225271 +-1 -1 276 256; +#X obj 190 365 nbx 5 14 0 1e+037 0 1 empty empty min 0 -6 0 10 -262131 +-1 -1 0 256; +#X obj 247 365 nbx 5 14 0 1e+037 0 1 empty empty max 0 -6 0 10 -262131 +-1 -1 10000 256; +#X text 192 378 min/max points; +#X obj 224 321 bng 15 250 50 0 empty empty loop_bang 0 -6 0 8 -262131 +-1 -1; +#X text 294 284 print attributes; +#X obj 617 574 nbx 5 14 0 1e+037 0 1 empty empty min 0 -6 0 10 -262131 +-1 -1 0 256; +#X obj 674 574 nbx 5 14 0 1e+037 0 1 empty empty max 0 -6 0 10 -262131 +-1 -1 10000 256; +#X obj 618 500 nbx 5 14 0 1e+037 0 1 empty empty min 0 -6 0 10 -225271 +-1 -1 78 256; +#X obj 675 500 nbx 5 14 0 1e+037 0 1 empty empty max 0 -6 0 10 -225271 +-1 -1 276 256; +#X connect 0 0 67 0; +#X connect 1 0 67 0; +#X connect 3 0 67 0; +#X connect 4 0 5 0; +#X connect 6 0 30 0; +#X connect 7 0 67 0; #X connect 8 0 9 0; -#X connect 10 0 38 0; -#X connect 11 0 77 0; -#X connect 12 0 13 0; -#X connect 13 0 77 0; -#X connect 14 0 16 0; -#X connect 15 0 16 0; -#X connect 16 0 77 0; -#X connect 17 0 78 0; -#X connect 18 0 78 0; -#X connect 21 0 78 2; -#X connect 22 0 78 3; -#X connect 23 0 78 0; -#X connect 24 0 25 0; -#X connect 26 0 37 0; -#X connect 27 0 28 0; -#X connect 28 0 78 0; -#X connect 29 0 30 0; -#X connect 30 0 78 0; -#X connect 31 0 32 0; -#X connect 32 0 78 0; -#X connect 33 0 78 0; -#X connect 34 0 36 0; -#X connect 34 0 66 0; -#X connect 35 0 78 0; -#X connect 37 0 24 0; -#X connect 38 0 8 0; -#X connect 39 0 43 0; -#X connect 40 0 77 0; -#X connect 41 0 78 0; -#X connect 43 0 42 0; -#X connect 44 0 43 1; -#X connect 45 0 42 0; -#X connect 46 0 45 1; -#X connect 47 0 45 0; -#X connect 47 1 45 0; -#X connect 63 0 77 0; -#X connect 64 0 30 0; -#X connect 65 0 78 1; -#X connect 66 0 65 0; -#X connect 67 0 77 0; -#X connect 69 0 77 0; -#X connect 70 0 42 0; -#X connect 71 0 70 1; -#X connect 72 0 70 0; -#X connect 73 0 35 0; -#X connect 77 0 8 0; -#X connect 77 1 2 0; -#X connect 77 2 3 0; -#X connect 77 4 68 0; -#X connect 78 0 24 0; -#X connect 78 1 19 0; -#X connect 78 2 20 0; +#X connect 9 0 67 0; +#X connect 10 0 12 0; +#X connect 11 0 12 0; +#X connect 12 0 67 0; +#X connect 13 0 68 0; +#X connect 14 0 68 0; +#X connect 15 0 68 0; +#X connect 16 0 17 0; +#X connect 18 0 29 0; +#X connect 19 0 20 0; +#X connect 20 0 68 0; +#X connect 21 0 22 0; +#X connect 22 0 68 0; +#X connect 23 0 24 0; +#X connect 24 0 68 0; +#X connect 25 0 68 0; +#X connect 26 0 28 0; +#X connect 26 0 56 0; +#X connect 27 0 68 0; +#X connect 29 0 16 0; +#X connect 30 0 4 0; +#X connect 31 0 35 0; +#X connect 32 0 67 0; +#X connect 33 0 68 0; +#X connect 35 0 34 0; +#X connect 36 0 35 1; +#X connect 37 0 34 0; +#X connect 38 0 37 1; +#X connect 39 0 37 0; +#X connect 39 1 37 0; +#X connect 53 0 67 0; +#X connect 54 0 22 0; +#X connect 55 0 68 1; +#X connect 56 0 55 0; +#X connect 57 0 67 0; +#X connect 59 0 67 0; +#X connect 60 0 34 0; +#X connect 61 0 60 1; +#X connect 62 0 60 0; +#X connect 63 0 27 0; +#X connect 67 0 4 0; +#X connect 67 1 75 0; +#X connect 67 2 76 0; +#X connect 67 3 78 0; +#X connect 67 4 58 0; +#X connect 68 0 16 0; +#X connect 68 1 80 0; +#X connect 68 2 81 0; +#X connect 73 0 67 2; +#X connect 74 0 67 3; +#X connect 82 0 68 2; +#X connect 83 0 68 3; diff --git a/externals/grill/xsample/readme.txt b/externals/grill/xsample/readme.txt index 20aa53df..b8bb2893 100644 --- a/externals/grill/xsample/readme.txt +++ b/externals/grill/xsample/readme.txt @@ -115,6 +115,13 @@ Goals/features of the package: Version history: +0.3.1: +- added mixmode=2 to Max/MSP help files +- fixed limit consideration for loopmode=0 and 2. +- fixed buggy sampling in crossfade zones (and simplified it a lot) +- different initialization on buffer absence +- renew units and scalemode on buffer change + 0.3.0: - added resources to MaxMSP build - xgroove~, xrecord~: introduced a loop/end bang outlet diff --git a/externals/grill/xsample/source/groove.cpp b/externals/grill/xsample/source/groove.cpp index f96b33bb..a3f2ed02 100644 --- a/externals/grill/xsample/source/groove.cpp +++ b/externals/grill/xsample/source/groove.cpp @@ -17,7 +17,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #endif -#define XZONE_TABLE 64 +#define XZONE_TABLE 512 class xgroove: @@ -300,7 +300,7 @@ V xgroove::m_max(F mx) V xgroove::m_pos(F pos) { - setpos(pos?pos/s2u:0); + setpos(pos && s2u?pos/s2u:0); } V xgroove::m_all() @@ -329,7 +329,7 @@ V xgroove::ms_xfade(I xf) V xgroove::ms_xzone(F xz) { bufchk(); - _xzone = xz < 0?0:xz/s2u; + _xzone = xz < 0 || !s2u?0:xz/s2u; // do_xzone(); s_dsp(); } @@ -642,6 +642,11 @@ V xgroove::s_pos_loopzn(I n,S *const *invecs,S *const *outvecs) // adapt the playing bounds to the current cross-fade zone const L smin = znsmin,smax = znsmax,plen = smax-smin; + // temporary storage + const L cmin = curmin,cmax = curmax; + // hack -> set curmin/curmax to loop extremes so that sampling functions (playfun) don't get confused + curmin = smin,curmax = smax; + if(buf && plen > 0) { BL inzn = false; register D o = curpos; @@ -661,17 +666,24 @@ V xgroove::s_pos_loopzn(I n,S *const *invecs,S *const *outvecs) lpbang = true; } +#if 1 if(o < lmin) { register F inp; if(o < lmin2) { + // in first half of early cross-fade zone + // this happens only once, then the offset is normalized to the end + // of the loop (before mid of late crossfade) + o += lsh; - lpbang = true; // now lmax <= o <= lmax2 + lpbang = true; inp = xz-(F)(o-lmax); // 0 <= inp < xz znpos[i] = lmin-inp; } - else { // in early cross-fade zone + else { + // in second half of early cross-fade zone + inp = xz+(F)(o-lmin); // 0 <= inp < xz znpos[i] = lmax+inp; } @@ -681,14 +693,18 @@ V xgroove::s_pos_loopzn(I n,S *const *invecs,S *const *outvecs) else if(!(o < lmax)) { register F inp; if(!(o < lmax2)) { + // in second half of late cross-fade zone + // this happens only once, then the offset is normalized to the beginning + // of the loop (after mid of early crossfade) o -= lsh; - lpbang = true; // now lmin2 <= o <= lmin + lpbang = true; inp = xz+(F)(o-lmin); // 0 <= inp < xz znpos[i] = lmax+inp; } - else { // in late cross-fade zone + else { + // in first half of late cross-fade zone inp = xz-(F)(o-lmax); // 0 <= inp < xz znpos[i] = lmin-inp; } @@ -701,6 +717,27 @@ V xgroove::s_pos_loopzn(I n,S *const *invecs,S *const *outvecs) const S spd = speed[i]; // must be first because the vector is reused for output! pos[i] = o; o += spd; +#else + if(o >= lmax) { + o -= lsh; + lpbang = true; + } + + if(o < lmin) { + register F inp = (F)(o-smin); // 0 <= inp < xz + znpos[i] = lmax+inp; + znidx[i] = inp*xf; + inzn = true; + } + else { + znpos[i] = 0; + znidx[i] = XZONE_TABLE; + } + + const S spd = speed[i]; // must be first because the vector is reused for output! + pos[i] = o; + o += spd; +#endif } // normalize and store current playing position @@ -736,6 +773,8 @@ V xgroove::s_pos_loopzn(I n,S *const *invecs,S *const *outvecs) else s_pos_off(n,invecs,outvecs); + curmin = cmin,curmax = cmax; + if(lpbang) ToOutBang(outchns+3); } @@ -787,12 +826,14 @@ V xgroove::s_pos_bidir(I n,S *const *invecs,S *const *outvecs) V xgroove::s_dsp() { if(doplay) { + // xzone might not be set yet (is done in do_xzone() ) + do_xzone(); // recalculate (s2u may have been 0 before) + switch(loopmode) { - case xsl_once: SETSIGFUN(posfun,SIGFUN(s_pos_once)); break; + case xsl_once: + SETSIGFUN(posfun,SIGFUN(s_pos_once)); + break; case xsl_loop: - // xzone might not be set yet (is done in do_xzone() ) - do_xzone(); // recalculate (s2u may have been 0 before) - if(xzone > 0) { const I blksz = Blocksize(); @@ -823,7 +864,9 @@ V xgroove::s_dsp() else SETSIGFUN(posfun,SIGFUN(s_pos_loop)); break; - case xsl_bidir: SETSIGFUN(posfun,SIGFUN(s_pos_bidir)); break; + case xsl_bidir: + SETSIGFUN(posfun,SIGFUN(s_pos_bidir)); + break; } } else diff --git a/externals/grill/xsample/source/main.cpp b/externals/grill/xsample/source/main.cpp index 258fb37a..3cec1b66 100644 --- a/externals/grill/xsample/source/main.cpp +++ b/externals/grill/xsample/source/main.cpp @@ -60,7 +60,7 @@ xsample::xsample(): unitmode(xsu_sample), // PD defaults to samples #endif sclmode(xss_unitsinbuf), - curmin(0),curmax(1<<30) + curmin(0),curmax(1<<31) {} xsample::~xsample() @@ -98,6 +98,8 @@ BL xsample::m_refresh() if(buf->Set()) { s_dsp(); ret = true; } // channel count may have changed else ret = false; + m_units(); + m_sclmode(); // realize positions... 2 times bufchk()!! m_min((F)curmin*s2u); // also checks pos m_max((F)curmax*s2u); // also checks pos @@ -129,70 +131,72 @@ V xsample::m_units(xs_unit mode) { if(mode != xsu__) unitmode = mode; - if(bufchk()) - switch(unitmode) { - case xsu_sample: // samples - s2u = 1; - break; - case xsu_buffer: // buffer size - s2u = 1.f/buf->Frames(); - break; - case xsu_ms: // ms - s2u = 1000.f/Samplerate(); - break; - case xsu_s: // s - s2u = 1.f/Samplerate(); - break; - default: - post("%s: Unknown unit mode",thisName()); - } + switch(unitmode) { + case xsu_sample: // samples + s2u = 1; + break; + case xsu_buffer: // buffer size + s2u = bufchk()?1.f/buf->Frames():0; + break; + case xsu_ms: // ms + s2u = 1000.f/Samplerate(); + break; + case xsu_s: // s + s2u = 1.f/Samplerate(); + break; + default: + post("%s: Unknown unit mode",thisName()); + } } V xsample::m_sclmode(xs_sclmd mode) { if(mode != xss__) sclmode = mode; - if(bufchk()) - switch(sclmode) { - case 0: // samples/units - sclmin = 0; sclmul = s2u; - break; - case 1: // samples/units from recmin to recmax - sclmin = curmin; sclmul = s2u; - break; - case 2: // unity between 0 and buffer size - sclmin = 0; sclmul = buf->Frames()?1.f/buf->Frames():0; - break; - case 3: // unity between recmin and recmax - sclmin = curmin; sclmul = curmin != curmax?1.f/(curmax-curmin):0; - break; - default: - post("%s: Unknown scale mode",thisName()); - } + switch(sclmode) { + case 0: // samples/units + sclmin = 0; sclmul = s2u; + break; + case 1: // samples/units from recmin to recmax + sclmin = curmin; sclmul = s2u; + break; + case 2: // unity between 0 and buffer size + sclmin = 0; sclmul = (bufchk() && buf->Frames())?1.f/buf->Frames():0; + break; + case 3: // unity between recmin and recmax + sclmin = curmin; sclmul = curmin != curmax?1.f/(curmax-curmin):0; + break; + default: + post("%s: Unknown scale mode",thisName()); + } } V xsample::m_min(F mn) { - if(!bufchk()) return; // if invalid do nothing (actually, it should be delayed) +// if(!bufchk()) return; // if invalid do nothing (actually, it should be delayed) - mn /= s2u; // conversion to samples - if(mn < 0) mn = 0; - else if(mn > curmax) mn = (F)curmax; - curmin = (I)(mn+.5); + if(s2u) { + mn /= s2u; // conversion to samples + if(mn < 0) mn = 0; + else if(mn > curmax) mn = (F)curmax; + curmin = (I)(mn+.5); - m_sclmode(); + m_sclmode(); + } } V xsample::m_max(F mx) { - if(!bufchk()) return; // if invalid do nothing (actually, it should be delayed) +// if(!bufchk()) return; // if invalid do nothing (actually, it should be delayed) - mx /= s2u; // conversion to samples - if(mx > buf->Frames()) mx = (F)buf->Frames(); - else if(mx < curmin) mx = (F)curmin; - curmax = (I)(mx+.5); + if(s2u) { + mx /= s2u; // conversion to samples + if(mx > buf->Frames()) mx = (F)buf->Frames(); + else if(mx < curmin) mx = (F)curmin; + curmax = (I)(mx+.5); - m_sclmode(); + m_sclmode(); + } } V xsample::m_all() diff --git a/externals/grill/xsample/source/main.h b/externals/grill/xsample/source/main.h index daa99b5d..c6511139 100644 --- a/externals/grill/xsample/source/main.h +++ b/externals/grill/xsample/source/main.h @@ -12,7 +12,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #define __XSAMPLE_H -#define XSAMPLE_VERSION "0.3.0" +#define XSAMPLE_VERSION "0.3.1pre3" #define FLEXT_ATTRIBUTES 1 diff --git a/externals/grill/xsample/xsample.cw b/externals/grill/xsample/xsample.cw index 78e49d4e..a74428fd 100755 Binary files a/externals/grill/xsample/xsample.cw and b/externals/grill/xsample/xsample.cw differ -- cgit v1.2.1