-
Notifications
You must be signed in to change notification settings - Fork 1
/
epicycles.html
3224 lines (3064 loc) · 140 KB
/
epicycles.html
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Clear-Site-Data" content="cache" />
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="dat.gui.js"></script>
<script src="jquery.js"></script>
<script src="sprintf.js"></script>
<script src="three.js"></script>
<script src="ace.js"></script>
<script src="tinycolor.js"></script>
<script src="CsoundAudioNode.js"></script>
<script src="CsoundAC.js"></script>
<script src="strudel_embed.js"></script>
<link rel="stylesheet" href="w3.css">
<link rel="icon" href="data:,">
<style>
.w3-container {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.w3-bar {
z-index: 1;
}
</style>
</head>
patched_text = text.replace(find_this, replace_with)
<body id="body" class="w3-medium w3-text-sand" style="height:100vh;">
<script>
if ('caches' in window) {
caches.keys().then(function(names) {
for (let name of names)
caches.delete(name);
console.log(`deleted ${name} from caches.`);
});
}
</script>
<!------------------------------------------------------------------------
This piece demonstrates and tests the CsoundAC StatefulPatterns class.
There is also much "infrastructure" code that sets up the user interface,
compiles the Csound orchestra, compiles any GLSL shaders, and handles
all events from the user interface. Most of this code requires little or
no change when writing a new piece.
Non-infrastructure code, the code that makes a piece, can be found between
the lines marked >>>>>>>> and <<<<<<<<< below.
------------------------------------------------------------------------->
<div class="w3-bar " style="position:fixed;background:transparent;">
<ul class = "menu">
<li id="menu_item_play" class="w3-btn w3-hover-text-light-green">Play</li>
<li id="menu_item_fullscreen" class="w3-btn w3-hover-text-light-green">Fullscreen</li>
<li id="menu_item_tidal" class="w3-btn w3-hover-text-light-green">Strudel</li>
<li id="menu_item_controls" class="w3-btn w3-hover-text-light-green">Controls</li>
<li id="menu_item_console" class="w3-btn w3-hover-text-light-green">Log</li>
<li id="menu_item_about" class="w3-btn w3-hover-text-light-green">About</li>
<li id="mini_console" class="w3-btn w3-text-light-green"></li>
</ul>
</div>
<canvas id="display" class="w3-container" style="background-color:black;height:100%;margin:0;padding:0;z-index:0;">
</canvas>
<!-- BEGIN define "Strudel" overlay. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -->
<strudel-repl-component id="tidal_view" class="w3-container" style="position:absolute;left:70px;top:140px;z-index:1;">
<!--
const csac = await import('../csoundac.mjs');
csac.diagnostic_level(csac.NEVER);
let pitv = csac.Pitv(4, 36, 60);
let pitvPatterns = new csac.PitvPatterns(pitv);
// Bind some Csound control channels to Strudel, to be
// controlled by sliders in the patch.
let gk_Bower_level = createParam('gk_Bower_level');
let gk_Bower_pressure = createParam('gk_Bower_pressure');
let gk_Blower_level = createParam('gk_Blower_level');
let gk_Blower_grainDensity = createParam('gk_Blower_grainDensity');
let gk_Blower_grainDuration = createParam('gk_Blower_grainDuration');
let gk_Blower_grainAmplitudeRange = createParam('gk_Blower_grainAmplitudeRange');
let gk_Blower_grainFrequencyRange = createParam('gk_Blower_grainFrequencyRange');
let gk_Sweeper_britel = createParam('gk_Sweeper_britel');
let gk_Sweeper_britels = createParam('gk_Sweeper_britels');
let gk_Sweeper_briteh = createParam('gk_Sweeper_briteh');
let gk_Sweeper_britehs = createParam('gk_Sweeper_britehs');
let gk_Droner_level = createParam('gk_Droner_level');
let gk_FilteredSines_level = createParam('gk_FilteredSines_level');
let gk_FMWaterBell_level = createParam('gk_FMWaterBell_level');
let gk_Guitar_level = createParam('gk_Guitar_level');
let gk_SeidelHarmOsc_level = createParam('gk_SeidelHarmOsc_level');
let gk_Harpsichord_level = createParam('gk_Harpsichord_level');
let gk_Kung2_level = createParam('gk_Kung2_level');
let gk_Kung4_level = createParam('gk_Kung4_level');
let gk_Plucked_level = createParam('gk_Plucked_level');
let gk_Shiner_level = createParam('gk_Shiner_level');
let gk_Sweeper_level = createParam('gk_Sweeper_level');
let gk_TubularBell_level = createParam('gk_TubularBell_level');
let gk_Xing_level = createParam('gk_Xing_level');
let gk_YiString_level = createParam('gk_YiString_level');
let gk_ZakianFlute_level = createParam('gk_ZakianFlute_level');
let gk_ReverbSC_feedback = createParam('gk_ReverbSC_feedback');
let gk_MasterOutput_level = createParam('gk_MasterOutput_level');
pure(0)
.acPP(pitvPatterns, "<12 4 11>/64")
.acPT(pitvPatterns, "<1 2 3 4 5>/16")
.acPO(pitvPatterns, "<1 2 3 44 5 20 18>/4")
.acPVV(pitvPatterns, 48)
.note()
.fast(3)
.legato(3)
.pianoroll({labels:1,fillActive:1,cycles:32,playhead:.9})
.csoundn("<5 6>/4")
// Levels and other controls for Csound instruments.
// Levels are initially more or less balanced.
/* 1 */ .gk_TubularBell_level(slider(0.55, 0, 1).sub(.5).mul(100))
/* 2 */ .gk_Droner_level(slider(0.13, 0, 1).sub(.5).mul(100))
/* 3 */ .gk_SeidelHarmOsc_level(slider(0.5, 0, 1).sub(.5).mul(100))
/* 4 */ .gk_Shiner_level(slider(0.525, 0, 1).sub(.5).mul(100))
/* 5 */ .gk_Xing_level(slider(0.1, 0, 1).sub(.5).mul(100))
/* 6 */ .gk_Guitar_level(slider(0.6, 0, 1).sub(.5).mul(100))
/* 7 */ .gk_FilteredSines_level(slider(0.22, 0, 1).sub(.5).mul(100))
/* 8 */ .gk_Blower_level(slider(0.54, 0, 1).sub(.5).mul(100))
.gk_Blower_grainDensity(slider(90, 0, 1000))
.gk_Blower_grainDuration(slider(0.02, 0.01, 2))
.gk_Blower_grainAmplitudeRange(slider(100, 0, 1000))
.gk_Blower_grainFrequencyRange(slider(10, 0, 300))
/* 9 */ .gk_Sweeper_level(slider(0.375, 0, 1).sub(.5).mul(100))
.gk_Sweeper_britel(slider(0.5, 0, 4))
.gk_Sweeper_britels(slider(0.25, 0, 4))
.gk_Sweeper_briteh(slider(4, 0, 4))
.gk_Sweeper_britehs(slider(0.5, 0, 4))
/* 10 */ .gk_Plucked_level(slider(0.645, 0, 1).sub(.5).mul(100))
/* 11 */ .gk_FMWaterBell_level(slider(0.6, 0, 1).sub(.5).mul(100))
/* 12 */ .gk_YiString_level(slider(0.375, 0, 1).sub(.5).mul(100))
/* 13 */ .gk_Harpsichord_level(slider(0.45, 0, 1).sub(.5).mul(100))
/* 14 */ .gk_ZakianFlute_level(slider(0.5, 0, 1).sub(.5).mul(100))
/* 15 */ .gk_Kung4_level(slider(0.5, 0, 1).sub(.5).mul(100))
/* 16 */ .gk_Kung2_level(slider(0.55, 0, 1).sub(.5).mul(100))
/* 17 */ .gk_Bower_level(slider(0.55, 0, 1).sub(.5).mul(100))
.gk_Bower_pressure(slider(0.325, 0, 4))
.gk_ReverbSC_feedback(slider(0.84, 0, 1))
//.gain("<.03 .1@2 .2@3 .3@2 .02@2>/6".mul(3))
.gk_MasterOutput_level(slider(0.493, 0, 1).sub(.5).mul(100))
.pianoroll({fillActive:1,minMidi:0,maxMidi:127,cycles:16,playhead:.75})
-->
</strudel-repl-component>
<!-- END define "Strudel" overlay. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -->
<div id="controls_view" class="w3-container" style="margin:2%;position:absolute;top:70px;z-index:2;background:transparent;">
<form id='persist'>
<table>
<col width="2*">
<col width="5*">
<col width="100px">
<!-- BEGIN Define "Controls" overlay. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -->
<!-- We comment out all HTML inputs that have been made into Strudel sliders.
<tr style="height:1em;"></tr>
<tr>
<td>
<label for=gk_TubularBell_level>01 TubularBell (dB)</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=-13 id=gk_TubularBell_level step=.001>
<td>
<output for=gk_TubularBell_level id=gk_TubularBell_level_output>-13</output>
</tr>
<tr>
<td>
<label for=gk_Droner_level>02 Droner (dB)</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=-30 id=gk_Droner_level step=.001>
<td>
<output for=gk_Droner_level id=gk_Droner_level_output>-30</output>
</tr>
<tr>
<td>
<label for=gk_SeidelHarmOsc_level>03 SeidelHarmOsc (dB)</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=-10 id=gk_SeidelHarmOsc_level step=.001>
<td>
<output for=gk_SeidelHarmOsc_level id=gk_SeidelHarmOsc_level_output>-10</output>
</tr>
<tr>
<td>
<label for=gk_Shiner_level>04 Shiner (dB)</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=-6 id=gk_Shiner_level step=.001>
<td>
<output for=gk_Shiner_level id=gk_Shiner_level_output>-6</output>
</tr>
<tr>
<td>
<label for=gk_Xing_level>05 Xing (dB)</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=-36 id=gk_Xing_level step=.001>
<td>
<output for=gk_Xing_level id=gk_Xing_level_output>-36</output>
</tr>
<tr>
<td>
<label for=gk_Guitar_level>06 Guitar (dB)</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=10 id=gk_Guitar_level step=.001>
<td>
<output for=gk_Guitar_level id=gk_Guitar_level_output>10</output>
</tr>
<tr>
<td>
<label for=gk_FilteredSines_level>07 FilteredSines (dB)</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=0 id=gk_FilteredSines_level step=.001>
<td>
<output for=gk_FilteredSines_level id=gk_FilteredSines_level_output>0</output>
</tr>
<tr>
<td>
<label for=gk_Blower_level>08 Blower (dB)</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=0 id=gk_Blower_level step=.001>
<td>
<output for=gk_Blower_level id=gk_Blower_level_output>0</output>
</tr>
<tr>
<td>
<label for=gk_Sweeper_level>09 Sweeper (dB)</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=-6 id=gk_Sweeper_level step=.001>
<td>
<output for=gk_Sweeper_level id=gk_Sweeper_level_output>6</output>
</tr>
<tr>
<td>
<label for=gk_Plucked_level>10 Plucked (dB)</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=3 id=gk_Plucked_level step=.001>
<td>
<output for=gk_Plucked_level id=gk_Plucked_level_output>3</output>
</tr>
<tr>
<td>
<label for=gk_FMWaterBell_level>11 FMWaterBell (dB)</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=3 id=gk_FMWaterBell_level step=.001>
<td>
<output for=gk_FMWaterBell_level id=gk_FMWaterBell_level_output>3</output>
</tr>
<tr>
<td>
<label for=gk_YiString_level>12 YiString (dB)</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=-6 id=gk_YiString_level step=.001>
<td>
<output for=gk_YiString_level id=gk_YiString_level_output>-6</output>
</tr>
<tr>
<td>
<label for=gk_Harpsichord_level>13 Harpsichord (dB)</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=-2 id=gk_Harpsichord_level step=.001>
<td>
<output for=gk_Harpsichord_level id=gk_Harpsichord_level_output>-2</output>
</tr>
<tr>
<td>
<label for=gk_ZakianFlute_level>14 ZakianFlute (dB)</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=0 id=gk_ZakianFlute_level step=.001>
<td>
<output for=gk_ZakianFlute_level id=gk_ZakianFlute_level_output>0</output>
</tr>
<tr>
<td>
<label for=gk_Kung4_level>15 Kung4 (dB)</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=6 id=gk_Kung4_level step=.001>
<td>
<output for=gk_Kung4_level id=gk_Kung4_level_output>6</output>
</tr>
<tr>
<td>
<label for=gk_Kung2_level>15 Kung2 (dB)</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=-7 id=gk_Kung2_level step=.001>
<td>
<output for=gk_Kung2_level id=gk_Kung2_level_output>-7</output>
</tr>
<tr style="height:1em;"></tr>
<tr>
<td>
<label for=gk_ReverbSC_feedback>Reverb delay feedback</label>
<td>
<input class=persistent-element type=range min=0 max=1 value=.92 id=gk_ReverbSC_feedback step=.001>
<td>
<output for=gk_ReverbSC_feedback id=gk_ReverbSC_feedback_output>.92</output>
</tr>
-->
<tr>
<td>
<label for=gk_ReverbSC_frequency_cutoff>Reverb highpass cutoff (Hz)</label>
<td>
<input class=persistent-element type=range min=0 max=20000 value=12000 id=gk_ReverbSC_frequency_cutoff step=.001>
<td>
<output for=gk_ReverbSC_frequency_cutoff id=gk_ReverbSC_frequency_cutoff_output>12000</output>
</tr>
<tr>
<td>
<label for=gi_ReverbSC_delay_modulation>Reverb delay modulation</label>
<td>
<input class=persistent-element type=range min=0 max=2 value=.005 id=gi_ReverbSC_delay_modulation step=.001>
<td>
<output for=gi_ReverbSC_delay_modulation id=gi_ReverbSC_delay_modulation_output>.005</output>
</tr>
<!--
<tr style="height:1em;"></tr>
<tr>
<td>
<label for=gk_MasterOutput_level>Master output level (dB)</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=-12 id=gk_MasterOutput_level step=.001>
<td>
<output for=gk_MasterOutput_level id=gk_MasterOutput_level_output>-12</output>
</tr>
-->
<tr style="height:1em;"></tr>
<tr>
<td>
<label for=gk_MasterOutput_duration>Duration (0 is indefinite)</label>
<td>
<input class=persistent-element type=range min=0 max=1000 value=540 id=gk_MasterOutput_duration step=.001>
<td>
<output for=gk_MasterOutput_duration id=gk_MasterOutput_duration_output>540</output>
</tr>
</table>
<p>
<!-- END Define "Controls" overlay. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -->
<input type="button" id='save' value="Save" class="w3-btn w3-hover-text-light-green"/>
<input type="button" id='restore' value="Restore" class="w3-btn w3-hover-text-light-green"/>
<input type="button" id='copy' value="Copy" class="w3-btn w3-hover-text-light-green"/>
<input type="button" id='paste' value="Paste" class="w3-btn w3-hover-text-light-green"/>
<input type="button" id='default' value="Defaults" class="w3-btn w3-hover-text-light-green"/>
</form>
</div>
<div id='console_view' class="w3-text-sand" style="position:absolute;top:70px;z-index:4;width:100vw;height:90vh;background:transparent;color;margin:1%;">
</div>
<div id="about_view" class="w3-container " style="position:absolute;top:70px;z-index:5;background:transparent;color:rgb(255, 255, 200, 67%);max-height: calc(100vh - 70px);overflow-y:auto;">
<!-- BEGIN define "About" overlay. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -->
<h1>Cancycle</h1>
<h3>Michael Gogins<br>
October 2023</h3>
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/"><img alt="Creative Commons License" style="border-width:0;" src="https://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png" /></a><p>This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.</a>
<p>This is a piece of interactive visual music implemented using my all-HTML5
system for making and performing computer music,
<a href="https://github.com/gogins/cloud-5">cloud-5</a>. The title refers to
the use of Strudel to cycle through this composition, while the performer
varies, by live coding, canonical relationships (along with other things)
within the piece.
<p>cloud-5 runs exclusively in standard Web browsers from a local or remote
Web server. The system includes <a href="https://github.com/gogins/csound-wasm">
WebAssembly builds</a> of <a href="https://csound.com/">Csound</a> and my
algorithmic composition library <a href="https://github.com/gogins/csound-ac">
CsoundAC</a>, the live coding system <a href="https://github.com/tidalcycles/strudel">
Strudel</a>, and whatever other JavaScript or WebAssembly components are needed.
<p>I composed this piece using:
<ul>
<li>A Strudel patch that uses the
<a href="https://mathworld.wolfram.com/CircleMap.html">circle map chaotic
dynamical system</a> to generate notes, incorporated into the Strudel patch
using my <a href="https://github.com/gogins/cloud-5/blob/main/public/statefulpatterns.mjs">
StatefulPatterns adapter class</a> that brings stateful objects into the
otherwise stateless paradigm of _pure functional reactive programming_ used by
Strudel.
<li>The patch also uses
<a href="https://github.com/gogins/csound-ac/blob/master/CsoundAC/ChordSpaceBase.hpp">CsoundAC's
Scale class</a> (via StatefulPatterns) to automatically generate quasi-tonal
chord progressions and modulations, using <a href="http://dmitri.tymoczko.com/">
Dmitri Tymoczko's</a> <a href="https://dmitri.mycpanel.princeton.edu/mozart.pdf">
model of functional harmony</a>.
<li>A Csound orchestra with fairly complex instrument definitions, including
both pad-like and percussive sounds. Sliders in the Strudel patch directly
control parameters of the Csound instruments.
<li>A music visualizer written in OpenGL Shader Language.
</ul>
<p>I set up the Strudel patch to make it easy to shape the piece by live
coding during performance. The basic idea is that there are three rather
repetitive sections, and the performer is expected to introduce variations in
these sections by moving the sliders (especially the circle map parameters and
the run and offset parameters), and by removing and adding code during play.
<p>Feel free to use this piece as a template for creating new pieces of this
type... as long as it honors the licenses and doesn't sound too much like this
one!
<p>Please report any problems you have playing this piece, or any ideas for
enhancements, at <a href="https://github.com/gogins/cloud-music/issues">
cloud-music issues</a>.
<ul>
<li>To view the source code of this piece, use your browser menu to view the
page source.
<li>To inspect or debug the code of this piece as it runs, use your browser
menu to open the developer tools.
</ul>
<h2>Credits</h2>
<p>Code for compiling and controlling shaders is adapted from <a
href="https://www.shadertoy.com">ShaderToy.com</a>.
<p>The algorithm for downsampling the video canvas is from <a
href="https://skemman.is/bitstream/1946/15343/3/SS_MSthesis.pdf">Sveinn
Steinarsson's MS thesis</a> with code from <a
href="https://github.com/pingec/downsample-lttb">
https://github.com/pingec/downsample-lttb</a>.
<p>The music visualization code is borrowed from <a
href="https://www.shadertoy.com/view/NdG3zw">
<i>Audio Reactive Galaxy</i></a>
by <a href="https://www.shadertoy.com/user/JelyMe314">JelyMe314</a>.
<p>Some of the Csound instruments are by me, others are adapted by me from
patches originally written by others (as noted in the orchestra).
<p>
<a href="http://michaelgogins.tumblr.com">
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Calque_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="36" height="36" viewBox="0 0 256 256" enable-background="new 0 0 256 256" xml:space="preserve">
<g>
<g>
<g>
<rect x="0.24" y="0.167" fill="#314358" width="255.52" height="256"/>
</g>
</g>
<g>
<path fill="#FFFFFF" d="M168.08,170.918c-2.969,1.416-8.647,2.648-12.881,2.754c-12.783,0.342-15.264-8.979-15.367-15.736v-49.705
h32.065V84.055h-31.954V43.382c0,0-23.008,0-23.383,0c-0.385,0-1.057,0.337-1.152,1.192c-1.368,12.448-7.192,34.296-31.416,43.032
v20.624h16.16v52.167c0,17.863,13.176,43.24,47.959,42.641c11.736-0.201,24.77-5.113,27.648-9.354L168.08,170.918"/>
</g>
</g>
</svg></a>
<a href="https://github.com/gogins">
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Calque_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="36" height="36" viewBox="0 0 256 256" enable-background="new 0 0 256 256" xml:space="preserve">
<g>
<path d="M128.00106,0 C57.3172926,0 0,57.3066942 0,128.00106 C0,184.555281 36.6761997,232.535542 87.534937,249.460899 C93.9320223,250.645779 96.280588,246.684165 96.280588,243.303333 C96.280588,240.251045 96.1618878,230.167899 96.106777,219.472176 C60.4967585,227.215235 52.9826207,204.369712 52.9826207,204.369712 C47.1599584,189.574598 38.770408,185.640538 38.770408,185.640538 C27.1568785,177.696113 39.6458206,177.859325 39.6458206,177.859325 C52.4993419,178.762293 59.267365,191.04987 59.267365,191.04987 C70.6837675,210.618423 89.2115753,204.961093 96.5158685,201.690482 C97.6647155,193.417512 100.981959,187.77078 104.642583,184.574357 C76.211799,181.33766 46.324819,170.362144 46.324819,121.315702 C46.324819,107.340889 51.3250588,95.9223682 59.5132437,86.9583937 C58.1842268,83.7344152 53.8029229,70.715562 60.7532354,53.0843636 C60.7532354,53.0843636 71.5019501,49.6441813 95.9626412,66.2049595 C106.172967,63.368876 117.123047,61.9465949 128.00106,61.8978432 C138.879073,61.9465949 149.837632,63.368876 160.067033,66.2049595 C184.49805,49.6441813 195.231926,53.0843636 195.231926,53.0843636 C202.199197,70.715562 197.815773,83.7344152 196.486756,86.9583937 C204.694018,95.9223682 209.660343,107.340889 209.660343,121.315702 C209.660343,170.478725 179.716133,181.303747 151.213281,184.472614 C155.80443,188.444828 159.895342,196.234518 159.895342,208.176593 C159.895342,225.303317 159.746968,239.087361 159.746968,243.303333 C159.746968,246.709601 162.05102,250.70089 168.53925,249.443941 C219.370432,232.499507 256,184.536204 256,128.00106 C256,57.3066942 198.691187,0 128.00106,0 Z M47.9405593,182.340212 C47.6586465,182.976105 46.6581745,183.166873 45.7467277,182.730227 C44.8183235,182.312656 44.2968914,181.445722 44.5978808,180.80771 C44.8734344,180.152739 45.876026,179.97045 46.8023103,180.409216 C47.7328342,180.826786 48.2627451,181.702199 47.9405593,182.340212 Z M54.2367892,187.958254 C53.6263318,188.524199 52.4329723,188.261363 51.6232682,187.366874 C50.7860088,186.474504 50.6291553,185.281144 51.2480912,184.70672 C51.8776254,184.140775 53.0349512,184.405731 53.8743302,185.298101 C54.7115892,186.201069 54.8748019,187.38595 54.2367892,187.958254 Z M58.5562413,195.146347 C57.7719732,195.691096 56.4895886,195.180261 55.6968417,194.042013 C54.9125733,192.903764 54.9125733,191.538713 55.713799,190.991845 C56.5086651,190.444977 57.7719732,190.936735 58.5753181,192.066505 C59.3574669,193.22383 59.3574669,194.58888 58.5562413,195.146347 Z M65.8613592,203.471174 C65.1597571,204.244846 63.6654083,204.03712 62.5716717,202.981538 C61.4524999,201.94927 61.1409122,200.484596 61.8446341,199.710926 C62.5547146,198.935137 64.0575422,199.15346 65.1597571,200.200564 C66.2704506,201.230712 66.6095936,202.705984 65.8613592,203.471174 Z M75.3025151,206.281542 C74.9930474,207.284134 73.553809,207.739857 72.1039724,207.313809 C70.6562556,206.875043 69.7087748,205.700761 70.0012857,204.687571 C70.302275,203.678621 71.7478721,203.20382 73.2083069,203.659543 C74.6539041,204.09619 75.6035048,205.261994 75.3025151,206.281542 Z M86.046947,207.473627 C86.0829806,208.529209 84.8535871,209.404622 83.3316829,209.4237 C81.8013,209.457614 80.563428,208.603398 80.5464708,207.564772 C80.5464708,206.498591 81.7483088,205.631657 83.2786917,205.606221 C84.8005962,205.576546 86.046947,206.424403 86.046947,207.473627 Z M96.6021471,207.069023 C96.7844366,208.099171 95.7267341,209.156872 94.215428,209.438785 C92.7295577,209.710099 91.3539086,209.074206 91.1652603,208.052538 C90.9808515,206.996955 92.0576306,205.939253 93.5413813,205.66582 C95.054807,205.402984 96.4092596,206.021919 96.6021471,207.069023 Z" fill="#161614"></path>
</g>
</svg>
</a>
<!-- END Define "About" overlay. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -->
</div>
<textarea id="csd" cols=80 rows=24 style="display:none;">
; BEGIN Define Csound orchestra. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<CsoundSynthesizer>
<CsOptions>
-+msg_color=0 -m34 -d --sample-accurate -f -odac
</CsOptions>
<CsInstruments>
sr = 48000
ksmps = 128
nchnls = 2
0dbfs = 8
gi_ampmidicurve_dynamic_range init .375
gi_ampmidicurve_exponent init 5
maxalloc 1, 8
maxalloc 2, 8
maxalloc 3, 8
maxalloc 4, 8
maxalloc 5, 8
maxalloc 6, 8
maxalloc 7, 8
maxalloc 8, 8
maxalloc 9, 8
maxalloc 10, 8
maxalloc 11, 8
maxalloc 12, 8
maxalloc 13, 8
maxalloc 14, 8
maxalloc 15, 8
maxalloc 16, 8
maxalloc 17, 8
connect "Blower", "outleft", "ReverbSC", "inleft"
connect "Blower", "outright", "ReverbSC", "inright"
connect "Bower", "outleft", "ReverbSC", "inleft"
connect "Bower", "outright", "ReverbSC", "inright"
connect "Droner", "outleft", "ReverbSC", "inleft"
connect "Droner", "outright", "ReverbSC", "inright"
connect "FilteredSines", "outleft", "ReverbSC", "inleft"
connect "FilteredSines", "outright", "ReverbSC", "inright"
connect "FMWaterBell", "outleft", "ReverbSC", "inleft"
connect "FMWaterBell", "outright", "ReverbSC", "inright"
connect "Guitar", "outleft", "ReverbSC", "inleft"
connect "Guitar", "outleft", "ReverbSC", "inleft"
connect "Harpsichord", "outleft", "ReverbSC", "inleft"
connect "Harpsichord", "outright", "ReverbSC", "inright"
connect "Kung2", "outleft", "ReverbSC", "inleft"
connect "Kung2", "outright", "ReverbSC", "inright"
connect "Kung4", "outleft", "ReverbSC", "inleft"
connect "Kung4", "outright", "ReverbSC", "inright"
connect "Plucked", "outleft", "ReverbSC", "inleft"
connect "Plucked", "outright", "ReverbSC", "inright"
connect "SeidelHarmOsc", "outleft", "ReverbSC", "inleft"
connect "SeidelHarmOsc", "outright", "ReverbSC", "inright"
connect "Shiner", "outleft", "ReverbSC", "inleft"
connect "Shiner", "outright", "ReverbSC", "inright"
connect "Sweeper", "outleft", "ReverbSC", "inleft"
connect "Sweeper", "outright", "ReverbSC", "inright"
connect "TubularBell", "outleft", "ReverbSC", "inleft"
connect "TubularBell", "outright", "ReverbSC", "inright"
connect "YiString", "outleft", "ReverbSC", "inleft"
connect "YiString", "outright", "ReverbSC", "inright"
connect "Xing", "outleft", "ReverbSC", "inleft"
connect "Xing", "outright", "ReverbSC", "inright"
connect "ZakianFlute", "outleft", "ReverbSC", "inleft"
connect "ZakianFlute", "outleft", "ReverbSC", "inleft"
connect "ReverbSC", "outleft", "MasterOutput", "inleft"
connect "ReverbSC", "outright", "MasterOutput", "inright"
alwayson "ReverbSC"
alwayson "MasterOutput"
gk_TubularBell_level chnexport "gk_TubularBell_level", 3
gi_TubularBell_crossfade chnexport "gi_TubularBell_crossfade", 3
gi_TubularBell_vibrato_depth chnexport "gi_TubularBell_vibrato_depth", 3
gi_TubularBell_vibrato_rate chnexport "gi_TubularBell_vibrato_rate", 3
gk_TubularBell_level init 0
gi_TubularBell_crossfade init 2
gi_TubularBell_vibrato_depth init .1
gi_TubularBell_vibrato_rate init 5
gk_TubularBell_midi_dynamic_range chnexport "gk_TubularBell_midi_dynamic_range", 3 ; 127
gk_TubularBell_midi_dynamic_range init 30
gk_TubularBell_space_left_to_right chnexport "gk_TubularBell_space_left_to_right", 3
gk_TubularBell_space_left_to_right init .5
gi_TubularBell_isine ftgen 0, 0, 65537, 10, 1
gi_TubularBell_icosine ftgen 0, 0, 65537, 11, 1
gi_TubularBell_icook3 ftgen 0, 0, 65537, 10, 1, .4, 0.2, 0.1, 0.1, .05
instr TubularBell
; Authors: Perry Cook, John ffitch, Michael Gogins
i_instrument = p1
i_time = p2
i_physical_decay = 15
if p3 == -1 then
i_duration = i_physical_decay
else
i_duration = p3
endif
i_midi_key = p4
i_midi_velocity = p5
k_space_front_to_back = p6
if p7 ==0 then
k_space_left_to_right = gk_TubularBell_space_left_to_right
else
k_space_left_to_right = p7
endif
k_space_bottom_to_top = p8
i_phase = p9
i_frequency = cpsmidinn(i_midi_key)
; Adjust the following value until "overall amps" at the end of performance is about -6 dB.
i_overall_amps = 12.5
i_normalization = ampdb(-i_overall_amps) / 2
i_midi_dynamic_range = i(gk_TubularBell_midi_dynamic_range)
i_midi_velocity = p5 * i_midi_dynamic_range / 127 + (63.5 - i_midi_dynamic_range / 2)
i_amplitude = ampdb(i_midi_velocity) * i_normalization
k_gain = ampdb(gk_TubularBell_level)
iattack = 0.002
isustain = p3
irelease = 0.05
iindex = 1
ifn1 = gi_TubularBell_isine
ifn2 = gi_TubularBell_icook3
ifn3 = gi_TubularBell_isine
ifn4 = gi_TubularBell_isine
ivibefn = gi_TubularBell_icosine
a_signal fmbell 1, i_frequency, iindex, gi_TubularBell_crossfade, gi_TubularBell_vibrato_depth, gi_TubularBell_vibrato_rate, ifn1, ifn2, ifn3, ifn4, ivibefn
i_attack = .002
i_sustain = i_duration
i_release = 0.01
; As with most software instruments that are modeled on an impulse exciting a
; resonator, there should be two envelopes. The "physical" envelope must have a
; fixed decay ending at zero.
i_declick_minimum = .001
i_attack = .001 / i_frequency + i_declick_minimum
i_exponent = 30
a_physical_envelope transeg 0, i_attack, i_exponent, 1, i_physical_decay, -i_exponent, 0
; The de-clicking envelope must have attack and release segments that damp
; artifacts in the signal. The duration of these segments depends on
; the behavior of the instrument, and may vary as a function of frequency.
i_declick_attack = .004
i_declick_release = i_declick_minimum * 2
; The end of the note must be extended _past_ the end of the release segment.
xtratim 1
a_declicking_envelope cossegr 0, i_declick_attack, 1, i_duration, 1, i_declick_release, 0
; The envelope of the instrument is the product of the physical envelope times
; the declicking envelope.
a_envelope = a_physical_envelope * a_declicking_envelope
; That envelope is then low-pass filtered to remove most discontinuities.
a_filtered_envelope tonex a_envelope, 320, 4
a_signal = a_signal * i_amplitude * a_filtered_envelope * k_gain *.001
a_out_left, a_out_right pan2 a_signal, k_space_left_to_right
outleta "outleft", a_out_left
outleta "outright", a_out_right
prints "TubularBell i %9.4f t %9.4f d %9.4f k %9.4f v %9.4f p %9.4f #%3d\n", p1, p2, p3, p4, p5, p7, active(p1)
endin
gk_Droner_partial1 chnexport "gk_Droner_partial1", 3
gk_Droner_partial2 chnexport "gk_Droner_partial2", 3
gk_Droner_partial3 chnexport "gk_Droner_partial3", 3
gk_Droner_partial4 chnexport "gk_Droner_partial4", 3
gk_Droner_partial5 chnexport "gk_Droner_partial5", 3
gk_Droner_partial6 chnexport "gk_Droner_partial6", 3
gk_Droner_partial7 chnexport "gk_Droner_partial7", 3
gk_Droner_partial8 chnexport "gk_Droner_partial8", 3
gk_Droner_partial9 chnexport "gk_Droner_partial9", 3
gk_Droner_partial10 chnexport "gk_Droner_partial10", 3
gk_Droner_level chnexport "gk_Droner_level", 3
gi_Droner_waveform chnexport "gi_Droner_waveform", 3
gk_Droner_partial1 init .5
gk_Droner_partial2 init .05
gk_Droner_partial3 init .1
gk_Droner_partial4 init .2
gk_Droner_partial5 init .1
gk_Droner_partial6 init 0
gk_Droner_partial7 init 0
gk_Droner_partial8 init 0
gk_Droner_partial9 init 0
gk_Droner_partial10 init 0
gk_Droner_level init 0
gi_Droner_waveform init 0
gk_Droner_space_left_to_right chnexport "gk_Droner_space_left_to_right", 3
gk_Droner_space_left_to_right init .5
gi_Droner_sine ftgen 0, 0, 65537, 10, 1, 0, .02
instr Droner
i_instrument = p1
i_time = p2
; Make indefinite notes last no longer than the physical decay.
i_physical_decay = 200000
if p3 == -1 then
i_duration = i_physical_decay
else
i_duration = p3
endif
i_midi_key = p4
i_midi_velocity = p5
k_space_front_to_back = p6
if p7 ==0 then
k_space_left_to_right = gk_Droner_space_left_to_right
else
k_space_left_to_right = p7
endif
k_space_bottom_to_top = p8
i_phase = p9
i_frequency = cpsmidinn(i_midi_key)
; Adjust the following value until "overall amps" at the end of performance is about -6 dB.
i_overall_amps = 19
i_normalization = ampdb(-i_overall_amps) / 2
i_amplitude = ampdb(i_midi_velocity) * i_normalization
k_gain = ampdb(gk_Droner_level)
k1 = gk_Droner_partial1
k2 = gk_Droner_partial2
k3 = gk_Droner_partial3
k4 = gk_Droner_partial4
k5 = gk_Droner_partial5
k6 = gk_Droner_partial6
k7 = gk_Droner_partial7
k8 = gk_Droner_partial8
k9 = gk_Droner_partial9
k10 = gk_Droner_partial10
iwaveform = gi_Droner_waveform
iattack = .5
idecay = .5
isustain = p3
aenvelope transegr 0.0, iattack / 2.0, 1.5, 1 / 2.0, iattack / 2.0, -1.5, 1, isustain, 0.0, 1, idecay / 2.0, 1.5, 1 / 2.0, idecay / 2.0, -1.5, 0
ihertz = cpsmidinn(i_midi_key)
if iwaveform == 0 goto i_waveform_0
if iwaveform == 1 goto i_waveform_1
if iwaveform == 2 goto i_waveform_2
i_waveform_0:
asignal poscil3 1, ihertz, gi_Droner_sine
goto i_waveform_endif
i_waveform_1:
asignal vco2 1, ihertz, 8 ; integrated saw
goto i_waveform_endif
i_waveform_2:
asignal vco2 1, ihertz, 12 ; triangle
i_waveform_endif:
a_signal chebyshevpoly asignal, 0, k1, k2, k3, k4, k5, k6, k7, k8, k9, k10
;adeclicking linsegr 0, .004, 1, p3 - .014, 1, .1, 0
;a_signal = asignal * adeclicking
;
; The de-clicking envelope must have attack and release segments that damp
; artifacts in the signal. The duration of these segments depends on
; the behavior of the instrument, and may vary as a function of frequency.
i_declick_attack = .005
i_declick_release = .01
; The end of the note must be extended _past_ the end of the release segment.
xtratim 1
a_declicking_envelope cossegr 0, i_declick_attack, 1, i_duration, 1, i_declick_release, 0
; The envelope of the instrument is the product of the physical envelope times
; the declicking envelope.
a_envelope = aenvelope * a_declicking_envelope
; That envelope is then low-pass filtered to remove most discontinuities.
a_filtered_envelope tonex a_envelope, 40, 4
a_signal = a_signal * i_amplitude * a_filtered_envelope * k_gain *.001
print p1,p2,p3,p4,p5,p6,p7,p8
prints "Droner i %9.4f t %9.4f d %9.4f k %9.4f v %9.4f p %9.4f #%3d\n", p1, p2, p3, p4, p5, p7, active(p1)
a_out_left, a_out_right pan2 a_signal, k_space_left_to_right
outleta "outleft", a_out_left
outleta "outright", a_out_right
endin
gi_SeidelHarmOsc_tabsz init 2^16
gi_SeidelHarmOsc_Sin ftgen 0, 0, gi_SeidelHarmOsc_tabsz, 9, 1,1,0
gi_SeidelHarmOsc_Tri ftgen 0, 0, gi_SeidelHarmOsc_tabsz, 9, 1,1,0, 3,0.333,180, 5,0.2,0, 7,0.143,180, 9,0.111,0, 11,0.091,180, 13,0.077,0, 15,0.067,180, 17,0.059,0, 19,0.053,180, 21,0.048,0, 23,0.043,180, 25,0.04,0, 27,0.037,180, 29,0.034,0, 31,0.032,180
gi_SeidelHarmOsc_Saw ftgen 0, 0, gi_SeidelHarmOsc_tabsz, 7, 0, gi_SeidelHarmOsc_tabsz/2, 1, 0, -1, gi_SeidelHarmOsc_tabsz/2, 0
gi_SeidelHarmOsc_Square ftgen 0, 0, gi_SeidelHarmOsc_tabsz, 7, 1, gi_SeidelHarmOsc_tabsz/2, 1, 0, -1, gi_SeidelHarmOsc_tabsz/2, -1
gi_SeidelHarmOsc_Prime ftgen 0, 0, gi_SeidelHarmOsc_tabsz, 9, 1,1,0, 2,0.5,0, 3,0.3333,0, 5,0.2,0, 7,0.143,0, 11,0.0909,0, 13,0.077,0, 17,0.0588,0, 19,0.0526,0, 23,0.0435,0, 27,0.037,0, 31,0.032,180
gi_SeidelHarmOsc_Fib ftgen 0, 0, gi_SeidelHarmOsc_tabsz, 9, 1,1,0, 2,0.5,0, 3,0.3333,0, 5,0.2,0, 8,0.125,0, 13,0.0769,0, 21,0.0476,0, 34,0.0294,0 ;, 55,0.0182,0, 89,0.0112,0, 144,0.0069,0
gi_SeidelHarmOsc_NumTables = 5
gi_SeidelHarmOsc_List ftgen 1000, 0, gi_SeidelHarmOsc_NumTables, -2, gi_SeidelHarmOsc_Tri, gi_SeidelHarmOsc_Saw, gi_SeidelHarmOsc_Square, gi_SeidelHarmOsc_Prime, gi_SeidelHarmOsc_Fib, gi_SeidelHarmOsc_Sin
gi_SeidelHarmOsc_Morf ftgen 1001, 0, gi_SeidelHarmOsc_tabsz, 10, 1
gi_SeidelHarmOsc_lforabsz init 2^13
gi_SeidelHarmOsc_LfoTri ftgen 0, 0, gi_SeidelHarmOsc_lforabsz, 7, 0, gi_SeidelHarmOsc_lforabsz/4, 1, gi_SeidelHarmOsc_lforabsz/2, -1, gi_SeidelHarmOsc_lforabsz/4, 0
gk_SeidelHarmOsc_level chnexport "gk_SeidelHarmOsc_level", 3 ; 0
gi_SeidelHarmOsc_attack chnexport "gi_SeidelHarmOsc_attack", 3 ; 0.003
gi_SeidelHarmOsc_petals chnexport "gi_SeidelHarmOsc_petals", 3 ; 2.99
gi_SeidelHarmOsc_release chnexport "gi_SeidelHarmOsc_release", 3 ; 0.01
gk_SeidelHarmOsc_midi_dynamic_range chnexport "gk_SeidelHarmOsc_midi_dynamic_range", 3 ; 20
gk_SeidelHarmOsc_level init 0
gi_SeidelHarmOsc_attack init 0.003
gi_SeidelHarmOsc_petals init 2.99
gi_SeidelHarmOsc_release init 0.01
gk_SeidelHarmOsc_midi_dynamic_range init 20
gk_SeidelHarmOsc_P1 chnexport "gk_SeidelHarmOsc_P1", 3
gk_SeidelHarmOsc_IN1CON chnexport "gk_SeidelHarmOsc_IN1CON", 3
gk_SeidelHarmOsc_IN1C1 chnexport "gk_SeidelHarmOsc_IN1C1", 3
gk_SeidelHarmOsc_P1 init 0.1
gk_SeidelHarmOsc_IN1CON init 0.1
gk_SeidelHarmOsc_IN1C1 init 1
gk_SeidelHarmOsc_P2 chnexport "gk_SeidelHarmOsc_P2", 3
gk_SeidelHarmOsc_IN2C1 chnexport "gk_SeidelHarmOsc_IN2C1", 3
gk_SeidelHarmOsc_IN2CON chnexport "gk_SeidelHarmOsc_IN2CON", 3
gk_SeidelHarmOsc_P2 init 0.1
gk_SeidelHarmOsc_IN2C1 init 1
gk_SeidelHarmOsc_IN2CON init 0.1
gk_SeidelHarmOsc_P3 chnexport "gk_SeidelHarmOsc_P3", 3
gk_SeidelHarmOsc_IN3C1 chnexport "gk_SeidelHarmOsc_IN3C1", 3
gk_SeidelHarmOsc_IN3CON chnexport "gk_SeidelHarmOsc_IN3CON", 3
gk_SeidelHarmOsc_P3 init 0.1
gk_SeidelHarmOsc_IN3C1 init 1
gk_SeidelHarmOsc_IN3CON init 0.1
gk_SeidelHarmOsc_P4 chnexport "gk_SeidelHarmOsc_P4", 3
gk_SeidelHarmOsc_IN4C1 chnexport "gk_SeidelHarmOsc_IN4C1", 3
gk_SeidelHarmOsc_IN4CON chnexport "gk_SeidelHarmOsc_IN4CON", 3
gk_SeidelHarmOsc_P4 init 0.1
gk_SeidelHarmOsc_IN4C1 init 1
gk_SeidelHarmOsc_IN4CON init 0.1
gi_SeidelHarmOsc_pitch_bend_table ftgen 0, 0, 1024, -7, 1, 1024, 1
gi_SeidelHarmOsc_sine ftgen 0, 0, 65537, 10, 1
instr SeidelHarmOsc
i_instrument = p1
i_time = p2
i_sustain = p3
xtratim gi_SeidelHarmOsc_attack + gi_SeidelHarmOsc_release
i_midi_key = p4
i_midi_dynamic_range = i(gk_SeidelHarmOsc_midi_dynamic_range)
i_midi_velocity = p5 * i_midi_dynamic_range / 127 + (63.6 - i_midi_dynamic_range / 2)
// Spatial location is specified in Ambisonic coordinates.
k_space_front_to_back = p6
// AKA stereo pan.
k_space_left_to_right = p7
k_space_bottom_to_top = p8
i_phase = p9
i_frequency = cpsmidinn(i_midi_key)
// Adjust the following value until "overall amps" at the end of performance is about -6 dB.
i_level_correction = 87
i_normalization = ampdb(-i_level_correction) / 2
i_amplitude = ampdb(i_midi_velocity) * i_normalization
k_gain = ampdb(gk_SeidelHarmOsc_level)
; prints("p1=%f, p2=%f, p3=%f, p4=%f\n", p1, p2, p3, p4)
;;;kfreq chnget sprintf("FREQ%d", p4)
kfreq init i_frequency
kin1con init 0
kin2con init 0
kin3con init 0
kin4con init 0
koff init 0.001
koff1 init 0.001
koff2 init 2 * 0.001
koff3 init 3 * 0.001
koff4 init 5 * 0.001
koffa = scale2(gk_SeidelHarmOsc_P1, 0.001, 0.1, -10, 10)
if (gk_SeidelHarmOsc_IN1CON == 1) then
koffb = scale2(gk_SeidelHarmOsc_IN1C1, 0.001, 0.1, 0, 10)
koff = koffa + koffb
else
koff = koffa
endif
koff1 = koff
koff2 = 2 * koff
koff3 = 3 * koff
koff4 = 5 * koff
itbl = gi_SeidelHarmOsc_Morf
kndx init 0
kndxa = scale2(gk_SeidelHarmOsc_P2, 0, gi_SeidelHarmOsc_NumTables-1.01, -10, 10)
if (gk_SeidelHarmOsc_IN2CON == 1) then
kndxb = scale2(gk_SeidelHarmOsc_IN2C1, 0, gi_SeidelHarmOsc_NumTables-1.01, 0, 10)
kndx = kndxa + kndxb
else
kndx = kndxa
endif
ftmorf kndx, gi_SeidelHarmOsc_List, gi_SeidelHarmOsc_Morf
kamp init 0.8/9
; a1 oscil3 kamp, kfreq, itbl
a2 oscil3 kamp, kfreq+koff1, itbl
a3 oscil3 kamp, kfreq+koff2, itbl
a4 oscil3 kamp, kfreq+koff3, itbl
a5 oscil3 kamp, kfreq+koff4, itbl
a6 oscil3 kamp, kfreq-koff1, itbl
a7 oscil3 kamp, kfreq-koff2, itbl
a8 oscil3 kamp, kfreq-koff3, itbl
a9 oscil3 kamp, kfreq-koff4, itbl
kdst init 0
kdsta = scale2(gk_SeidelHarmOsc_P3, 0, 10, -10, 10)
if (gk_SeidelHarmOsc_IN3CON == 1) then
kdstb = scale2(gk_SeidelHarmOsc_IN3C1, 0, 10, 0, 10)
kdst = kdsta + kdstb
else
kdst = kdsta
endif
aL = a2+a4+a6+a8
aR = a3+a5+a7+a9
aoutL = aL + distort1(aL, kdst, 0.1, 0, 0)
aoutR = aR + distort1(aR, kdst, 0.1, 0, 0)
kpana = scale2(gk_SeidelHarmOsc_P4, 0, 7, -10, 10)
if (gk_SeidelHarmOsc_IN4CON == 1) then
kpanb = scale2(gk_SeidelHarmOsc_IN4C1, 0, 5, 0, 10)
kpan = kpana + kpanb
else
kpan = kpana
endif
if (kpan == 0) then
kext = 0
else
kext = 0.1
endif
klfoL oscili 0.49, kpan-kext, gi_SeidelHarmOsc_LfoTri, 90
klfoR oscili 0.49, kpan+kext, gi_SeidelHarmOsc_LfoTri, 270
klfoL += 0.5
klfoR += 0.5
aoutL1, aoutR1 pan2 aoutL, klfoL
aoutL2, aoutR2 pan2 aoutR, klfoR
aoutL = aoutL1+aoutL2
aoutR = aoutR1+aoutR2
aenv madsr 0.07,0,1,0.7
a_out_left = aoutL * aenv * k_gain * i_amplitude
a_out_right = aoutR * aenv * k_gain * i_amplitude
;;; outs aoutL*aenv, aoutR*aenv
;;; a_out_left, a_out_right pan2 a_signal, k_space_left_to_right
prints "SeidelHarmOsc i %9.4f t %9.4f d %9.4f k %9.4f v %9.4f p %9.4f #%3d\n", p1, p2, p3, p4, p5, p7, active(p1)
outleta "outleft", a_out_left
outleta "outright", a_out_right
endin
gk_Shiner_midi_dynamic_range chnexport "gk_Shiner_midi_dynamic_range", 3 ; 127
gk_Shiner_attack chnexport "gk_Shiner_attack", 3 ; .0125
gk_Shiner_release chnexport "gk_Shiner_release", 3 ; .0125
gk_Shiner_level chnexport "gk_Shiner_level", 3 ; 0.5
gk_Shiner_midi_dynamic_range init 20
gk_Shiner_attack init .0125
gk_Shiner_release init .0125
gk_Shiner_level init 0
gk_Shiner_front_to_back chnexport "gk_Shiner_front_to_back", 3 ; 0
gk_Shiner_left_to_right chnexport "gk_Shiner_left_to_right", 3 ; 0.5
gk_Shiner_bottom_to_top chnexport "gk_Shiner_bottom_to_top", 3 ; 0
gk_Shiner_front_to_back init 0
gk_Shiner_left_to_right init 0.5
gk_Shiner_bottom_to_top init 0
instr Shiner
i_instrument = p1
i_time = p2
; Make indefinite notes last no longer than the physical decay.
i_physical_decay = 20
if p3 == -1 then
i_duration = i_physical_decay
else
i_duration = p3
endif
i_midi_key = p4
i_midi_dynamic_range = i(gk_Shiner_midi_dynamic_range)
i_midi_velocity = p5 * i_midi_dynamic_range / 127 + (63.5 - i_midi_dynamic_range / 2)
k_space_front_to_back = p6
if p7 ==0 then
k_space_left_to_right = gk_Shiner_left_to_right
else
k_space_left_to_right = p7
endif
k_space_bottom_to_top = p8
i_phase = p9
i_frequency = cpsmidinn(i_midi_key)
; Adjust the following value until "overall amps" at the end of performance is about -6 dB.
i_level_correction = 42.5
i_normalization = ampdb(-i_level_correction) / 2
i_amplitude = ampdb(i_midi_velocity) * i_normalization
k_gain = ampdb(gk_Shiner_level)
iattack = i(gk_Shiner_attack)
idecay = i(gk_Shiner_release)
isustain = i_duration
a_physical_envelope transeg 0.0, iattack / 2.0, 1.5, i_amplitude / 2.0, iattack / 2.0, -1.5, i_amplitude, isustain, 0.0, i_amplitude, idecay / 2.0, 1.5, i_amplitude / 2.0, idecay / 2.0, -1.5, 0
ihertz = cpsmidinn(i_midi_key)
gk_Harmonics = 1 * 20
a_signal vco2 4, ihertz, 12
kgain = ampdb(gk_Shiner_level) * .5
; The end of the note must be extended _past_ the end of the release segment.
xtratim 1
a_declicking_envelope cossegr 0, .005, 1, i_duration, 1, .01, 0
; The envelope of the instrument is the product of the physical envelope times
; the declicking envelope.
a_envelope = a_physical_envelope * a_declicking_envelope
; That envelope is then low-pass filtered to remove most discontinuities.
a_filtered_envelope tonex a_envelope, 40, 4
a_signal = a_signal * i_amplitude * a_filtered_envelope * k_gain *.001
prints "Shiner i %9.4f t %9.4f d %9.4f k %9.4f v %9.4f p %9.4f #%3d\n", p1, p2, p3, p4, p5, p7, active(p1)
a_out_left, a_out_right pan2 a_signal, k_space_left_to_right
outleta "outleft", a_out_left
outleta "outright", a_out_right
endin
gk_Xing_level chnexport "gk_Xing_level", 3
gk_Xing_level init 0
gi_Xing_isine ftgen 0, 0, 65537, 10, 1
instr Xing
; Author: Andrew Horner
i_instrument = p1
i_time = p2
i_duration = p3
i_midi_key = p4
i_midi_velocity = p5
k_space_front_to_back = p6
k_space_left_to_right = p7
k_space_bottom_to_top = p8
i_phase = p9
i_overall_amps = 75
i_normalization = ampdb(-i_overall_amps) / 2
i_amplitude = ampdb(i_midi_velocity) * i_normalization