«In-between, longing» by jpdrecourt
on 29 Sep'20 23:04 inThis is the full code of the piece "In-between, longing" posted here for reference. For a brief explanation of some of the features of the code, please check my blog post. You can also listen to the piece on Bandcamp. Unfortunately, the sound files are copyrighted, so I can't share them here. Feel free to reach out through my website if you have any questions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313
( s.options.memSize_(2**18); s.reboot; s.waitForBoot { Buffer.freeAll(s); Pdef.clear; s.freeAll; q.clear; s.sync; m = ProxySpace.new; // Mixer // Dictionaries v = (); // Variables f = (); // Functions p = (); // Patterns b = (); // Busses c = (); // Buffers g = (); // Groups i = (); // Synth (instruments) t = TempoClock.default; s.sync; // Various setup v[\seed] = 262; // Random seed v[\debug] = false; // Debugging messages v[\mixerOn] = false; // Visual mixer v[\record] = true; // Recording the output // Piece version thisThread.randSeed = v[\seed]; // Tempo variation t.tempo = 1; t.sched(0, {|beat| t.tempo = (60 + (12*sin((beat/200)*(2*pi))))/60; 1;}); v[\partDur] = 41; // Silence management v[\silenceProb] = 0.2; //////////////////////////////////////////////////////////// // SynthDefs //// Routing synth SynthDef(\route2, {|in = 0, out = 0| Out.ar(out, In.ar(in, 2)); }).add; //// Playing mono buffer SynthDef(\bufRdPan, {|out = 0, bufnum = 0, pan = 0.0, amp = 1.0, start = 0.0, end = 1.0, fade = 0.001, rate = 1.0| var sig, bStart, bEnd, env; bStart = start*BufFrames.ir(bufnum); bEnd = end*BufFrames.ir(bufnum); sig = BufRd.ar(1, bufnum, Phasor.ar(0, BufRateScale.ir(bufnum)*rate, bStart, bEnd, bStart), 0.0); env = Env([0.0, 1.0, 1.0, 0.0], [fade, (BufDur.ir(bufnum)*(end - start)/rate) - (2.0*fade), fade]).ar(Done.freeSelf); env = env*amp; sig = Pan2.ar(sig, pan); Out.ar(out, sig*env); }).add; //// Playing a mono buffer with a loop in the middle SynthDef(\bufRdPanInnerLoop, {|out = 0, bufnum = 0, pan = 0.0, amp = 1.0, lStart = 0.5, lWidth = 0.05, nLoop = 12| var sig, envGen; envGen = EnvGen.ar( Env([0, lStart, lStart + lWidth, lStart, lStart + lWidth, 1]*BufFrames.ir(bufnum), [lStart, lWidth, lWidth, lWidth, 1 - lStart - lWidth]*BufDur.ir(bufnum), releaseNode: 4, loopNode: 2, curve: 0 ), gate: Trig.ar(1, (lStart + (((2 * nLoop) + 1) * lWidth))*BufDur.ir(bufnum)), doneAction: Done.freeSelf ); sig = BufRd.ar(1, bufnum, envGen, 0); Out.ar(out, Pan2.ar(sig, pan, amp)); }).add; //// Playing an expanding or contracting loop SynthDef(\bufRdPanExpandLoop, {|out = 0, bufnum = 0, pan = 0.0 ,amp = 1.0, len = 2.0, sus = 1.0, t_trig = 1, dir = 1, minWidth = 0.2, initPos = 0.2| var sig, startPos, endPos, phase, fade, env; fade = (len - sus)/2.0; startPos = Env( levels: [(1 + dir), (1 + dir), (1 - dir)] / 2.0 * (initPos * (1 - (minWidth/2.0))), times: [fade, sus] ).kr() * BufFrames.kr(bufnum); endPos = Env( levels: ([(1 + dir), (1 + dir), (1 - dir)] / 2.0 * ((initPos * (1 + (minWidth/2.0)))- 1)) + 1, times: [fade, sus] ).kr() * BufFrames.kr(bufnum); phase = Phasor.ar(0, BufRateScale.kr(bufnum), startPos, endPos); env = Env( levels: [0, 1, 1, 0], times: [fade, sus, fade], curve: \sin ).kr(Done.freeSelf); sig = BufRd.ar(1, bufnum, phase)*env*amp; sig = Median.ar(7, sig); sig = Pan2.ar(sig, pan); Out.ar(out, sig); }).add; // FX generator f[\makeFx] = {|name, func| SynthDef(name, {|out = 0, amp = 1.0, wet = 1.0| var sig = In.ar(out, 2); sig = ((1 - wet)*sig) + (wet*SynthDef.wrap(func, prependArgs: [sig])); ReplaceOut.ar(out, sig*amp); }).add; }; f[\makeFx].(\companderFx, {|sig, thresh = 0.1, slope = 0.5, clamp = 0.02, relax = 0.4| sig = CompanderD.ar(sig, sig, thresh: thresh, slopeAbove: slope, clampTime: clamp, relaxTime: relax ); sig }); //// Masterchain FX f[\makeFx].(\masterChainFx, {|sig, thresh = 0.1, slope = 0.5, clamp = 0.02, relax = 0.4, hpfFreq = 50, gainDb = 0| sig = HPF.ar(sig, hpfFreq); sig = CompanderD.ar(sig, sig, thresh: thresh, slopeAbove: slope, clampTime: clamp, relaxTime: relax ); sig = sig*gainDb.dbamp; sig = Limiter.ar(sig, -0.7.dbamp, 0.006); sig }); //// EQ FX, hardcoded, easier but naughty ;) f[\makeFx].(\eqFx, {|sig| sig = BPeakEQ.ar(sig, freq: 2300, rq:1/1.1, db: 0.5); sig = BHiShelf.ar(sig, freq: 7910, db: 1.6, rs: 1.0); sig }); //// Haas FX f[\makeFx].(\haasFx, {|sig, delay = 0.020, gate = 1| Env([1, 1, 0], [0.1, 0.1], \lin, 1).kr(gate: gate, doneAction: Done.freeSelf); sig[1] = DelayN.ar(sig[1], 0.1, delay); sig }); //// Distorsion f[\makeFx].(\softclipFx, {|sig, preAmp = 1.0, postAmp = 1.0| var oldSig = sig; sig = (sig * preAmp).softclip; sig = Balance.ar(sig, oldSig); sig * postAmp; }); //// LFO panning with triangular wave f[\makeFx].(\triPanner, {|sig ,freq = 1.0, iphase = 0.0, lo = -1.0, hi = 1.0| sig = Balance2.ar(sig[0], sig[1], LFTri.kr(freq, iphase).range(lo, hi)); sig }); // Dust trigger for stutter SynthDef(\varyDust, {|out = 0, trigLow = 0.2, trigHigh = 0.6, trigChangeF = 0.5| var trig = Dust.kr(LFNoise0.kr(trigChangeF).range(trigLow, trigHigh)); Out.kr(out, trig); }).add; // Invert the phase of one channel Fx f[\makeFx].(\chPhaseInvertFx , {|sig| var sigLPF = LPF.ar(sig, 300); sig = sig - sigLPF; sig[1] = 0 - sig[1]; sig = sig + ((sigLPF[0] + sigLPF[1])/2); }); // Wavetable reader with bell type sound SynthDef(\wavetableBell, {|out = 0, freq = 200, t_trig = 1, firstBufnum, lastBufnum, release = 0.5, amp = 0.8, pan = 0, attack = 0.01, rq = 1.0, curve = -4| var env, sig, theBuf; env = Env.perc(attackTime: attack, releaseTime: release, curve: curve).kr(gate: t_trig); theBuf = Env([0, 0.9999], [release + attack]).kr(gate:t_trig).linlin(0, 1, firstBufnum, lastBufnum); sig = VOsc.ar(theBuf, freq); sig = BPF.ar(sig, freq, rq, 1/rq.sqrt); Out.ar(out, Pan2.ar(sig, pan, amp*env)); Env([1, 1], [release + attack]*1.2).kr(gate: t_trig, doneAction: Done.freeSelf); } ).add; // Bad radio Fx f[\makeFx].(\badRadioFx, {|sig, freq = 1100, staticWet = 0.4, noise = 0.05, rq = 0.6| var hum, dustNoise, staticNoise, humFreq, numHarms, dcSig; // Radio static (inspired by http://sccode.org/1-4Wu) numHarms = 7; humFreq = 100; hum = Array.fill(numHarms, {|i| SinOsc.ar( (i+1) * humFreq, 0, 1/numHarms)}); hum = hum.sum; dustNoise = Dust2.ar(LFNoise1.ar(0.5).range(1000,15000)); // Dust or Dust2 ? staticNoise = hum * dustNoise * LFNoise1.ar(1).range(0.8, 1.2); // Add DC parasites dcSig = Dust2.ar(LFNoise1.ar(5).exprange(500, 2000))*noise*Env([0, 1, 0], [0, 3], \exp, releaseNode: 1).kr(gate: Trig.kr(DetectSilence.kr(A2K.kr(sig[0]), -30.dbamp), 0.001)); // Add the static noise (Convolution) sig = SelectX.ar(staticWet, [sig, Convolution.ar(sig + dcSig, staticNoise)]); // Speaker effect sig = BPF.ar(sig, freq, rq, 1/(rq.sqrt)); sig = (sig*2).distort*0.5; sig }); // Random delay on the right channel Fx f[\makeFx].(\rndDelayRightFx, {|sig, changeFreq = 0.5| var time, lastTime, delayedTime, slope; time = LFNoise0.kr(changeFreq, 2.5, 2.5); lastTime = LastValue.kr(time); delayedTime = DelayN.kr(time, 0.03, 0.03); sig[1] = SelectX.ar(EnvGen.kr(Env([0, 0, 0, 1], [0.02, 0.02, 0.02], \sine), Changed.kr(time)), [DelayN.ar(sig[1], 5, lastTime), DelayN.ar(sig[1], 5, delayedTime)]); sig }); // Switch left and right channel randomly Fx f[\makeFx].(\switchLRFx, {|sig, switchFreq = 0.1| sig = SelectX.ar(Lag3.kr(LFClipNoise.kr(switchFreq)).linlin(-1, 1, 0, 1), [[sig[0], sig[1]], [sig[1], sig[0]]]); sig }); // Stutter Fx f[\makeFx].(\stutterFx, {|sig, bufLen = 20, trigIn, maxLen = 0.25| var rBuf, start, stop, trig, phase, stutterDur, d; // Create the buffer rBuf = LocalBuf(s.sampleRate*bufLen, 2).clear; // Record the incoming sound BufWr.ar(sig, rBuf, Phasor.ar(1, BufRateScale.ir(rBuf), 0.0, BufFrames.ir(rBuf))); // Trigger the buffer repetition trig = In.kr(trigIn); d = Dwhite(0.0, 1.0); // Extract from the buffer start = Demand.kr(trig, 0, d); stop = (start + ((Demand.kr(trig, 0, d))*maxLen)).min(1.0); stutterDur = BufDur.ir(rBuf)*(stop - start); // Read the buffer phase = Env( levels: [0, start*BufFrames.ir(rBuf), stop*BufFrames.ir(rBuf)], times: [0, stutterDur]).ar(gate: trig); sig = BufRd.ar(2, rBuf, phase); sig = sig*Env([0, 0, 1, 1, 0], [0, 0.001, inf, 0.001], releaseNode: 3).kr(gate: Trig.kr(trig, stutterDur)); // Scramble sig = SelectX.ar(Env([1, 1, 0], [inf, 0.1], releaseNode: 1).kr(gate: Trig.kr(trig, LFNoise0.kr(0.1).range(0.0, 2.0))), [sig, DelayC.ar(sig, 1.0, LFNoise0.ar(8).range(0.0, 1.0))]); sig }); // Convolution reverb with mono IR, and Haas delay to give a sense of space f[\makeFx].(\convRevFx8192, {|sig, irSpectrum, mul, haas| // Convolution reverb with mono sig = PartConv.ar(sig, 8192, irSpectrum, mul); sig[1] = DelayN.ar(sig[1], haas, haas); sig }); // Changing Echo Fx f[\makeFx].(\changingEchoFx, {|sig, send = 0.4, slope = 1.0, time = 10, decay = 5.0, gate = 1| var mul; mul = (Line.kr(0, send, time)*slope) + ((1 - slope)/2*send); sig = AllpassN.ar(sig*mul, 0.2, 0.2, decay, 1.0, sig); sig = sig*Env([1, 1, 0], [1, decay*1.5], \lin, 1).kr(gate: gate, doneAction: Done.freeSelf); sig }); // Band Pass filter Fx f[\makeFx].(\bpfFx, {|sig, gate = 1, freq = 850, rq = 2| sig = BPF.ar(sig, freq, rq, 1/rq.sqrt); sig = sig*Env([1, 1, 0], [1, 4], \lin, 1).kr(gate: gate, doneAction: Done.freeSelf); sig }); s.sync; // High pass filter Fx f[\makeFx].(\hpfFx, {|sig, gate = 1, freq = 1000| sig = HPF.ar(sig, freq); sig = sig*Env([1, 1, 0], [1, 4], \lin, 1).kr(gate: gate, doneAction: Done.freeSelf); sig }); // Guts Fx f[\makeFx].(\gutsFx, {|sig, freq = 150, rq = 0.1| sig = Mix.ar(Array.fill(7, {|i| CombL.ar(sig, 0.2, LFNoise1.kr(0.1*((LFTri.kr(0.01, 0, 4.9, 5)*i) + 1), 0.08, 0.1)/((i + 1)), 2)*0.5 })); 4.do({ sig = AllpassN.ar(sig, 0.1, [LFNoise1.kr(0.1.rand, 0.04, 0.05), LFNoise1.kr(0.1.rand, 0.04, 0.05)], 5) }); sig = BPF.ar(sig, freq, rq); sig }); // MultiDelay Fx f[\makeFx].(\multiDelayFx, {|sig, combDelay = 1.7, allpassDelay = 2.5, decayTime = 5.0| var n, harm, amps, ring; sig = CombN.ar(AllpassN.ar(sig, allpassDelay, allpassDelay, decayTime, ), combDelay, combDelay, decayTime); sig }); // Wash Reverb Fx f[\makeFx].(\washReverbFx, { |sig, gate = 1.0| // From 17_Delays_reverbs var z, y; z = DelayN.ar(HPF.ar(sig, 300), 0.1); // 7 length modulated comb delays in parallel : y = Mix.ar(Array.fill(7,{ CombL.ar(z, 0.1, LFNoise1.kr(0.1.rand, 0.04, 0.05), 15) })); // two parallel chains of 4 allpass delays (8 total) : 4.do({ y = AllpassN.ar(y, 0.050, [0.050.rand, 0.050.rand], 1) }); sig = y; sig }); // High shelf FX f[\makeFx].(\highShelfFx, {|sig, freq = 1200, rs = 1.0, db = 0.0| sig = BHiShelf.ar(sig, freq, rs, db); sig }); // Phaser f[\makeFx].(\phaserFx, {|sig, delay = 0.2, decay = 1.0| var theDelay = delay + SinOsc.kr([4, 5], [0, pi/2], 0.05*delay); sig = AllpassN(sig, delay, delay, decay) - sig; sig }); // Theta wave distortion f[\makeFx].(\thetaDistortFx, {|sig, freq = 6.0, preAmp = 0.5| var oldSig, control = SinOsc.ar(freq, 0.0, preAmp); oldSig = sig; sig = Compander.ar(sig, control, 0.9, 1.0, 0.0, 0.001, 0.001); sig = Balance.ar(sig, oldSig); sig }); // Simple envelope out on bus SynthDef(\simpleEnv, {|out = 0, startVal = 0.0, endVal = 1.0, dur = 10.0, curve = \sin| Out.kr(out, Env([startVal, endVal], [dur], curve).kr(Done.freeSelf)); }).add; // Setup a convolution reverb f[\convSetup] = {|ir, channel, amp, synth = \convRevFx8192| Synth(synth, [\out, b[channel], \irSpectrum, c[\IR][ir][\buffer], \mul, c[\IR][ir][\mul], \haas, c[\IR][ir][\haas], \amp, amp ], g[channel], \addToTail) }; // Mouse XY router SynthDef(\mouseXY, {|outX, minX =0, maxX = 1, warpX = 0, outY, minY = 0, maxY = 0, warpY = 0| Out.kr(outX, Poll(MouseButton.kr, MouseX.kr(minX, maxX, warpX))); Out.kr(outY, Poll(MouseButton.kr, MouseY.kr(minY, maxY, warpY))); }).add; b[\mouseX] = Bus.control(s, 1); b[\mouseY] = Bus.control(s, 1); //////////////////////////////////////////////////////////// ////// cKey: Key for a channel (adds extra zero for channels 0-9) f[\cKey] = {|i| ("c" ++ i.asString.padLeft(2, "0")).asSymbol }; //////////////////////////////////////////////////////////// // Basic mixer // Convention: // Send effects: m[\c00] to m[\c09] (max 9) // Channels: m[\c10] to m[\c99] (max 90) v[\nChannels] = 15; v[\nSends] = 4; b[\master] = 0; b[\send] = (); s.sync; // Channels v[\nChannels].do { |i| var ch = f[\cKey].(i + 10); var chWrapper = (ch ++ "Wrap").asSymbol; b[ch] = Bus.audio(s, 2); b[chWrapper] = Bus.audio(s, 2); g[chWrapper] = Group.new; // Send the bus to the master bus Synth.tail(g[chWrapper], \route2, [\in, b[chWrapper], \out, b[\master]]); s.sync; m[ch].play(out: b[chWrapper], numChannels: 2, group: g[chWrapper], addAction: \addToHead); // Create the channel and play on its private bus // Group where to insert the instrument m[ch].source_({|pan = 0.0, width = 1.0| var thewidth = width.min(1 - pan.abs); var sig = In.ar(b[ch], 2); Splay.ar(sig, thewidth, 1, pan); }); s.sync; g[ch] = Group.new(g[chWrapper], \addToHead); }; Spec.add(\width, ControlSpec(0.0, 1.0, default: 1.0)); // Sends v[\nSends].do { |i| var snd = f[\cKey].(i); var sndWrapper = (snd ++ "Fx").asSymbol; b[snd] = Bus.audio(s, 2); g[sndWrapper] = Group.new; // Send the bus to the master bus Synth.tail(g[sndWrapper], \route2, [\in, b[snd], \out, b[\master]]); // Group where the FX should be inserted g[snd] = Group.new(g[sndWrapper], \addToHead); s.sync; // Create the channel and play it before the FX group m[snd].play(b[snd], 2, group: g[sndWrapper], addAction: \addToHead); s.sync; // Capture each channel post fader v[\nChannels].do { |j| var ch = f[\cKey].(j + 10); var chWrapper = (ch ++ "Wrap").asSymbol; var mix = (\mix ++ (j + 10)).asSymbol; m[snd][j + 10] = \mix -> {In.ar(b[chWrapper], 2)}; m[snd].set(mix, 0.0); // Adds a proper slider for the ProxyMixer Spec.add(mix, ControlSpec(0, 6.dbamp, \amp, 0, 1.0)); }; }; Spec.add(\amp, ControlSpec(0, 6.dbamp, \amp, 0, 1.0)); // Master chain s.sync; i[\masterChain] = (); i[\masterChain][\compLim] = Synth.tail(s, \masterChainFx, [\out, b[\master], \thresh, 0.075, \gainDb, 12.5]); i[\masterChain][\eq] = Synth.before(i[\masterChain][\compLim], \eqFx, [\out, b[\master]]); // Visual mixer s.sync; v[\mixerOn].if { v[\mixer] = ProxyMixer(m); ProxyMeter.addMixer(v[\mixer]); CmdPeriod.doOnce({ v[\mixer].close }); }; //////////////////////////////////////////////////////////// // Variables and functions init //// Paths v[\path] = (); if(thisProcess.platform.name == \windows, {v[\path][\root] = PathName.new(thisProcess.nowExecutingPath).parentPath}, {v[\path][\root] = PathName.new("~").fullPath} ); v[\path][\data] = v[\path][\root] +/+ "Data Files"; v[\path][\IR] = v[\path][\data] +/+ "IR"; v[\path][\IRData] = v[\path][\IR] +/+ "IRData.txt"; v[\path][\groupSequence] = v[\path][\data] +/+ "8_groups_sequence.txt"; v[\path][\media] = v[\path][\root] +/+ "Media Files"; //// Load IRs c[\IR] = (); TabFileReader.read(v[\path][\IRData], true).do {|row| var name = row[0].asSymbol; c[\IR][name] = (); c[\IR][name][\buffer] = Buffer.read(s, v[\path][\IR] +/+ row[1]); c[\IR][name][\fftSize] = row[2].asInteger; c[\IR][name][\mul] = row[3].asFloat; c[\IR][name][\haas] = row[4].asFloat; }; //// Soundfiles list v[\soundFiles] = (); PathName(v[\path][\media]).folders.do { |folder| (folder.folderName.asSymbol === \story).if { // Story file list update later v[\soundFiles][\story] = (); } { // Other folders treated as one v[\soundFiles][folder.folderName.asSymbol] = SoundFile.collect( folder.fullPath +/+ "*.flac"); } }; //// Remember Wavetable v[\soundFiles][\rememberWT] = (); PathName(v[\path][\media] +/+ \remember).folders.do { |folder| v[\soundFiles][\rememberWT][folder.folderName.asSymbol] = SoundFile.collect( folder.fullPath +/+ "*.wavetable"); }; //// Garbage collection v[\garbageDelta] = 20; //// Recording v[\record].if { s.record(v[\path][\root] +/+ 'Recordings' +/+ 'In_Between-Longing-' ++ v[\seed].asString.padLeft(4, "0") ++ ".aif", b[\master], 2, duration:70*60); }; //// Functions ////// rndBufs : Select randomly (with repetition) a given number of files ////// in the soundFileList (created with SoundFile.collect) and create buffers ////// Returns the buffers f[\rndBufs] = { |soundFileList, nFiles = 1| var bufferArray, isLoaded; isLoaded = Array.fill(nFiles, false); bufferArray = Array.fill(nFiles, {|i| var buffer; buffer = Buffer.read(s, soundFileList.choose.path, action: {isLoaded[i] = true}); }); bufferArray }; ////// bufInfo : Returns a string with the buffer number and the file name w/o path f[\bufInfo] = {|b| "" ++ b.bufnum ++ " -> " ++ PathName(b.path).fileName }; //////toGarbage: Schedules a buffer for freeing f[\toGarbage] = {|buffer, delta = (v[\garbageDelta])| // postln("Scheduling for freeing: " ++ f[\bufInfo].(buffer)); AppClock.sched(delta, { // postln("Freeing: " ++ f[\bufInfo].(buffer)); buffer.free; }); }; ////// bufDur: Returns the buffer duration or zero (useful if the buffer is late) f[\bufDur] = {|buf| var bufDur = 0; try {bufDur = buf.duration}; bufDur }; ////// Trace the buffer number f[\bufDebug] = {|pattern| Pchain(Pbind(\callback, {postln(try {"Playing: " ++ f[\bufInfo].(~bufnum)}{postln(~instrument)})}), pattern) }; ////// Resetting a part using the f[\partReset] function f[\resetPart] = {|part, delta| TempoClock.sched(delta,{ f[(part ++ \Reset).asSymbol].(); nil }); }; s.sync; //////////////////////////////////////////////////////////// // MasterChain effects //// Theta distorsion i[\masterChain][\thetaDistort] = Synth.before(i[\masterChain][\compLim],\thetaDistortFx, [\out, b[\master]]); b[\masterThetaFreq] = Bus.control(s, 1).value_(4.0); b[\masterThetaPreAmp] = Bus.control(s, 1).value_(0.0); i[\masterChain][\thetaDistort].map(\freq, b[\masterThetaFreq]); i[\masterChain][\thetaDistort].map(\preAmp, b[\masterThetaPreAmp]); //////////////////////////////////////////////////////////// // Send effects //// c00: Stutter radio i[\c00] = (); b[\varyDust] = Bus.control(s); i[\c00][\varyDust] = Synth(\varyDust, [\out, b[\varyDust], \trigHigh, 0.55], g[\c00]); i[\c00][\stutterFx] = Synth(\stutterFx, [\trigIn, b[\varyDust], \out, b[\c00]], g[\c00], \addToTail); i[\c00][\badRadioFx] = Synth(\badRadioFx, [\out, b[\c00], \amp, 3.dbamp], g[\c00], \addToTail); //// c01: Convolution reverb 1 b[\c01Amp] = Bus.control(s, 1).value_(1.0); //// c02: Convolution reverb 2 b[\c02Amp] = Bus.control(s, 1).value_(0.0); //// c03: Wash reverb i[\c03] = (); i[\c03][\washReverb] = Synth(\washReverbFx, [\out, b[\c03], \amp, 1.0], g[\c03]); //////////////////////////////////////////////////////////// // Story c[\story] = (); v[\storyRhythms] = [ Pseq([5, 4, 2, 1, 4, 6], inf)*Pwhite(0.9, 1.1), Pn(Pgeom(1, 1.23, 7)*2), Pn(Pgeom(4, 0.9, 7)*1.5) ]; //// Story effects i[\c10] = (); i[\c10][\rndDelayRight] = Synth(\rndDelayRightFx, [\out, b[\c10], \wet, 1, \amp, 1], g[\c10], \addToTail); i[\c10][\switchLR] = Synth(\switchLRFx, [\out, b[\c10], \amp, 1.0], g[\c10], \addToTail); //// Story data v[\storyGroups] = Array.with( nil, [\Corridor, \Walls, \Creating, \Brightday, \Inbetween, \Stable], // G1 [\Six, \Talked, \Hair, \Eyes, \Boys], // G2 [\Moment, \Walking, \Side, \Was, \Other], // G3 [\Alone, \Close, \Friend, \Name, \Knew], // G4 [\Following, \Ahead, \Sure, \Facing, \Longing], // G5 [\Smocks, \Painted, \Bricks, \Brise, \Casting], // G6 [\Roofs, \Stone, \Tarmac, \Intimacy], // G7 [\Incredible, \Wanting, \Someone, \Away, \Stay, \Anywhere, \Lost] // G8 ); //// Initialize patterns v[\storyGroups].do {|group, iGroup| group.notNil.if { v[\storyGroups][iGroup].do{|item, iItem| // Creates the patterns with an empty buffer array // The array will be filled at initialisation c[\story][item.asSymbol] = []; v[\soundFiles][\story][item] = SoundFile.collect(v[\path][\media] +/+ "story" +/+ "G" ++ iGroup ++ "-" ++ item ++ "-*.flac"); p[(\story ++ item).asSymbol] = Pbind( \instrument, \bufRdPan, \bufnum, Pfuncn {c[\story][item].choose}, \amp, 0.4, ); }; }; }; //// FSM for each group p[\storyG1] = Pfsm([ #[0, 2, 4, 5], p[(\story ++ v[\storyGroups][1][0]).asSymbol], #[1, 2, 3, 4, 5], p[(\story ++ v[\storyGroups][1][1]).asSymbol], #[2, 4,5], p[(\story ++ v[\storyGroups][1][2]).asSymbol], #[1, 3], p[(\story ++ v[\storyGroups][1][3]).asSymbol], #[0, 1, 2], p[(\story ++ v[\storyGroups][1][4]).asSymbol], #[0, 1, 2, 5], p[(\story ++ v[\storyGroups][1][5]).asSymbol], #[0, 2, 4], nil, nil ]); p[\storyG2] = Pfsm([ #[0, 1], p[(\story ++ v[\storyGroups][2][0]).asSymbol], #[1, 4], p[(\story ++ v[\storyGroups][2][1]).asSymbol], #[0, 2, 3, 4], p[(\story ++ v[\storyGroups][2][2]).asSymbol], #[3, 4], p[(\story ++ v[\storyGroups][2][3]).asSymbol], #[2, 4], p[(\story ++ v[\storyGroups][2][4]).asSymbol], #[0, 1, 2, 3], nil, nil ]); p[\storyG3] = Pfsm([ #[0, 1], p[(\story ++ v[\storyGroups][3][0]).asSymbol], #[1, 2, 3], p[(\story ++ v[\storyGroups][3][1]).asSymbol], #[0, 2, 3], p[(\story ++ v[\storyGroups][3][2]).asSymbol], #[0, 1, 3, 4], p[(\story ++ v[\storyGroups][3][3]).asSymbol], #[2, 4], p[(\story ++ v[\storyGroups][3][4]).asSymbol], #[0, 1, 3], nil, nil ]); p[\storyG4] = Pfsm([ #[0, 1, 3, 4], p[(\story ++ v[\storyGroups][4][0]).asSymbol], #[1, 3, 4], p[(\story ++ v[\storyGroups][4][1]).asSymbol], #[2, 3, 4], p[(\story ++ v[\storyGroups][4][2]).asSymbol], #[1, 3, 4], p[(\story ++ v[\storyGroups][4][3]).asSymbol], #[0, 1, 2, 4], p[(\story ++ v[\storyGroups][4][4]).asSymbol], #[1, 3], nil, nil ]); p[\storyG5] = Pfsm([ #[0, 1, 2, 3, 4], p[(\story ++ v[\storyGroups][5][0]).asSymbol], #[1, 2, 3, 4], p[(\story ++ v[\storyGroups][5][1]).asSymbol], #[0, 2, 3, 4], p[(\story ++ v[\storyGroups][5][2]).asSymbol], #[0, 1, 3, 4], p[(\story ++ v[\storyGroups][5][3]).asSymbol], #[0, 1, 2, 4], p[(\story ++ v[\storyGroups][5][4]).asSymbol], #[0, 1, 2, 3], nil, nil ]); p[\storyG6] = Pfsm([ #[0, 1, 2], p[(\story ++ v[\storyGroups][6][0]).asSymbol], #[1, 2, 4], p[(\story ++ v[\storyGroups][6][1]).asSymbol], #[0, 2], p[(\story ++ v[\storyGroups][6][2]).asSymbol], #[1, 3, 4], p[(\story ++ v[\storyGroups][6][3]).asSymbol], #[1, 2, 4], p[(\story ++ v[\storyGroups][6][4]).asSymbol], #[0, 1, 2, 3], nil, nil ]); p[\storyG7] = Pfsm([ #[0, 1, 2, 3], p[(\story ++ v[\storyGroups][7][0]).asSymbol], #[1, 2, 3], p[(\story ++ v[\storyGroups][7][1]).asSymbol], #[0, 2, 3], p[(\story ++ v[\storyGroups][7][2]).asSymbol], #[0, 1, 3], p[(\story ++ v[\storyGroups][7][3]).asSymbol], #[0, 1, 2], nil, nil ]); p[\storyG8] = Pfsm([ #[0, 1, 2, 3, 6], p[(\story ++ v[\storyGroups][8][0]).asSymbol], #[1, 2, 4, 5, 6], p[(\story ++ v[\storyGroups][8][1]).asSymbol], #[0, 2, 3, 4, 5, 6], p[(\story ++ v[\storyGroups][8][2]).asSymbol], #[0, 1, 3, 4, 6], p[(\story ++ v[\storyGroups][8][3]).asSymbol], #[0, 1, 2, 4, 6], p[(\story ++ v[\storyGroups][8][4]).asSymbol], #[0, 5, 6], p[(\story ++ v[\storyGroups][8][5]).asSymbol], #[0, 3, 4, 6], p[(\story ++ v[\storyGroups][8][6]).asSymbol], #[0], nil, nil ]); //// Load group sequence and start at a random place v[\groupSequence] = File.readAllString(v[\path][\groupSequence]); v[\iGroup] = v[\groupSequence].size.rand; f[\storyReset] = { // Clean old buffers v[\storyGroups][v[\groupSequence][v[\iGroup]].digit].do {|item| c[\story][item].do {|buf| f[\toGarbage].(buf); }; }; // Choose the rhythm v[\storyRhythm] = v[\storyRhythms].choose; // Change the frequencies i[\c10][\rndDelayRight].set(\changeFreq, 0.8.rand); i[\c10][\switchLR].set(\switchFreq, 0.8.rand); // Prepare new buffers v[\iGroup] = (v[\iGroup] + 1)% v[\groupSequence].size; v[\storyGroups][v[\groupSequence][v[\iGroup]].digit].do {|item| c[\story][item] = f[\rndBufs].(v[\soundFiles][\story][item], 3) }; // Return nothing nil }; //// First initialisation f[\storyReset].(); //// Init story pattern p[\storyTold] = Plazy { p[(\storyG ++ v[\groupSequence][v[\iGroup]]).asSymbol] <> Pbind(\delta, v[\storyRhythm]); }; //// Story pattern p[\story] = p[\storyTold]; p[\story] = (p[\story] <> (group: g[\c10], out: b[\c10])); v[\debug].if {p[\story] = f[\bufDebug].(p[\story])}; //////////////////////////////////////////////////////////// // Ands //// Ands variations v[\andsPanVars] = Array.with( (Pgeom(1, 0.95) - 1) * Pseq([-1, 1], inf), // Expanding Pgeom(1, 0.95) * Pseq([-1, 1], inf), // Concentrating ); v[\shortAndsVars] = Array.with ( { // Expand/Contract Pseq([ Event.silent(4.0), Pbind( \instrument, \bufRdPan, \bufnum, Pseq([Pfuncn {c[\ands][\short].choose}], {20 + 20.rand}), \delta, Pfunc {0.1.rand}, \rate, Pseq([ Pn(1, 10), 25 - Pgeom(15, 0,9) ]), \pan, Plazy {v[\andsPan]}, \amp, Pseq([Pn(0.4, 10), Pn(0.2)]), )], inf)},{ // Bursts var pat; pat = Pbind( \instrument, \bufRdPan, \bufnum, Pstutter(4, Pfunc {c[\ands][\short].choose}), \delta, Pseq([1, 0.1, 0.5, Pfuncn {(4.0 + 4.0.rand)}], inf), \amp, Pseq([0.2, 0.25, 0.32, 0.4], inf), \pan, Pn(Pstutter(4, Pwhite(-1.0, 1.0, 1)) * Pgeom(1, 0.5, 4)) ); pat = Ptpar([0.0, pat, {4.0.rand}, pat]); pat} ); //// Ands Init c[\ands] = (); f[\andsReset] = { // Clean old buffers c[\ands].do {|bufs| bufs.do {|buf| f[\toGarbage].(buf); }; }; // Variations v[\andsPan] = v[\andsPanVars].choose; v[\shortAnds] = v[\shortAndsVars].choose; // Select new buffers c[\ands][\long] = f[\rndBufs].(v[\soundFiles][\andLong], 1); c[\ands][\short] = f[\rndBufs].(v[\soundFiles][\andVowel], 5); // Return nothing nil }; f[\andsReset].(); //// Ands Patterns p[\longAnds] = Pbind( \instrument, \bufRdPanInnerLoop, \bufnum, Pfunc {c[\ands][\long].choose}, \delta, 6, \nLoop, Pstutter(inf, Pfuncn {2 + 7.rand}), \lWidth, Pstutter(inf, Pfuncn {0.2.rand + 0.01}), \lStart, Pstutter(inf, Pfuncn {0.5.rand + 0.1}), \amp, 0.4, ); p[\shortAnds] = Plazy ({v[\shortAnds].()}); p[\ands] = Ppar([p[\longAnds], p[\shortAnds]]); p[\ands] = p[\ands] <> (group: g[\c11], out: b[\c11]); v[\debug].if {p[\ands] = f[\bufDebug].(p[\ands])}; //////////////////////////////////////////////////////////// // Colours //// Colours init c[\colours] = (); i[\colours] = (); i[\colours][\triPanner] = Synth(\triPanner, [\freq, 0.1, \amp, 1.0, \out, b[\c12]], g[\c12]); f[\coloursReset] = { // Clean old buffers c[\colours].do {|bufs| bufs.do {|buf| f[\toGarbage].(buf); }; }; // Variants v[\shadowsLen] = 10 + 10.0.rand; i[\colours][\triPanner].set(\freq, 1/rrand(5.0, 20.0)); v[\nReds] = rrand(5, 10); v[\nBW] = 3 + 5.rand; v[\shadowsDelta] = 7.0 + 2.0.rand; v[\shadowsExpand] = 1.0 + 0.1.rand2; // Select new buffers [\black, \red, \white, \shadows, \brightWhisper, \darkWhisper, \shadeWhisper].do { |item| c[\colours][item] = f[\rndBufs].(v[\soundFiles][item], 3); }; // Return nothing nil }; f[\coloursReset].(); //// Colours patterns ////// Whispered spirals p[\coloursWhisperedSpirals] = Pbind( \instrument, \bufRdPanExpandLoop, \len, Pfunc {v[\shadowsLen] + 2.5.rand2}, \sus, Pkey(\len)/2, \amp, 0.1, \initPos, 0.4, \minWidth, 0.4, \bufnum, Prand([ Pfuncn {c[\colours][\brightWhisper].choose}, Pfuncn {c[\colours][\darkWhisper].choose}, Pfuncn {c[\colours][\shadeWhisper].choose}, ], inf), \dir, Pgeom(1, -1, inf), \delta, (Pkey(\sus) + Pkey(\len))/2, ); p[\coloursWhisperedSpirals] = p[\coloursWhisperedSpirals] <> (group: g[\c12], out: b[\c12]); ////// BWR p[\coloursBWR] = Pseq([Event.silent(1.0), Pbind(\instrument, \bufRdPan, \bufnum, Pfin({v[\nBW]}, Prand([ Pfuncn({c[\colours][\black].choose}), Pfuncn({c[\colours][\white].choose}),], inf)), \pan, Pfunc {1.0.rand2}, \delta, Pfunc {2 + 2.0.rand}, \amp, 0.4, ), Pbind(\instrument, \bufRdPan, \bufnum, Pfunc({c[\colours][\red].choose}), \panValue, Pstutter({v[\nReds]}, Pfunc({1.0.rand2})), \pan, Pcollect({|item| item + 0.1.rand2}, Pkey(\panValue)), \delta, Pn(Pfuncn({0.1.rand}), {v[\nReds]}), \amp, 0.25, ), Event.silent(3.0) ], inf); p[\coloursBWR] = p[\coloursBWR] <> (group: g[\c13], out: b[\c13]); ////// Shadows i[\colours][\haas] = Synth(\haasFx, [\amp, 1.0, out: b[\c14]], g[\c14]); p[\coloursShadows] = Pseq([Plazy {Event.silent(v[\shadowsDelta])}, Pbind( \instrument, \bufRdPan, \bufnum, Pfunc {c[\colours][\shadows].choose}, \delta, Pfunc {v[\shadowsDelta]}, \amp, 0.45, \action, Pn(Plazy { v[\shadowsDelta] = v[\shadowsDelta]*v[\shadowsExpand]; })) ]); p[\coloursShadows] = p[\coloursShadows] <> (group: g[\c14], out: b[\c14]); ////// Colours together p[\colours] = Ppar([ p[\coloursBWR], p[\coloursShadows], p[\coloursWhisperedSpirals], ]); v[\debug].if {p[\colours] = f[\bufDebug].(p[\colours])}; //////////////////////////////////////////////////////////// // Intimacy //// Intimacy init c[\intimacy] = (); f[\intimacyReset] = { // Clean old buffers c[\intimacy].do {|bufs| bufs.do {|buf| f[\toGarbage].(buf); }; }; // Select new buffers [\intimacy, \close].do { |item| c[\intimacy][item] = f[\rndBufs].(v[\soundFiles][item], 3); }; // Return nothing nil }; f[\intimacyReset].(); //// Intimacy patterns p[\closeWiden] = Pbind( \instrument, \bufRdPan, \bufnum, Pfunc {c[\intimacy][\close].choose}, \start, Pseg([0, 0, 0], [6, 2]), \end, Pseg([0.1, 1, 1], [6, 2]), \pan, Pseg([1, 0, 0], [6, 2])*Pseq([1, -1], inf), \delta, (Pkey(\end) - Pkey(\start))*1.2, \amp, 0.4, ); p[\closeWiden] = Pfxb(p[\closeWiden], \changingEchoFx, \slope, -1.0, \time, 12, \send, 0.6, \amp, 1.0 ); p[\closeNarrow] = Pbind( \instrument, \bufRdPan, \bufnum, Pfunc {c[\intimacy][\close].choose}, \start, Pseg([0, 0.2, 0.2], [6, 5]), \end, Pseg([1, 0.5, 0.3], [6, 5]), \pan, Pseg([0, 1, 1], [6, 5])*Pseq([1, -1], inf), \delta, (Pkey(\end) - Pkey(\start))*1.1, \amp, 0.4 ); p[\closeNarrow] = Pfxb(p[\closeNarrow], \changingEchoFx, \slope, -1.0, \time, 12, \send, 0.6, \amp, 1.0 ); p[\oneIntimacy] = Pbind( \instrument, \bufRdPan, \bufnum, Pfuncn {c[\intimacy][\intimacy].choose}, \delta, 1.5, \amp, 0.8 ); p[\oneIntimacy] = Pfxb(p[\oneIntimacy], \bpfFx, \amp, 1.5, \rq, 1, \freq, 900); p[\intimacy] = Pseq([Prand([p[\closeWiden], p[\closeNarrow]]), Plazy {Event.silent(3.0.rand)}, p[\oneIntimacy], Plazy {Event.silent(5.0.rand)}], inf); p[\intimacy] = p[\intimacy] <> (group: g[\c15], out: b[\c15]); v[\debug].if {p[\intimacy] = f[\bufDebug].(p[\intimacy])}; //////////////////////////////////////////////////////////// // Incredible //// Incredible Init c[\incredible] = (); v[\partIncredibleVars] = Array.with( Pn(Pbind( \instrument, \bufRdPan, \bufnum, Pfuncn {c[\incredible][\incredible].choose}, \start, Pfuncn {0.7.rand}, \end, Pcollect({|item| rrand(item + 0.1, 1.0)}, Pkey(\start)), \fade, 0.01, \delta, Pfuncn {0.4.rand}, \pan, Pfuncn {1.0.rand2}, \amp, Pfuncn {rrand(0.2, 0.5)}, ), {rrand(20, 30)}), Ppar(Pseq([ Plazy {Event.silent(4.0.rand)}, Pbind( \instrument, \bufRdPan, \bufnum, Pstutter(inf, Pfuncn {c[\incredible][\incredible].choose}), \start, Pseries(0, 0.01, 90), \end, Pkey(\start) + 0.1, \pan, Pgeom(0.1, -1.024, 90), // \pan, Pwhite(-1.0, 1.0), \delta, Pgeom({0.2 + 0.1.rand}, 0.98), \amp, Prand([ 0.0, 0.6], inf), \fade, 0.0005, \rate, Pgeom(1, 1.0007, inf) )])!4); ); f[\incredibleReset] = { // Clean old buffers c[\incredible].do {|bufs| bufs.do {|buf| f[\toGarbage].(buf); }; }; // Select variant v[\partIncredible] = v[\partIncredibleVars].choose; // Select new buffers [\incredible].do { |item| c[\incredible][item] = f[\rndBufs].(v[\soundFiles][item], 3); }; // Return nothing nil }; f[\incredibleReset].(); //// Incredible patterns p[\partIncredible] = Pfxb(Plazy {v[\partIncredible]}, \hpfFx, \freq, 165, \amp, 1.0); p[\oneIncredible] = Pseq([Event.silent(1.0), Pbind( \instrument, \bufRdPan, \bufnum, Pfuncn {c[\incredible][\incredible].choose}, \delta, 1, \amp, 0.70, ) ]); p[\oneIncredible] = Pfxb(p[\oneIncredible], \haasFx, \delay, {rrand(0.01, 0.025)}, \amp, 1.0); p[\incredible] = Pseq([p[\oneIncredible], Plazy {Event.silent(3.0.rand)}, p[\partIncredible], Plazy {Event.silent(5.0.rand)}], inf); p[\incredible] = p[\incredible] <> (group: g[\c16], out: b[\c16]); v[\debug].if {p[\incredible] = f[\bufDebug].(p[\incredible])}; //////////////////////////////////////////////////////////// // I remember //// Remember Init c[\remember] = (); f[\rememberReset] = { // Clean old buffers c[\remember].do {|bufs| bufs.do {|buf| f[\toGarbage].(buf); }; }; // Change the scrambling and the number of repetitions v[\rememberSpliceLen] = rrand(0.08, 0.12); v[\startSeq] = (0, v[\rememberSpliceLen]..1).scramble.stutter(1 + 3.rand); // Select new buffers [\remember].do { |item| c[\remember][item] = f[\rndBufs].(v[\soundFiles][item], 1); }; // Return nothing nil }; f[\rememberReset].(); s.sync; //// Chasing effect i[\remember] = (); i[\remember][\multiDelay] = Synth(\multiDelayFx, [\out, b[\c17], \wet, 0.3, \amp,1.5], g[\c17]); // Pan goes left to right and back to centre v[\pan] = Array.series((v[\startSeq].size*0.5).floor, -1, (1/(v[\startSeq].size*0.5).floor)*2) ++ Array.series((v[\startSeq].size*0.5).ceil, 1, -1/(v[\startSeq].size*0.5).ceil); //// Remember parameters p[\leftFaster] = Pbind( \instrument, \bufRdPan, \bufnum, Pfunc {c[\remember][\remember].choose}, \start, Pseq(v[\startSeq]), \end, Pkey(\start) + v[\rememberSpliceLen], \amp, 0.4, \delta, 0.4 * 2 * v[\rememberSpliceLen] * Pgeom(3, 0.96), \pan, Pseq(v[\pan]) ); p[\leftSlower] = Pbindf(p[\leftFaster], \delta, 0.4 * v[\rememberSpliceLen] * Pgeom(0.4, 1.08)); p[\rightSlower] = Pbindf(p[\leftSlower], \pan, 0 - Pseq(v[\pan])); p[\rightFaster]= Pbindf(p[\leftFaster], \pan, 0 - Pseq(v[\pan])); p[\remember] = Pseq([ Pseq([ Plazy {Event.silent(3.0.rand)}, Prand([p[\leftSlower], p[\rightSlower], p[\leftFaster], p[\rightFaster]]) ], 2), Plazy {Event.silent(3.0.rand)} ], inf); p[\remember] = p[\remember] <> (group: g[\c17], out: b[\c17]); v[\debug].if {p[\remember] = f[\bufDebug].(p[\remember])}; //////////////////////////////////////////////////////////// // Silence p[\silence] = Event.silent(inf); //////////////////////////////////////////////////////////// // Clarity //// Clarity init v[\octaScale] = Scale.new(#[0, 2, 3, 5, 6, 8, 9, 11], name: "octatonic"); f[\shepardDegrees] = {|x| ((((0, 9..63) + x)%72) - 32).sort}; c[\clarity] = []; f[\clarityReset] = { // Clean old buffers c[\clarity].do {|buf| f[\toGarbage].(buf); }; // Load a set of wavetables v[\rememberWTs] = v[\soundFiles][\rememberWT].choose; c[\clarity] = Buffer.allocConsecutive(v[\rememberWTs].size, s, 2048, 1, {|buf, i| buf.readMsg(v[\rememberWTs][i].path); }); // Return nothing nil }; //// First clarity init f[\clarityReset].(); //// Clarity pattern i[\clarity] = (); i[\clarity][\phaser] = Synth(\phaserFx, [\out, b[\c18], \delay, 0.01, \decay, 0.3, \amp, 1.0], g[\c18], \addToTail); i[\clarity][\hpf] = Synth(\hpfFx, [\out, b[\c18], \amp, 1.0, \freq, 110], g[\c18], \addToTail); p[\clarity] = Pbind( \instrument, \wavetableBell, \scale, v[\octaScale], \degree, Pcollect(f[\shepardDegrees], Pseq((0..71).rotate(72.rand), inf)), \attack, v[\partDur]/5*Pwhite(1.0, 1.3), \release, v[\partDur]/3*Pwhite(1.0, 1.3), \firstBufnum, c[\clarity].first.bufnum + 1, \lastBufnum, c[\clarity].last.bufnum - 1, \delta, (3*v[\partDur]/7)*Prand([1, 2, 5], inf), \pan, 0, \amp, 0.1/([4, 3, 2, 1, 2, 3, 4, 5]**2), \rq, 1, ); p[\clarity] = p[\clarity] <> (group: g[\c18], out: b[\c18]); v[\debug].if {p[\clarity] = p[\clarity].trace(\firstBufnum, prefix: "Clarity: ")}; //////////////////////////////////////////////////////////// // Consonants c[\consonants] = (); i[\consonants] = (); f[\consonantsReset] = { // Clean old buffers c[\consonants].do {|bufs| bufs.do {|buf| f[\toGarbage].(buf); }; }; // Select new buffers [\aggg, \ffff, \kkkk, \shhh, \ssss, \tttt].do { |item| c[\consonants][item] = f[\rndBufs].(v[\soundFiles][item], 3); }; // Return nothing nil }; f[\consonantsReset].(); p[\consonantsTypes] = (); p[\consonantsTypes][\repeatPan] = Pfin({7 + 11.rand}, Pbind( \instrument, \bufRdPan, \bufnum, Pfunc {c[\consonants][\aggg].choose}, \delta, Pfunc {0.4.rand}, \amp, Pfunc {0.3 + 0.3.rand}, \pan, Pfunc {1.0.rand2} )); v[\insectPan] = Pbrown(-1.0, 1.0).asStream; p[\consonantsTypes][\insect] = Pfxb(Pfin({19 + 17.rand}, Pbind( \instrument, \bufRdPan, \bufnum, Pfunc {(c[\consonants][\ffff] ++ c[\consonants][\ssss]).choose}, \delta, Pfunc {0.15.rand}, \amp, 0.25, \pan, Pfunc {v[\insectPan].next}, )), \hpfFx, \freq, 1500, \amp, 1.0); p[\consonantsTypes][\pour] = Pfxb(Pfin({(25 + 10.rand)}, Pbind( \instrument, \bufRdPan, \bufnum, Pfunc {(c[\consonants][\kkkk] ++ c[\consonants][\tttt]).choose}, \delta, Pgeom(0.035, 1.07), \pan, Pstutter(inf, Pwhite(-0.5, 0.5, 1)) + Pwhite(-0.05, 0.05), \amp, 0.5, \rate, Pgeom(1.05, 0.997), )), \hpfFx, \freq, 1500, \amp, 1.0); p[\consonantsTypes][\shhh] = Pfxb(Pbind( \instrument, \bufRdPan, \bufnum, Pfuncn({c[\consonants][\shhh].choose}, 5), \delta, Pwhite(1.3, 1.7), \amp, Prand([0, 0.3, 0.4], 5), \pan, Prand([Pseries(-0.5, 0.19, 5), Pseries(0.5, -0.19, 5)]), \fade, 0.01, ), \bpfFx, \freq, 2100, \amp, 1.0); p[\consonants] = Plazy { Pseq([ Plazy {Event.silent(rrand(10.0, 20.0))}, p[\consonantsTypes].choose, ]); }; p[\consonants] = p[\consonants] <> (group: g[\c22], out: b[\c22]); v[\debug].if {p[\consonants] = f[\bufDebug].(p[\consonants])}; //////////////////////////////////////////////////////////// // Waves and breath layer //// Waves init c[\waves] = (); f[\wavesReset] = { // Clean old buffers c[\waves].do {|bufs| bufs.do {|buf| f[\toGarbage].(buf); }; }; // Select new buffers [\wave, \inhale, \exhale].do { |item| c[\waves][item] = f[\rndBufs].(v[\soundFiles][item], 3); }; // Return nothing nil }; f[\wavesReset].(); i[\waves] = (); i[\waves][\guts] = Synth(\gutsFx, [\out, b[\c23], \freq, 140, \rq, 0.30, \amp, 2.0, \wet, 0.98, ], g[\c23], \addToTail); //// Wave patterns p[\waves] = Pbind( \instrument, \bufRdPan, \bufnum, Pfuncn {c[\waves][\wave].choose}, \pan, Pwhite(-0.5, 0.5), \delta, Pwhite(4.0, 6.0), \amp, Pwhite(0.2, 0.3), \rate, Pwhite(0.8, 1.2), ); p[\waves] = Pseq([Pn(p[\waves], 5), Plazy {Event.silent(rrand(10.0, 30.0))}]); p[\waves] = p[\waves] <> (group: g[\c23], out: b[\c23]); v[\debug].if {p[\waves] = f[\bufDebug].(p[\waves])}; //// Breath pattern i[\breath] = (); i[\breath][\softclip] = Synth(\softclipFx, [\out, b[\c24], \preAmp, 90], g[\c24]); i[\breath][\highShelf] = Synth(\highShelfFx, [\out, b[\c24], \freq, 2400, \rs, 1.0, \db, -4.0], g[\c24], \addToTail); i[\breath][\chPhaseInvert] = Synth(\chPhaseInvertFx, [\out, b[\c24]], g[\c24], \addToTail); v[\breathInhaleTime] = Pbrown(2.0, 6.0).asStream; v[\breathExhaleTime] = Pbrown(5.0, 7.0).asStream; p[\breathInhale] = Pbind( \instrument, \bufRdPan, \bufnum, Pfuncn {c[\waves][\inhale].choose}, \amp, 0.7, \delta, Pwrand([Pfuncn {v[\breathInhaleTime].next}, Pwhite(2.0, 5.0, 1)], [10, 1].normalizeSum), \rate, Pwhite(0.8, 1.2), ); p[\breathExhale] = Pbind( \instrument, \bufRdPan, \bufnum, Pfuncn {c[\waves][\exhale].choose}, \amp, 0.7, \delta, Pfuncn {v[\breathExhaleTime].next}, \rate, Pwhite(0.8, 1.2), ); p[\breaths] = Pseq([p[\breathInhale], p[\breathExhale]], 6); p[\breaths] = p[\breaths] <> (group: g[\c24], out: b[\c24]); v[\debug].if {p[\breaths] = f[\bufDebug].(p[\breaths])}; //////////////////////////////////////////////////////////// // Mixing //// Fx ////// c00: Bad radio m[\c00].set( 'mix10', 1.0, 'mix11', 1.0, 'mix12', 1.0, 'mix13', 1.0, 'mix14', 1.0, 'mix15', 1.0, 'mix16', 1.0, 'mix17', 1.0, ); ////// c01: Reverb 1 m[\c01].set( 'mix10', 0.10, 'mix11', 0.06, 'mix12', 0.12, 'mix13', 0.06, 'mix14', 0.06, 'mix15', 0.06, 'mix16', 0.06, 'mix17', 0.06, 'mix18', 0.06, 'mix22', 0.10, 'mix23', 0.15, 'mix24', 0.15, ); ////// c02: Reverb 2 m[\c02].set( 'mix10', 0.10, 'mix11', 0.06, 'mix12', 0.12, 'mix13', 0.06, 'mix14', 0.06, 'mix15', 0.06, 'mix16', 0.06, 'mix17', 0.06, 'mix18', 0.06, 'mix22', 0.10, 'mix23', 0.15, 'mix24', 0.15, ); ////// c03: Wash reverb m[\c03].set( 'mix18', 0.68 ); //// Channels ////// c10: Story m[\c10].set('width', 0.4); m[\c10].vol = 0.86; ////// c11: Ands m[\c11].vol = 0.53; ////// c12: Colours Whispered spirals m[\c12].vol = 0.65; ////// c13: Colours BWR m[\c13].vol = 0.86; ////// c14: Colours Shadows m[\c14].vol = 0.75; ////// c15: Intimacy m[\c15].vol = 0.79; ////// c16: Incredible m[\c16].vol = 0.47; ////// c17: Remember m[\c17].vol = 0.58; ////// c18: Clarity m[\c18].vol = 0.025; m[\c18].set('pan', -0.13); ////// c22: Consonants m[\c22].vol = 0.14; ////// c23: Waves m[\c23].vol = 0.24; ////// c24: Breath m[\c24].vol = 0.09; m[\c24].set('pan', -0.11); s.sync; //////////////////////////////////////////////////////////// // Flavours //// Different reverbs v[\reverbChange] = 61; ///// Reverb change p[\switchReverb] = Pbind( \amp, Rest(), \ir, Pseq([\UEMT, \Tower, \Tight, \Arundel, \Underwater, \Demon].rotate(6.rand), inf), \target, Pseq([\c01, \c02], inf), \delta, Pseq([Pfuncn {v[\reverbChange]/2}, Pfunc {v[\reverbChange]}]), \callback, { // postln("Reverb " ++ ~ir ++ " to " ++ ~target); i[~target].free; i[~target] = f[\convSetup].(~ir, ~target, 0.0); i[~target].map(\amp, b[(~target ++ \Amp).asSymbol]); }, ); ////// Reverb 1 p[\c01] = Pbind( \instrument, \simpleEnv, \out, b[\c01Amp], \startVal, Pseq([1, 0], inf), \endVal, Pseq([0, 1], inf), \delta, Pfunc {v[\reverbChange]}, ); ////// Reverb 2 p[\c02] = Pbind( \instrument, \simpleEnv, \out, b[\c02Amp], \startVal, Pseq([0, 1], inf), \endVal, Pseq([1, 0], inf), \delta, Pfunc {v[\reverbChange]}, ); ////// Pattern Ptpar([ 0.0, p[\switchReverb], v[\reverbChange], p[\c01], v[\reverbChange], p[\c02], ]).play; //// Theta wave distortion { var env, trig; trig = Impulse.kr(LFNoise0.kr(0.1).range(1/73, 1/67), 1.0.rand); env = Env([0, 1, 1, 0], [3, 0.01, 5], \sine, releaseNode: 2).kr(gate: Trig.kr(trig, dur: LFNoise0.kr(0.1).range(3, 10))); Out.kr(b[\masterThetaFreq], LFNoise1.kr(1).range(3, 7)); Out.kr(b[\masterThetaPreAmp], 0.5 + (1.6*env)); }.play; //////////////////////////////////////////////////////////// // Orchestration v[\debug].if {"Starting".postln}; // Consonants Pseq([p[\consonants], Pfuncn {f[\consonantsReset].(); 1}], inf).play; // Waves Pseq([p[\waves], Pfuncn {f[\wavesReset].(); 1}], inf).play; // Breath Pseq([p[\breaths], Pfuncn {f[\breathsReset].(); 1}], inf).play; // Clarity p[\clarity].play; // Sequence v[\resetPart] = nil; p[\sequence] = Pbind( \amp, Rest(), \delta, v[\partDur], \part, Prout({ var parts = [[\story], [\ands, \incredible, \remember, \colours, \intimacy].rotate(5.rand)]; loop { parts[0][0].yield; parts[0] = parts[0].rotate; parts = parts.rotate; v[\silenceProb].coin.if { \silence.yield} } }), \callback, { v[\debug].if {~part.postln}; (v[\resetPart].notNil).if { f[\resetPart].(v[\resetPart], v[\partDur]/2); }; v[\resetPart] = ~part; v[\debug].if {("Tempo: " ++ t.tempo).postln}; Pfindur({v[\partDur]}, Pseq([Event.silent(2), p[~part]])).play; } ); p[\sequence].play(quant: #[0, 0, 0.5]); });
descendants
full graph
«Re: In-between, longing» by kiptok (private)
reception
comments