-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSonicMirror.scd
2200 lines (1908 loc) · 75.6 KB
/
SonicMirror.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
/**********SONIC MIRROR**********
An open-ended audio software (and hardware) instrument designed for autonomous embedded audio recording, generative sound, and musical performance.
Project details and documentation online: http://scott-tooby.com/sonic-mirror.html
=============
LAUNCH INSTRUCTIONS: Evaluate the lines and bracketed blocks of code below in order from #1 - 3.
=============
OPERATING INSTRUCTIONS:
• Press the 'REC' button to begin recording audio input to the buffer
• Press the 'PLAY' button to begin playing audio back from the buffer
• Press the "REV" button to play audio in reverse
• Enabling the "!", "!!", or "!!!" buttons will trigger various autonomous playback behaviors. Parameters like: rate, pitch, pitch shift mix, output volume, reverse, and playhead position will be randomly modulated over time.
• Pro tip: arranging your microphone and speaker(s) so they feed back on themselves can create some fantastic sounds when the Sonic Mirror's autonomous behavior buttons are enabled, or during manual control of various playback parameters. Watch out for runaway feedback!
=============
This is a work in progress...
Feel free to use, experiment, and contribute: https://github.com/stooby/sonic-mirror
st, 2016
-----------------*/
(
//INITIALIZE #1 - DEFAULT ============================
//run this chunk of code first to use your system's built-in soundcard at default 44.1k sampling rate
s = Server.local;
s.options.sampleRate = 44100;
s.options.inDevice = "Built-in Microph";
s.options.outDevice = "Built-in Output";
s.boot;
//if the SC server crashes and fails to start after executing, try evaluating again....the server's sometimes stubborn...alternatively, you can delete the brackets around this chunk of code and execute each line individually...this seems to be more agreeable to the SC server
)
ServerOptions.devices; //execute this command to view your system's available input/output options
(//INITIALIZE #1 - CUSTOM
//OR, if you'd like to configure the SC server for your unique audio system, you can do so by editing or commenting/uncommenting lines here.
//alternatively, edit and run this chunk of code first if you'd like to use configure the SC server with custom audio settings
s = Server.local;
s.options.sampleRate= 48000;
s.options.inDevice = "MiC";
//s.options.device = "iConnectAudio4+";
s.boot;
)
s.quit; //convenience method (for cleanup)
s.plotTree; //for debugging
Buffer.freeAll; //for cleanup
(//CREATE SYNTHDEFS AND BUSSES - #2 ============================
//Record audio input to buffer using audio-rate input Phasor to control position in buffer
SynthDef(\RecBuf_loop, { //<---NEW -- Added Lo-cut
arg phaseBus, buf, sendBus, loCutoff = 90, rQ = 1, mul = 1;
//var sig = SoundIn.ar(bus: 0, mul: mul);
var sig = BHiPass4.ar( SoundIn.ar(bus: 0, mul: 1), loCutoff, rq: rQ, mul: mul); //pass SoundIn through HiPass
BufWr.ar(sig, buf, InFeedback.ar(phaseBus) );
//OffsetOut.ar(sendBus, sig); //would this provide better sample accurate scope plotting and recording?
Out.ar(sendBus, sig); //<---
} ).add;
/*SynthDef(\RecBuf_loop, { //pre-Hipass
arg phaseBus, buf, sendBus, mul = 1;
var sig = SoundIn.ar(bus: 0, mul: mul);
BufWr.ar(sig, buf, InFeedback.ar(phaseBus) );
//OffsetOut.ar(sendBus, sig);
Out.ar(sendBus, sig); //<---
} ).add; */
/*//from earliest version of sonic mirror...use RecordBuf to continuously record to buffer 1, when reach end, loop back to beginning and write over prev data...not as flexible as writing to buffer with phasor
SynthDef.new(\RecBuf_loop, {
arg buf = ~buffer.bufnum;
var sound = SoundIn.ar(0);
RecordBuf.ar(sound, buf, loop: 1, doneAction: 0); //consider making 'run' a configurable parameter to permit pickup at last buffer index when resuming recording after pause....
} ).add;*/
// Phasor drives the buffer scaling at audio rate
SynthDef(\phasor, {
arg out=0, buf, trig = 0, rate = 1, start = 0, end = BufFrames.kr(buf) - 1, resetPos = 0;
//Out.ar(out, Phasor.ar(trig, BufRateScale.kr(buf) * rate, start * BufFrames.kr(buf), (end * BufFrames.kr(buf)) - 1, resetPos ) );
Out.ar(out, Phasor.ar(trig, BufRateScale.kr(buf) * rate, start, end, resetPos ) );
}).add;
// Needed to monitor phasor
SynthDef(\a2k_patch, {
arg in, out;
Out.kr(out, A2K.kr(InFeedback.ar(in) ) ); //is InFeedback necessary?
}).add;
// Takes audio-rate input phase to control the buffer position
SynthDef.new(\ReadBuf_loop, { //define synth to read from buffer w/ phasor...
arg amp=1, out=0, phaseBus, buf;
var sig;
sig = BufRd.ar(1, buf, InFeedback.ar(phaseBus));
sig = sig * amp;
//~sliderPlayPos.value_(ptr);
Out.ar(out, sig);
} ).add;
SynthDef.new(\pitchShifter, {
arg inBus, outBus, windowSize = 0.2, pitchRatio = 1, pitchDispers = 0, timeDispers = 0.2, amp = 1;
var sigIn, sigOut;
sigIn = In.ar(inBus, 1);
//sigIn = InFeedback.ar(inBus, 1);
sigOut = PitchShift.ar(sigIn, windowSize, pitchRatio, pitchDispers, timeDispers, amp);
Out.ar(outBus, sigOut);
}).add;
SynthDef.new(\XFade, { //newer version w/ global amp control
|in1, in2, out, amountControlBus, amp = 1|
var inArray, mixSignal, sig;
inArray = [In.ar(in1), In.ar(in2)];
//inArray = [InFeedback.ar(in1), InFeedback.ar(in2)];
mixSignal = SelectX.ar(amountControlBus, inArray);
sig = mixSignal * amp;
Out.ar(out, sig);
} ).add;
/*SynthDef.new(\XFade, {
|in1, in2, out, amountControlBus|
var inArray, mixSignal;
inArray = [In.ar(in1), In.ar(in2)];
//inArray = [InFeedback.ar(in1), InFeedback.ar(in2)];
mixSignal = SelectX.ar(amountControlBus, inArray);
Out.ar(out, mixSignal);
} ).add; */
SynthDef(\LinInterp_pitch, {
arg startVal, stopVal, duration, out;
Out.kr(out, Line.kr(startVal, stopVal, duration, doneAction: 2).midiratio);
} ).add;
SynthDef(\LinInterp_rate, {
arg startVal, stopVal, duration, out, rateMod = 1;
var outputVal = rateMod * Line.kr(startVal, stopVal, duration, doneAction: 2).midiratio;
Out.kr(out, outputVal);
} ).add;
SynthDef(\LinInterp_num, {
arg startVal, stopVal, duration, mult = 1, out;
Out.kr(out, Line.kr(startVal, stopVal, duration, mul: mult, doneAction: 2));
} ).add;
SynthDef.new(\subMix, { //<--NEW - utility
|in, amp = 1, out|
var sig;
sig = In.ar(in) * amp;
//sig = InFeedback.ar(in) * amp;
//OffsetOut.ar(out, sig);
Out.ar(out, sig);
} ).add;
SynthDef.new(\mainOut, { //<--NEW w/ Lo-cut
|in, loCutoff = 90, rQ = 1, amp = 1|
var sig;
sig = BHiPass4.ar( In.ar(in), loCutoff, rq: rQ, mul: amp);
//sig = In.ar(in) * amp;
//sig = InFeedback.ar(in) * amp;
//OffsetOut.ar(0, sig);
Out.ar([0, 1], sig);
} ).add;
/*SynthDef.new(\mainOut, { //ORIG mainOut
|in, amp = 1|
var sig;
sig = In.ar(in) * amp;
//sig = InFeedback.ar(in) * amp;
//OffsetOut.ar(0, sig);
Out.ar([0, 1], sig);
} ).add; */
SynthDef.new(\scopeOut, { //<------NEW
|inBus, buf|
var sig;
sig = In.ar(inBus, 1);
ScopeOut2.ar(sig, buf);
} ).add;
SynthDef(\write2Disk, {arg buf, inBus = 0; //record audio file to disk - mono
DiskOut.ar(buf, In.ar(inBus, 1));
}).add;
// play audio file from disk WITH an amplitude envelope to avoid clicks @ beginning & end of sample
SynthDef(\readDisk, { arg buf, sampleDur, amp = 1, out; //<----NEW MOD VERS w/ amp control
var env, envgen, sig;
env = Env.linen(0.02, (sampleDur - 0.04), 0.02, 1, -1);
envgen = EnvGen.ar(env, doneAction: 2);
sig = (DiskIn.ar(1, buf) * envgen) * amp;
Out.ar(out, sig);
}).add;
/*SynthDef(\readDisk, { arg buf, sampleDur, out;
var env, envgen, sig;
env = Env.linen(0.02, (sampleDur - 0.04), 0.02, 1, -1);
envgen = EnvGen.ar(env, doneAction: 2);
sig = DiskIn.ar(1, buf) * envgen;
Out.ar(out, sig);
}).add; */
//-----BUSSES-----
~recInPosBus = Bus.control(s, 1);
~recOutPosBus = Bus.control(s, 1);
~playInPosBus = Bus.control(s, 1);
~playOutPosBus = Bus.control(s, 1);
~rateBus = Bus.control(s, 1);
~pitchBus = Bus.control(s, 1);
~pitchShiftMixValBus = Bus.control(s, 1); //mix % between orig and pitch-shifted signal
~pitchShiftOut = Bus.audio(s, 1);
~inputStreamLevelBus = Bus.control(s, 1); //level of audio output from ~pShiftMix Synth <-----NEW
~fileOutputLevelBus = Bus.control(s, 1); //level of audio file playback <------- NEW
~revRateBusMon = Bus.control(s, 1);
~phaseBusRec = Bus.audio(s, 1);
~phaseBusMonRec = Bus.control(s, 1);
~inputLevelBus = Bus.control(s, 1);
~loCutBus_in = Bus.control(s, 1); //<----NEW
~loCutBus_out = Bus.control(s, 1); //<----NEW
~inputSendBus = Bus.audio(s, 1); //<---NEW
~phaseBusPly = Bus.audio(s, 1);
~phaseBusMonPly = Bus.control(s, 1);
~play1LevelBus = Bus.control(s, 1); //to control level of audioPlayback ("playhead1")
~playOut1Bus = Bus.audio(s, 1);
~outMainLevelBus = Bus.control(s, 1);
~outMainBus = Bus.audio(s, 1);
)
( //LAUNCH GUI & RUN - #3 ============================
////GLOBAL VARIABLES
~bufferSize = 60.0;
~buffer = Buffer.alloc(s, s.sampleRate * ~bufferSize, 1);
~delayTime = 1.23;
~play2recOffset; //displacement of playhead pos from rec pos (in frames/samples)
~lastPlayPhasePos = 0; //for resume functionality - stores last pos (frame) of play head before playback disabled
~lastRecPhasePos = 0; //for resume functionality - stores last pos (frame) of rec head before recording disabled
~playTrig = false;
~recTrig = false;
~fixPlayRecOffset = false;
~pitchShiftValPrev_rate;
~pitchShiftValTarget_rate = 0;
~pitchInterp_rate = false;
~pitchShiftValPrev_freq;
~pitchShiftValTarget_freq;
~pitchInterp_freq = false;
~outMainLevVal_prev; //<--
~outMainLevVal_target; //<--not currently being used...could be useful in future though....
~outMainLevInterp = false; //<--not currently being monitored...
~reverseFlag = false; //currentlly using ~buttonRev.value as flag, but is that a good long-term idea????
~randomPos_flag = false;
~time2NextRandom_rate = 0;
~time2NextRandom_freq = 0;
~time2NextRandom_pitchShiftMix = 0;
~pitchShiftMix_prev;
~pitchShiftMix_target; //<- not using right now, might not need unless interpolating
~pitchShiftMix_prevChangeTime = 0;
~pitchShiftMix_interp = false;
~currentPlayInFrame = 0;
~currentPlayOutFrame = ~bufferSize * s.sampleRate - 1; //~buffer.numFrames - 1; (won't work unless ~buffer's already been allocated...)
~currentRecInFrame = 0;
~currentRecOutFrame = ~bufferSize * s.sampleRate - 1;
~playBehavior = 0; //stores state of playback behavior
////////////////
~minRecDur = 3.0; //<-----NEW: min sec per recorded sample
~maxRecDur = 6.0; //<----NEW: max sec per recorded sample
~recSound_input = false; //<---NEW: write audio file 2 disk flag....should I store this info in a contol bus?
~recSound_input_startTime; //<---NEW: .............should I store this info in a contol bus?
~recSound_input_stopTime; //<---NEW: .............should I store this info in a contol bus?
~playSound = false; //<---NEW: play audio file from disk flag
~hearSound = false; //<---NEW: for machine listening
~listenInterval_intraSound = 1.0; //<----NEW: amount of time (sec) to continue listening for continuation of contiguous sound object between gaps of silence (e.g. seperation threshold for dividing sound objects)
~playSoundBuf = Buffer.alloc(s, 65536, 1); //buffer for playing back mono audio files from disk
~input1_specFlatVal; //<---NEW: .........should I store this info in a contol bus?
~input1_ampVal; //<---NEW: .........should I store this info in a contol bus?
//////////////////
~fileAudio_writeOut_nameNum = 0; //counter for writing/reading audio file names
//~fileAudio_writeOut_lastPath = ("~/Music/SCrecs/SncMir-MainOut_" ++ ~fileAudio_writeOut_nameNum ++ ".aiff");
~fileAudio_writeOut_lastPath = "~/Music/SCrecs/SncMir-MainOut_"; //stores string of file path for last written audio file from disk
//~fileAudio_lastReadPath = ("~/Music/SCrecs/SncMir-MainOut_" ++ ~fileAudio_writeOut_nameNum ++ ".aiff"); //stores string of file path for last read audio file from disk
~fileAudio_writeOut_maxNum = 30; //<---NEW: max # of files written per session (wrap-around & overwrite limit)
~fileAudio_writeIn_nameNum = 0; //counter for writing/reading audio file name
~fileAudio_writeIn_lastPath = "~/Music/SCrecs/SncMir-In_"; //stores string of file path for last written audio file
~minNumFilesB4Playback = 1; //<----!!!!!NEW!!!!!!! file # threshold before file playback routine commences
~loCutVal_in = 90; //<-----NEW initialization val for loCut (and also stores ongoing values?)
~loCutVal_out = 90; //<-----NEW ...for initialization
////
Window.closeAll;
w = Window.new("SonicMirror", Rect.new(470, 330, 780, 405))
.front
.alwaysOnTop_(true);
w.onClose_{s.freeAll; Buffer.freeAll(s); CmdPeriod.clearClocks; CmdPeriod.run;}; // clean up when window is closed
//(RESET BUS VALUES FOR INITIALIZATION OF SKETCH)
~playInPosBus.set(0);
~playOutPosBus.set(~currentPlayOutFrame);
~recInPosBus.set(0);
~recOutPosBus.set(~currentRecOutFrame);
~rateBus.set(1);
~pitchBus.set(1);
~pitchShiftMixValBus.set(0); //<---
~revRateBusMon.set(1); //<---
~inputLevelBus.set(1);
~play1LevelBus.set(1); //<--NO SLIDER CREATED YET!!!!!....
~inputStreamLevelBus.set(1); //<---NEW
~fileOutputLevelBus.set(1); //<---NEW
~outMainLevelBus.set(1);
~phaseBusMonPly.set(0);
~phaseBusMonRec.set(0);
~loCutBus_in.set(~loCutVal_in); //<---NEW
~loCutBus_out.set(~loCutVal_out); //<----NEW
////BUFFER CONTROLS////
~label_LoCut = StaticText(w, Rect(693, 226, 48, 20) )//<---
.string_("LoCut-Hz")
.font_(Font("Monaco", 10) )
.align_(\left);
~numBox_inputLoCut = NumberBox(w, Rect(680, 216, 32, 14))//<---
.value_(~loCutVal_in)
.clipLo_(10) //smallest possible length of buffer (in seconds)
.clipHi_(20000) //longest possible length of buffer (in seconds)
.font_(Font("Monaco", 8) )
.decimals_(2)
.action_( {
arg obj;
~loCutVal_in = obj.value.round(0.01);
~loCutBus_in.set(~loCutVal_in);
//~loCutBus_in.setSynchronous([~loCutVal_in]); //??????? for synchronous control? is this better?
("***LoCutFreq_in=" ++ ~loCutVal_in ++ "Hz").postln;
} );
~numBox_outputLoCut = NumberBox(w, Rect(724, 216, 32, 14))//<---
.value_(~loCutVal_out)
.clipLo_(10) //smallest possible length of buffer (in seconds)
.clipHi_(20000) //longest possible length of buffer (in seconds)
.font_(Font("Monaco", 8) )
.decimals_(2)
.action_( {
arg obj;
~loCutVal_out = obj.value.round(0.01);
~loCutBus_out.set(~loCutVal_out);
//~loCutBus_out.setSynchronous([~loCutVal_out]); //??????? for synchronous control? is this better?
("***LoCutFreq_out=" ++ ~loCutVal_out ++ "Hz").postln;
} );
~labelBufSize = StaticText(w, Rect(568, 380, 200, 20) )
.string_("Buf(sec)")
.font_(Font("Monaco", 12) )
.align_(\left);
~numBoxBuf = NumberBox(w, Rect(490, 377, 75, 25))
.value_(~bufferSize)
.clipLo_(10) //smallest possible length of buffer (in seconds)
.clipHi_(120) //longest possible length of buffer (in seconds)
.font_(Font("Monaco", 14) )
.decimals_(2)
.action_( {
arg obj;
~bufferSize = obj.value.round(0.01);
("***Buffer Length=" + ~bufferSize + "seconds.").postln;
} );
~buttonBuf = Button(w, Rect(400, 377, 85, 25)) //Activate / Deactivate audio buffer
.states_( [
["BUF_ACT", Color.black, Color.gray(0.8)] ,
["BUF_ACT", Color.white, Color(0.8,0.8, 0)]
] )
.value_(1)
.font_(Font("Monaco", 14) )
.action_( {
arg obj;
if (
obj.value == 1,
{//allocate(create) buffer w/ duration = bufferSize seconds
~buffer = Buffer.alloc(s, s.sampleRate * ~bufferSize, 1);
} , //else
{~buffer.close; ~buffer.free;} //free(erase) buffer
);
} );
~buttonRecOut = Button(w, Rect(16, 372, 45, 20) )
.states_( [
["RECOUT", Color.black, Color(0.95, 0, 0, 0.3)] ,
["RECOUT", Color.white, Color(0.95, 0, 0)]
] )
.font_(Font("Monaco", 11) )
.action_( {
arg obj;
if (
obj.value == 1,
{//BEGIN RECORDING / WRITING MAIN AUDIO OUTPUT TO FILE
~bufferMainOutWrite = Buffer.alloc(s, 65536, 1); //allocate a disk i/o buffer (min rec frame size is 65536)
~bufferMainOutWrite.write((~fileAudio_writeOut_lastPath++~fileAudio_writeOut_nameNum++".aiff").standardizePath, "aiff", "int24", 0, 0, true); // create an output file for this buffer, leaving it "open" (not recording yet, just created file w/ format header)
~write2Disk = Synth.tail(nil, \write2Disk, [\buf, ~bufferMainOutWrite, \inBus, 0] ); //record audio sent to bus 0 to buffer writing to audio file
} ,
{//STOP RECORDING / WRITING MAIN AUDIO OUTPUT TO FILE
~write2Disk.free; //stop recording to disk
~bufferMainOutWrite.close; //close the buffer to finish writing the sound file (won't be readable otherwise)
~bufferMainOutWrite.free; //free buffer
~fileAudio_writeOut_nameNum = ~fileAudio_writeOut_nameNum + 1; //increment file name suffix in prep for next rec file
} );
} );
/*
~labelPlayFile = StaticText(w, Rect(130, 373, 135, 20) ) //<------NEW
.string_("FILENAMEFILENAME...")
.font_(Font("Monaco", 12) )
.align_(\left);
*/
~buttonPlayFile = Button(w, Rect(62, 372, 65, 20) ) //<------TODO!!!!
.states_( [
["PLAY FILE", Color.black, Color(0.0, 0.5, 0.5, 0.3)] ,
["PLAY FILE", Color.white, Color(0.0, 0.5, 0.5)]
] )
.font_(Font("Monaco", 11) )
.action_( {
arg obj;
if (
obj.value == 1,
{//BEGIN PLAYING AUDIO FILE
} ,
{//STOP RECORDING / WRITING AUDIO INPUT TO FILE
} );
} );
~buttonRecIn = Button(w, Rect(16, 352, 45, 20) ) //<------NEW
.states_( [
["RECIN", Color.black, Color(0.0, 0.5, 0, 0.3)] ,
["RECIN", Color.white, Color(0.0, 0.5, 0)]
] )
.font_(Font("Monaco", 11) )
.action_( {
arg obj;
if (
obj.value == 1,
{//BEGIN RECORDING / WRITING AUDIO INPUT TO FILE
~bufferInWrite = Buffer.alloc(s, 65536, 1); //allocate a disk i/o buffer (min rec frame size is 65536)
~bufferInWrite.write((~fileAudio_writeIn_lastPath++~fileAudio_writeIn_nameNum++".aiff").standardizePath, "aiff", "int24", 0, 0, true); // create an output file for this buffer, leaving it "open" (not recording yet, just created file w/ format header)
~writeIn2Disk = Synth.tail(nil, \write2Disk, [\buf, ~bufferInWrite, \inBus, ~inputSendBus] ); //record audio sent to first input channel bus to buffer, and write an audio file to hard disk
} ,
{//STOP RECORDING / WRITING AUDIO INPUT TO FILE
~writeIn2Disk.free; //stop recording to disk
~bufferInWrite.close; //close the buffer to finish writing the sound file (won't be readable otherwise)
~bufferInWrite.free;
~fileAudio_writeIn_nameNum = ~fileAudio_writeIn_nameNum + 1; //increment file name suffix in prep for next rec file
} );
} );
~numBoxDel = NumberBox(w, Rect(610, 349, 75, 25)) //WORKS but a little buggy....
.value_(~delayTime)
.clipLo_(0)
.clipHi_(~bufferSize - 0.01)
.font_(Font("Monaco", 14) )
.decimals_(2)
.scroll_step_(0.01)
.step_(0.01)
.action_( {
arg obj;
var lastPlay2RecOffset;
~delayTime = obj.value.round(0.01);
//~delayTime.postln;
//~sliderDelay.value = obj.value.linlin(0, ~bufferSize - 0.01, 0, 1); //ideally do this only when the numBox is being manipulated directly, otherwise it's redundantly updating value of slider...OBSOLESCED in 1.82
~playHeadOffsetRoutine.reset;
AppClock.play(~playHeadOffsetRoutine);
/* ~phaseBusMonRec.get( { //<----works but BUGGY small delay values don't seem to be accurate...
//calculate the offset of the playhead from the rechead
arg val;
~play2recOffset = val - ((~delayTime * s.sampleRate).round(1));
lastPlay2RecOffset = val - ((~delayTime * s.sampleRate).round(1));
//if (~play2recOffset < 0,
if (lastPlay2RecOffset < 0,
{//~lastPlayPhasePos = (~buffer.numFrames - 1) + ~play2recOffset;
~lastPlayPhasePos = (~buffer.numFrames - 1) + lastPlay2RecOffset;
} ,
{//~lastPlayPhasePos = ~play2recOffset;
~lastPlayPhasePos = lastPlay2RecOffset;
}
);
} );
if (~buttonPlay.value == 1, {~playPhase.set(\resetPos, ~lastPlayPhasePos, \trig, 1); } ); */
} );
~labelDelTime = StaticText(w, Rect(688, 352, 78, 20) )
.string_("Offset(sec)")
.font_(Font("Monaco", 12) )
.align_(\left);
/*~sliderDelay = Slider(w, Rect(489, 332, 180, 15))
.background_(Color(0.85, 0.85, 0.0))
.value_(~delayTime.linlin(0, ~bufferSize - 0.01, 0, 1))
.action_( { //<----BUGGY....?????
arg obj;
var pos, playPosFrame;
pos = obj.value.linlin(0, 1, 0, ~bufferSize - 0.01).round(0.01);
//~numBoxDel.value_(pos); //update numBoxPitch value
~numBoxDel.valueAction_(pos); //so we don't have to duplicate calc code from numBoxDel here
} ); */
~buttonDel = Button(w, Rect(550, 349, 55, 25)) //Delay Offset Sync button --- WORKS but a little buggy....
.states_( [
["SYNC", Color.black, Color(0.7, 0.7, 0, 0.3)] ,
["SYNC", Color.white, Color(0.8, 0.8, 0)]
] )
.font_(Font("Monaco", 18) )
.action_( {
arg obj;
if (
obj.value == 1, // when sync button enabled
{
~fixPlayRecOffset = true; //IS THIS BETTER THAN POLLING BUTTON.VALUE?????
~playHeadOffsetRoutine.reset;
AppClock.play(~playHeadOffsetRoutine);
/*
//snap playhead to position based on delay offset from rechead<------
~phaseBusMonRec.get( { //<----this block doesn't function properly when uncommented, needs to be in a routine?????
//calculate the offset of the playhead from the rechead
arg val;
~play2recOffset = val - ((~delayTime * s.sampleRate).round(1));
if (~play2recOffset < 0,
{~lastPlayPhasePos = (~buffer.numFrames - 1) + ~play2recOffset;
//lastPlay2RecOffset = ~lastPlayPhasePos;
} ,
{~lastPlayPhasePos = ~play2recOffset;
//lastPlay2RecOffset = ~play2recOffset;
}
);
} );
if (~buttonPlay.value == 1, {~playPhase.set(\resetPos, ~lastPlayPhasePos, \trig, 1); } );
*/
},
{ //when button disabled
~fixPlayRecOffset = false;
~playHeadOffsetRoutine.stop;
}
);
} )
.value_(0);
/////ROUTINES/////
~soundRoutine_autoRec = Routine.new( { //<---TODO!!!!!!, model after autoPlay below until machine listening functionality is implemented
if (~recSound_input == true,
{
} ,
{
}
);
} );
~soundRoutine_autoPlay = Routine.new( {
if (~playSound == true,
{ //if already playing sound file, we can assume it's completed by the time this routine has stopped yielding based on commands when ~playSound == false (see below code in 'else' of this conditional)...
var time2yield, interpSynth;
interpSynth = Synth(\LinInterp_num, [\startVal, 0.0, \stopVal, 1.0, \duration, 0.2, \out, ~inputStreamLevelBus]); //turn inStreamLevel back to 1.0 in 0.2 sec (++++\startVal should probs = variable storing current value of inputStreamLevel++++)
~sliderInStreamLevel.value = 1; //update GUI
~numBoxInStreamLevel.value = 1; //update GUI
0.2.yield; //<----is this necessary????
~playSound = false;
~buttonPlayFile.value = 0; //update GUI button
~playSoundBuf.close; //<----IS THIS NECESSARY IF GOING TO REASSIGN LATER, SHOULD I ONLY DO THIS DURING FINAL CLEANUP????
~playSoundBuf.free; //<----IS THIS NECESSARY HERE????
~playSoundBuf = Buffer.alloc(s, 65536, 1); //<----IS THIS NECESSARY HERE????
time2yield = rrand(12, 35); //<-----TIME RANGE - TRIGGER RATE (IN SEC).....
("---time2nextSoundPlay=" ++ time2yield ++ "sec").postln;
time2yield.yieldAndReset;
},
{//if not playing a soundFile, ~playSound == false
if (~recSound_input == false,
{
if (~fileAudio_writeIn_nameNum >= ~minNumFilesB4Playback, //if min # of files have been written
{
//PLAYBACK AUDIO FILE FROM DISK
var readDiskSynth, interpSynth, readFileFunc, randFilePick, duration;
~playSound = true; //set flag
randFilePick = rrand(0, (~fileAudio_writeIn_nameNum - 1)); //pick a random file to play (needs to be "current nameNum counter val - 1" b/c current counter value doesn't have a file associated w/ it yet due to counter incrementing after a new file has been written...)
("PLAYING BACK FILE:" + (~fileAudio_writeIn_lastPath++randFilePick++".aiff").standardizePath).postln;
~buttonPlayFile.value = 1; //update GUI
readDiskSynth = Synth.basicNew(\readDisk);
readFileFunc = { arg buf;
var fileDir, soundFile;
fileDir = (~fileAudio_writeIn_lastPath++randFilePick++".aiff").standardizePath;
soundFile = SoundFile.new;
soundFile.openRead(fileDir);
duration = soundFile.numFrames/s.sampleRate;
//duration = soundFile.duration;
//("soundFileDur=" + duration).postln;
soundFile.close;
readDiskSynth.addToHeadMsg(nil, [\buf, buf, \sampleDur, duration, \amp, ~fileOutputLevelBus.asMap, \out, ~outMainBus]) //<---now w/ amp control
};
interpSynth = Synth(\LinInterp_num, [\startVal, 1.0, \stopVal, 0.0, \duration, 0.2, \out, ~inputStreamLevelBus]); //silence input stream in 0.2 sec (***startVal should probs = variable storing current value of inputStreamLevel***
~sliderInStreamLevel.value = 0; //update GUI
~numBoxInStreamLevel.value = 0; //update GUI
0.2.yield; //<---routine fails w/out this sometimes, is there a better way to do this w/out adding latency?
~playSoundBuf = Buffer.cueSoundFile(s, (~fileAudio_writeIn_lastPath++randFilePick++".aiff").standardizePath, 0, 1, completionMessage: readFileFunc); //PLAY SOUND FILE from disk
(duration + 0.2).yieldAndReset; //<-------might not be necessary to add 0.2 sec, experiment
},
{15.yieldAndReset;} //<------------ wait if not enough files have been written yet
);
}, //else if (~recSoundInput == true)
{5.yieldAndReset;}
);
}
);
} );
~playHeadOffsetRoutine = Routine.new( {
~phaseBusMonRec.get( {
arg val;
~play2recOffset = val - ((~delayTime * s.sampleRate).round(1)); //calculate the offset of the playhead from the rechead
if (~play2recOffset < 0,
{~lastPlayPhasePos = (~buffer.numFrames - 1) + ~play2recOffset;} ,
{~lastPlayPhasePos = ~play2recOffset;}
);
} );
0.1.yield; //<--------------IS THERE ANY OTHER WAY???????????
if (~buttonPlay.value == 1, {~playPhase.set(\resetPos, ~lastPlayPhasePos, \trig, 1); } );
nil;
} );
~updateGUI_rate = Routine.new ( {
~rateBus.get( {
arg val;
var thisVal = val.abs; //in case "Reverse" enabled and rate is negative... <-----
AppClock.sched(0.0, { //this is necessary for some reason...
//"pitchBusVal= ".post; val.ratiomidi.round(0.01).postln;
//~sliderRate.value_(val.ratiomidi.linlin(-48, 48, 0, 1) );
~sliderRate.value_(thisVal.ratiomidi.linlin(-48, 48, 0, 1) );
//~numBoxRate.value_(val.ratiomidi.round(0.01));
~numBoxRate.value_(thisVal.ratiomidi.round(0.01));
nil;
} );
} );
0.1.yieldAndReset;
} );
~updateGUI_freq = Routine.new ( {
~pitchBus.get( {
arg val;
AppClock.sched(0.0, { //this is necessary for some reason...???????
//"pitchBusVal= ".post; val.ratiomidi.round(0.01).postln;
~sliderPitch.value_(val.ratiomidi.linlin(-48, 24, 0, 1) );
~numBoxPitch.value_(val.ratiomidi.round(0.01));
nil;
} );
} );
0.1.yieldAndReset;
} );
~updateGUI_outMainLevel = Routine.new ( {
~outMainLevelBus.get( {
arg val;
AppClock.sched(0.0, { //this is necessary for some reason...??????
~sliderOutputLevel.value_(val);
~numBoxOutputLevel.value_(val.round(0.01));
nil;
} );
} );
0.1.yieldAndReset;
} );
~updateGUI_pitchShiftMix = Routine.new ( {
~pitchShiftMixValBus.get( {
arg val;
AppClock.sched(0.0, { //this is necessary for some reason...??????
~sliderPitchShiftMix.value_(val);
~numBoxPitchMix.value_((val * 100).round(1));
nil;
} );
} );
0.1.yieldAndReset;
} );
~randomRoutine_freq = Routine.new ( {
//Automatically randomize pitch w/out time change (granular pitch shift)
var time2nextRandomize, randNum4transp, newPitch, pitchCase, pitchInterp, interpTime;
~pitchBus.get( {
arg val;
//AppClock.sched(0.0, {
~pitchShiftValPrev_freq = val.ratiomidi;
//("-*-prevFreq=" + ~pitchShiftValPrev_freq).postln;
//nil;
//} );
} );
0.1.yield; //<<<<<works, but not sure if ideal way...???
randNum4transp = rrand(1.0, 10.0); //based on random # from 1-10, determine type of pitch transposition
pitchCase = case
{randNum4transp <= 5} { //50% chance of raising/lowering pitch randomly
var thisRandNum = rrand(1, 10);
if (thisRandNum <= 5, // 50/50 change pitch is raised or lowered
{newPitch = rrand(-24.0, -0.2).round(0.01);},
{newPitch = rrand(0.2, 24).round(0.01);} );
}
{randNum4transp > 5 && randNum4transp <= 8.5} { //35% chance pitch change in response to current rate
newPitch = ~pitchShiftValTarget_rate * -1;
}
{randNum4transp > 8.5} { //15% chance of no pitch change
newPitch = ~pitchShiftValPrev_freq;
};
~pitchShiftValTarget_freq = newPitch; //set target pitch to shift to
//(" | targetPitch_freq=" + ~pitchShiftValTarget_freq).postln;
if (newPitch != ~pitchShiftValPrev_freq, { //if newPitch isn't the same as the last...
var thisDangoRandomNum;
interpTime = rrand(0.25, 6.0); //===INTERP TIME===
//("-*-freq_interpTime=" + interpTime).postln;
pitchInterp = Synth(\LinInterp_pitch, [\out, ~pitchBus, \startVal, ~pitchShiftValPrev_freq, \stopVal, ~pitchShiftValTarget_freq, \duration, interpTime] );
~pitchInterp_freq = true;
//("*****pitchInterp=" + ~pitchInterp_rate).postln;
~updateGUI_freq.reset;
AppClock.play(~updateGUI_freq);
(interpTime + 0.1).yield; //<----IS IT ALWAYS NECESSARY TO ADD 0.1 to accommodate Synth interp? ?????????????????
//1.3.yield; //keep or no!??? <-----
~pitchInterp_freq = false;
//("*****pitchInterp=" + ~pitchInterp_rate).postln;
~updateGUI_freq.stop;
//var thisDangoRandomNum = rrand(1, 10);
thisDangoRandomNum = rrand(1.0, 10.0);
if (thisDangoRandomNum <= 4.5, { //45% chance time2next pitch change is SHORT
time2nextRandomize = rrand(0.3, 4.0).round(0.1); //if newPitch != the last pitch
}, { //55% chance time2next pitch change is LONG
time2nextRandomize = rrand(4, 17);
} );
} , { //ELSE
time2nextRandomize = rrand(4, 10); //if newPitch == last pitch
} );
~time2NextRandom_freq = time2nextRandomize; //for populating GUI
time2nextRandomize.yieldAndReset;
} );
~randomRoutine_outputLevel = Routine.new ( {
var time2nextRandomize, randNum, interpLevel, interpTime;
//("***OUTPUTlevl_randomRoutine***").postln;
~outMainLevelBus.get( { //////method derived from ~randomRoutine_rate and freq....
arg val;
~outMainLevVal_prev = val;
//("--OutputLvlRtn: CURRENTLVL =" + val).postln;
} );
0.1.yield; //<<<<<works, but not sure if ideal way...
if (~outMainLevVal_prev < 1.0, { //if outMainLevel is 0 or less than 1, SET LVL BACK TO 1
//("--CASE1-SET LVL TO 1: outLevelPrev=" + ~outMainLevVal_prev).postln;
randNum = rrand(1, 10);
//("randNum1=" + randNum + " | ").post;
if (randNum <= 4, //PICK INTERPTIME BASED ON RAND NUM
{interpTime = rrand(0.25, 0.75); /* ("interpTime=" + interpTime).postln; */ },
{interpTime = rrand(3.25, 6.0); /* ("interpTime=" + interpTime).postln; */ } );
interpLevel = Synth(\LinInterp_num, [\out, ~outMainLevelBus, \startVal, ~outMainLevVal_prev, \stopVal, 1.0, \duration, interpTime] );
~outMainLevInterp = true;
~updateGUI_outMainLevel.reset;
AppClock.play(~updateGUI_outMainLevel);
(interpTime + 0.1).yield; //<----IS IT ALWAYS NECESSARY TO ADD 0.1 to accommodate Synth interp?
~outMainLevInterp = false;
~updateGUI_outMainLevel.stop;
randNum = rrand(1, 10);
//("randNum2=" + randNum + " | ").post;
//("---outLevel-randNum=" + randNum).postln;
if (randNum >= 8,
{time2nextRandomize = rrand(8, 20); //80% of time, long time2nextRand
//("time2Next=" + time2nextRandomize).postln;
} ,
{time2nextRandomize = rrand(0.25, 3).round(0.01); //20% of time short time2nextRand
//("time2Next=" + time2nextRandomize).postln;
}
);
//("---outLevel-randomTime=" + time2nextRandomize).postln;
//time2nextRandomize.yieldAndReset;
}, { //else if val >= 1
//("--CASE2: outLevelprev=" + ~outMainLevVal_prev).postln;
randNum = rrand(1.0, 10.0);
//("randNum1=" + randNum + " | ").post;
//("---outLevel-randNum=" + randNum).postln;
if (randNum <= 8.8, { //88% of time keep level at 1
//~outMainLevelBus.set(1);
//~sliderOutputLevel.value_(1);
time2nextRandomize = rrand(12, 18);
//("--NO LEVEL CHANGE...time2next=" + time2nextRandomize).postln;
},
{ //12% of time set level to 0
interpTime = rrand(0.1, 0.35).round(0.01);
//("--SET LVL to 0...interpTime=" + interpTime).postln;
interpLevel = Synth(\LinInterp_num, [\out, ~outMainLevelBus, \startVal, ~outMainLevVal_prev, \stopVal, 0.0, \duration, interpTime] );
~outMainLevInterp = true;
~updateGUI_outMainLevel.reset;
AppClock.play(~updateGUI_outMainLevel);
(interpTime + 0.1).yield; //<----IS IT ALWAYS NECESSARY TO ADD 0.1 to accommodate Synth interp?
~outMainLevInterp = false;
~updateGUI_outMainLevel.stop;
/* //ORIG randomization to pick time2nextRandomize
randNum = rrand(1, 10);
if (randNum <= 4, {
time2nextRandomize = rrand(3.0, 5.0).round(0.01);
}, {
time2nextRandomize = rrand(5.0, 10.0).round(0.01);
} );
*/
time2nextRandomize = rrand(2.5, 4.0).round(0.01);
//("--SET LVL TO 0 | time2nextRand=" + time2nextRandomize).postln;
} );
//("---outLevel-randomTime=" + time2nextRandomize).postln;
//time2nextRandomize.yieldAndReset;
} );
//("---outLevel-randomTime=" + time2nextRandomize).postln;
time2nextRandomize.yieldAndReset;
} );
~randomRoutine_reverse = Routine.new ( {
var time2nextRandomize, thisRandomNum;
thisRandomNum = rrand(1.0, 10.0);
//("randRoutine: randNum=" + thisRandomNum).postln;
if (~buttonRev.value == 0, { //if REVERSE disabled
if (thisRandomNum <= 3.2, { //32% chance REVERSE enabled
~buttonRev.valueAction_(1);
//~revRateBusMon.set(-1); // <--DO THIS instead of valueAction !!!!!!!!!!
//~buttonRev.value_(1); // <--DO THIS instead of valueAction !!!!!!!!!!!!
thisRandomNum = rrand(1, 10);
//("***thisRandNum-reroll" + thisRandomNum).postln;
if (thisRandomNum <= 8,
{time2nextRandomize = rrand(3.5, 6.0);},
{time2nextRandomize = rrand(6.0, 10.0);} );
//("time2NextRand=" + time2nextRandomize).postln;
time2nextRandomize.yieldAndReset;
}, { //71% chance REVERSE remains disabled
time2nextRandomize = rrand(9, 20);
//("time2NextRand=" + time2nextRandomize).postln;
time2nextRandomize.yieldAndReset;
} );
}, { //if REVERSE enabled
if (thisRandomNum <= 9, {
~buttonRev.valueAction_(0); //90% chance REVERSE disabled
//~revRateBusMon.set(1); // <--DO THIS instead of valueAction !!!!!!!!!!
//~buttonRev.value_(0); // <--DO THIS instead of valueAction !!!!!!!!!!!!
time2nextRandomize = rrand(9, 20);
//("time2NextRand=" + time2nextRandomize).postln;
time2nextRandomize.yieldAndReset;
}, {
time2nextRandomize = rrand(3.0, 5.0); //20% chance REVERSE remains enabled
//("time2NextRand=" + time2nextRandomize).postln;
time2nextRandomize.yieldAndReset;
} );
} );
} );
/*
~randomRoutine_pitchShiftMix = Routine.new ( {
var time2nextRandomize, mixCase; /*, currentTime, newMixVal, interpTime*/
~pitchShiftMixValBus.get( {
arg val;
~pitchShiftMix_prev = val;
} );
//currentTime = Date.localtime;
//("-->pShftMixCurntTime=" + currentTime).postln;
0.1.yield;
//simple chance based method-------
if (~pitchShiftMix_prev == 0, {
var thisRandomNum = rrand(1, 10);
mixCase = case
{thisRandomNum <= 7} {
~sliderPitchShiftMix.valueAction_(1); //maybe not best way in long run, but convenient for now...
//~pitchShiftMixValBus.set(1);
//~numBoxPitchMix.value_(100);
}
{thisRandomNum >= 8 && thisRandomNum <= 9} {
~sliderPitchShiftMix.valueAction_(0.5);
}
{thisRandomNum >= 10} {
~sliderPitchShiftMix.valueAction_(0);
};
} , { //else if pitchShiftMix != 0
var thisRandomNum = rrand(1, 10);
mixCase = case
{thisRandomNum <= 6} {
~sliderPitchShiftMix.valueAction_(1); //maybe not best way in long run, but convenient for now...
//~pitchShiftMixValBus.set(1);
//~numBoxPitchMix.value_(100);
}
{thisRandomNum >= 7 && thisRandomNum <= 8} {
~sliderPitchShiftMix.valueAction_(0.5);
}
{thisRandomNum >= 9} {
~sliderPitchShiftMix.valueAction_(0);
};
} );
time2nextRandomize = rrand(5, 20);
~time2NextRandom_pitchShiftMix = time2nextRandomize;
time2nextRandomize.yieldAndReset;
//------more complicated chance and time based method-------
//currentTime = Date.localtime;
//~pitchShiftMix_prevChangeTime = currentTime.rawSeconds;
} ); */
~randomRoutine_pitchShiftMix = Routine.new ( {
var time2nextRandomize, randNum, mixCase, interpMix, interpTime;
~pitchShiftMixValBus.get( {
arg val;
~pitchShiftMix_prev = val;
} );
//!!!!!CONSIDER ALSO GETTING CURRENT pitchShift value....if == 0 make mixVal = 0 !!!!!!!
0.1.yield; //<<<<<works, but not sure if ideal way...
if (~pitchShiftMix_prev == 0, { //<-----CONSIDER CHANGING THIS TO CASE INSTEAD BASED ON PRECISE CURRENT VALUE OF PITCH SHIFT MIX TO AVOID NEEDLESS GUI INTERPOLATION ROUTINES-------
randNum = rrand(1.0, 10.0);
mixCase = case
{randNum <= 4} { //set mix to 100%
interpTime = rrand(0.25, 5.0); //("interpTime=" + interpTime).postln;
interpMix = Synth(\LinInterp_num, [\out, ~pitchShiftMixValBus, \startVal, ~pitchShiftMix_prev, \stopVal, 1.0, \duration, interpTime] );
~pitchShiftMix_interp = true;
~updateGUI_pitchShiftMix.reset;
AppClock.play(~updateGUI_pitchShiftMix);
(interpTime + 0.1).yield;
~pitchShiftMix_interp = false;
~updateGUI_pitchShiftMix.stop;
}
{randNum > 4 && randNum <= 7} { //set mix to 50%