-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_1_Init_BuffersSynths_132.scd
15722 lines (12496 loc) · 753 KB
/
_1_Init_BuffersSynths_132.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
(
~loadServer = { | server, name, serverNb, port, serverFX, nameFX, portFX |
var serverFXV, nameFXV, portFXV;
if ( serverFX.isNil or: { ~viaJACK == 0 }, { ~serverFX = 0; serverFXV = server; nameFXV = name; portFXV = port; }, { ~serverFX = 1; serverFXV = serverFX; nameFXV = nameFX; portFXV = portFX; } );
( // ServerOptions
currentEnvironment[server] = Server(name, NetAddr("127.0.0.1", port));
// Server.default = s = Server.local;
if (currentEnvironment[server] == ~server1 and: {~mainServer1Window == 0}, {Server.default = currentEnvironment[server]; } );
~serverOptions = currentEnvironment[server].options;
if (Server.program.split($/).last == "supernova", {
~serverOptions.threads = ~supernovaThreads; ~serverOptions.useSystemClock = ~scClock /*false*/ /*default = sample clock */;
});
if (~viaJACK == 1, { ~serverOptions.device = "JackRouter";
// "SC_JACK_DEFAULT_INPUTS".setenv("system");
// "SC_JACK_DEFAULT_OUTPUTS".setenv("system");
} ); // ROUTING JACK
// s.options.device = "JackRouter";
// Quel Buffer size pour Jack choisir ? // 128 -> apparemment 512 necessaire pour éviter les lates ???
/*
// connect first to input channels with system
"SC_JACK_DEFAULT_INPUTS".setenv("system:capture_1,system:capture_2");
// connect all output channels with system
"SC_JACK_DEFAULT_OUTPUTS".setenv("system");
// hook up jack ports to audio channels
"SC_JACK_DEFAULT_INPUTS".setenv("system");
"SC_JACK_DEFAULT_OUTPUTS".setenv("system");
*/
// Linux Server Options
/*
s.options.sampleRate_(48000);
s.options.numAudioBusChannels_(2.pow(11));
s.options.numOutputBusChannels_(30);
s.options.numInputBusChannels_(2);
s.options.numBuffers_(2048);
s.options.memSize_(2.pow(21));
s.options.numWireBufs_(2.pow(16));
*/
if (~setSampleRate == true, {~serverOptions.sampleRate_(~sampleRate)} ); // set the sampleRate
~serverOptions.pingsBeforeConsideredDead = 350;
// /*s.aliveThreadPeriod = 0.01;*/ s.options.pingsBeforeConsideredDead = 350; // Init des requêtes CPU et coupure du server - mais pb lors du chargement des buffers avec aliveThreadPeriod
Platform.case(
\osx, { /*"OSX".postln*/
~serverOptions.numWireBufs_( 2.pow(13).asInteger /*8192*12000*/ /*2.pow(26)*/ ); // try 4096 / 2.pow(12) or 1024 / 2.pow(10) if still you generate errors // 2.pow(26) apparently makes crash the server whereas 8192*12000 was ok before...
~serverOptions.maxNodes_(8192*5000); // default 1024
~serverOptions.memSize_(2.pow(21)); // (2.pow(21)) - 2GB alloué - vraiment nécessaire ???????????????????????????
},
\linux, { /*"Linux".postln*/
~serverOptions.numWireBufs_(2.pow(10)); // numWireBufs to limit to 800 or 1024 if you generate errors like grey count ????
~serverOptions.maxNodes_(8192*5000); // default 1024
~serverOptions.memSize_(2.pow(21)); // (2.pow(21)) - 2GB alloué - vraiment nécessaire ???????????????????????????
},
\windows, { /*"Windows".postln*/
~serverOptions.numWireBufs_(2.pow(10)); // To check if it can be higher ?
~serverOptions.maxNodes_(8192*500); // default 1024 // To check if it can be higher ?
~serverOptions.memSize_(2.pow(20)); // To check if it can be higher ?
~serverOptions.inDevice_(~windowsInDevice);
~serverOptions.outDevice_(~windowsOutDevice);
}
);
// ~serverOptions.numWireBufs_(8192*12000); // 5000 auparavant - default 64 The maximum number of buffers that are allocated to interconnect unit generators -> This sets the limit of complexity of SynthDefs that can be loaded at runtime. This value will be automatically increased if a more complex def is loaded at startup, but it cannot be increased thereafter without rebooting.
/*
(8192*5000)
(8192*9000)
(2.pow(16))
(2.pow(27))
*/
// ~serverOptions.maxNodes_(8192*5000); // default 1024
// This memory is used to allocate synths and any memory that unit generators themselves allocate (for instance in the case of delay ugens which do not use buffers, such as CombN), and is separate from the memory used for buffers. Setting this too low is a common cause of 'exception in real time: alloc failed' errors.
// ~serverOptions.memSize_(2.pow(18)) // 262.144 // insuffisant et provoque des bursts du Server quand on change de presets ou buffers rapidement
// ~serverOptions.memSize_(65536 * 4); // 262.144 - necessary for Greyhole & JPVerb
// ~serverOptions.memSize_(2.pow(21)); // (2.pow(21)) - 2GB alloué - vraiment nécessaire ???????????????????????????
// (1024*1900) 1.945.600 // to get the nb of MB // -> 1.6GB // default 8192 kilobytes (8 M) of real time memory allocated to the server // crash à 2GB ?????????
// Yes - the memory is definitely grabbed on server boot and unavailable to other apps.
// it's reserverd in the sense that it would immediately be made accessible by the operating system in case of being needed.
// It refers to a block of memory that the server reserves in advance while booting -- the "real-time memory pool." It needs this because some UGens need to grab extra memory, and it is not safe to ask the OS for memory in a context (such as real-time DSP) where low latency is critical. The server has its own, faster allocator that uses this pre-reserved block.
~serverOptions.numBuffers_(8000); // default 1024
~serverOptions.maxSynthDefs_(10000); // to adapt according to the nb of synthdefs created
~serverOptions.hardwareBufferSize = ~hardwareBufferSize; // 512 par défaut sur la carte son -> to get less audio input latency -> impact CPU et sur enregistrement ???
// 64 apparemment suporte mieux les surcharges du server mais ne résoud pas la coupure de l'enregistrement à certains moments ??? XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
/*
1/441000*512 -> 0.0011609977324263
1/441000*64 -> 0.00014512471655329
*/
// ServerOptions ci-dessous à modifier pour optimiser le Server ???
~serverOptions.zeroConf = true; // A Boolean indication whether or not the server should publish its port using zero configuration networking, to facilitate network interaction. This is true by default; if you find unacceptable delays (beachballing) upon server boot, you can try setting this to false.
// intérêt ??? - apparemment pas d'effet
~serverOptions.memoryLocking = true; // A Boolean indicating whether the server should try to lock its memory into physical RAM. Default is false.
// ~serverOptions.numBuffers;
// ~serverOptions.numWireBufs;
// ~serverOptions.maxNodes;
// ~serverOptions.memSize/1024; // en MB
// ~serverOptions.blockSize; // The number of samples in one control period. The default is 64.
// ~serverOptions.hardwareBufferSize; // The preferred hardware buffer size. If non-nil the server app will attempt to set the hardware buffer frame size.
// SC_AudioDriver: sample rate = 44100.000000, driver's block size = 512 ??? for audio internal card & RME
// Config multicanale pour version stéréo si besoin des pistes séparées dans un séquenceur
~numChannels = ~numChannelsConfig.split($-)[0].asInteger;
currentEnvironment[server]/*[\server1]*/.recChannels = ~numChannels; // Pour que le nombre de pistes de l'enregistrement corresponde au nombre de canaux de sorties
if (~numChannelsConfig == "2-MultiChannelSequencer", {
~serverOptions.numOutputBusChannels = 16; ~numChannelsFX = 16
}, {
~serverOptions.numOutputBusChannels = ~numChannels; ~numChannelsFX = ~numChannels
});
// ~serverOptions.numOutputBusChannels = ~numChannels;
// ~serverOptions.numOutputBusChannels = 5
// ~serverOptions.numInputBusChannels;
// Particularité Salle Claude Champagne ou Dome 32 HP - Overwrite
// if (~numChannelsConfig == "22-8+Dome-8-4-2-Pair", {~serverOptions.numOutputBusChannels = 36; ~numChannelsFX = 14}); // 22 HP normaux, mais aussi HP en 33 / 34 / 35 / 36
case
{~numChannelsConfig == "4"}
{~serverOptions.numInputBusChannels = ~inputBusChannelsNb; ~serverOptions.numOutputBusChannels = ~numChannels; ~numChannelsFX = ~numChannels}
{~numChannelsConfig == "16-Dome-8-6-2-Clock"}
{~serverOptions.numInputBusChannels = ~inputBusChannelsNb; ~serverOptions.numOutputBusChannels = 18; ~numChannelsFX = 16} // 16 HP, mais aussi 2 Subs
{~numChannelsConfig == "16-Dome-8-6-2-Clock-CC"}
{~serverOptions.numInputBusChannels = ~inputBusChannelsNb; ~serverOptions.numOutputBusChannels = 20; ~numChannelsFX = 16} // 16 HP, mais aussi 4 Subs
{~numChannelsConfig == "22-8+Dome-8-4-2-Pair"}
{~serverOptions.numInputBusChannels = ~inputBusChannelsNb; ~serverOptions.numOutputBusChannels = 36; ~numChannelsFX = 14} // 22 HP, mais aussi Susbs en 33 / 34 / 35 / 36
{~numChannelsConfig == "16-UsineC-2Octo"}
{~serverOptions.numInputBusChannels = ~inputBusChannelsNb; ~serverOptions.numOutputBusChannels = 18; ~numChannelsFX = 16}
{~numChannelsConfig == "24-UsineC-3Octo"}
{~serverOptions.numInputBusChannels = ~inputBusChannelsNb; ~serverOptions.numOutputBusChannels = 27; ~numChannelsFX = 24}
{~numChannelsConfig == "32-Dome-12-10-8-2-Motu" or: { ~numChannelsConfig == "32-Dome-12-10-8-2" } } // 32 HP, mais aussi 2 Subs
{~serverOptions.numInputBusChannels = ~inputBusChannelsNb; ~serverOptions.numOutputBusChannels = 34; ~numChannelsFX = 32; // 32 HP, mais aussi Subs en 33 / 34
// Adaptation des FX quand nb de canaux supérieurs à 16 faute de CPU
~numChannelsFX2 = 16;
~outChannelsFXSpaceCuts = [(0,2..30), ((0,2..30)+1)];
// ~outChannelsFXSpaceCuts[0].collect { |i, id| i.postln; id.postln };
}
{~numChannelsConfig == "32-Dome-UQAM-11-11-9-1" } // 32 HP pas de sub
{~serverOptions.numInputBusChannels = ~inputBusChannelsNb; ~serverOptions.numOutputBusChannels = 32; ~numChannelsFX = 32; // 32 HP pas de sub
// Adaptation des FX quand nb de canaux supérieurs à 16 faute de CPU
~numChannelsFX2 = 16;
~outChannelsFXSpaceCuts = [(0,2..30), ((0,2..30)+1)];
// ~outChannelsFXSpaceCuts[0].collect { |i, id| i.postln; id.postln };
};
// Une fois que la distinction Performance ou multi-canale est faite, besoin de les regrouper pour l'utilisation ~numChannelsConfig pour la version stéréo
if (~numChannels == 2, { ~numChannelsConfig = "2"});
// numAudioBusChannels Par default 128 avant, mais maintenant 1024, donc plus bsesoin de le changer quand config de 64 HP
// if (~numChannels > 16, {~serverOptions.numAudioBusChannels = 40 * 6} ); // correspondant à ~fxMulChannel
// if (~numChannels > 32, {~serverOptions.numAudioBusChannels = 70 * 6} );
if (~serverFX == 1, {
currentEnvironment[serverFXV] = Server(nameFXV, NetAddr("127.0.0.1", portFXV));
~serverOptionsFX = currentEnvironment[serverFXV].options;
~serverOptionsFX.device = ~serverOptions.device;
if (~setSampleRate == true, {~serverOptionsFX.sampleRate_(~sampleRate)} );
~serverOptionsFX.pingsBeforeConsideredDead = ~serverOptions.pingsBeforeConsideredDead;
~serverOptionsFX.numWireBufs_(~serverOptions.numWireBufs);
~serverOptionsFX.maxNodes_(~serverOptions.maxNodes);
~serverOptionsFX.memSize_(~serverOptions.memSize);
~serverOptionsFX.numBuffers_(~serverOptions.numBuffers);
~serverOptionsFX.maxSynthDefs_(~serverOptions.maxSynthDefs);
~serverOptionsFX.hardwareBufferSize = ~serverOptions.hardwareBufferSize;
~serverOptionsFX.zeroConf = ~serverOptions.zeroConf;
~serverOptionsFX.memoryLocking = ~serverOptions.memoryLocking;
~serverOptionsFX.numOutputBusChannels = ~serverOptions.numOutputBusChannels;
~serverOptionsFX.numInputBusChannels = 40 * 6 /*~numChannels*/; // Important car dans les serveurs générateurs, il n'y en a que 2.
~serverOptions.numOutputBusChannels = 40 * 6;
});
VBAPSpeakerArray.maxNumSpeakers = ~numChannels;
// s.latency = 1.0; // pour réduire les late ???? - ServerTiming
// Chemin nécessaire pour charger les fichiers html de code qui s'affichent dans les TextViews de la GUI
// Mais pourquoi ~currentPath doit être indiqué auparavant et non pas dans le fichier de la GUI ???
~currentPath = thisProcess.nowExecutingPath; // pour charger les presets & les fichiers html de code qui s'affichent dans les TextViews de la GUI
/*
// Auparavant avant l'IDE, ce code marchait pour lancer un fichier
~home = Document.current.path.dirname ++ "/";
this.executeFile( ~home ++ "uc33e3.scd" );
// Désormais le code ci-dessous pour récupérer l'adresse
thisProcess.nowExecutingPath;
*/
);
// SynthDef Management
if (currentEnvironment[server] == ~server1, {
~synthDefsFolderS1 = Platform.userAppSupportDir ++ "/synthdefsL4L-" ++ ~numChannelsConfig ++"-S1";
// Création d'un dossier de synthé pour chaque type de config multi-canale
// Nécessité de rajouter les synthés dans synthdefsInit, par exemple pour jitlib ou autres - utiliser SynthDescLib.send(s); ?????????
if (PathName(~synthDefsFolderS1).isFolder == false, {~synthDefsFolderS1.mkdir; /*~synthDefsBuild = 1; ~synthDefsManagementChoose = 1*/ } );
if (PathName(~synthDefsFolderS1).files == [ ], {~synthDefsBuild = 1; ~synthDefsManagementChoose = 1} ); // Construction des synthés si dossier vide
},{
~synthDefsFolderS2 = Platform.userAppSupportDir ++ "/synthdefsL4L-" ++ ~numChannelsConfig ++"-S2";
if (PathName(~synthDefsFolderS2).isFolder == false, {~synthDefsFolderS2.mkdir; /*~synthDefsBuild = 1; ~synthDefsManagementChoose = 1*/ } );
if (PathName(~synthDefsFolderS2).files == [ ], {~synthDefsBuild = 1; ~synthDefsManagementChoose = 1} ); // Construction des synthés si dossier vide
});
// See SynthDesc helpfile
// Store the SynthDef along with metadata
// d.store(mdPlugin: TextArchiveMDPlugin);
// Pas vraiment nécessaire car obligé de récupérer les descriptions des synthés avec SynthDescLib.global.read
/*
~synthDefsManagementChoose = 0; // 0 -> add / 1 -> load --- utile seulement si ~synthDefsBuild = 1
*/
// ~synthDefsManagementList = ["add", "store((mdPlugin: TextArchiveMDPlugin));", "writeDefFile(\""++~synthDefsFolder++"\")"];
~synthDefsManagementList = ["add", "store", "store((mdPlugin: TextArchiveMDPlugin));"];
~synthDefsManagement = ~synthDefsManagementList[~synthDefsManagementChoose];
if (currentEnvironment[server] == ~server1, {SynthDef.synthDefDir = ~synthDefsFolderS1}, {SynthDef.synthDefDir = ~synthDefsFolderS2} );
/*
SynthDef.synthDefDir = "/Users/Xon/Library/Application Support/SuperCollider/synthdefsLiveForLife/"
SynthDef.synthDefDir
*/
// Look at Server helpfile
// all defs in this directory will be loaded when a local server boots
/*
"SC_SYNTHDEF_PATH".setenv("~/scwork/".standardizePath);
"SC_SYNTHDEF_PATH".setenv("/Users/Xon77/Library/Application Support/SuperCollider/synthdefsLiveForLife-5-Centre/".standardizePath);
"echo $SC_SYNTHDEF_PATH".unixCmd;
*/
if ( ~synthDefsBuild == 0, {"SC_SYNTHDEF_PATH".setenv(SynthDef.synthDefDir.standardizePath) });
SynthDescLib.global.addServer(currentEnvironment[server]); // n'a pas l'air d'être nécessaire ???
// SI, sinon les synthés du 2ème serveur ne sont pas chargés lors de la constuction des synthés et obligé de rebooter le server pour que les synthés soient lus
if (~serverFX == 1, { SynthDescLib.global.addServer(currentEnvironment[serverFXV]); }); // n'a pas l'air d'être nécessaire au chargement des synthés dans le 2ème serveur ??? voire ci-dessus
~windowHeight = Window.screenBounds.height/*.asInteger*/; // ~windowHeight = Window.availableBounds.height/*.asInteger*/;
~windowWidth = Window.screenBounds.width/*.asInteger*/;
if (Platform.architecture == \x86_64, {~windowTopMargin = 0; ~windowUpperMargin = 6}, {~windowTopMargin = 26; ~windowUpperMargin = 0});
currentEnvironment[server].waitForBoot(limit: 1000, onComplete:{
// currentEnvironment[server].sync; // Apparemment aide à faire cracher le serveur // 3.wait;
// { // à décommenter pour mesurer la rapidité d'affichage de la GUI et réorganistion des sons
// permet d'utiliser les Ndef bien que this.send(server, false) soit mis en commentaire dans SynthDescLib *initClass
// SynthDescLib.send(s); // plus nécessaire
// Problème Server failed to start lorsque le nb de SynthDefs à charger est > 3500 ou 4000 ?????????
// '_ServerShmInterface_connectSharedMem' failed.
// Augmentation de la limite à 1000 au lieu de 100 et rajout de s.initTree;
// s.initTree; // Apparemment ne provoque pas d'erreur ???
// sinon :
// FAILURE IN SERVER /s_new Node 1 not found
// FAILURE IN SERVER /n_set Node 1003 not found
if (currentEnvironment[server] == ~server1 and: {~mainServer1Window == 1}, {
~server1Window = currentEnvironment[server].makeWindow;
if (~serverFX == 1, {
~server1Window.window/*.alpha_(0.6)*/.bounds_(Rect.new(33,925,283,94)).alwaysOnTop_(true);
},{
// ~server2Window.window.bounds_(Rect.new(0,124,305,100)).alwaysOnTop_(true);
// ~server2Window = currentEnvironment[\server2].makeWindow;
~server1Window.window/*.alpha_(0.7)*/.bounds_(Rect.new(230, /*1080*/ /*(~windowHeight-1329)*/ 0, 286,94)).alwaysOnTop_(true);
});
});
if (currentEnvironment[server] == ~server2, {
~server2Window = currentEnvironment[server].makeWindow;
if (~serverFX == 1, {
~server2Window.window.alpha_(0.6).bounds_(Rect.new(33,925,283,94)).alwaysOnTop_(true);
},{
// ~server2Window.window.bounds_(Rect.new(0,124,305,100)).alwaysOnTop_(true);
// ~server2Window = currentEnvironment[\server2].makeWindow;
~server2Window.window.alpha_(0.7).bounds_(Rect.new(41, /*1080*/ (~windowHeight-120), 274,94)).alwaysOnTop_(true);
});
});
currentEnvironment[server].loadDirectory (Platform.userAppSupportDir ++ "/synthdefs", "loading Initial SynthDefs".postln); // Chargement des synthés initiaux
currentEnvironment[server].sync;
if (~serverFX == 1, {
currentEnvironment[serverFXV].waitForBoot(limit: 1000, onComplete:{
if (currentEnvironment[server] == ~server1, {
~server1FXWindow = currentEnvironment[serverFXV].makeWindow; ~server1FXWindow.window.alpha_(0.6).bounds_(Rect.new(33,1070,283,94)).alwaysOnTop_(true);
},{
~server2FXWindow = currentEnvironment[serverFXV].makeWindow; ~server2FXWindow.window.alpha_(0.6).bounds_(Rect.new(33,1000,283,94)).alwaysOnTop_(true);
~limiterNotification[serverNb] = 0; ~limiterFunction.(serverFXV, serverNb);
// Ligne au dessus necessaire car sinon la limiteur ne se lance pas dès la première fois sur le 2 ème serveur FX
// donc obligé de le redéclencher quand le 2ème serveur FX est vraiment en place
/**** ERROR: SynthDef Limiter not found
FAILURE IN SERVER /s_new SynthDef not found*/
});
currentEnvironment[serverFXV].loadDirectory (Platform.userAppSupportDir ++ "/synthdefs", "loading Initial SynthDefs".postln); // Chargement des synthés initiaux
currentEnvironment[serverFXV].sync;
});
3.wait; // si retiré génération d'une erreur dans les synthés FX -> ERROR: binary operator '/' failed.
});
// Chargement des buffers du Kernel ambisonique : binaural et stéréo - mis à la fin de la spatialisation car le numéro de VBAP.bufnum change sinon XXX
/*case
{~ambATKConfig == "binaural"}
{ ~binauralDecoder = ~binauralDecoder.interpret }
{~ambATKConfig == "stereo"}
{ ~stereoDecoder = FoaDecoderKernel.newUHJ };*/
// Temps pour libérer le synthé lorsqu'il franchit un seuil ou est égal à 0
~silenceTime = 0.1;
// Activate limiter - transféré dans la GUI après le s.volume
// prevents nan in audio & limiter in Bat lib
// StageLimiter.activate(numChannels: ~numChannels);
// StageLimiterCL.activate(numChannels: ~numChannels, level: 0.8, dur: 0.01); // XXXXXXXXXXXXXXX
// StageLimiter.deactivate;
/*
SynthDef(\SanitizeLimiter, { |level = 0.8|
var input = In.ar(0, ~numChannels);
ReplaceOut.ar(0, SanitizeLimit.ar(input, level)) ;
}).add;
Synth(\SanitizeLimiter, target: RootNode(Server.default), addAction: \addToTail);
*/
/*
SynthDef(\Limiter, { | limDrive = 1, ampLimit = 0.99, postAmp = 1, sigMax = 10 |
var input, bad, badTrig, sign, signLatch, sig, limitSig;
input = In.ar(0, /*2*/ ~numChannels);
bad = CheckBadValues.ar(input, 0, 0);
badTrig = (bad > 0) + (abs(input) > sigMax);
// hold last sign to avoid sudden sign changes
sign = input.sign;
signLatch = Select.ar(badTrig, [sign, Latch.ar(sign, badTrig)]);
sig = Select.ar(badTrig, [input, signLatch * sigMax]);
ReplaceOut.ar(0, LeakDC.ar(Limiter.ar(input * limDrive, ampLimit) * postAmp));
}).add;
*/
// Intérêt du SafetyNet vs limiter CL en termes d'efficacité d'explosion et de CPU ???
// Le limiter CL comprend : Select / CheckBadValues / Limiter / LeakDC / ReplaceOut + Out & NumChannels pour le mixage du Sub (à optimiser en fonction du Quark SafetyNet)
// SafetyNet comprend : ReplaceBadValues (Select / CheckBadValues + array) / ReplaceOut + .softclip ( d'autres synthés sont aussi dispos...)
/*
s.numChannels // ???
Safety(s).numChannels;
Safety(s).defaultDefName; Safety(s).synthDefs; Safety(s).synth
Safety(s).defName = \safeClip
Safety(s).defName = \safeLimit;
Safety(s).initSynthDefs(5);
Safety(s).enable; // remake list of default synthdefs for a given number of channels
Safety(s).synth.set(\limit, 0.5); // set limit lower
Safety.all;
*/
/*
// Safety ne marche pas bien si server par défault ~server1 : ajoute 1 synthé et ne les supprime pas peu importe la commande ???
Safety( s /*s*/ /*\localhost*/).enable;
Safety( s /*s*/ /*\localhost*/).disable;
Safety( ~server1 /*s*/ /*\localhost*/).disable; // Safety(s).enable; ou supprimer le quark - vient de façon automatique
*/
// Particularité Salle Claude Champagne et Dôme 32 HP - Overwrite POUR REASSIGNATION SUB
case
{ ~numChannelsConfig == "16-Dome-8-6-2-Clock" }
{
// Equivalent au StageLimiter, mais fait à la main
SynthDef(\Limiter, { | limDrive = 1, ampLimit = 0.99, postAmp = 1, mulSub = 0.8 |
var input = In.ar(0, /*2*/ ~numChannels);
input = Select.ar(CheckBadValues.ar(input, 0, 0), [input, DC.ar(0), DC.ar(0), input]); // Pour réduire l'impact CPU de 2%
// Check Bad Values -> repris de StageLimiter de Botuhan Bozkurt
input = LeakDC.ar(input, 0.995);
input = Limiter.ar(input * limDrive, ampLimit) * postAmp;
// input = BHiPass4.ar(input, 50); // quel est le meilleur Ugen (efficace en termes de CPU) qui filtre les infra-basses pour les petits HP ?????????
ReplaceOut.ar(0, input);
// Sub G 16 / D 17 - Assignation G / D sauf pour les HP 9 et 12 ou sorties 8 et 11, qui sont respectivement en Avant centre et en Arriere centre
/*Out.ar(16, LPF.ar(NumChannels.ar(input[0, 7, 13, 14, 8, 5, 6, 12, 11], 1) * mulSub), 80); // HP réels 1 / 8 / 14 / 15 / 9 // Ne marche que pour le 1er input
Out.ar(17, LPF.ar(NumChannels.ar(input[1, 2, 9, 15, 8, 3, 4, 10, 11], 1) * mulSub), 80); // HP réels 2 / 3 / 10 / 16 / 9 // Ne marche que pour le 1er input*/
Out.ar(16, LPF.ar(Mix.new([input[0], input[7], input[13], input[14], input[8], input[5], input[6], input[12], input[11]], 1) * mulSub), 80);
Out.ar(17, LPF.ar(Mix.new([input[1], input[2], input[9], input[15], input[8], input[3], input[4], input[10], input[11]], 1) * mulSub), 80);
}).add;
}
{ ~numChannelsConfig == "16-Dome-8-6-2-Clock-CC" }
{
// Equivalent au StageLimiter, mais fait à la main
SynthDef(\Limiter, { | limDrive = 1, ampLimit = 0.99, postAmp = 1, mulSub = 0.8 |
var input = In.ar(0, /*2*/ ~numChannels);
input = Select.ar(CheckBadValues.ar(input, 0, 0), [input, DC.ar(0), DC.ar(0), input]); // Pour réduire l'impact CPU de 2%
// Check Bad Values -> repris de StageLimiter de Botuhan Bozkurt
input = LeakDC.ar(input, 0.995);
input = Limiter.ar(input * limDrive, ampLimit) * postAmp;
// input = BHiPass4.ar(input, 50); // quel est le meilleur Ugen (efficace en termes de CPU) qui filtre les infra-basses pour les petits HP ?????????
ReplaceOut.ar(0, input);
// Sub Av G 16 / D 17 / Ar G 18 / Ar D 19
// 1. Assignation à chaque sub au point cardinal des 3 HP les + proches
// 2. Attribution latérale pour les 2 HP au plafond 15 & 16 et avant/arrière pour HP 9 & 10
// 3. Attribution latérale pour les 4 lointains avant de chaque côté (latérales pas prises en compte)
/*Out.ar(16, LPF.ar(NumChannels.ar(input[0, 7, 13, 14, 8], 1) * mulSub), 80); // HP réels 1 / 8 / 14 / 15 / 9 // Ne marche que pour le 1er input
Out.ar(17, LPF.ar(NumChannels.ar(input[1, 2, 9, 15, 8], 1) * mulSub), 80); // HP réels 2 / 3 / 10 / 16 / 9 // Ne marche que pour le 1er input
Out.ar(18, LPF.ar(NumChannels.ar(input[5, 6, 12, 14, 11], 1) * mulSub), 80); // HP réels 6 / 7 / 13 / 15 / 12 // Ne marche que pour le 1er input
Out.ar(19, LPF.ar(NumChannels.ar(input[3, 4, 10, 15, 11], 1) * mulSub), 80); // HP réels 4 / 5 / 11 / 16 / 12 // Ne marche que pour le 1er input*/
Out.ar(16, LPF.ar(Mix.new([input[0], input[7], input[13], input[14], input[8]], 1) * mulSub), 80);
Out.ar(17, LPF.ar(Mix.new([input[1], input[2], input[9], input[15], input[8]], 1) * mulSub), 80);
Out.ar(18, LPF.ar(Mix.new([input[5], input[6], input[12], input[14], input[11]], 1) * mulSub), 80);
Out.ar(19, LPF.ar(Mix.new([input[3], input[4], input[10], input[15], input[11]], 1) * mulSub), 80);
}).add;
}
{ ~numChannelsConfig == "22-8+Dome-8-4-2-Pair" }
{
// Equivalent au StageLimiter, mais fait à la main
SynthDef(\Limiter, { | limDrive = 1, ampLimit = 0.99, postAmp = 1, mulSub = 0.8 |
var input = In.ar(0, /*2*/ ~numChannels);
input = Select.ar(CheckBadValues.ar(input, 0, 0), [input, DC.ar(0), DC.ar(0), input]); // Pour réduire l'impact CPU de 2%
// Check Bad Values -> repris de StageLimiter de Botuhan Bozkurt
input = LeakDC.ar(input, 0.995);
input = Limiter.ar(input * limDrive, ampLimit) * postAmp;
// input = BHiPass4.ar(input, 50); // quel est le meilleur Ugen (efficace en termes de CPU) qui filtre les infra-basses pour les petits HP ?????????
ReplaceOut.ar(0, input);
// Sub Av G 33 / D 34 / Ar G 35 / Ar D 36
// 1. Assignation à chaque sub au point cardinal des 3 HP les + proches
// 2. Attribution latérale pour les 2 HP au plafond 12 & 13
// 3. Attribution latérale pour les 4 lointains avant de chaque côté
/*Out.ar(32, NumChannels.ar(input[0, 2, 8, 12, 14, 16, 18, 20], 1) * mulSub);
Out.ar(33, NumChannels.ar(input[1, 3, 9, 13, 15, 17, 19, 21], 1) * mulSub);
Out.ar(34, NumChannels.ar(input[4, 6, 10, 12, 14, 16, 18, 20], 1) * mulSub);
Out.ar(35, NumChannels.ar(input[5, 7, 11, 13, 15, 17, 19, 21], 1) * mulSub);*/
Out.ar(32, LPF.ar(Mix.new([input[0], input[2], input[8], input[12], input[14], input[16], input[18], input[20]], 1) * mulSub), 80);
Out.ar(33, LPF.ar(Mix.new([input[1], input[3], input[9], input[13], input[15], input[17], input[19], input[21]], 1) * mulSub), 80);
Out.ar(34, LPF.ar(Mix.new([input[4], input[6], input[10], input[12], input[14], input[16], input[18], input[20]], 1) * mulSub), 80);
Out.ar(35, LPF.ar(Mix.new([input[5], input[7], input[11], input[13], input[15], input[17], input[19], input[21]], 1) * mulSub), 80);
}).add;
}
{ ~numChannelsConfig == "16-UsineC-2Octo" }
{
// Equivalent au StageLimiter, mais fait à la main
SynthDef(\Limiter, { | limDrive = 1, ampLimit = 0.99, postAmp = 1, mulSub = 0.8 |
var input = In.ar(0, /*2*/ ~numChannels);
input = Select.ar(CheckBadValues.ar(input, 0, 0), [input, DC.ar(0), DC.ar(0), input]); // Pour réduire l'impact CPU de 2%
// Check Bad Values -> repris de StageLimiter de Botuhan Bozkurt
input = LeakDC.ar(input, 0.995);
input = Limiter.ar(input * limDrive, ampLimit) * postAmp;
// input = BHiPass4.ar(input, 50); // quel est le meilleur Ugen (efficace en termes de CPU) qui filtre les infra-basses pour les petits HP ?????????
ReplaceOut.ar(0, input);
Out.ar(16, LPF.ar(Mix.new([input[0], input[1], input[2], input[3], input[4], input[5], input[6], input[7]], 1) * mulSub), 80);
Out.ar(17, LPF.ar(Mix.new([input[8], input[9], input[10], input[11], input[12], input[13], input[14], input[15]]) * mulSub), 80);
}).add;
}
{ ~numChannelsConfig == "24-UsineC-3Octo" }
{
// Equivalent au StageLimiter, mais fait à la main
SynthDef(\Limiter, { | limDrive = 1, ampLimit = 0.99, postAmp = 1, mulSub = 0.8, mulSub2 = 0.8 |
var input = In.ar(0, /*2*/ ~numChannels);
input = Select.ar(CheckBadValues.ar(input, 0, 0), [input, DC.ar(0), DC.ar(0), input]); // Pour réduire l'impact CPU de 2%
// Check Bad Values -> repris de StageLimiter de Botuhan Bozkurt
input = LeakDC.ar(input, 0.995);
input = Limiter.ar(input * limDrive, ampLimit) * postAmp;
// input = BHiPass4.ar(input, 50); // quel est le meilleur Ugen (efficace en termes de CPU) qui filtre les infra-basses pour les petits HP ?????????
ReplaceOut.ar(0, input);
Out.ar(24, LPF.ar(Mix.new([input[0], input[1], input[2], input[3], input[4], input[5], input[6], input[7]], 1) * mulSub), 80);
Out.ar(25, LPF.ar(Mix.new([input[8], input[13], input[14], input[15], input[16], input[21], input[22], input[23]]) * mulSub2), 80);
Out.ar(26, LPF.ar(Mix.new([input[9], input[10], input[11], input[12], input[17], input[18], input[19], input[20]]) * mulSub2), 80);
}).add;
}
{ ~numChannelsConfig == "32-Dome-12-10-8-2" }
{
// Equivalent au StageLimiter, mais fait à la main
SynthDef(\Limiter, { | limDrive = 1, ampLimit = 0.99, postAmp = 1, mulSub = 0.8 |
var input = In.ar(0, /*2*/ ~numChannels);
input = Select.ar(CheckBadValues.ar(input, 0, 0), [input, DC.ar(0), DC.ar(0), input]); // Pour réduire l'impact CPU de 2%
// Check Bad Values -> repris de StageLimiter de Botuhan Bozkurt
input = LeakDC.ar(input, 0.995);
input = Limiter.ar(input * limDrive, ampLimit) * postAmp;
// input = BHiPass4.ar(input, 50); // quel est le meilleur Ugen (efficace en termes de CPU) qui filtre les infra-basses pour les petits HP ?????????
ReplaceOut.ar(0, input);
// 1. Assignation Gauche Droite
/*Out.ar(32, NumChannels.ar(input[0, 11, 10, 9, 8, 7, 12, 21, 20, 19, 18, 22, 29, 28, 27, 30], 1, true) * mulSub); // Ne marche que pour le 1er input
Out.ar(33, NumChannels.ar(input[1, 2, 3, 4, 5, 6, 13, 14, 15, 16, 17, 23, 24, 25, 26, 31], 1, true) * mulSub);*/
/*Out.ar(32, Mix.new(input[0, 11, 10, 9, 8, 7, 12, 21, 20, 19, 18, 22, 29, 28, 27, 30]) * mulSub);
Out.ar(33, Mix.new(input[1, 2, 3, 4, 5, 6, 13, 14, 15, 16, 17, 23, 24, 25, 26, 31]) * mulSub);*/
Out.ar(32, LPF.ar(Mix.new([input[0], input[11], input[10], input[9], input[8], input[7], input[12], input[21], input[20], input[19], input[18], input[22], input[29], input[28], input[27], input[30]]) * mulSub), 80);
Out.ar(33, LPF.ar(Mix.new([input[1], input[2], input[3], input[4], input[5], input[6], input[13], input[14], input[15], input[16], input[17], input[23], input[24], input[25], input[26], input[31]]) * mulSub), 80);
}).add;
}
{ ~numChannelsConfig == "32-Dome-12-10-8-2-Motu" }
{
// Equivalent au StageLimiter, mais fait à la main
SynthDef(\Limiter, { | limDrive = 1, ampLimit = 0.99, postAmp = 1, mulSub = 0.8 |
var input = In.ar(0, /*2*/ ~numChannels);
input = Select.ar(CheckBadValues.ar(input, 0, 0), [input, DC.ar(0), DC.ar(0), input]); // Pour réduire l'impact CPU de 2%
// Check Bad Values -> repris de StageLimiter de Botuhan Bozkurt
input = LeakDC.ar(input, 0.995);
input = Limiter.ar(input * limDrive, ampLimit) * postAmp;
// input = BHiPass4.ar(input, 50); // quel est le meilleur Ugen (efficace en termes de CPU) qui filtre les infra-basses pour les petits HP ?????????
ReplaceOut.ar(0, input);
// 1. Assignation Gauche Droites
Out.ar(32, NumChannels.ar(input[10, 20, 24, 22, 29, 16, 5, 9, 19, 31, 30, 17, 6, 8, 18, 7], 1) * mulSub); // Ne marche que pour le 1er input
Out.ar(33, NumChannels.ar(input[11, 21, 25, 23, 28, 15, 4, 0, 12, 26, 27, 14, 3, 1, 13, 2], 1) * mulSub); // Ne marche que pour le 1er input
}).add;
}
{ ~numChannelsConfig != "22-8+Dome-8-4-2-Pair" or: {~numChannelsConfig != "32-Dome-12-10-8-2"} or: {~numChannelsConfig != "32-Dome-12-10-8-2-Motu"} or: {~numChannelsConfig != "16-Dome-8-6-2-Clock-CC"} or: {~numChannelsConfig != "16-Dome-8-6-2-Clock"} or: {~numChannelsConfig != "24-UsineC-3Octo"} or: {~numChannelsConfig != "16-UsineC-2Octo"} or: {~numChannelsConfig != "32-Dome-UQAM-11-11-9-1"} }
{
SynthDef(\Limiter, { | limDrive = 1, ampLimit = 0.99, postAmp = 1, mulSub = 0.8 |
var input = In.ar(0, /*2*/ ~numChannels);
input = Select.ar(CheckBadValues.ar(input, 0, 0), [input, DC.ar(0), DC.ar(0), input]); // Pour réduire l'impact CPU de 2%
// Check Bad Values -> repris de StageLimiter de Botuhan Bozkurt
input = LeakDC.ar(input, 0.995);
input = Limiter.ar(input * limDrive, ampLimit) * postAmp;
// input = BHiPass4.ar(input, 50); // quel est le meilleur Ugen (efficace en termes de CPU) qui filtre les infra-basses pour les petits HP ?????????
ReplaceOut.ar(0, input);
}).add;
/*
BHiPass4
BLowShelf
BPeakEQ
LeakDC
*/
};
// if (currentEnvironment[server] == ~server1, { ~limiter = 0 ! 2; ~limiterNotification = 0 ! 2; } );
if (~limiter.isNil, { ~limiter = 0 ! 2; ~limiterNotification = 0 ! 2; } );
~limiterFunction = { |serverFX, serverNb|
{
if (~limiterNotification[serverNb] == 0, {
~limiter[serverNb] = Synth(\Limiter, target: RootNode(currentEnvironment[serverFX]), addAction: \addToTail);
~limiter[serverNb].set(\ampLimit, ~ampLimiter);
("Limiter "++serverNb++" triggered").postln; ~limiterNotification[serverNb] = 1
}, {
("Limiter "++serverNb++" already playing").postln; /*~limiterNotification = 1*/} )
}.defer(1)
};
// ~limiterNotification[serverNb] = 0;
~limiterFunction.(serverFXV, serverNb);
CmdPeriod.add({
if (~server2.notNil, {
~limiterNotification[0] = 0; ~limiterNotification[1] = 0;
if (~serverFX == 0, {
~limiterFunction.(\server1, 0); ~limiterFunction.(\server2, 1);
},{
~limiterFunction.(\serverFX1, 0); ~limiterFunction.(\serverFX2, 1);
});
},{
~limiterNotification[0] = 0;
if (~serverFX == 0, {
~limiterFunction.(\server1, 0);
},{
~limiterFunction.(\serverFX1, 0);
});
});
try { ~spatioScopePlayer.stop };
});
// ~limiter.set(\ampLimit, 0.8);
// Model for the global volume of the synthesis server Volume (server, startBus: 0, numChans, min: -90, max: 6, persist: false)
// Create and return a new instance of Volume for a given server, ranging from startBus over numChans (usually the server's number of output bus channels)
/*
~serverVolume = s.volume;
// if (~serverVolume.isNil, { ~serverVolume = s.volume }); // Protection pour éviter de le relancer quand relancement de la GUI
*/
// if (currentEnvironment[server] == ~server1, { ~serverVolume = 0 ! 2 });
if (~serverVolume.isNil, { ~serverVolume = 0 ! 2 });
~serverVolume[serverNb] = Volume(currentEnvironment[serverFXV], 0, ~numChannels, -90, ~maxServerVolume, false /*true*/).lag_(7);
currentEnvironment[server].sync;
// Génération de 2 synthés volumeAmpControl si mise en veille de l'ordi ???
// ~serverVolume.lag = 1;
// ~serverVolume.lag_(1);
/*
~serverVolume.min;
~serverVolume.max;
~serverVolume.volume = rrand(-50, 5);
~serverVolume.setVolumeRange(-90, 8);
~serverVolume.mute;
~serverVolume.unmute;
~serverVolume.numChans;
~serverVolume.gui; // separate window
*/
// Allocation de buffers pour le synthé WarpIn
// if (currentEnvironment[server] == ~server1, { ~bufEmpty = 0 ! 2 });
if (~bufEmpty.isNil, { ~bufEmpty = 0 ! 2 });
~bufEmpty[serverNb] = Buffer.alloc(currentEnvironment[server], currentEnvironment[server].sampleRate * 16, 1);
if (~chaoticEnvString.isNil, { ~chaoticEnvString = 0 ! 3; // ajout des buffers d'enveloppes
// ~chaoticEnv[0] = Env([0, 1], [0.1]) ++ Env.saw2(segs: 700, amp: 1, startPhase: 0, endPhase: 1900pi, dur: 1-0.1-0.1).range(0, 1) ++ Env.cutoff(0.1, 0); // avec fades
// à utiliser pour éviter Env.linen dans les enveloppes -> plus économique ???
~chaoticEnvString[0] = "Env.saw2(segs: 700, startPhase: 0, endPhase: 1900pi, amp: 1, dur: 1) .range(0, 1)";
~chaoticEnvString[1] = "Env.triangle2(segs: 700, startPhase: 0, endPhase: 401pi, amp: 1, dur: 1) .range(0, 1)";
~chaoticEnvString[2] = "Env.square2(segs: 1000, startPhase: 0, endPhase: 401pi, amp: 1, dur: 1) .range(0, 1)";
});
if (~chaoticEnv.isNil, { ~chaoticEnv = 0 ! 3 }); // ajout des enveloppes
3.do { |i| ~chaoticEnv[i] = ~chaoticEnvString[i].interpret };
~bufEnvFunc = { |servers, serverNbs, i| ~bufEnv[serverNbs][i] = Buffer.sendCollection(servers, ~chaoticEnv[i].asArray, numChannels: 1, wait: -1, action: { "Chaotic Buffer loaded".postln }) };
// currentEnvironment[\server1]
if (~bufEnv.isNil, { ~bufEnv = 0 ! 3 ! 2 });
/*if (currentEnvironment[server] == ~server1, {
~bufEnv = 0 ! 3 ! 2; // ajout des buffers d'enveloppes
// ~bufEnvFunc = { |i| ~bufEnv[0][i] = Buffer.sendCollection(currentEnvironment[server], ~chaoticEnv[i].asArray, numChannels: 1, wait: -1, action: { "Chaotic Buffer loaded".postln }) };
// 3.do { |i| ~bufEnvFunc.(i) };
},{
// ~bufEnvFunc = { |i| ~bufEnv[1][i] = Buffer.sendCollection(currentEnvironment[server], ~chaoticEnv[i].asArray, numChannels: 1, wait: -1, action: { "Chaotic Buffer loaded".postln }) };
// 3.do { |i| ~bufEnvFunc.(i) };
});*/
3.do { |i| ~bufEnvFunc.(currentEnvironment[server], serverNb, i) };
/*
~chaoticEnv[0].plot
~chaoticEnv[1].plot
~chaoticEnv[2].plot
~bufEnv[0].getn(0, 800, {|msg| msg.postcs});
*/
if (~qitchBuffer.isNil,{ ~qitchBuffer = 0 ! 2; });
// path to auxiliary wav file for Qitch - frequency tracking
if (currentEnvironment[server] == ~server1, {
// ~qitchBuffer = 0 ! 2;
if (~sampleRate == 44100, {
~qitchBuffer[0] = Buffer.read(currentEnvironment[server],
if ((Platform.userAppSupportDir ++ "/Extensions/plugins").isFolder, {
Platform.userAppSupportDir ++ "/Extensions/plugins/PitchDetection/extraqitchfiles/QspeckernN2048SR44100.wav"
},{
Platform.userAppSupportDir ++ "/Extensions/SC3plugins/PitchDetection/extraqitchfiles/QspeckernN2048SR44100.wav"
});
);
}, {
~qitchBuffer[0] = Buffer.read(currentEnvironment[server],
if ((Platform.userAppSupportDir ++ "/Extensions/plugins").isFolder, {
Platform.userAppSupportDir ++ "/Extensions/plugins/PitchDetection/extraqitchfiles/QspeckernN2048SR48000.wav"
},{
Platform.userAppSupportDir ++ "/Extensions/SC3plugins/PitchDetection/extraqitchfiles/QspeckernN2048SR48000.wav"
});
);
});
},{
if (~sampleRate == 44100, {
~qitchBuffer[1] = Buffer.read(currentEnvironment[server],
if ((Platform.userAppSupportDir ++ "/Extensions/plugins").isFolder, {
Platform.userAppSupportDir ++ "/Extensions/plugins/PitchDetection/extraqitchfiles/QspeckernN2048SR44100.wav"
},{
Platform.userAppSupportDir ++ "/Extensions/SC3plugins/PitchDetection/extraqitchfiles/QspeckernN2048SR44100.wav"
});
);
}, {
~qitchBuffer[1] = Buffer.read(currentEnvironment[server],
if ((Platform.userAppSupportDir ++ "/Extensions/plugins").isFolder, {
Platform.userAppSupportDir ++ "/Extensions/plugins/PitchDetection/extraqitchfiles/QspeckernN2048SR48000.wav"
},{
Platform.userAppSupportDir ++ "/Extensions/SC3plugins/PitchDetection/extraqitchfiles/QspeckernN2048SR48000.wav"
});
);
});
});
// j -> enveloppe -> utilisé préalablement pour GrainIn, GrainSin, GrainFM -> utilisation actuellement d'une enveloppe générique avec -1
/*j = Env([0, 1, 0], [0.5, 0.5], [-5, 5]);
j = Buffer.sendCollection(s, j.discretize, 1);*/
currentEnvironment[server].sync;
( // Load Synthdefs
// Enveloppes
/*
Check SC Book Chapter 16 Microsound
"/Users/Xon/Documents/SC3/Super Collider Book/code/Ch 16 Microsound/c16_micro_figures2_anatomy.scd".openDocument;
( // a sinc function envelope
q = q ? ();
q.makeSinc = { |q, num=1, size=400|
dup({ |x| x = x.linlin(0, size-1, -pi, pi) * num; sin(x) / x }, size);
};
a = q.makeSinc(6);
a.plot(bounds: Rect(0,0,409,200), minval: -1, maxval: 1);
)
( // more envelopes plotted
[ Env.sine,
Env([0, 1, 1, 0], [0.2, 0.6, 0.2], \sin),
Env([0, 1, 1, 0], [0.2, 0.6, 0.2], \lin),
Env([0, 1, 1, 0], [0.2, 0.6, 0.2], \welch),
Env([1, 0.001], [1], \exp),
Env([0.001, 1], [1], \exp),
Env.perc(0.05, 0.95)
] .collect(_.discretize(400))
.add(q.makeSinc(6)).clump(4).collect { |gr4, i|
gr4.flop.flat.plot(
["Sine (gauss), Quasi-gauss, Line, Welch",
"Exp decay, Rev Exp decay, Perc, Sinc" ][i],
Rect(420 * i + 100, 300, 408, 400), numChannels: 4)
};
)
( // Enveloppes plotted in Synths
var atk = 0.1, rel = 0.1, durenv = 1, amp = 1;
var width = 0.6, holdT = durenv * width, fadeT = 1 - width * durenv * 0.5;
var width2 = 0.2, holdT2 = durenv * width2, fadeT2 = 1 - width2 * durenv * 0.5;
[ Env.linen(atk, durenv-atk-rel, rel, amp),
Env.sine,
// Env.sine/*(durenv, amp)*/,
Env([0, 1, 1, 0], [fadeT, holdT, fadeT], \sin),
Env([0, 1, 1, 0], [fadeT2, holdT2, fadeT2], \sin), // \welch
Env.perc(atk, 1-atk, amp), // pas besoin de amp - par défaut 1 ?
Env.perc(1-rel, rel, amp),
Env([1, 0.001], [1], \exp),
Env([0.001, 1], [1], \exp),
] .collect(_.discretize(400))
.add(q.makeSinc(6)).clump(4).collect { |gr4, i|
gr4.flop.flat.plot(
["Line, Sine, Gauss1, Gauss2", "Perc, PercRev, Exp, ExpRev", "SincFunc"][i],
Rect(420 * i + 100, 300, 408, 400), numChannels: 4)
};
)
( // Enveloppes plotted in Synths 2
var atk = 0.1, rel = 0.1, durenv = 1, amp = 1;
var width = 0.998, holdT = durenv * width, fadeT = 1 - width * durenv * 0.5;
var width2 = 0.4, holdT2 = durenv * width2, fadeT2 = 1 - width2 * durenv * 0.5;
q = q ? ();
q.makeSinc = { |q, num=1, size=400|
dup({ |x| x = x.linlin(0, size-1, -pi, pi) * num; sin(x) / x }, size);
};
[ Env.linen(atk, durenv-atk-rel, rel, amp),
Env.sine,
// Env.sine/*(durenv, amp)*/,
Env([0, 1, 1, 0], [fadeT, holdT, fadeT], \sin),
Env([0, 1, 1, 0], [fadeT2, holdT2, fadeT2], \sin), // \welch
Env.perc(atk, 1-atk, amp), // pas besoin de amp - par défaut 1 ?
Env.perc(1-rel, rel, amp),
Env([1, 0.001], [1], \exp),
Env([0.001, 1], [1], \exp),
Env.square2(segs: 1000, amp: 1, startPhase: 0, endPhase: 401pi, dur: 1).range(0, 1), // Bad Fadeout
Env.saw2(segs: 700, amp: 1, startPhase: 0, endPhase: 1900pi, dur: 1).range(0, 1),
Env.triangle2(segs: 700, amp: 1, startPhase: 0, endPhase: 401pi, dur: 1).range(0, 1),
] .collect(_.discretize(400))
.add(q.makeSinc(6)).clump(4).collect { |gr4, i|
gr4.flop.flat.plot(
["Line, Sine, Gauss1, Gauss2", "Perc, PercRev, Exp, ExpRev", "Chaos1, Chaos2, Chaos3, SincFunc"][i],
Rect(420 * i + 100, 300, 408, 400), numChannels: 4)
};
)
// Changement du paramètre env en réduisant le nb de synthés et le basculant sur le pattern // Checker impact Server ??? trop gourmand (40% vs 30%)
// env = Control.names([\envelope]).kr(env.asArray);
("_Init Buffers & Synths 20.scd").loadRelative;
("_Init GUI 37.scd").loadRelative;
("_Init Pattern 32.scd").loadRelative;
// Env is fixed-length (e.g. Env.linen, Env.perc) ?????????
(
SynthDef(\sin, {