aboutsummaryrefslogtreecommitdiff
path: root/externals/grill
diff options
context:
space:
mode:
Diffstat (limited to 'externals/grill')
-rw-r--r--externals/grill/xsample/pd/xgroove~.pd296
-rw-r--r--externals/grill/xsample/source/groove.cpp239
-rw-r--r--externals/grill/xsample/source/main.h6
3 files changed, 310 insertions, 231 deletions
diff --git a/externals/grill/xsample/pd/xgroove~.pd b/externals/grill/xsample/pd/xgroove~.pd
index 012dcb92..b2b84517 100644
--- a/externals/grill/xsample/pd/xgroove~.pd
+++ b/externals/grill/xsample/pd/xgroove~.pd
@@ -1,6 +1,6 @@
-#N canvas 92 110 847 566 12;
+#N canvas 92 110 891 610 12;
#X obj 258 240 hsl 128 15 0.001 3 1 1 empty empty empty 20 8 0 8 -225271
--1 -1 3400 1;
+-1 -1 8500 1;
#X floatatom 255 261 8 0 0 0 - - -;
#X floatatom 275 312 8 0 0 0 - - -;
#X floatatom 350 312 8 0 0 0 - - -;
@@ -8,84 +8,81 @@
#X floatatom 348 372 8 0 0 0 - - -;
#X obj 275 419 loadbang;
#X obj 274 445 metro 30;
-#X obj 250 470 snapshot~;
-#X floatatom 250 494 8 0 0 0 - - -;
+#X obj 275 471 snapshot~;
+#X floatatom 275 495 8 0 0 0 - - -;
#X msg 258 82 loop \$1;
#X obj 159 27 bng 15 250 50 0 empty empty empty 20 8 0 8 -258699 -1
-1;
#X msg 158 47 stop;
#N canvas 0 0 450 300 graph7 0;
#X array buf 300 float 1;
-#A 0 0.841115 0.9094 0.95923 0.989636 0.999991 0.990063 0.960094 0.910649
-0.842757 0.757796 0.65746 0.543816 0.419143 0.285978 0.147021 0.00508036
--0.136962 -0.276228 -0.409895 -0.535265 -0.649771 -0.751121 -0.83725
--0.906401 -0.957205 -0.988587 -0.999947 -0.991051 -0.962051 -0.913577
--0.846573 -0.762418 -0.662823 -0.549777 -0.425604 -0.292801 -0.154064
--0.0122066 0.129898 0.269372 0.403387 0.529223 0.644347 0.746395 0.833328
-0.903378 0.955105 0.987498 0.99986 0.991967 0.963983 0.91644 0.850346
-0.767009 0.668129 0.555721 0.432034 0.299602 0.161097 0.0193266 -0.122836
--0.262506 -0.396859 -0.523173 -0.638875 -0.741645 -0.82937 -0.900294
--0.952984 -0.986339 -0.999729 -0.992844 -0.965842 -0.919283 -0.854067
--0.771564 -0.673418 -0.561622 -0.438457 -0.306392 -0.168126 -0.0264512
-0.115759 0.255627 0.390308 0.517083 0.633384 0.736837 0.825374 0.89717
-0.95079 0.985156 0.999531 0.993672 0.967666 0.922048 0.857765 0.776069
-0.678665 0.567504 0.444838 0.313167 0.175141 0.0335691 -0.108684 -0.248732
--0.383745 -0.510974 -0.627851 -0.732014 -0.821324 -0.894008 -0.948562
--0.983895 -0.999309 -0.994439 -0.96944 -0.924788 -0.861391 -0.780556
--0.683878 -0.573355 -0.451214 -0.319922 -0.182154 -0.0406903 0.101596
-0.241826 0.37715 0.504839 0.62229 0.727131 0.81725 0.890784 0.946286
-0.982602 0.999003 0.99518 0.971156 0.927473 0.864993 0.784974 0.689065
-0.579174 0.457555 0.326665 0.189149 0.047805 -0.0945095 -0.234908 -0.370551
--0.498674 -0.616703 -0.722227 -0.813114 -0.887541 -0.943952 -0.981256
--0.998669 -0.995836 -0.972845 -0.93011 -0.868543 -0.789377 -0.694202
--0.584975 -0.463879 -0.333389 -0.196144 -0.0549212 0.0874133 0.227976
-0.363918 0.492493 0.611072 0.717282 0.80895 0.88422 0.941593 0.979852
-0.998275 0.996467 0.974453 0.932714 0.872048 0.793723 0.699318 0.590728
-0.47018 0.340094 0.20312 0.0620311 -0.0803164 -0.221037 -0.357277 -0.486275
--0.605431 -0.712297 -0.804743 -0.880878 -0.939154 -0.97842 -0.99783
--0.997035 -0.976038 -0.935246 -0.875523 -0.798037 -0.704388 -0.596471
--0.476452 -0.346789 -0.210093 -0.0691412 0.0732124 0.21408 0.350613
-0.480039 0.599733 0.707289 0.800488 0.87748 0.936691 0.976908 0.997349
-0.997554 0.977556 0.937754 0.87893 0.802314 0.709426 0.602164 0.482708
-0.353456 0.217051 0.0762439 -0.0661074 -0.207122 -0.343933 -0.473779
--0.594024 -0.702224 -0.796211 -0.87404 -0.934169 -0.975372 -0.996792
--0.998035 -0.979032 -0.940196 -0.882319 -0.806539 -0.714434 -0.60784
--0.48893 -0.36012 -0.224 -0.0833475 0.0589955 0.200142 0.337238 0.467489
-0.588274 0.69714 0.791867 0.870566 0.931602 0.973768 0.996211 0.998443
-0.980464 0.9426 0.885637 0.810741 0.719392 0.613481 0.495132 0.366748
-0.230939 0.0904412 -0.0518851 -0.193161 -0.33052 -0.461188 -0.582499
--0.692013 -0.787507 -0.867028 -0.928998 -0.972125 -0.995556 -0.998827
--0.98183 -0.944959 -0.888927 -0.81488 -0.724336 -0.619089 -0.501311
--0.373371;
+#A 0 0.665266 0.658123 0.65098 0.643838 0.636695 0.629552 0.622409
+0.615266 0.611933 0.6086 0.605266 0.601933 0.5986 0.595266 0.591933
+0.5886 0.585266 0.581933 0.5786 0.575266 0.571933 0.5686 0.565266 0.561933
+0.5586 0.555266 0.551933 0.5486 0.545266 0.541933 0.5386 0.535266 0.531933
+0.5286 0.525266 0.521933 0.5186 0.515267 0.512236 0.509206 0.506176
+0.503145 0.500115 0.497085 0.494054 0.491024 0.487994 0.484964 0.481933
+0.478903 0.475873 0.472842 0.469812 0.466782 0.463751 0.460721 0.457691
+0.454661 0.45163 0.4486 0.44557 0.442539 0.439509 0.436479 0.433448
+0.430418 0.427388 0.424358 0.421327 0.418297 0.415267 0.408449 0.401631
+0.394812 0.387994 0.381176 0.374358 0.36754 0.360722 0.353903 0.347085
+0.340267 0.333449 0.326631 0.319813 0.312994 0.306176 0.299358 0.29254
+0.285722 0.278903 0.272085 0.265267 0.260823 0.256378 0.251934 0.247489
+0.243045 0.238601 0.234156 0.229712 0.225267 0.220823 0.216378 0.211934
+0.20749 0.203045 0.198601 0.194156 0.189712 0.185267 0.180601 0.175934
+0.171267 0.166601 0.161934 0.157267 0.152601 0.147934 0.143267 0.138601
+0.133934 0.129267 0.124601 0.104601 0.104601 0.104601 0.104601 0.104601
+0.0846011 0.0846011 0.0846011 0.0646012 0.0579345 0.0512679 0.0446012
+0.0446012 0.0446012 0.0306011 0.0259344 0.0212678 0.0166011 0.0119345
+0.00726783 0.00260118 -0.00206548 -0.00673213 -0.0113988 -0.0160654
+-0.0207321 -0.0253987 -0.0300654 -0.034732 -0.0408859 -0.0470397 -0.0531935
+-0.0593474 -0.0655012 -0.071655 -0.0778088 -0.0839627 -0.0901165 -0.0962703
+-0.102424 -0.108578 -0.114732 -0.118232 -0.121732 -0.125232 -0.128732
+-0.132232 -0.135732 -0.139232 -0.142732 -0.146232 -0.149732 -0.153232
+-0.156732 -0.160232 -0.163732 -0.167232 -0.170732 -0.174232 -0.177732
+-0.181232 -0.184732 -0.188065 -0.191398 -0.194732 -0.198065 -0.201398
+-0.204732 -0.208065 -0.211398 -0.214731 -0.218065 -0.221398 -0.224731
+-0.228065 -0.231398 -0.234731 -0.238898 -0.243065 -0.247231 -0.251398
+-0.255565 -0.259731 -0.263898 -0.268065 -0.272231 -0.276398 -0.280565
+-0.284731 -0.290731 -0.296731 -0.302731 -0.308731 -0.314731 -0.319398
+-0.324065 -0.328731 -0.333398 -0.338064 -0.342731 -0.347398 -0.352064
+-0.356731 -0.356731 -0.364731 -0.372731 -0.380731 -0.388731 -0.396731
+-0.401437 -0.406143 -0.410848 -0.415554 -0.42026 -0.424966 -0.429672
+-0.434378 -0.439084 -0.44379 -0.448495 -0.453201 -0.457907 -0.462613
+-0.467319 -0.472025 -0.476731 -0.483397 -0.490064 -0.496731 -0.501731
+-0.50673 -0.51173 -0.51673 -0.52173 -0.52673 -0.53173 -0.53673 -0.54173
+-0.546731 -0.552064 -0.557397 -0.562731 -0.568064 -0.573397 -0.57873
+-0.584064 -0.589397 -0.59473 -0.600064 -0.605397 -0.61073 -0.616064
+-0.621397 -0.62673 -0.62673 -0.62673 -0.62673 -0.62673 -0.62673 -0.62673
+-0.62673 -0.63298 -0.63923 -0.64548 -0.65173 -0.65798 -0.66423 -0.67048
+-0.67673 -0.68073 -0.68473 -0.68873 -0.69273 -0.72673 -0.72673 -0.74673
+;
#X coords 0 1 299 -1 300 200 1;
#X restore 521 23 graph;
-#X obj 144 486 dac~;
-#X msg 157 86 reset;
+#X obj 171 574 dac~;
+#X msg 155 88 reset;
#X text 290 292 min/max points;
#X text 289 390 min/max points;
-#X text 323 494 position;
+#X text 348 495 position;
#X text 181 24 start;
#X text 198 45 stop;
#X msg 156 113 help;
#X text 416 234 speed;
#X text 337 254 (float or signal);
-#X obj 656 365 table buf2;
-#X floatatom 519 380 8 0 0 0 - - -;
-#X obj 519 353 soundfiler;
-#X msg 158 172 set buf2;
+#X msg 156 169 set buf2;
#X msg 157 144 set buf;
#X msg 372 82 interp \$1;
#X msg 240 312 all;
#X obj 191 344 xgroove~ buf;
#X text 255 10 looping mode;
#X text 370 9 interpolation;
-#X msg 10 149 pos 100;
-#X msg 25 180 pos 200;
-#X obj 152 447 *~;
-#X msg 10 105 xzone \$1;
-#X obj 13 62 hsl 128 15 0 300 0 0 empty empty empty -2 -6 0 8 -262144
--1 -1 0 1;
-#X floatatom 10 83 5 0 0 0 - - -;
+#X msg 11 114 pos 100;
+#X msg 31 138 pos 200;
+#X obj 172 384 *~;
+#X msg 13 359 xzone \$1;
+#X obj 16 321 hsl 128 15 0 300 0 0 empty empty empty -2 -6 0 8 -262131
+-1 -1 1500 1;
+#X floatatom 13 339 5 0 0 0 - - -;
#X obj 258 32 vdl 15 0 0 3 empty empty empty 0 -6 0 8 -262144 -1 -1
0;
#X text 277 29 once;
@@ -96,10 +93,6 @@
#X text 391 28 none;
#X text 391 44 linear;
#X text 391 60 4-point;
-#X obj 520 299 openpanel;
-#X msg 521 326 read -resize \$1 buf2;
-#X obj 521 275 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
--1;
#X obj 256 134 vdl 15 0 0 4 empty empty empty 0 -6 0 8 -262144 -1 -1
0;
#X text 255 113 units;
@@ -116,11 +109,11 @@
#X text 383 163 buffer;
#X text 383 178 loop;
#X text 383 131 units in buffer;
-#X obj 524 440 osc~ 1000;
-#X obj 524 498 tabwrite~ buf;
-#X obj 536 467 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+#X obj 646 475 osc~ 1000;
+#X obj 646 533 tabwrite~ buf;
+#X obj 658 502 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
-#X msg 557 468 stop;
+#X msg 679 503 stop;
#X obj 319 343 print A;
#X msg 131 213 getattributes;
#X msg 177 248 getmax;
@@ -158,54 +151,129 @@
#X connect 11 0 13 0;
#X connect 12 0 0 0;
#X connect 13 0 0 0;
-#X restore 19 287 pd ramp;
-#X obj 46 230 loadbang;
-#X msg 46 255 10;
+#X restore 20 252 pd ramp;
+#X obj 49 199 loadbang;
+#X msg 49 224 10;
+#N canvas 0 0 450 300 graph2 0;
+#X array buf2 300 float 1;
+#A 0 0.0542877 0.0528716 0.0514554 0.0499469 0.0483065 0.0467235 0.0453892
+0.0444954 0.0441347 0.0441533 0.0443594 0.0445614 0.0446597 0.045062
+0.0455113 0.045605 0.0449404 0.043072 0.0400357 0.0364854 0.0330926
+0.0305273 0.0289475 0.0279315 0.027211 0.0265175 0.0256073 0.024616
+0.0236247 0.0226334 0.0216421 0.0206508 0.0196594 0.0186681 0.0176768
+0.0166855 0.0156941 0.0147029 0.0137115 0.0127203 0.0117289 0.0107376
+0.00974629 0.008755 0.00776365 0.0067723 0.00578102 0.00478967 0.00379839
+0.00280704 0.00181576 0.000824409 -0.000166872 -0.00115822 -0.0021495
+-0.00314085 -0.00413213 -0.00512348 -0.00611476 -0.00710611 -0.00809747
+-0.00908875 -0.0100801 -0.0110714 -0.0120627 -0.013054 -0.0140453 -0.0150366
+-0.0160279 -0.0170192 -0.0180106 -0.0190019 -0.0199932 -0.0209845 -0.0219759
+-0.0229672 -0.0239585 -0.0249498 -0.0259411 -0.0269325 -0.0279237 -0.0289151
+-0.0299064 -0.0308783 -0.0318198 -0.032773 -0.0337804 -0.034885 -0.0361087
+-0.0374184 -0.0387711 -0.0401239 -0.0414409 -0.0427481 -0.0440554 -0.0453626
+-0.0466698 -0.047977 -0.0492843 -0.0505914 -0.0518987 -0.0532059 -0.0545132
+-0.0558204 -0.0571277 -0.058435 -0.0597422 -0.0610494 -0.0623566 -0.0636639
+-0.064971 -0.0662783 -0.0675855 -0.0688928 -0.0701999 -0.0715072 -0.0728144
+-0.0741216 -0.0754288 -0.0767361 -0.0780434 -0.0793506 -0.0806578 -0.0819651
+-0.0832723 -0.0845795 -0.0858868 -0.087194 -0.0885012 -0.0898084 -0.0911157
+-0.0924229 -0.0937301 -0.0950373 -0.0963446 -0.0976517 -0.098959 -0.100266
+-0.101573 -0.102881 -0.104188 -0.105495 -0.106802 -0.10811 -0.109438
+-0.110829 -0.112215 -0.113519 -0.114664 -0.115596 -0.116359 -0.117031
+-0.117687 -0.118401 -0.119144 -0.119888 -0.120631 -0.121374 -0.122118
+-0.122861 -0.123605 -0.124348 -0.125092 -0.125835 -0.126579 -0.127322
+-0.128066 -0.128809 -0.129553 -0.130296 -0.13104 -0.131783 -0.132527
+-0.13327 -0.134014 -0.134757 -0.135501 -0.136244 -0.136988 -0.137731
+-0.138475 -0.139218 -0.139962 -0.140705 -0.141449 -0.142192 -0.142936
+-0.143679 -0.144423 -0.145166 -0.14591 -0.146653 -0.147397 -0.14814
+-0.148884 -0.149627 -0.150371 -0.151114 -0.151858 -0.152601 -0.153345
+-0.154088 -0.154832 -0.155575 -0.156319 -0.157062 -0.157806 -0.158549
+-0.159292 -0.160036 -0.160779 -0.161523 -0.162266 -0.16301 -0.163753
+-0.164497 -0.16524 -0.165984 -0.166727 -0.167471 -0.168214 -0.168958
+-0.169701 -0.170445 -0.171188 -0.171932 -0.172675 -0.173419 -0.174162
+-0.174906 -0.175649 -0.176393 -0.177136 -0.17788 -0.178623 -0.179367
+-0.18011 -0.180854 -0.181598 -0.182346 -0.183095 -0.18384 -0.184575
+-0.185297 -0.186007 -0.186711 -0.187414 -0.188119 -0.188827 -0.189535
+-0.190243 -0.190951 -0.191659 -0.192367 -0.193076 -0.193784 -0.194492
+-0.1952 -0.195908 -0.196616 -0.197324 -0.198032 -0.19874 -0.199448
+-0.200156 -0.200864 -0.201572 -0.20228 -0.202989 -0.203697 -0.204405
+-0.205113 -0.205821 -0.206529 -0.207237 -0.207945 -0.208653 -0.209361
+-0.210069 -0.210777 -0.211485 -0.212193 -0.212901 -0.213609 -0.214317
+-0.215026 -0.215734 -0.216442 -0.21715 -0.217859 -0.218567 -0.219275
+-0.219983 -0.220691 -0.221399 -0.222107 -0.222815 -0.223523 -0.224231
+-0.224939;
+#X coords 0 1 299 -1 300 140 1;
+#X restore 521 232 graph;
+#X obj 228 516 tabwrite~ buf2;
+#X obj 211 483 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X obj 15 421 hsl 128 15 0 1 0 0 empty empty empty -2 -6 0 8 -262131
+-1 -1 0 1;
+#X msg 12 397 0.5;
+#X obj 172 548 *~;
+#X obj 228 553 hsl 128 15 0.0001 1 1 0 empty empty empty -2 -6 0 8
+-261689 -1 -1 8800 1;
+#X obj 226 573 nbx 5 14 -1e+037 1e+037 0 0 empty empty empty 0 -6 0
+10 -261689 -1 -1 0.059109 256;
+#X msg 12 440 xshape 2 \$1;
+#X msg 11 564 xfade \$1;
+#X obj 10 499 vdl 15 0 0 4 empty empty empty 0 -6 0 8 -262144 -1 -1
+0;
+#X text 9 480 loop zone mode;
+#X text 29 498 keep loop pos;
+#X text 29 514 keep loop length;
+#X text 29 530 keep fade length;
+#X text 29 545 inside loop;
#X connect 0 0 1 0;
-#X connect 1 0 31 0;
-#X connect 2 0 31 1;
-#X connect 3 0 31 2;
+#X connect 1 0 28 0;
+#X connect 2 0 28 1;
+#X connect 3 0 28 2;
#X connect 6 0 7 0;
#X connect 7 0 8 0;
+#X connect 7 0 71 0;
#X connect 8 0 9 0;
-#X connect 10 0 31 0;
-#X connect 11 0 31 0;
-#X connect 12 0 31 0;
-#X connect 15 0 31 0;
-#X connect 21 0 31 0;
-#X connect 26 0 25 0;
-#X connect 27 0 31 0;
-#X connect 28 0 31 0;
-#X connect 29 0 31 0;
-#X connect 30 0 31 0;
-#X connect 31 0 36 1;
-#X connect 31 1 8 0;
-#X connect 31 2 4 0;
-#X connect 31 3 5 0;
-#X connect 31 5 69 0;
-#X connect 34 0 73 0;
-#X connect 35 0 73 0;
-#X connect 36 0 14 0;
-#X connect 36 0 14 1;
-#X connect 37 0 31 0;
-#X connect 38 0 39 0;
-#X connect 39 0 37 0;
-#X connect 40 0 10 0;
-#X connect 44 0 29 0;
-#X connect 48 0 49 0;
-#X connect 49 0 26 0;
-#X connect 50 0 48 0;
-#X connect 51 0 53 0;
-#X connect 53 0 31 0;
-#X connect 54 0 56 0;
-#X connect 56 0 31 0;
-#X connect 65 0 66 0;
-#X connect 67 0 66 0;
-#X connect 68 0 66 0;
-#X connect 70 0 31 0;
-#X connect 71 0 31 0;
-#X connect 72 0 31 0;
-#X connect 73 0 36 0;
-#X connect 73 1 31 0;
-#X connect 74 0 75 0;
-#X connect 75 0 73 1;
+#X connect 10 0 28 0;
+#X connect 11 0 28 0;
+#X connect 12 0 28 0;
+#X connect 15 0 28 0;
+#X connect 21 0 28 0;
+#X connect 24 0 28 0;
+#X connect 25 0 28 0;
+#X connect 26 0 28 0;
+#X connect 27 0 28 0;
+#X connect 28 0 33 1;
+#X connect 28 0 71 0;
+#X connect 28 1 8 0;
+#X connect 28 2 4 0;
+#X connect 28 3 5 0;
+#X connect 28 5 63 0;
+#X connect 31 0 67 0;
+#X connect 32 0 67 0;
+#X connect 33 0 75 0;
+#X connect 34 0 28 0;
+#X connect 35 0 36 0;
+#X connect 36 0 34 0;
+#X connect 37 0 10 0;
+#X connect 41 0 26 0;
+#X connect 45 0 47 0;
+#X connect 47 0 28 0;
+#X connect 48 0 50 0;
+#X connect 50 0 28 0;
+#X connect 59 0 60 0;
+#X connect 61 0 60 0;
+#X connect 62 0 60 0;
+#X connect 64 0 28 0;
+#X connect 65 0 28 0;
+#X connect 66 0 28 0;
+#X connect 67 0 33 0;
+#X connect 67 1 28 0;
+#X connect 68 0 69 0;
+#X connect 69 0 67 1;
+#X connect 72 0 71 0;
+#X connect 73 0 78 0;
+#X connect 74 0 73 0;
+#X connect 75 0 14 0;
+#X connect 75 0 14 1;
+#X connect 76 0 75 1;
+#X connect 76 0 77 0;
+#X connect 78 0 28 0;
+#X connect 79 0 28 0;
+#X connect 80 0 79 0;
diff --git a/externals/grill/xsample/source/groove.cpp b/externals/grill/xsample/source/groove.cpp
index dc268e91..0da9087c 100644
--- a/externals/grill/xsample/source/groove.cpp
+++ b/externals/grill/xsample/source/groove.cpp
@@ -43,20 +43,26 @@ public:
virtual V m_all();
virtual V m_min(F mn);
virtual V m_max(F mx);
-
+
+ V ms_xfade(I xf);
+
V ms_xzone(F xz);
- V mg_xzone(F &xz);
- V m_xsymm(F xz);
+ V mg_xzone(F &xz) { xz = _xzone*s2u; }
+
V m_xshape(I argc = 0,const t_atom *argv = NULL);
inline V ms_xshape(const AtomList &ret) { m_xshape(ret.Count(),ret.Atoms()); }
V mg_xshape(AtomList &ret) const;
- V m_xkeep(BL k);
enum xs_loop {
xsl__ = -1, // don't change
xsl_once = 0,xsl_loop,xsl_bidir
};
-
+
+ enum xs_fade {
+ xsf__ = -1, // don't change
+ xsf_keeplooppos = 0,xsf_keeplooplen,xsf_keepfade,xsf_inside
+ };
+
V m_loop(xs_loop lp = xsl__);
protected:
@@ -65,12 +71,12 @@ protected:
D curpos; // in samples
I bidir;
- F _xzone,xzone,xsymm;
+ F _xzone,xzone;
L znsmin,znsmax;
+ xs_fade xfade;
I xshape;
F xshparam;
D znmin,znmax;
- BL xkeep;
S **znbuf;
S *znpos,*znmul,*znidx;
I pblksz;
@@ -129,13 +135,11 @@ private:
FLEXT_CALLBACK_F(m_max)
FLEXT_CALLBACK(m_all)
+ FLEXT_CALLSET_I(ms_xfade)
+ FLEXT_ATTRGET_I(xfade)
FLEXT_CALLSET_F(ms_xzone)
FLEXT_CALLGET_F(mg_xzone)
- FLEXT_CALLSET_F(m_xsymm)
- FLEXT_ATTRGET_F(xsymm)
FLEXT_CALLVAR_V(mg_xshape,ms_xshape)
- FLEXT_CALLSET_B(m_xkeep)
- FLEXT_ATTRGET_B(xkeep)
FLEXT_CALLVAR_F(mg_pos,m_pos)
FLEXT_CALLSET_F(m_min)
@@ -163,16 +167,15 @@ V xgroove::setup(t_classid c)
FLEXT_CADDATTR_VAR_E(c,"loop",loopmode,m_loop);
+ FLEXT_CADDATTR_VAR(c,"xfade",xfade,ms_xfade);
FLEXT_CADDATTR_VAR(c,"xzone",mg_xzone,ms_xzone);
- FLEXT_CADDATTR_VAR(c,"xsymm",xsymm,m_xsymm);
FLEXT_CADDATTR_VAR(c,"xshape",mg_xshape,ms_xshape);
- FLEXT_CADDATTR_VAR(c,"xkeep",xkeep,m_xkeep);
}
xgroove::xgroove(I argc,const t_atom *argv):
loopmode(xsl_loop),curpos(0),
- _xzone(0),xzone(0),xsymm(0.5),xkeep(false),pblksz(0),
- xshape(0),xshparam(1),
+ _xzone(0),xzone(0),pblksz(0),
+ xfade(xsf_keeplooppos),xshape(0),xshparam(1),
znbuf(NULL),znmul(NULL),znidx(NULL),znpos(NULL),
bidir(1)
{
@@ -216,24 +219,26 @@ xgroove::xgroove(I argc,const t_atom *argv):
AddOutFloat("Ending point (rounded to frame)"); // play max
AddOutBang("Bang on loop end/rollover"); // loop bang
+ // don't know vector size yet -> wait for m_dsp
znbuf = new S *[outchns];
- for(I i = 0; i < outchns; ++i) znbuf[i] = new S[0];
- znpos = new S[0]; // don't know vector size yet -> wait for m_dsp
- znidx = new S[0];
+ for(I i = 0; i < outchns; ++i) znbuf[i] = NULL;
+ znpos = NULL;
+ znidx = NULL;
znmul = new S[XZONE_TABLE+1];
+
m_xshape();
}
xgroove::~xgroove()
{
if(znbuf) {
- for(I i = 0; i < outchns; ++i) delete[] znbuf[i];
+ for(I i = 0; i < outchns; ++i) if(znbuf[i]) delete[] znbuf[i];
delete[] znbuf;
}
- if(znmul) delete[] znmul;
if(znpos) delete[] znpos;
if(znidx) delete[] znidx;
+ delete[] znmul;
}
BL xgroove::Init()
@@ -259,7 +264,8 @@ V xgroove::m_min(F mn)
{
xsample::m_min(mn);
m_pos(curpos*s2u);
- do_xzone();
+// do_xzone();
+ s_dsp();
outputmin();
}
@@ -267,7 +273,8 @@ V xgroove::m_max(F mx)
{
xsample::m_max(mx);
m_pos(curpos*s2u);
- do_xzone();
+// do_xzone();
+ s_dsp();
outputmax();
}
@@ -279,7 +286,8 @@ V xgroove::m_pos(F pos)
V xgroove::m_all()
{
xsample::m_all();
- do_xzone();
+// do_xzone();
+ s_dsp();
outputmin();
outputmax();
}
@@ -291,6 +299,13 @@ BL xgroove::m_reset()
return xsample::m_reset();
}
+V xgroove::ms_xfade(I xf)
+{
+ xfade = (xs_fade)xf;
+ // do_xzone();
+ s_dsp();
+}
+
V xgroove::ms_xzone(F xz)
{
bufchk();
@@ -299,24 +314,6 @@ V xgroove::ms_xzone(F xz)
s_dsp();
}
-V xgroove::mg_xzone(F &xz)
-{
- xz = _xzone*s2u;
-}
-
-V xgroove::m_xsymm(F xs)
-{
- if(xs < 0)
- xsymm = -1;
- else if(xs <= 1)
- xsymm = xs;
- else {
- post("%s - xsymm value out of range - set to center (0.5)",thisName());
- xsymm = 0.5;
- }
- do_xzone();
-}
-
V xgroove::m_xshape(I argc,const t_atom *argv)
{
const F pi = 3.14159265358979f;
@@ -360,61 +357,77 @@ V xgroove::mg_xshape(AtomList &ret) const
}
-V xgroove::m_xkeep(BL k)
-{
- xkeep = k;
- do_xzone();
-}
-
V xgroove::do_xzone()
{
if(!s2u) return; // this can happen if DSP is off
xzone = _xzone; // make a copy for changing it
- znsmin = curmin,znsmax = curmax;
- I plen = znsmax-znsmin; //curlen;
- if(xsymm < 0) {
- // crossfade zone is inside the loop (-> loop is shorter than nominal!)
- if(xzone >= plen) xzone = plen-1;
- znmin = znsmin+xzone,znmax = znsmax-xzone;
+ if(xfade == xsf_inside) { // fade zone goes inside the loop -> loop gets shorter
+ const L maxfd = (curmax-curmin)/2;
+ if(xzone > maxfd) xzone = maxfd;
+
+ znsmin = curmin,znsmax = curmax;
}
- else {
- // desired crossfade points
- znmin = znsmin+xzone*xsymm,znmax = znsmax+xzone*(xsymm-1);
- // extra space at beginning and end
- D o1 = znmin-xzone,o2 = buf->Frames()-(znmax+xzone);
-
- if(o1 < 0 || o2 < 0) { // or (o1*o2 < 0)
- if(o1+o2 < 0) {
- // must reduce crossfade/loop length
- if(!xkeep) {
- // prefer preservation of cross-fade length
- if(xzone*2 >= plen) // have to reduce cross-fade length
- xzone = plen/2;
- znmin = xzone,znmax = buf->Frames()-xzone;
- }
- else {
- // prefer preservation of loop length
- znmin += o1,znmax -= o2;
- xzone = (buf->Frames()-(znmax-znmin))/2;
- }
- znsmin = 0,znsmax = buf->Frames();
- }
- else if(o1 < 0) {
- // min point is out of bounds (but enough space for mere shift)
- I i1 = (I)o1;
- znsmin -= i1,znsmax -= i1;
- znmin = znsmin+xzone*xsymm,znmax = znsmax+xzone*(xsymm-1);
- }
- else /* o2 < 0 */ {
- // max point is out of bounds (but enough space for mere shift)
- I i2 = (I)o2;
- znsmin += i2,znsmax += i2;
- znmin = znsmin+xzone*xsymm,znmax = znsmax+xzone*(xsymm-1);
- }
+ else if(xfade == xsf_keepfade) {
+ // try to keep fade zone
+ // shifting of loop bounds may happen
+
+ // restrict xzone to half of buffer
+ const L maxfd = buf->Frames()/2;
+ if(xzone > maxfd) xzone = maxfd;
+
+ znsmin = curmin-xzone/2;
+ znsmax = curmax+xzone/2;
+
+ // check buffer limits and shift bounds if necessary
+ if(znsmin < 0) {
+ znsmax -= znsmin;
+ znsmin = 0;
+ }
+ if(znsmax > buf->Frames())
+ znsmax = buf->Frames();
+ }
+ else if(xfade == xsf_keeplooplen) {
+ // try to keep loop length
+ // shifting of loop bounds may happen
+
+ const L maxfd = buf->Frames()-(curmax-curmin);
+ if(xzone > maxfd) xzone = maxfd;
+
+ znsmin = curmin-xzone/2;
+ znsmax = curmax+xzone/2;
+
+ // check buffer limits and shift bounds if necessary
+ // both cases can't happen because of xzone having been limited above
+ if(znsmin < 0) {
+ znsmax -= znsmin;
+ znsmin = 0;
+ }
+ else if(znsmax > buf->Frames()) {
+ znsmin -= znsmax-buf->Frames();
+ znsmax = buf->Frames();
+ }
+ }
+ else if(xfade == xsf_keeplooppos) {
+ // try to keep loop position and length
+
+ znsmin = curmin-xzone/2;
+ znsmax = curmax+xzone/2;
+
+ L ovr = znsmax-buf->Frames();
+ if(-znsmin > ovr) ovr = -znsmin;
+ if(ovr > 0) {
+ znsmin += ovr;
+ znsmax -= ovr;
+ xzone -= ovr*2;
}
}
+
+ znmin = znsmin+xzone;
+ znmax = znsmax-xzone;
+
+ FLEXT_ASSERT(znsmin <= znsmax && (znsmax-znsmin) >= xzone*2);
}
V xgroove::m_loop(xs_loop lp)
@@ -442,7 +455,7 @@ V xgroove::s_pos_once(I n,S *const *invecs,S *const *outvecs)
S *pos = outvecs[outchns];
BL lpbang = false;
- const D smin = curmin,smax = curmax,plen = smax-smin; //curlen;
+ const D smin = curmin,smax = curmax,plen = smax-smin;
if(buf && plen > 0) {
register D o = curpos;
@@ -450,7 +463,7 @@ V xgroove::s_pos_once(I n,S *const *invecs,S *const *outvecs)
for(I i = 0; i < n; ++i) {
const S spd = speed[i]; // must be first because the vector is reused for output!
- if(o >= smax) { o = smax; lpbang = true; }
+ if(!(o < smax)) { o = smax; lpbang = true; }
else if(o < smin) { o = smin; lpbang = true; }
pos[i] = o;
@@ -476,13 +489,13 @@ V xgroove::s_pos_c_once(I n,S *const *invecs,S *const *outvecs)
S *pos = outvecs[outchns];
BL lpbang = false;
- const D smin = curmin,smax = curmax,plen = smax-smin; //curlen;
+ const D smin = curmin,smax = curmax,plen = smax-smin;
if(buf && plen > 0) {
register D o = curpos;
for(I i = 0; i < n; ++i) {
- if(o >= smax) { o = smax; lpbang = true; }
+ if(!(o < smax)) { o = smax; lpbang = true; }
else if(o < smin) { o = smin; lpbang = true; }
pos[i] = o;
@@ -522,7 +535,7 @@ V xgroove::s_pos_loop(I n,S *const *invecs,S *const *outvecs)
vec_dst(speed,GetPrefetchConstant(1,n>>2,0),0);
#endif
- const D smin = curmin,smax = curmax,plen = smax-smin; //curlen;
+ const D smin = curmin,smax = curmax,plen = smax-smin;
if(buf && plen > 0) {
register D o = curpos;
@@ -567,7 +580,7 @@ V xgroove::s_pos_c_loop(I n,S *const *invecs,S *const *outvecs)
S *pos = outvecs[outchns];
BL lpbang = false;
- const D smin = curmin,smax = curmax,plen = smax-smin; //curlen;
+ const D smin = curmin,smax = curmax,plen = smax-smin;
if(buf && plen > 0) {
register D o = curpos;
@@ -615,11 +628,13 @@ V xgroove::s_pos_loopzn(I n,S *const *invecs,S *const *outvecs)
S *pos = outvecs[outchns];
BL lpbang = false;
+ FLEXT_ASSERT(xzone);
+
const F xz = xzone,xf = (F)XZONE_TABLE/xz;
- const D lmin = znmin,lmax = znmax,lsh = lmax+xz-lmin;
+ const D lmin = znmin,lmax = znmax,lsh = lmax-lmin+xz;
// adapt the playing bounds to the current cross-fade zone
- const I smin = znsmin,smax = znsmax,plen = smax-smin; //curlen;
+ const L smin = znsmin,smax = znsmax,plen = smax-smin;
if(buf && plen > 0) {
BL inzn = false;
@@ -629,7 +644,7 @@ V xgroove::s_pos_loopzn(I n,S *const *invecs,S *const *outvecs)
// \TODO: exploit relationships: smin <= lmin, smax >= lmax
// normalize offset
- if(o >= smax) {
+ if(!(o < smax)) {
o = fmod(o-smin,plen)+smin;
lpbang = true;
}
@@ -638,20 +653,15 @@ V xgroove::s_pos_loopzn(I n,S *const *invecs,S *const *outvecs)
lpbang = true;
}
- // now: smin <= o < smax
-
if(o >= lmax) {
// in late cross-fade zone
+ o -= lsh;
+ }
- // shift it into early zone
- o -= lsh;
- }
-
- // now: lmin-xz <= o < lmax
-
+ // now: smin <= o < smax
if(o < lmin) {
// in early cross-fade zone
- register F inp = xz-(F)(lmin-o); // 0 <= inp < xz
+ register F inp = xz+(F)(o-lmin); // 0 <= inp < xz
znidx[i] = inp*xf;
znpos[i] = lmax+inp;
inzn = true;
@@ -707,7 +717,7 @@ V xgroove::s_pos_bidir(I n,S *const *invecs,S *const *outvecs)
S *pos = outvecs[outchns];
BL lpbang = false;
- const I smin = curmin,smax = curmax,plen = smax-smin; //curlen;
+ const I smin = curmin,smax = curmax,plen = smax-smin;
if(buf && plen > 0) {
register D o = curpos;
@@ -717,7 +727,7 @@ V xgroove::s_pos_bidir(I n,S *const *invecs,S *const *outvecs)
const S spd = speed[i]; // must be first because the vector is reused for output!
// normalize offset
- if(o >= smax) {
+ if(!(o < smax)) {
o = smax-fmod(o-smin,plen); // mirror the position at smax
bd = -bd;
lpbang = true;
@@ -752,25 +762,26 @@ V xgroove::s_dsp()
switch(loopmode) {
case xsl_once: SETSIGFUN(posfun,SIGFUN(s_pos_once)); break;
case xsl_loop:
- if(_xzone > 0) {
- // xzone might not be set yet (is done in do_xzone() )
+ // 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();
if(pblksz != blksz) {
for(I o = 0; o < outchns; ++o) {
- delete[] znbuf[o];
+ if(znbuf[o]) delete[] znbuf[o];
znbuf[o] = new S[blksz];
}
- delete[] znpos; znpos = new S[blksz];
- delete[] znidx; znidx = new S[blksz];
+ if(znpos) delete[] znpos;
+ znpos = new S[blksz];
+ if(znidx) delete[] znidx;
+ znidx = new S[blksz];
pblksz = blksz;
}
- do_xzone(); // recalculate (s2u may have been 0 before)
-
SETSIGFUN(posfun,SIGFUN(s_pos_loopzn));
// linear interpolation should be just ok for fade zone, no?
diff --git a/externals/grill/xsample/source/main.h b/externals/grill/xsample/source/main.h
index 15dee169..f19dce45 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.0pre18"
+#define XSAMPLE_VERSION "0.3.0pre19"
#define FLEXT_ATTRIBUTES 1
@@ -113,7 +113,7 @@ public:
enum xs_intp {
xsi__ = -1, // don't change
- xsi_none = 0,xsi_4p,xsi_lin
+ xsi_none = 0,xsi_lin,xsi_4p
};
enum xs_sclmd {
@@ -146,7 +146,7 @@ protected:
xs_unit unitmode; //iunitmode,ounitmode;
xs_sclmd sclmode; //isclmode,osclmode;
- I curmin,curmax; //,curlen; // in samples
+ L curmin,curmax; //,curlen; // in samples
I sclmin; // in samples
F sclmul;
F s2u; // sample to unit conversion factor