-
Notifications
You must be signed in to change notification settings - Fork 0
/
LiveSampler.scd
4376 lines (4028 loc) · 167 KB
/
LiveSampler.scd
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
// LiveSampler by Robert van Heumen 2011-2018.
// Based upon a setup in STEIM's LiSa combined with junXion.
// Tested with SC 3.8.0
// Dependencies:
// GlobalVars.scd for global variable definitions
// cfg.libDir/Patterns.scd for patterns definitions
// cfg.libDir/SampleLists/~project.scd for sample load mapping
// InOut.scd for audio routing
// Controllers.scd for controller OSC data
// LapisStatus.scd for status display (when enabled)
// Synth output can be send to any of these busses:
// ~aBus.outA volume controlled by Faderfox LV2 Mastervolume
// ~aBus.outB volume controlled by volume pedal
// ~aBus.outBL limited and volume controlled by volume pedal
// ~aBus.outMain bypassing volume control, not recommended
// Configuration switches on LX
// RED2 switches between effects banks 1 and 2
// RED3 switches the source of the effects between sample playback and input channels
(
s.waitForBoot({
///////////////////////////////////////////// variables //////////////////////////////////////
// configuration settings
var cfg = (
zonePlayRelease: 0.02, // crossfade time when modulating zone start position
playBufLag: 0.05, // lag in PlayBufCF & PlayBufAlt
ampCurZoneFactor: 1.5, // amplification factor for current zone
distortionMax: if(~distortionMax.notNil, {~distortionMax},{50}), // upper level for amplitude multiplication
deBug: 0, // when set to 1 some debugging message will be postlined
midiSrc: "MUL,EXT", // filtering allowed midi sources; comma-separated list with possibly: MUL = Motu Ultralite, IAC1, IAC2, IAC3, LPK
quantize: 0, // if value = 1 then loops of zone4 and zone3 will be quantized to cfg.bmp
bpm: 120, // BPM in quantize case
copySamples: 0, // set to 1 to activate sample copy on load - make sure the folder /Data/Samples/~project exists
crashMode: 1, // set to 0 to disable patterns on zone8play1
bufferViewPlayHeadFreq: 20, // freqency of playhead refresh in bufferView
bufferViewRefreshFreq: 0.5, // frequency of bufferView refresh while recording
bufferViewBlocksize: 512, // block size for reading soundfile in bufferview
bufferViewDeferRead: 1, // defer of reading file in buffer after buffer.write
sampleDir: "/Users/Robert/---data---/audio/samples/", // location of samples
docDir: Document.dir++"/Lapis/", // current location
libDir: "Data/", // library files location
localAddr: NetAddr("127.0.0.1", 57120), // to send OSC to other SC programs
touchOSCAddr: NetAddr("169.254.0.3", 57120), // to send OSC to an iPod running TouchOSC
dragEmptyBeforeLoad: 1, // 1: when dragging, empty buffer before load
);
// buffers
var sRate = s.sampleRate;
var buffer = ( // when changing these values: test thoroughly as some values might be interdependent, also connected with zoneRec
mainLen: sRate * 400, processLen: sRate * 30,
aStart: sRate * 0, aLen: sRate * 65, aTail: sRate * 5, bStart: sRate * 65, bLen: sRate * 85, bTail: sRate * 20,
dyn1Start: sRate * 150, dyn1Len: sRate * 5, dyn2Start: sRate * 180, dyn2Len: sRate * 5,
dyn3Start: sRate * 210, dyn3Len: sRate * 5, dyn4Start: sRate * 240, dyn4Len: sRate * 5
);
// specs
var spec = (
// effects dm=deciMate dl=deLay apf=ampPitchFollow mtf=multiTapFreeze
efxVol: Env.xyc([[0.0, 0.0, \lin], [0.01, 0.001,\exp],[0.3, 0.3, \lin],[1, 1.0]]),
dmAmp: Env.new([0.01,0.01,0.1,0.1], [0.4,0.6], [\lin]),
dmProb: Env.new([0.1,0.1,0.9], [0.8,0.2], [\lin]),
dmMixDec: Env.new([1,1,0,0], [0.2,0.4,0.4], [\lin]),
dmMixCross: Env.new([0,0,1,1,0], [0.2,0.2,0.2,0.4], [\lin]),
dmMixDis: Env.new([0,0,1,1], [0.6,0.2,0.2], [\lin]),
dmDec: Env.new([100,10000], [1], [\lin]),
dlTime: Env.new([0.2,0.2,1,1],[0.1,0.6,0.3],[\lin]),
dlMixTrem: Env.new([1,1,0,0],[0.1,0.05,0.85], [\lin]),
dlMixDelay: Env.new([0,0,1,1,0,0],[0.1,0.05,0.5, 0.05, 0.3],[\lin]),
dlMixDub: Env.new([0,0,1,1],[0.65, 0.05, 0.3],[\lin]),
dlFeed: Env.new([0.5,0.5,1.1],[0.7, 0.3],[\lin]),
dlTremSpeed: ControlSpec.new(0.3,0.01,\exp),
// dlTremSpeed: ControlSpec.new(1,0.05,\exp),
dlTremVar0Mix: Env.new([0,0,1,1,0,0],[0.1,0.01,0.78,0.01,0.1],[\lin]),
dlTremVar1Mix: Env.new([1,1,0,0],[0.1,0.01,0.89],[\lin]),
dlTremVar2Mix: Env.new([0,0,1,1],[0.89,0.01,0.1],[\lin]),
apfMixNoise: Env.new([0,0,1,1],[0.15,0.35,0.5], [\lin]),
apfMixPitch: Env.new([0,0,1,1,0,0],[0.05,0.05,0.15,0.5,0.25], [\lin]),
apfMixSchr: Env.new([1,1,0,0],[0.05,0.05,0.9], [\lin]),
mtfVol: Env.new([0,1,1], [0.9,0.1], [\lin]),
mtfDecay: Env.new([0,0,1,1], [0.5,0.4,0.1], [\lin]),
mtfMix: Env.new([0,0,1,1], [0.5,0.25,0.25], [\lin]), // mix FreeVerb
mtfMixTap: Env.new([1,1,0,0], [0.9,0.08,0.02], [\lin]), // mix Tab
mtfMixFreeze: Env.new([0,0,1,1], [0.9,0.08,0.02], [\lin]), // mix Freeze
mtfFF: Env.new([500,10000], [1], [\lin]),
// mtfTap: Env.new([3,3,2,1,0,0],[0.125,0.125,0.125,0.125,0.5],[\step]),
mtfTap1: Env.new([1,1,0,0],[0.1,0.05,0.85],[\lin]),
mtfTap2: Env.new([0,0,1,1,0,0],[0.1,0.05,0.15,0.05,0.65],[\lin]),
mtfTap3: Env.new([0,0,1,1,0,0],[0.3,0.05,0.15,0.05,0.45],[\lin]),
mtfTap4: Env.new([0,0,1,1],[0.5,0.05,0.45],[\lin]),
mtfRLPFff: Env.new([10000,10000,10],[0.75,0.25],[\lin,\exp]),
mftRLPFmul: Env.new([10,10,1],[0.5,0.5], [\lin]),
// zones
amp21: Env.xyc([[0.0, 0.0, \lin], [0.001, 0.001,\exp],[0.2, 0.2, \lin],[1, 1.0]]),
dist21: ControlSpec.new(1,cfg.distortionMax,\exp),
dist21hf: ControlSpec.new(1,cfg.distortionMax,\exp),
dist21lf: ControlSpec.new(2,cfg.distortionMax,\exp),
pitch21: ControlSpec.new(0.8,1.2,\lin),
len21L: Env.xyc([[0, 0.1 * sRate,\exp],[0.5, 30 * sRate, \lin],[1, 60 * sRate]]), // van 0.1 naar 60 sec
len21R: Env.xyc([[0, 0.1 * sRate,\exp],[0.5, 29.8 * sRate, \lin],[1, 59.6 * sRate]]), // van 0.1 naar 59.6 sec
startPos21L: ControlSpec.new(buffer.aStart, buffer.aStart + buffer.aLen + buffer.bLen - buffer.bTail, \lin),
startPos21R: ControlSpec.new(buffer.aStart, buffer.aStart + buffer.aLen + buffer.bLen - buffer.bTail - (0.3*sRate), \lin),
ff21: ControlSpec.new(50,20000,\exp),
mix21: Env.new([0,0,1,1,0,0],[0.1,0.05,0.7,0.05,0.1],[\lin]),
mix21lf: Env.new([1,1,0,0],[0.65,0.05,0.3],[\lin]),
mix21hf: Env.new([0,0,1,1],[0.3,0.05,0.65],[\lin]),
spModSpd31: Env.new([0.02,10],[127],[\exp]),
panSpd31: ControlSpec.new(1,50,\lin),
ampModSpd31: ControlSpec.new(1,0.01,\exp),
len31: Env.xyc([[0, 0.1 * sRate,\exp],[0.5, 30 * sRate, \lin],[1, 60 * sRate]]), // van 0.1 naar 60 sec
ff31: Env.new([10,1000,10000,15000],[0.3,0.5,0.2],[\exp,\lin,\exp]),
mulHPF31: Env.new([1,1,20,50],[0.3,0.5,0.2],[\lin, \lin, \lin]),
pitch41: ControlSpec.new(0.8,1.2,\lin),
pitch412: ControlSpec.new(0.1,1.9,\lin),
ffSpeed41: ControlSpec.new(0.2,2,\lin),
len41: Env.xyc([[0, 0.2,\exp],[64, 30, \lin],[127, 60]]), // van 0.1 naar 60 sec
ff41: ControlSpec.new(200,20000,\exp),
len61: ControlSpec.new(10, 0.03,\exp), // van 10 sec naar 0,03 sec
startPos61: ControlSpec.new(buffer.bStart, buffer.bStart + buffer.bLen - buffer.bTail, \lin, 0.02 * (buffer.bLen - buffer.bTail)),
pitch61: Env.new([0.1,12],[1],[\exp]),
// pitch61: ControlSpec.new(0.1,12,\exp),
dist61: Env.new([cfg.distortionMax,1],[1], [\exp]),
// dist61: ControlSpec.new(cfg.distortionMax,1,\exp),
amp61: ControlSpec.new(0.0,1.0,\lin),
len61Plus1: ControlSpec.new(2, 0.025,\exp), // van 2 sec naar 0,025 sec
startPos61Plus1: ControlSpec.new(buffer.bStart + (2 * sRate),
buffer.bStart + buffer.bLen - buffer.bTail + (2 * sRate), \lin, 0.02 * (buffer.bLen - buffer.bTail + (2 * sRate))),
len61Plus2: ControlSpec.new(6, 0.02,\exp), // van 6 sec naar 0,02 sec
startPos61Plus2: ControlSpec.new(buffer.bStart + (4 * sRate),
buffer.bStart + buffer.bLen - buffer.bTail + (4 * sRate), \lin, 0.02 * (buffer.bLen - buffer.bTail + (4 * sRate))),
len62: ControlSpec.new(1, 0.01,\exp), // van 10 sec naar 0,01 sec
startPos62: ControlSpec.new(buffer.bStart, buffer.bStart + buffer.bLen - buffer.bTail, \lin, 0.01 * (buffer.bLen - buffer.bTail)),
ff62: ControlSpec.new(50,5000,\exp),
pan62: [-1,1,-1,1,-1,1,-1,1,-1].resize(1024, \linear),
len63: ControlSpec.new(2, 0.015, \exp), // van 2 sec naar 0,02 sec
startPos63: ControlSpec.new(buffer.bStart, buffer.bStart + buffer.bLen - buffer.bTail, \lin, 0.01 * (buffer.bLen - buffer.bTail)),
ff63: ControlSpec.new(50,20000,\exp),
pan63: [1,-1,1].resize(1024, \linear),
len64: Env.new([2,1,0.005],[0.5,0.5],[\lin,\exp]), // van 2 sec naar 0,005 sec
startPos64: ControlSpec.new(buffer.aStart, buffer.aStart + buffer.aLen - buffer.aTail, \lin, 0.01 * (buffer.bLen - buffer.bTail)),
pitch64: ControlSpec.new(0.8,1.2,\exp),
pan64: [1,-0.5,0].resize(1024, \linear),
len65: Env.new([3,0.5,0.2],[0.5,0.5]),
low65: Env.new([0,1,2],[0.5,0.5]),
high65: Env.new([2,1,0],[0.5,0.5]),
dec65: Env.new([0,0,0.1,2],[0.2,0.3,0.5]),
pitch65: ControlSpec.new(0.6,1.4,\exp),
pan65: [0.5,-0.5,0].resize(1024, \linear),
ampMod66: Env.new([2,20],[1],[\lin]),
cutoff66: Env.new([5000,800,50],[0.5,0.5],[\lin]),
res66: Env.new([0.2,1,2],[0.5,0.5],[\lin]),
pitch66: Env.new([0.9,1.1],[1],[\lin]),
dist66: Env.new([10,2],[1],[\lin]),
freq67: Env.new([1,1000],[1],[\lin]),
gravAmp67: Env.new([0.01,1],[1],[\lin]),
cutoff67: Env.new([10000,10],[1],[\lin]),
ring67: Env.new([100,-10],[1],[\lin]),
distFftDrone: Env.new([10,1],[1]),
cutoffFftDrone: Env.new([10000,1000,500],[0.5,0.5],[\lin]),
pulseFftDrone: Env.new([1,0.3,1],[0.5,0.5]),
amp21: Env.xyc([[0.0, 0.0, \lin], [0.001, 0.001,\exp],[0.2, 0.2, \lin],[1, 1.0]]),
amp81: Env.new([0,0.001,0.2,0.7],[0.001, 0.2, 0.8],[\lin,\exp,\lin]),
len81: Env.xyc([[0, 0.1 * sRate,\exp],[0.5, 30 * sRate, \lin],[1, 60 * sRate]]), // van 0.1 naar 60 sec
pitch81: Env.xyc([[0, 0.2,\lin],[0.5, 1, \lin],[1, 2]]),
patt81: nil,
rate81: Env.new([0.4,1,2],[0.5,0.5]),
pitch16select: Env.new([0,0,1,2,3,4],[0.1,0.25,0.3,0.25,0.1],[\step]),
pitch162: Env.new([1,3],[1],[\exp]),
pitch162up1: Env.new([1,6],[1],[\exp]),
pitch162up2: Env.new([1,8],[1],[\exp]),
pitch162down1: Env.new([0.5,1],[1],[\exp]),
pitch162down2: Env.new([0.1,0.6],[1],[\exp]),
pitch162lisa1: Env.new(
[1, 0.6, 2, 1, 1.1, 3, 4, 1, 1.2, 7, 9, 0.5, 1, 9, 10, 1.2, 1.5, 1, 0.3, 0.3, 1, 1, 0.2, 0.1, 0.9, 0.8, 0.05, 0.01, 0.8, 0.3, 5, 1],
[ 15, 10, 0.01, 3, 0.01, 2, 0.01, 2, 0.01, 9, 0.01, 2, 0.01, 9, 0.01, 6, 20, 1, 2, 0.01, 2, 0.01, 2, 0.01, 2, 0.01, 10, 0.01, 5, 0.1, 5]/115,
[\exponential]
),
pitch162lisa2: Env.new(
[0.5, 1, 8, 10, 1, 1.2, 6, 7, 0.3, 0.2, 6, 7, 1.5, 0.2, 5, 7, 0.2, 0.01, 1, 2, 0.1, 0.05, 2, 1, 8, 11, 0.4, 0.5],
[ 30, 0.01, 15, 0.01, 35, 0.01,5,10, 25, 40, 20, 0.01, 25, 1, 25, 15, 15, 10, 30, 0.01, 15, 0.01, 5, 3, 20, 0.01, 3] / 355,
[\exponential]
),
pitch162ran: Env.new([1,0.5,5],[0.1, 0.9],[\exp]),
pan161: ControlSpec.new(-1.0, 1.0, \lin),
pan164: ControlSpec.new(1.0, -1.0, \lin),
startPos171: ControlSpec.new(buffer.aStart, buffer.bStart + buffer.bLen - buffer.bTail, \lin,
0.01 * (buffer.bStart + buffer.bLen - buffer.bTail)),
amp171: ControlSpec.new(0, 1, \lin),
dist171: ControlSpec.new(1, 10, \lin),
tempo171: ControlSpec.new(1,8),
diskPlayRate: Env.new([33/45,1],[1],[\lin]),
diskPlayRateMod: Env.new([0,0.05],[1],[\lin])
);
// control busses
var cBus = (
// joystick
ex3dProBusX62: Bus.control(s,1).set(0), ex3dProBusX63: Bus.control(s,1).set(0), ex3dProBusX64: Bus.control(s,1).set(0),
ex3dProBusX65: Bus.control(s,1).set(0), ex3dProBusX66: Bus.control(s,1).set(0), ex3dProBusX67: Bus.control(s,1).set(0),
ex3dProY: Bus.control(s,1).set(0.5), ex3dProYpitch: Bus.control(s,1).set(spec.pitch61.at(0.5)),
ex3dProR: Bus.control(s,1).set(0.5), ex3dProS: Bus.control(s,1).set(1),
// Faderfox LV1, LV2
midiLV1Fader1: Bus.control(s,1).set(0), midiLV1Fader2: Bus.control(s,1).set(0), midiLV1Fader3: Bus.control(s,1).set(0),
midiLV1Fader4: Bus.control(s,1).set(0), midiLV1Fader5: Bus.control(s,1).set(0), midiLV1Fader8: Bus.control(s,1).set(0),
midiLV1KnobA1: Bus.control(s,1).set(0.5), midiLV1KnobA2: Bus.control(s,1).set(0.5), midiLV1KnobB1: Bus.control(s,1).set(0.5),
midiLV1KnobB2: Bus.control(s,1).set(0.7), midiLV1KnobB3: Bus.control(s,1).set(0.7), midiLV1KnobC1: Bus.control(s,1).set(0.5),
midiLV1KnobC2: Bus.control(s,1).set(0), midiLV1KnobD1: Bus.control(s,1).set(0.5), midiLV1KnobD2: Bus.control(s,1).set(0),
midiLV1JoyX: Bus.control(s,1).set(0), midiLV1JoyY: Bus.control(s,1).set(0.5), midiLV1CrossFader: Bus.control(s,1).set(0),
midiLV1KnobMasterVol: Bus.control(s,1).set(1),
midiLV2Fader1: Bus.control(s,1).set(0), midiLV2Fader3: Bus.control(s,1).set(0), midiLV2Fader4: Bus.control(s,1).set(0),
midiLV2Fader5: Bus.control(s,1).set(0), midiLV2Fader6: Bus.control(s,1).set(0), midiLV2Fader7: Bus.control(s,1).set(0),
midiLV2Fader8: Bus.control(s,1).set(0), midiLV2Fader9: Bus.control(s,1).set(0), midiLV2Fader10: Bus.control(s,1).set(0),
midiLV2Fader11: Bus.control(s,1).set(0), midiLV2Fader12: Bus.control(s,1).set(0), midiLV2Fader13: Bus.control(s,1).set(0),
midiLV2Fader14: Bus.control(s,1).set(1),
midiLV2Fader15: Bus.control(s,1).set(1), midiLV2Fader16: Bus.control(s,1).set(0.7),
midiLV2KnobA1: Bus.control(s,1).set(spec.len41.at(64)), midiLV2KnobA2: Bus.control(s,1).set(0.5),
midiLV2KnobB1: Bus.control(s,1).set(0), midiLV2KnobB2: Bus.control(s,1).set(0.5), midiLV2KnobB3: Bus.control(s,1).set(0.5),
midiLV2KnobC1: Bus.control(s,1).set(0), midiLV2KnobC2: Bus.control(s,1).set(1), midiLV2KnobC3: Bus.control(s,1).set(0),
midiLV2KnobD1: Bus.control(s,1).set(0), midiLV2KnobD2: Bus.control(s,1).set(0), midiLV2KnobD3: Bus.control(s,1).set(0),
midiLV2JoyX: Bus.control(s,1).set(1), midiLV2JoyY: Bus.control(s,1).set(0.5), midiLV2JoyY2: Bus.control(s,1).set(0.5),
midiLV2CrossFader: Bus.control(s,1).set(0), midiLV2KnobMasterVol: Bus.control(s,1).set(1),
// Arduino
ardAna1Bus: Bus.control(s,1).set(1),
// other
spModBus31: Bus.control(s,1).set(0), ampModOnBus31: Bus.control(s,1).set(0),
jumpBus81: Bus.control(s,1).set(0), panBus81: Bus.control(s,1).set(0), pitchBus81: Bus.control(s,1).set(0.95),
ampPattBus81: Bus.control(s,1).set(1), dirBus81: Bus.control(s,1).set(1),
spModBus161: Bus.control(s,1).set(0), spModBus164: Bus.control(s,1).set(0),
lenBus161: Bus.control(s,1).set(buffer.dyn1Len / sRate), lenBus162: Bus.control(s,1).set(buffer.dyn2Len / sRate),
lenBus163: Bus.control(s,1).set(buffer.dyn3Len / sRate), lenBus164: Bus.control(s,1).set(buffer.dyn4Len / sRate),
// pulseVolBus: Bus.control(s,1).set(0), pulseSpeedBus: Bus.control(s,1).set(0), pulseWidthBus: Bus.control(s,1).set(0)
);
// general
var curZone = "0", curRecZone = "0", curZoneStart = 0, curZoneLen = 0, tCurZone;
var fAmpCurZone, fBufferRead, fQuantize, fInitOutput, fInitLapisStatus, fSendLapisStatus, fGetInChanEfx;
var fGetInChanSampling, fSetCurZone, fOctavesPitchshift, fGetInAttenuation, fGetInGroup;
var onExternalInput = 0; // 0=effects on sample playback, 1=effects on input channels - switchable with red3 button on LX
var sampleFile, sampleListLV1, sampleListLV2, sampleListLX;
// remote control
var button1disable = 0, button2disable = 0, localControl = 1;
// GUI
var dispPlay, dispRec, fCountZones, countRec = 0, countPlay = 0, dispEfx, countEfx = 0, loadFileA, loadFileB;
var screenHeight = Window.screenBounds.height, screenWidth = Window.screenBounds.width;
var dispBaseBtn, dispBaseBtn2, dispDisablePitch, dispDisableStartPos;
var colorOff = Color.white;
var fontLabel = Font(~font,10), fontButton = Font(~font,12), fontBufferView = Font("Helvetica", 10);
// bufferView
var bufferView = Array.newClear(6), curPlayHead = 0, curRecHead = 0, fileBufferView = SoundFile.new().dup(6);
var bufferViewFolder = Archive.archiveDir ++ "/bufferViewTemp/", fDisplayBufferView, fRefreshBufferview;
var bufferViewLab = Array.newClear(3);
var bufferViewColors = [Color.white, Color.grey, Color.green(0.3), Color.black, Color.blue(1,0.3), Color.red];
// background, grid, waveforms, playbackhead, selection, selection recording
// zones
var zone2 = (play1L: nil, play1R: nil, play1Act: 0, startPos1: 0, play1hf: nil, play1hfAct: 0, play1lf: nil, play1lfAct: 0);
var zone3 = (
play1: nil, play1Act: 0, startPos1: 0,
stepsOffset1: Array.new(24), stepsOffset1tmp: Array.new(24),
spModSpd1: 127, tModSP1: nil
);
var fModSP31;
var zone4 = (play1: nil, play1Act: 0, startPos1: 0, play1hf: nil, play1hfAct: 0, play1lf: nil, play1lfAct: 0);
var zone6 = (
play1: Array.new(50), play1Act: 0, startPos1: 0, play1St: 0, play1Nbr: 0, play1Add: 0.2,
disablePitch: 0, disableStartPos: 0, disableXhid: 0, octavesPitchshift: 0,
play2: nil, play2Act: 0, startPos2: 0, play3: nil, play3Act: 0, startPos3: 0,
play4: nil, play4Act: 0, startPos4: 0, play5: nil, play5Act: 0, startPos5: 0, len5: 1,
play6: nil, play6Act: 0, play6Pitch: 0, play7: nil, play7Act: 0, play8: nil, play8Act: 0
);
var zone8 = (play1: nil, play1Act: 0, startPos1: 0, tPatt1: nil, patt1: nil, patt1Def: 0, patt1Nbr: 0, sign1: 0);
var f81jump, f81;
var zone16 = (
play1: nil, play1Act: 0,
// tModSP1: nil, spMod1Spd: nil, spModOn1: 1,
play2: nil, play2Act: 0, mode2: "",
play3: nil, play3Act: 0, mode3: "",
play4: nil, play4Act: 0, tModSP4: nil, spMod4Spd: nil, spModOn4: 1, stepsOffset1: Array.new(9),
);
var fModSP161, fModSP164;
var zone17 = (
play1: nil, play1Act: 0, patt1:nil, startPos1: 0, len1: 0.5, ampSine1: 0, ampPluck1: 0, dist1: 0, amp1: 0,
tempoClock1: TempoClock.new(8);
);
// zoneRec
var zoneRec = (
ch1A: nil, ch1B: nil, ch2A: nil, ch2B: nil, dynOverflow: 0.05, dynLenMax: 30, dynLenMaxFrames: 30*sRate,
dyn1: nil, dyn1St: nil, dyn2: nil, dyn2St: nil, dyn3: nil, dyn3St:nil, dyn4: nil, dyn4St: nil, len1: 5,
dyn1SavedLen: 5, dyn2SavedLen: 5, dyn3SavedLen: 5, dyn4SavedLen: 5
);
// just playing samples from green buttons keysets 2 & 3
var dpIndex, diskPlay = (), diskPlayFile;
// effects
var efx1Act = 0, efxBank = 1, efx2Act = 0;
// Vanoli Pulse
// var zonePulse = ( play1: nil, play1Act: 0 );
///////////////////////////////////////////// initialize variables //////////////////////////////////////
var mainBuf = Buffer.alloc(s, buffer.mainLen, 2);
var mtfBufL = Buffer.alloc(s, sRate*3,1), mtfBufR = Buffer.alloc(s, sRate*3,1); // buffers for effect multiTapFreeze
// load global variables
"GlobalVars.scd".loadRelative();
// project specific
if(~projectID == \lcm, { (Document.dir++"Loop-Copy-Mutate/LoadRecordings.scd").load() });
// if(~projectID == \sh, { (Document.dir++"Shackle/Curves.scd").load() });
zone8.patt1Def = 0; // default pattern
zone8.patt1 = (cfg.libDir++"Patterns.scd").loadRelative[0][0]; // load pattern definitions
spec.patt81 = Array.iota(zone8.patt1.size);
spec.patt81 = spec.patt81.resize(128, \step);
// accomodate in case Arduino is not available
if(~noArduino == 1, {
"\nLiveSampler: Remapping dist61 because no Arduino availabe".postln;
spec.dist61 = Env.new([cfg.distortionMax,1,1],[0.5,0.5], [\exp,\lin]);
});
// SP offset tables
//zone3.stepsOffset1 = [0.11, 0.1, 0.5, 0.1, 0.11, 0.6, 0.5, 0.9, 0.91, 0.1, 0.9, 0.91, 0.1];
zone3.stepsOffset1 = [0.11, 0.1, 0.11, 0.1, 0.11, 0.1, 0.11, 0.1];
zone3.stepsOffset1tmp = zone3.stepsOffset1;
zone16.stepsOffset1 = [0.0, 0.1, 0.0, 0.2, 0.1, 0.3, 0.5, 0.6, 0.9];
// sample lists
sampleFile = (cfg.libDir++"SampleLists/"++~project++".scd").loadRelative[0];
sampleListLV1 = sampleFile[0];
sampleListLV2 = sampleFile[1];
sampleListLX = sampleFile[2]; // blue keysets 1, 2 & 3 and green keysets 1 & 2
if(sampleFile.size > 3, { // sample list settings for diskPlay synth triggered by green keysets 2 & 3
diskPlay.put('sampleList', sampleFile[3].sampleList);
if(sampleFile[3].att.size >= diskPlay.sampleList.size,
{diskPlay.put('att', sampleFile[3].att)},
{diskPlay.put('att', 0.1.dup(diskPlay.sampleList.size))}); // defaults to 0.1 if not provided
if(sampleFile[3].rel.size >= diskPlay.sampleList.size,
{diskPlay.put('rel', sampleFile[3].rel)},
{diskPlay.put('rel', 0.1.dup(diskPlay.sampleList.size))}); // defaults to 0.1 if not provided
if(sampleFile[3].out.size >= diskPlay.sampleList.size,
{diskPlay.put('out', sampleFile[3].out)},
{diskPlay.put('out', ~aBus.outMain.dup(diskPlay.sampleList.size))}); // defaults to ~aBus.outMain if not provided
if(sampleFile[3].lp.size >= diskPlay.sampleList.size,
{diskPlay.put('lp', sampleFile[3].lp)},
{diskPlay.put('lp', 1.dup(diskPlay.sampleList.size))}); // defaults to 1 if not provided
if(sampleFile[3].lpfOn.size >= diskPlay.sampleList.size,
{diskPlay.put('lpfOn', sampleFile[3].lpfOn)},
{diskPlay.put('lpfOn', 1.dup(diskPlay.sampleList.size))}); // defaults to 1 if not provided
if(sampleFile[3].rate.size >= diskPlay.sampleList.size,
{diskPlay.put('rate', sampleFile[3].rate)},
{diskPlay.put('rate', 1.dup(diskPlay.sampleList.size))}); // defaults to 1 if not provided
if(sampleFile[3].start.size >= diskPlay.sampleList.size,
{diskPlay.put('start', sampleFile[3].start)},
{diskPlay.put('start', 0.dup(diskPlay.sampleList.size))}); // defaults to 0 if not provided
if(sampleFile[3].gain.size >= diskPlay.sampleList.size,
{diskPlay.put('gain', sampleFile[3].gain)},
{diskPlay.put('gain', 1.dup(diskPlay.sampleList.size))}); // defaults to 1 if not provided
diskPlay.put(\synthVar, Array.newClear(diskPlay.sampleList.size));
diskPlay.put(\playing, Array.series(diskPlay.sampleList.size,0,0));
diskPlay.put('buf', Array.newClear(diskPlay.sampleList.size));
diskPlay.put('len', Array.newClear(diskPlay.sampleList.size));
diskPlay.put('numChan', Array.newClear(diskPlay.sampleList.size));
diskPlay.sampleList.size.do({ arg i;
diskPlayFile = SoundFile.new;
if(diskPlayFile.openRead(cfg.sampleDir ++ diskPlay.sampleList[i]), { // if file found
diskPlay.numChan[i] = diskPlayFile.numChannels;
diskPlay.buf[i] = Buffer.alloc(s, 32768,diskPlayFile.numChannels);
diskPlay.len[i] = round(diskPlayFile.numFrames / ~sRate,0.01);
diskPlayFile.close;
},{ // file not found
("diskPlay file:" + cfg.sampleDir ++ diskPlay.sampleList[i] + "not found.").postln;
});
});
}, {diskPlay.put('sampleList', [])});
///////////////////////////////////////////// Synths //////////////////////////////////////
////////// Recording //////////////////////////////////////
SynthDef(\zoneRec, { // general recording zone for mono recording
arg gate, chan1, chan2, start, len, recZone, attenuation; // start/stop env, input chan, start pos (frames), length (secs), unique ID for curRecZone
var playHead;
// update bufferView
if(~showBufferView == 1,{
playHead = (Phasor.ar(1,1, start, start + (len*sRate), start)) % BufFrames.kr(mainBuf);
SendReply.kr(Impulse.kr(cfg.bufferViewPlayHeadFreq), "/playHead", [playHead/sRate, start/sRate, len], recZone);
SendReply.kr(Impulse.kr(cfg.bufferViewRefreshFreq),"/bufferViewRefresh", start, recZone);
});
RecordBuf.ar(In.ar([chan1,chan2]), mainBuf, start, loop: 0, recLevel: attenuation) *
EnvGen.kr(Env.linen(0,len,0), gate, doneAction: 2);
}).send(s);
SynthDef(\zoneRecDyn, { // dynamic length recording zone for mono recording
arg gate, chan1, chan2, start, len, recZone, attenuation; // start/stop env, input chan, start pos (frames), length (secs), unique ID for curRecZone
var playHead;
// update bufferView
if(~showBufferView == 1, {
playHead = (Phasor.ar(1,1, start, start + (len*sRate), start)) % BufFrames.kr(mainBuf);
SendReply.kr(Impulse.kr(cfg.bufferViewPlayHeadFreq), "/playHead", [playHead/sRate, start/sRate, len], recZone);
SendReply.kr(Impulse.kr(cfg.bufferViewRefreshFreq),"/bufferViewRefresh", start, recZone);
});
RecordBuf.ar(In.ar([chan1,chan2]), mainBuf, start, loop: 0, recLevel: attenuation) *
EnvGen.kr(Env.linen(0,len,0), gate, doneAction: 2);
}).send(s);
////////// Zone 2 MIDI //////////////////////////////////////
SynthDef(\zone2play1L, { // with zone2play1R triggered by LV1 fader1, going out of phase
arg gate, ampBus, startPosition = 0, lenBus, distBus, resetPosBus, ffBus, mixBus;
// start/stop env, start pos (frames), busses range 0-1 for length, amplitude, distortion, reset playhead, filter freq
// control by: LV1 fader1, fader1, fader2, knobA1, crossfader, joyX, mastervolknob
var sig, lenBusVal, resetTrig, resetPosBusVal, playHead, mixBusVal;
lenBusVal = IEnvGen.kr(spec.len21L, In.kr(lenBus,1)); // in frames
resetPosBusVal = In.kr(resetPosBus,1) * lenBusVal; // in frames
startPosition = spec.startPos21L.map(startPosition); // in frames
resetTrig = HPZ2.kr(In.kr(resetPosBus,1)); // detect a change in the resetPosBus value
mixBusVal = IEnvGen.kr(spec.mix21, In.kr(mixBus,1));
// Poll.kr(Impulse.kr(20), startPosition/sRate);
playHead = ( Phasor.ar(
resetTrig, // reset
BufRateScale.kr(mainBuf), // rate
startPosition, // start
startPosition + lenBusVal, // end
startPosition + resetPosBusVal // resetPos
) ) % BufFrames.kr(mainBuf);
// update bufferView
if(~showBufferView == 1, {SendReply.kr(Impulse.kr(cfg.bufferViewPlayHeadFreq), "/playHead",
[playHead/sRate, startPosition/sRate, lenBusVal/sRate], 21)});
sig = BufRd.ar(2, mainBuf, playHead, 1, 4) * EnvGen.kr(Env.adsr(0.1,0,1,0.1), gate, doneAction: 2);
sig = IEnvGen.kr(spec.amp21, In.kr(ampBus,1)) * sig; // volume bus
sig = spec.dist21.map(In.kr(distBus,1)) * sig; // distortion bus
sig = Balance2.ar(sig[0], sig[1],-1); // panning hard left
sig = RLPF.ar(sig, spec.ff21.map(In.kr(ffBus,1)), 0.5); // low pass filter
Out.ar(~aBus.outA, sig*mixBusVal);
}).send(s);
SynthDef(\zone2play1R, { // with zone2play1L triggered by LV1 fader1, going out of phase
arg gate, startPosition = 0, lenBus, ampBus, distBus, pitchBus, resetPosBus, ffBus, mixBus;
// start/stop env, start pos (frames), busses range 0-1 for length, amplitude, distortion, pitch, reset playhead, filter freq
// control by: LV1 fader1, fader1, fader2, knobA1, crossfader, joyY, joyX, mastervolknob
var sig, lenBusVal, resetTrig, resetPosBusVal, playHead, mixBusVal;
lenBusVal = IEnvGen.kr(spec.len21R, In.kr(lenBus,1)); // in frames
resetPosBusVal = In.kr(resetPosBus,1) * lenBusVal; // in frames
startPosition = spec.startPos21R.map(startPosition); // in frames
resetTrig = HPZ2.kr(In.kr(resetPosBus,1)); // detect a change in the resetPosBus value
mixBusVal = IEnvGen.kr(spec.mix21, In.kr(mixBus,1));
playHead = ( Phasor.ar(
resetTrig, // reset
spec.pitch21.map(In.kr(pitchBus,1)) * BufRateScale.kr(mainBuf), // rate
startPosition, // start
startPosition + lenBusVal, // end
startPosition + resetPosBusVal // resetPos
) ) % BufFrames.kr(mainBuf);
sig = BufRd.ar(2, mainBuf, playHead, 1, 4) * EnvGen.kr(Env.adsr(0.1,0,1,0.1), gate, doneAction: 2);
sig = IEnvGen.kr(spec.amp21, In.kr(ampBus,1)) * sig; // volume bus
sig = spec.dist21.map(In.kr(distBus,1)) * sig; // distortion bus
sig = Balance2.ar(sig[0], sig[1],1); // panning hard right
sig = RLPF.ar(sig, spec.ff21.map(In.kr(ffBus,1)), 0.5); // low pass filter
Out.ar(~aBus.outA, sig*mixBusVal);
}).send(s);
SynthDef(\zone2play1hf, { // triggered by LV1 fader1 when value more than 0.97
arg gate, startPosition = 0, lenBus, distBus, resetPosBus, mixBus;
// start/stop env, start pos (frames), busses range 0-1 for length, distortion, reset playhead
// control by: LV1 fader1, fader2, knobA1, crossfader, joyX
var sig, lenBusVal, resetTrig, resetPosBusVal, playHead, mixBusVal;
lenBusVal = IEnvGen.kr(spec.len21R, In.kr(lenBus,1)); // in frames
resetPosBusVal = In.kr(resetPosBus,1) * lenBusVal; // in frames
startPosition = spec.startPos21R.map(startPosition); // in frames
resetTrig = HPZ2.kr(In.kr(resetPosBus,1)); // detect change in the resetPosBus value
mixBusVal = IEnvGen.kr(spec.mix21hf, In.kr(mixBus,1));
playHead = ( Phasor.ar(
resetTrig, // reset
(2**4) * BufRateScale.kr(mainBuf), // rate
startPosition, // start
startPosition + lenBusVal, // end
startPosition + resetPosBusVal // resetPos
) ) % BufFrames.kr(mainBuf);
sig = BufRd.ar(2, mainBuf, playHead, 1, 4) * EnvGen.kr(Env.adsr(0.1,0,1,0.1), gate, doneAction: 2);
sig = spec.dist21hf.map(In.kr(distBus,1)) * sig; // distortion bus
Out.ar(~aBus.outA, sig*mixBusVal);
}).send(s);
SynthDef(\zone2play1lf, { // triggered by LV1 fader1 when value more than 0.99
arg gate, startPosition = 0, lenBus, distBus, resetPosBus, mixBus;
// start/stop env, start pos (frames), busses range 0-1 for length, distortion, reset playhead
// control by: LV1 fader1, fader2, knobA1, crossfader, joyX
var sig, lenBusVal, resetTrig, resetPosBusVal, playHead, mixBusVal;
lenBusVal = IEnvGen.kr(spec.len21R, In.kr(lenBus,1)); // in frames
resetPosBusVal = In.kr(resetPosBus,1) * lenBusVal; // in frames
startPosition = spec.startPos21R.map(startPosition); // in frames
resetTrig = HPZ2.kr(In.kr(resetPosBus,1)); // detect change in the resetPosBus value
mixBusVal = IEnvGen.kr(spec.mix21lf, In.kr(mixBus,1));
playHead = ( Phasor.ar(
resetTrig, // reset
(0.5**4) * BufRateScale.kr(mainBuf), // rate
startPosition, // start
startPosition + lenBusVal, // end
startPosition + resetPosBusVal // resetPos
) ) % BufFrames.kr(mainBuf);
sig = BufRd.ar(2, mainBuf, playHead, 1, 4) * EnvGen.kr(Env.adsr(0.1,0,1,0.1), gate, doneAction: 2);
sig = spec.dist21lf.map(In.kr(distBus,1)) * sig; // distortion bus
Out.ar(~aBus.outA, sig*mixBusVal);
}).send(s);
////////// Zone 3 MIDI //////////////////////////////////////
SynthDef(\zone3play1, {
arg gate, lenBus, startPosition = 0, ampBus, distBus, pitchBus, resetPosBus, panSpdBus, ampModSpdBus, ampModOnBus, ffBus;
var sig, lenBusVal, resetTrig = 1, resetPosBusVal, ampModSpdVal, ampModBusOnVal, ffBusVal, playHead;
lenBusVal = IEnvGen.kr(spec.len31, In.kr(lenBus,1));
resetPosBusVal = In.kr(resetPosBus,1) * lenBusVal;
startPosition = spec.startPos21L.map(startPosition);
resetTrig = HPZ2.kr(In.kr(resetPosBus,1));
ampModSpdVal = In.kr(ampModSpdBus,1);
ampModBusOnVal = In.kr(ampModOnBus,1);
ffBusVal = In.kr(ffBus,1);
playHead = ( Phasor.ar(
resetTrig,
spec.pitch21.map(In.kr(pitchBus,1)) * BufRateScale.kr(mainBuf),
startPosition,
startPosition + lenBusVal,
startPosition + resetPosBusVal
) ) % BufFrames.kr(mainBuf);
if(~showBufferView == 1,
{SendReply.kr(Impulse.kr(cfg.bufferViewPlayHeadFreq), "/playHead", [playHead/sRate, startPosition/sRate, lenBusVal/sRate], 31)});
sig = BufRd.ar(2, mainBuf, playHead, 1, 4 ) * EnvGen.kr(Env.adsr(0.1,0,1,0.1), gate, doneAction: 2);
sig = IEnvGen.kr(spec.amp21, In.kr(ampBus,1)) * sig;
sig = spec.dist21.map(In.kr(distBus,1)) * sig;
sig = (ffBusVal.ceil * RHPF.ar(sig, IEnvGen.kr(spec.ff31, ffBusVal), 0.5, IEnvGen.kr(spec.mulHPF31, ffBusVal))) +
((1 - ffBusVal.ceil) * sig); // if ffBusVal=0, don't go through filter
sig = Balance2.ar(sig[0], sig[1], LFNoise1.ar(spec.panSpd31.map(In.kr(panSpdBus,1))));
sig =
((1 - ampModBusOnVal) * sig) +
// on/off modulation, clicky
// (ampModBusOnVal * sig * LFPulse.ar(1 / spec.ampModSpd31.map(ampModSpdVal)));
// sine modulation, too smooth maybe
// (ampModBusOnVal * sig * SinOsc.ar(1 / spec.ampModSpd31.map(ampModSpdVal)).range(0,1));
// a mix between the above, depending on the mod speed
(ampModBusOnVal * sig * ampModSpdVal *
SinOsc.ar(1 / spec.ampModSpd31.map(ampModSpdVal)).range(0,1)) +
(ampModBusOnVal * sig * (1 - ampModSpdVal) *
LFPulse.ar(1 / spec.ampModSpd31.map(ampModSpdVal)));
Out.ar(~aBus.outA, sig);
}).send(s);
////////// Zone 4 MIDI //////////////////////////////////////
SynthDef(\zone4play1, {
arg gate, lenBus, startPosition = 0, ampBus, distBus, pitchBus, pitch2Bus, ffBus, ffSpeedBus;
var trig, sig, lenBusVal, playHead, sign, trig2, ffSpeedVal;
ffSpeedVal = spec.ffSpeed41.map(In.kr(ffSpeedBus,1));
lenBusVal = In.kr(lenBus,1);
// trig = Impulse.ar(1 / IEnvGen.kr(spec.len41, In.kr(lenBus,1)));
trig = Impulse.ar(1 / lenBusVal);
if(~showBufferView == 1, {
trig2 = Impulse.ar(1 / (lenBusVal * 2));
sign = LFPulse.ar(1 / (lenBusVal * 2), width: 0.5).range(-1,1);
playHead = ( Phasor.ar(
trig2,
spec.pitch41.map(In.kr(pitchBus,1)) * BufRateScale.kr(mainBuf) * sign,
spec.startPos21L.map(startPosition),
spec.startPos21L.map(startPosition) + (lenBusVal*2*sRate),
spec.startPos21L.map(startPosition)
) ) % BufFrames.kr(mainBuf);
SendReply.kr(Impulse.kr(cfg.bufferViewPlayHeadFreq), "/playHead",
[playHead/sRate, spec.startPos21L.map(startPosition)/sRate, lenBusVal], 41)
});
// SendTrig.kr(Impulse.kr(4),1,In.kr(lenBus,1));
sig = PlayBufAlt.ar(2, mainBuf,
spec.pitch41.map(In.kr(pitchBus,1)) * spec.pitch412.map(In.kr(pitch2Bus,1)) * BufRateScale.kr(mainBuf),
trig, spec.startPos21L.map(startPosition), 1, lag: cfg.playBufLag
) * EnvGen.kr(Env.adsr(0.05,0,1,0.05), gate, doneAction: 2);
sig = IEnvGen.kr(spec.amp21, In.kr(ampBus,1)) * sig;
sig = spec.dist21.map(In.kr(distBus,1)) * sig;
sig = RLPF.ar(sig, spec.ff41.map(In.kr(ffBus,1) + (0.2 * LFNoise1.kr(ffSpeedVal))), 0.5 + (0.1 * LFNoise1.kr(1)));
// sig = RLPF.ar(sig, spec.ff41.map(In.kr(ffBus,1) + (0.2 * LFNoise1.kr(0.2))), 0.5 + (0.1 * LFNoise1.kr(1)));
// sig = RLPF.ar(sig, spec.ff41.map(In.kr(ffBus,1) + (0.2 * LFNoise1.kr(2))), 0.5 + (0.1 * LFNoise1.kr(1)));
Out.ar(~aBus.outA, sig);
}).send(s);
SynthDef(\zone4play1hf, {
arg gate, lenBus, startPosition = 0, distBus;
var trig, sig;
// trig = Impulse.ar(1 / IEnvGen.kr(spec.len41, In.kr(lenBus,1)));
trig = Impulse.ar((2**3) * BufRateScale.kr(mainBuf) / In.kr(lenBus,1));
sig = PlayBufAlt.ar(2, mainBuf, (2**3) * BufRateScale.kr(mainBuf), trig, spec.startPos21L.map(startPosition), 1, lag: cfg.playBufLag
) * EnvGen.kr(Env.adsr(0.05,0,1,0.05), gate, doneAction: 2);
sig = spec.dist21hf.map(In.kr(distBus,1)) * sig;
Out.ar(~aBus.outA, sig);
}).send(s);
SynthDef(\zone4play1lf, {
arg gate, lenBus, startPosition = 0, distBus;
var trig, sig;
trig = Impulse.ar(1 / In.kr(lenBus,1));
sig = PlayBufAlt.ar(2, mainBuf, (0.5**3) * BufRateScale.kr(mainBuf), trig, spec.startPos21L.map(startPosition), 1, lag: cfg.playBufLag
) * EnvGen.kr(Env.adsr(0.05,0,1,0.05), gate, doneAction: 2);
sig = spec.dist21lf.map(In.kr(distBus,1)) * sig;
Out.ar(~aBus.outA, sig);
}).send(s);
////////// Zone 6 joystick //////////////////////////////////////
SynthDef(\zone6play1, { // trigger button
arg gate, lenBus, startPosition = 0, distBus, pitchBus;
var trig, sig, lenBusVal, playHead, pitchBusVal;
lenBusVal = spec.len61.map(In.kr(lenBus,1));
// pitchBusVal = spec.pitch61.map(In.kr(pitchBus,1));
// pitchBusVal = IEnvGen.kr(spec.pitch61, In.kr(pitchBus,1));
pitchBusVal = In.kr(pitchBus,1); // pitchBus already spec'd in OSCresponder
trig = Impulse.ar(1 / lenBusVal);
if(~showBufferView == 1,{
playHead = ( Phasor.ar(
trig,
pitchBusVal * BufRateScale.kr(mainBuf),
spec.startPos61.map(startPosition),
spec.startPos61.map(startPosition) + ((lenBusVal*pitchBusVal)*sRate),
spec.startPos61.map(startPosition)
) ) % BufFrames.kr(mainBuf);
SendReply.kr(Impulse.kr(cfg.bufferViewPlayHeadFreq), "/playHead",
[playHead/sRate, spec.startPos61.map(startPosition)/sRate, lenBusVal*pitchBusVal], 61)
});
sig = PlayBufCF.ar(2, mainBuf, pitchBusVal * BufRateScale.kr(mainBuf), trig, spec.startPos61.map(startPosition), 1,
lag: cfg.playBufLag
) * EnvGen.kr(Env.adsr(0.05,0,1,0.05), gate, doneAction: 2);
sig = IEnvGen.kr(spec.dist61, In.kr(distBus,1)) * sig;
Out.ar(~aBus.outB, sig);
}).send(s);
SynthDef(\zone6play1Plus, { // trigger button
arg gate, lenBus, startPosition = 0, distBus, pitchBus;
var trig1, trig2, sig1, sig2, sig;
trig1 = Impulse.ar(1 / spec.len61Plus1.map(In.kr(lenBus,1)));
trig2 = Impulse.ar(1 / spec.len61Plus2.map(In.kr(lenBus,1)));
sig1 = PlayBufCF.ar(2, mainBuf,
// spec.pitch61.map(In.kr(pitchBus,1)) * BufRateScale.kr(mainBuf),
// IEnvGen.kr(spec.pitch61,In.kr(pitchBus,1)) * BufRateScale.kr(mainBuf),
In.kr(pitchBus,1) * BufRateScale.kr(mainBuf), // pitchBus already spec'd in OSCresponder
trig1, spec.startPos61Plus1.map(startPosition), 1, lag: cfg.playBufLag
) * EnvGen.kr(Env.adsr(0.05,0,1,0.05), gate, doneAction: 2);
sig2 = PlayBufCF.ar(2, mainBuf,
// spec.pitch61.map(In.kr(pitchBus,1)) * BufRateScale.kr(mainBuf),
// IEnvGen.kr(spec.pitch61,In.kr(pitchBus,1)) * BufRateScale.kr(mainBuf),
In.kr(pitchBus,1) * BufRateScale.kr(mainBuf), // pitchBus already spec'd in OSCresponder
trig2, spec.startPos61Plus2.map(startPosition), 1, lag: cfg.playBufLag
) * EnvGen.kr(Env.adsr(0.05,0,1,0.05), gate, doneAction: 2);
sig1 = Balance2.ar(sig1[0], sig1[1],-0.8);
sig2 = Balance2.ar(sig2[0], sig2[1],0.8);
sig = sig1 + sig2;
sig = IEnvGen.kr(spec.dist61, In.kr(distBus,1)) * sig;
Out.ar(~aBus.outB, sig);
}).send(s);
SynthDef(\zone6play2, { // side button
arg gate, lenBus, startPosition = 0, distBus, ffBus, panBus;
var trig, sig, playHead, lenBusVal;
lenBusVal = spec.len62.map(In.kr(lenBus,1));
trig = Impulse.ar(1 / lenBusVal);
if(~showBufferView == 1, {
playHead = ( Phasor.ar(
trig,
BufRateScale.kr(mainBuf),
spec.startPos62.map(startPosition),
spec.startPos62.map(startPosition) + (lenBusVal*sRate),
spec.startPos62.map(startPosition)
) ) % BufFrames.kr(mainBuf);
SendReply.kr(Impulse.kr(cfg.bufferViewPlayHeadFreq), "/playHead",
[playHead/sRate, spec.startPos62.map(startPosition)/sRate, lenBusVal], 62)
});
sig = PlayBufCF.ar(2, mainBuf, BufRateScale.kr(mainBuf), trig, spec.startPos62.map(startPosition), 1, lag: cfg.playBufLag
) * EnvGen.kr(Env.adsr(0.05,0,1,0.05), gate, doneAction: 2);
sig = IEnvGen.kr(spec.dist61, In.kr(distBus,1)) * sig;
sig = RHPF.ar(sig, spec.ff62.map(In.kr(ffBus,1)), 0.5);
sig = Balance2.ar(sig[0], sig[1],In.kr(panBus,1));
Out.ar(~aBus.outB, sig);
}).send(s);
SynthDef(\zone6play3, { // top button
arg gate, lenBus, startPosition = 0, distBus, ffBus, panBus;
var trig, sig, playHead, lenBusVal;
lenBusVal = spec.len63.map(In.kr(lenBus,1));
trig = Impulse.ar(1 / lenBusVal);
if(~showBufferView == 1, {
playHead = ( Phasor.ar(
trig,
BufRateScale.kr(mainBuf),
spec.startPos63.map(startPosition),
spec.startPos63.map(startPosition) + (lenBusVal*sRate),
spec.startPos63.map(startPosition)
) ) % BufFrames.kr(mainBuf);
SendReply.kr(Impulse.kr(cfg.bufferViewPlayHeadFreq), "/playHead",
[playHead/sRate, spec.startPos63.map(startPosition)/sRate, lenBusVal], 63)
});
sig = PlayBufCF.ar(2, mainBuf, BufRateScale.kr(mainBuf), trig, spec.startPos63.map(startPosition), 1, lag: cfg.playBufLag
) * EnvGen.kr(Env.adsr(0.05,0,1,0.05), gate, doneAction: 2);
sig = IEnvGen.kr(spec.dist61, In.kr(distBus,1)) * sig;
sig = RLPF.ar(sig, spec.ff63.map(In.kr(ffBus,1)), 0.5);
sig = Balance2.ar(sig[0], sig[1],In.kr(panBus,1));
Out.ar(~aBus.outB, sig);
}).send(s);
SynthDef(\zone6play4, { // base button 1
arg gate, lenBus, startPosition = 0, distBus, pitchBus, panBus;
var trig, sig, playHead, lenBusVal, pitchBusVal;
lenBusVal = IEnvGen.kr(spec.len64,In.kr(lenBus,1));
pitchBusVal = spec.pitch64.map(In.kr(pitchBus,1));
trig = Impulse.ar(1 / lenBusVal);
// SendTrig.kr(Impulse.kr(4),1,In.kr(panBus,1));
if(~showBufferView == 1, {
playHead = ( Phasor.ar(
trig,
BufRateScale.kr(mainBuf),
spec.startPos64.map(startPosition),
spec.startPos64.map(startPosition) + (lenBusVal*pitchBusVal*sRate),
spec.startPos64.map(startPosition)
) ) % BufFrames.kr(mainBuf);
SendReply.kr(Impulse.kr(cfg.bufferViewPlayHeadFreq), "/playHead",
[playHead/sRate, spec.startPos64.map(startPosition)/sRate, lenBusVal*pitchBusVal], 64)
});
sig = PlayBufCF.ar(2, mainBuf, pitchBusVal * BufRateScale.kr(mainBuf), trig, spec.startPos64.map(startPosition), 1,
lag: cfg.playBufLag
) * EnvGen.kr(Env.adsr(0.05,0,1,0.05), gate, doneAction: 2);
sig = IEnvGen.kr(spec.dist61, In.kr(distBus,1)) * sig;
sig = Balance2.ar(sig[0], sig[1],In.kr(panBus,1));
Out.ar(~aBus.outB, sig);
}).send(s);
// SynthDef(\zone6play5, { // base button 2 --- not used
// arg gate, lenBus, startPosition = 0, distBus, pitchBus, panBus;
// var trig, sig, playHead, lenBusVal, pitchBusVal;
//
// lenBusVal = spec.len65.at(In.kr(lenBus,1));
// pitchBusVal = spec.pitch65.map(In.kr(pitchBus,1));
//
// trig = Impulse.ar(1 / lenBusVal);
//
// if(~showBufferView == 1,{
// playHead = (
// Phasor.ar(
// trig,
// pitchBusVal * BufRateScale.kr(mainBuf),
// spec.startPos64.map(startPosition),
// spec.startPos64.map(startPosition) + (lenBusVal*pitchBusVal*sRate),
// spec.startPos64.map(startPosition)
// )
// ) % BufFrames.kr(mainBuf);
// SendReply.kr(Impulse.kr(cfg.bufferViewPlayHeadFreq), "/playHead",
// [playHead/sRate, spec.startPos64.map(startPosition)/sRate, lenBusVal*pitchBusVal], 65)
// });
//
// sig = PlayBufCF.ar(
// 2,
// mainBuf,
// pitchBusVal * BufRateScale.kr(mainBuf),
// trig,
// spec.startPos64.map(startPosition),
// 1,
// lag: cfg.playBufLag
// ) * EnvGen.kr(Env.adsr(0.05,0,1,0.05), gate, doneAction: 2);
// // sig = spec.dist61.map(In.kr(distBus,1)) * sig;
// sig = IEnvGen.kr(spec.dist61, In.kr(distBus,1)) * sig;
// sig = Balance2.ar(sig[0], sig[1],In.kr(panBus,1));
// Out.ar(~aBus.outB, sig);
// }).send(s);
////////// Zone 8 MIDI //////////////////////////////////////
SynthDef(\zone8play1, {
arg gate, lenBus, startPosition = 0, ampBus, distBus, pitchPattBus, jumpBus, panBus, ampPattBus, dirBus, pitchBus, pattSelBus;
var sig, lenBusVal, resetTrig = 1, jumpBusVal, playHead, rateOn, rate, winSize, winRanRatio, winOverlaps, pitch;
// map params dependent on rateOn, so dependent on the pattern select knob
rate = IEnvGen.kr(spec.rate81, In.kr(pitchBus,1));
rateOn = ( In.kr(pattSelBus,1) < 0.05 );
rate = (rateOn * rate) + (1-rateOn);
winSize = (rateOn * 0.2) + ((1-rateOn) * 0.1);
winRanRatio = (rateOn * 0.5) + ((1-rateOn) * 0.2);
winOverlaps = (rateOn * 8) + ((1-rateOn) * 4);
pitch = rateOn + ( (1-rateOn)*IEnvGen.kr(spec.pitch81, In.kr(pitchBus,1)) );
lenBusVal = IEnvGen.kr(spec.len81, In.kr(lenBus,1)) / rate;
jumpBusVal = In.kr(jumpBus,1) / rate;
startPosition = spec.startPos21L.map(startPosition) / rate;
resetTrig = HPZ2.kr(jumpBusVal);
playHead = ( Phasor.ar(
resetTrig,
// IEnvGen.kr(spec.pitch81, In.kr(pitchBus,1)) * In.kr(pitchPattBus,1) * // uncomment in case of using BufRd
BufRateScale.kr(mainBuf) * In.kr(dirBus,1),
startPosition,
startPosition + lenBusVal,
startPosition + (jumpBusVal % lenBusVal)
) ) % BufFrames.kr(mainBuf);
playHead = rate * playHead;
// update bufferView
if(~showBufferView == 1,
{SendReply.kr(Impulse.kr(cfg.bufferViewPlayHeadFreq), "/playHead",
[playHead/sRate, startPosition/sRate*rate, lenBusVal/sRate*rate], 81)});
// sig = BufRd.ar(2, mainBuf, playHead, 1, 4);
sig = Warp1.ar(2, mainBuf, playHead/BufFrames.kr(mainBuf), pitch * In.kr(pitchPattBus,1),
winSize, -1, winOverlaps, winRanRatio, 4);
sig = sig * EnvGen.kr(Env.adsr(0.1,0,1,0.1), gate, doneAction: 2);
sig = IEnvGen.kr(spec.amp81, In.kr(ampBus,1)) * sig;
sig = spec.dist21.map(In.kr(distBus,1)) * sig;
sig = In.kr(ampPattBus,1) * sig;
sig = Balance2.ar(sig[0], sig[1],In.kr(panBus,1));
Out.ar(~aBus.outA, sig);
}).send(s);
////////// Zone 16 MIDI //////////////////////////////////////
SynthDef(\zone16play1_old_version, {
arg gate, ampBus, distBus, resetPosBus, lenBus, panBus, ffBus;
var sig, resetTrig = 1, resetPosBusVal, lenBusVal, playHead;
lenBusVal = In.kr(lenBus,1) * sRate;
resetPosBusVal = In.kr(resetPosBus,1) * lenBusVal;
resetTrig = HPZ2.kr(In.kr(resetPosBus,1));
playHead = ( Phasor.ar(
resetTrig,
BufRateScale.kr(mainBuf),
buffer.dyn1Start,
buffer.dyn1Start + lenBusVal,
buffer.dyn1Start + resetPosBusVal
) ) % BufFrames.kr(mainBuf);
// update bufferView
if(~showBufferView == 1,
{SendReply.kr(Impulse.kr(cfg.bufferViewPlayHeadFreq), "/playHead",
[playHead/sRate, buffer.dyn1Start/sRate, lenBusVal/sRate], 161)});
// sig = Warp1.ar(2, mainBuf, playHead / BufFrames.kr(mainBuf)) * EnvGen.kr(Env.adsr(0.1,0,1,0.1), gate, doneAction: 2);
sig = BufRd.ar(2, mainBuf, playHead, 1, 4) * EnvGen.kr(Env.adsr(0.1,0,1,0.1), gate, doneAction: 2);
sig = IEnvGen.kr(spec.amp21, In.kr(ampBus,1)) * sig;
sig = spec.dist21.map(In.kr(distBus,1)) * sig;
sig = Balance2.ar(sig[0], sig[1],spec.pan161.map(In.kr(panBus,1)));
sig = RLPF.ar(sig, spec.ff21.map(In.kr(ffBus,1)), 0.5);
Out.ar(~aBus.outA, sig);
}).send(s);
SynthDef(\zone16play1, {
arg gate, ampBus, distBus, lenBus, panBus, ffBus;
var sig, trig, env, lenFactor = 1, startFactor = 0, startPos, lenBusVal, playHead;
var stepsOffset = [0.0, 0.1, 0.0, 0.2, 0.1, 0.3, 0.5, 0.6, 0.9]; // offset values for SP
var modDepth = [0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 0.9, 0.8, 0.7, 0.6, 0.5]; // factor values for SP
lenBusVal = In.kr(lenBus,1);
lenFactor = LFNoise0.kr(1).range(0.3,1);
trig = Impulse.kr( 1 / (lenFactor * min(lenBusVal,1)) );
startFactor = Demand.kr(trig, 0, Dseq(stepsOffset, inf) * Dseq(modDepth, inf));
startPos = buffer.dyn1Start + (startFactor * lenBusVal * sRate);
// update bufferView
if(~showBufferView == 1, {
playHead = Phasor.ar(
trig,
BufRateScale.kr(mainBuf),
startPos,
startPos + (lenFactor * min(lenBusVal,1)),
startPos
) % BufFrames.kr(mainBuf);
SendReply.kr(Impulse.kr(cfg.bufferViewPlayHeadFreq), "/playHead",
[playHead/sRate, buffer.dyn1Start/sRate, lenBusVal/sRate], 161)
});
env = EnvGen.ar(Env.adsr(0.1,0,1,0.1), gate, doneAction: 2);
sig = PlayBufCF.ar(2,mainBuf, trigger: trig, lag: 0.05, n: 2, startPos: startPos);
sig = IEnvGen.kr(spec.amp21, In.kr(ampBus,1)) * sig;
sig = spec.dist21.map(In.kr(distBus,1)) * sig;
sig = Balance2.ar(sig[0], sig[1],spec.pan161.map(In.kr(panBus,1)));
sig = RLPF.ar(sig, spec.ff21.map(In.kr(ffBus,1)), 0.5);
Out.ar(~aBus.outA, sig);
}).send(s);
2.do { |i|
SynthDef("zone16play2" ++ if(i==0, {""}, {"bw"}), {
arg gate, ampBus, lenBus, distBus, pitchRangeBus, pitchSelectBus;
var trig, sig, pitchArray, pitchSelected, playHead, sign, trig2, lenBusVal;
lenBusVal = In.kr(lenBus,1);
pitchArray = [
IEnvGen.kr(spec.pitch162, LFTri.ar(0.2).range(0,In.kr(pitchRangeBus,1))),
IEnvGen.kr(spec.pitch162up1, LFSaw.ar(0.4).range(0,In.kr(pitchRangeBus,1))),
IEnvGen.kr(spec.pitch162down1, LFSaw.ar(0.4).range(1, (1 - In.kr(pitchRangeBus,1)))),
IEnvGen.kr(spec.pitch162lisa1, LFSaw.ar(0.3).range(0,In.kr(pitchRangeBus,1))),
IEnvGen.kr(spec.pitch162ran, LFNoise0.ar(100).range(0,In.kr(pitchRangeBus,1)))
];
pitchSelected = Select.kr(
IEnvGen.kr(spec.pitch16select, In.kr(pitchSelectBus,1)),
pitchArray);
trig = Impulse.ar(pitchSelected / (lenBusVal - zoneRec.dynOverflow));
if(~showBufferView == 1,{
trig2 = Impulse.ar(pitchSelected / (lenBusVal*2));
sign = LFPulse.ar(pitchSelected / (lenBusVal*2), width: 0.5).range(-1,1);
playHead = ( Phasor.ar(
trig2,
pitchSelected * BufRateScale.kr(mainBuf) * sign,
buffer.dyn2Start,
buffer.dyn2Start + (lenBusVal*2*sRate),
buffer.dyn2Start
) ) % BufFrames.kr(mainBuf);
SendReply.kr(Impulse.kr(cfg.bufferViewPlayHeadFreq), "/playHead", [playHead/sRate, buffer.dyn2Start/sRate, lenBusVal], 162)
});
if(i==0, {
sig = PlayBufAlt.ar(2, mainBuf, pitchSelected * BufRateScale.kr(mainBuf), trig, buffer.dyn2Start, 1, lag: cfg.playBufLag);
}, {
sig = PlayBufCF.ar(2, mainBuf, -1.0 * pitchSelected * BufRateScale.kr(mainBuf), trig, buffer.dyn2Start + (lenBusVal*sRate),
1, lag: cfg.playBufLag);
});
sig = sig * EnvGen.kr(Env.adsr(0.05,0,1,0.05), gate, doneAction: 2);
sig = IEnvGen.kr(spec.amp21, In.kr(ampBus,1)) * sig;
sig = spec.dist21.map(In.kr(distBus,1)) * sig;
sig = Balance2.ar(sig[0], sig[1],-0.5);
Out.ar(~aBus.outA, sig);
}).send(s);
};
2.do { |i|
SynthDef("zone16play3" ++ if(i==0, {""}, {"bw"}), {
arg gate, ampBus, lenBus, distBus, pitchRangeBus, pitchSelectBus;
var trig, sig, pitchArray, pitchSelected, playHead, sign, trig2, lenBusVal;
lenBusVal = In.kr(lenBus,1);
pitchArray = [
IEnvGen.kr(spec.pitch162, LFTri.ar(0.2).range(0,In.kr(pitchRangeBus,1))),
IEnvGen.kr(spec.pitch162up2, LFSaw.ar(0.4).range(0,In.kr(pitchRangeBus,1))),
IEnvGen.kr(spec.pitch162down2, LFSaw.ar(0.4).range(1, (1 - In.kr(pitchRangeBus,1)))),
IEnvGen.kr(spec.pitch162lisa2, LFSaw.ar(0.2).range(0,In.kr(pitchRangeBus,1))),
IEnvGen.kr(spec.pitch162ran, LFNoise0.ar(100).range(0,In.kr(pitchRangeBus,1)))
];
pitchSelected = Select.kr(
IEnvGen.kr(spec.pitch16select, In.kr(pitchSelectBus,1)),
pitchArray);
trig = Impulse.ar(pitchSelected / (lenBusVal - zoneRec.dynOverflow));
if(~showBufferView == 1,{
trig2 = Impulse.ar(pitchSelected / (lenBusVal*2));
sign = LFPulse.ar(pitchSelected / (lenBusVal*2), width: 0.5).range(-1,1);
playHead = ( Phasor.ar(
trig2,
pitchSelected * BufRateScale.kr(mainBuf) * sign,