-
Notifications
You must be signed in to change notification settings - Fork 1
/
cloud_music_no_11.html
2724 lines (2534 loc) · 121 KB
/
cloud_music_no_11.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='cache-control' content='no-cache'>
<meta http-equiv='expires' content='0'>
<meta http-equiv='pragma' content='no-cache'>
<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 ChordPatterns 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>
</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.INFORMATION);
csac.diagnostic('This is a NEVER notification\n', csac.NEVER);
csac.diagnostic('This is a DEBUG notification\n', csac.DEBUG);
csac.diagnostic('This is an INFORMATION notification\n', csac.INFORMATION);
csac.diagnostic('This is a WARNING notification\n', csac.WARNING);
csac.diagnostic('This is an ERROR notification\n', csac.ERROR);
csac.diagnostic('This is an ALWAYS notification\n', csac.ALWAYS);
/**
* Classes can be used to define stateful Patterns; such classes can have an
* 'evaluate' method that sets a 'value' property, which could be of any type.
* Using classes makes it easy to encapsulate different collections of state.
*/
class LogisticPattern extends csac.StatefulPatterns {
constructor(c = .888, y = .5) {
super();
this.registerPatterns();
// Initial values.
this.c = c;
this.y = y;
this.midi_key = 36;
this.counter = 0;
}
/**
* Patternify the 'c' coefficient of the logistic equation.
*/
Logistic(is_onset, c, hap) {
if (is_onset) {
// This has been invoked from a trigger and should update state.
this.c = c;
let y1 = 4 * this.c * this.y * (1 - this.y);
this.midi_key = Math.round(y1 * 36 + 36);
this.y = y1;
hap.value = this.midi_key;
this.counter = this.counter + 1;
csac.print_counter('Logistic onset', this.counter, hap);
}
hap.value = this.midi_key;
///csac.print_counter('Logistic value', this.counter, hap);
return hap;
}
}
let logisticInstance = new LogisticPattern();
let GM = csac.Chord('GM');
let chordPattern = new csac.ChordPatterns(GM);
pure(0)
.fast(32)
.Logistic(logisticInstance, ".888")
.acC(chordPattern, "<CM7 Dm7 Em7 G7>/3").slow(2)
// This pattern should be very clearly audible.
.acCT(chordPattern, "0 1 2 3 4 -10".slow(12)).slow(2)
.acCV(chordPattern)
.note()
.legato("2")
.pianoroll({labels:1,fold:0,scaleauto:1,fill:0,stroke:1,fillActive:1,cycles:32,playhead:.9})
.csoundn("5")
-->
</strudel-repl-component>
<!-- END define "Strudel" overlay. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -->
<div id="controls_view" class="w3-container" style="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. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -->
<tr style="height:1em;"></tr>
<tr>
<td>
<label for=gk_Guitar_level> 1 Guitar level</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=21 id=gk_Guitar_level step=.001>
<td>
<output for=gk_Guitar_level id=gk_Guitar_level_output>21</output>
</tr>
<tr>
<td>
<label for=gk_FilteredSines_level> 2 FilteredSines level</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=3 id=gk_FilteredSines_level
step=.001>
<td>
<output for=gk_FilteredSines_level id=gk_FilteredSines_level_output>3</output>
</tr>
<tr>
<td>
<label for=gk_Blower_level> 3 Blower level</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=-5 id=gk_Blower_level step=.001>
<td>
<output for=gk_Blower_level id=gk_Blower_level_output>-5</output>
</tr>
<tr>
<td>
<label for=gk_Sweeper_level> 4 Sweeper level</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=-1 id=gk_Sweeper_level
step=.001>
<td>
<output for=gk_Sweeper_level id=gk_Sweeper_level_output>-1</output>
</tr>
<tr>
<td>
<label for=gk_Plucked_level> 5 Plucked level</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=15 id=gk_Plucked_level
step=.001>
<td>
<output for=gk_Plucked_level id=gk_Plucked_level_output>15</output>
</tr>
<tr>
<td>
<label for=gk_FMWaterBell_level> 6 FM Water Bell level</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=7 id=gk_FMWaterBell_level
step=.001>
<td>
<output for=gk_FMWaterBell_level id=gk_FMWaterBell_level_output>7</output>
</tr>
<tr>
<td>
<label for=gk_YiString_level> 7 Yi String level</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=-5 id=gk_YiString_level
step=.001>
<td>
<output for=gk_YiString_level id=gk_YiString_level_output>-5</output>
</tr>
<tr>
<td>
<label for=gk_Harpsichord_level> 8 Harpsichord level</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> 9 Zakian Flute level</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=2.5 id=gk_ZakianFlute_level
step=.001>
<td>
<output for=gk_ZakianFlute_level id=gk_ZakianFlute_level_output>2.5</output>
</tr>
<tr>
<td>
<label for=gk_Kung4_level>10 Kung instrument 4 level</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=-8 id=gk_Kung4_level step=.001>
<td>
<output for=gk_Kung4_level id=gk_Kung4_level_output>-8</output>
</tr>
<tr>
<td>
<label for=gk_Kung2_level>11 Kung instrument 2 level</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=-8 id=gk_Kung2_level step=.001>
<td>
<output for=gk_Kung2_level id=gk_Kung2_level_output>-8</output>
</tr>
<tr>
<td>
<label for=gk_Bower_level>12 Bower level</label>
<td>
<input class=persistent-element type=range min=-40 max=40 value=-8 id=gk_Bower_level step=.001>
<td>
<output for=gk_Bower_level id=gk_Bower_level_output>-8</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=.83 id=gk_ReverbSC_feedback
step=.001>
<td>
<output for=gk_ReverbSC_feedback id=gk_ReverbSC_feedback_output>.83</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=10000
id=gk_ReverbSC_frequency_cutoff step=.001>
<td>
<output for=gk_ReverbSC_frequency_cutoff id=gk_ReverbSC_frequency_cutoff_output>1000</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=.05 id=gi_ReverbSC_delay_modulation
step=.001>
<td>
<output for=gi_ReverbSC_delay_modulation id=gi_ReverbSC_delay_modulation_output>.05</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=0 id=gk_MasterOutput_level
step=.001>
<td>
<output for=gk_MasterOutput_level id=gk_MasterOutput_level_output>0</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-left:53px;">
</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>CsoundAC Example No. 3 ChordPatterns</h1>
<h3>Michael Gogins<br>
August 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 an online piece of electroacoustic music, rendered in your Web
browser using high-resolution audio. It will play indefinitely, never ending,
always changing. The piece demonstrates and tests all the Patterns implemented
in the ScalePatterns class found in csoundac.mjs.
<p>The notes in this piece are generated by
<a href="https://strudel.tidalcycles.org/">Strudel</a>, a JavaScript
implementation of Strudel Cycles, which is accessed from a REPL embedded
in this piece -- use the Strudel button to view the Strudel REPL. The user can
edit the Strudel code that generates the score, and click on the update button
to hear it. Thanks to Felix Roos for helpful hints along the way. Strudel
sends its notes to Csound for synthesis.
<p>The notes are played by a Csound orchestra that is embedded in this Web
page using my <a href="https://github.com/gogins/csound-wasm">WebAssembly
build of Csound</a>. This in turn includes my
<a href="https://github.com/gogins/csound-ac">CsoundAC</a> library for
algorithmic composition.
<p>The synthesized audio is then sampled (using a WebAudio Analyzer) to generate
a sine-wave visualization of the music.
<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 adapted from <a href="https://www.shadertoy.com/view/4ljGD1"><b><i>Sound
Sinus Wave</i></b></a>
by <a href="https://www.shadertoy.com/user/Eitraz">Eitraz</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
connect "Blower", "outleft", "ReverbSC", "inleft"
connect "Blower", "outright", "ReverbSC", "inright"
connect "Bower", "outleft", "ReverbSC", "inleft"
connect "Bower", "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 "Sweeper", "outleft", "ReverbSC", "inleft"
connect "Sweeper", "outright", "ReverbSC", "inright"
connect "YiString", "outleft", "ReverbSC", "inleft"
connect "YiString", "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_Guitar_midi_dynamic_range chnexport "gk_Guitar_midi_dynamic_range", 3 ; 127
gk_Guitar_midi_dynamic_range init 30
gk_Guitar_level chnexport "gk_Guitar_level", 3
gk_Guitar_level init 0
gk_Guitar_space_left_to_right chnexport "gk_Guitar_space_left_to_right", 3
gk_Guitar_space_left_to_right init .5
instr Guitar
; Michael Gogins
; Simple emulation of a Spanish guitar.
; Considerably cleaned up after close listening and systematic testing.
; But I think the plain `pluck` opcode is inherently a bit noisy. The
; waveform is just jagged at first.
i_instrument = p1
i_time = p2
; Make indefinite notes last no longer than the physical decay.
i_physical_decay = 60
if p3 == -1 then
i_duration = i_physical_decay
else
i_duration = p3
endif
i_midi_key = p4
i_midi_dynamic_range = i(gk_Guitar_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_Guitar_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_level_correction = 73
i_normalization = ampdb(-i_level_correction) / 2
i_amplitude = ampdb(i_midi_velocity) * i_normalization
k_gain = ampdb(gk_Guitar_level)
i_frequency2 = i_frequency
a_signal pluck 1.0, i_frequency, i_frequency2, 0, 6
a_top_body reson a_signal, 110, 80
a_bottom_body reson a_signal, 220, 100
a_whole_body reson a_signal, 440, 80
a_signal = (.6 * a_top_body + .8 * a_bottom_body + .6 * a_whole_body + .4 * a_signal)
; For testing envelopes with a simple signal that lacks confounding artifacts.
; a_signal oscils .1, i_frequency2, 0
; For testing envelopes with a DC signal (shows only the envelope).
; a_signal = .25
; 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 = .003
i_attack = .001 / i_frequency + i_declick_minimum
i_exponent = 7
a_physical_envelope transeg 0, i_attack, i_exponent, 1, i_physical_decay, -i_exponent, .2
; 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 = i_attack
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, 40, 4
a_signal = a_signal * i_amplitude * a_filtered_envelope * k_gain *.001
#ifdef USE_SPATIALIZATION
a_spatial_reverb_send init 0
a_bsignal[] init 16
a_bsignal, a_spatial_reverb_send Spatialize a_signal, k_space_front_to_back, k_space_left_to_right, k_space_bottom_to_top
outletv "outbformat", a_bsignal
outleta "out", a_spatial_reverb_send
#else
a_out_left, a_out_right pan2 a_signal, k_space_left_to_right
outleta "outleft", a_out_left
outleta "outright", a_out_right
#endif
prints "%-24s i %9.4f t %9.4f d %9.4f k %9.4f v %9.4f p %9.4f #%3d\n", nstrstr(p1), p1, p2, p3, p4, p5, p7, active(p1)
endin
gk_FilteredSines_level chnexport "gk_FilteredSines_level", 3
gi_FilteredSines_attack chnexport "gi_FilteredSines_attack", 3
gi_FilteredSines_release chnexport "gi_FilteredSines_release", 3
gk_FilteredSines_level init 0
gi_FilteredSines_attack init 1
gi_FilteredSines_release init 1
gi_FilteredSines_bergeman ftgen 0, 0, 65537, 10, .28, 1, .74, .66, .78, .48, .05, .33, 0.12, .08, .01, .54, 0.19, .08, .05, 0.16, .01, 0.11, .3, .02, 0.2 ; Bergeman f1
instr FilteredSines
; Author: Michael Bergeman
; Modified by: Michael Gogins
xtratim gi_FilteredSines_attack + gi_FilteredSines_release
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 = 166
i_normalization = ampdb(-i_overall_amps) / 2
i_amplitude = ampdb(i_midi_velocity) * i_normalization
i_frequency = cpsmidinn(i_midi_key)
k_gain = ampdb(gk_FilteredSines_level)
kHz = k(i_frequency)
koctave = octcps(kHz)
iattack init gi_FilteredSines_attack
isustain init p3
irelease init gi_FilteredSines_release
idb = 1.5
ip5 = gi_FilteredSines_bergeman
ip3 = 5.0
ip6 = 0.9
ip7 = 1.4
kp8 = cpsoct(koctave - .01)
kp9 = cpsoct(koctave + .01)
isc = idb * .333
k1 linseg 40, ip3, 800, p3, 800, 0.06, 0.0
k2 linseg 440, ip3, 220, p3, 220, 0.06, 0.0
k3 linseg 0.0, ip6, 800, ip7, 200.0, p3, 200, 0.06, 0.0
k4 linseg 800, ip3, 40, p3, 40, 0.06, 0.0
k5 linseg 220, ip3, 440, p3, 440, 0.06, 0.0
k6 linseg isc, ip6, p3, ip7, p3, 0.06, 0.0
k7 linseg 0.0, ip6, 1, ip7, .3, p3, .1, 0.06, 0.0
a5 poscil k3, kp8, ip5
a6 poscil k3, kp8 * 0.999, ip5
a7 poscil k3, kp8 * 1.001, ip5
a1 = a5 + a6 + a7
a8 poscil k6, kp9, ip5
a9 poscil k6, kp9 * 0.999, ip5
a10 poscil k6, kp9 * 1.001, ip5
a11 = a8 + a9 + a10
a2 butterbp a1, k1, 40
a3 butterbp a2, k5, k2 * 0.8
a4 balance a3, a1
a12 butterbp a11, k4, 40
a13 butterbp a12, k2, k5 * 0.8
a14 balance a13, a11
a15 reverb2 a4, 5, 0.3
a16 reverb2 a4, 4, 0.2
a17 = (a15 + a4) * k7
a18 = (a16 + a4) * k7
a_signal = (a17 + a18)
i_attack = .002
i_sustain = p3
i_release = 0.01
xtratim (i_attack + i_release)
a_declicking linsegr 0, i_attack, 1, i_sustain, 1, i_release, 0
a_signal = a_signal * i_amplitude * a_declicking * k_gain * 1.88
#ifdef USE_SPATIALIZATION
a_spatial_reverb_send init 0
a_bsignal[] init 16
a_bsignal, a_spatial_reverb_send Spatialize a_signal, k_space_front_to_back, k_space_left_to_right, k_space_bottom_to_top
outletv "outbformat", a_bsignal
outleta "out", a_spatial_reverb_send
#else
a_out_left, a_out_right pan2 a_signal, k_space_left_to_right
outleta "outleft", a_out_left
outleta "outright", a_out_right
#endif
prints "%-24s i %9.4f t %9.4f d %9.4f k %9.4f v %9.4f p %9.4f #%3d\n", nstrstr(p1), p1, p2, p3, p4, p5, p7, active(p1)
endin
gk_Blower_grainDensity chnexport "gk_Blower_grainDensity", 3
gk_Blower_grainDuration chnexport "gk_Blower_grainDuration", 3
gk_Blower_grainAmplitudeRange chnexport "gk_Blower_grainAmplitudeRange", 3
gk_Blower_grainFrequencyRange chnexport "gk_Blower_grainFrequencyRange", 3
gk_Blower_level chnexport "gk_Blower_level", 3
gk_Blower_midi_dynamic_range chnexport "gk_Blower_midi_dynamic_range", 3
gk_Blower_grainDensity init 90
gk_Blower_grainDuration init 0.2
gk_Blower_grainAmplitudeRange init 100
gk_Blower_grainFrequencyRange init 10
gk_Blower_level init 0
gk_Blower_midi_dynamic_range init 20
gk_Blower_space_left_to_right chnexport "gk_Blower_space_left_to_right", 3
gk_Blower_space_left_to_right init .5
gi_Blower_grtab ftgen 0, 0, 65537, 10, 1, .3, .1, 0, .2, .02, 0, .1, .04
gi_Blower_wintab ftgen 0, 0, 65537, 10, 1, 0, .5, 0, .33, 0, .25, 0, .2, 0, .167
instr Blower
//////////////////////////////////////////////
// Original by Hans Mikelson.
// Adapted by Michael Gogins.
//////////////////////////////////////////////
i_instrument = p1
i_time = p2
i_duration = p3
i_midi_key = p4
i_midi_dynamic_range = i(gk_Blower_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_Blower_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_level_correction = 123
i_normalization = ampdb(-i_level_correction) / 2
i_amplitude = ampdb(i_midi_velocity) * i_normalization
k_gain = ampdb(gk_Blower_level)
iHz = i_frequency
ihertz = iHz
ip4 = i_amplitude
ip5 = iHz
ip6 = gi_Blower_grtab
ip7 = gi_Blower_wintab
ip8 = 0.033
ip8 = .002
ip9 = 150
ip9 = 100
ip10 = 1.6
ip10 = 3
idur = p3
iamp = i_amplitude ; p4
ifqc = iHz ; cpspch(p5)
igrtab = ip6
iwintab = ip7
ifrng = ip8
idens = ip9
ifade = ip10
igdur = 0.2
iattack = 0.5
i_sustain = p3
idecay = 1.5
xtratim iattack + idecay
kenvelope transegr 0.0, iattack / 2.0, 1.5, .5, iattack / 2.0, -1.5, 1, i_sustain, 0.0, 1, idecay / 2.0, 1.5, .5, idecay / 2.0, -1.5, 0
; kamp linseg 0, ifade, 1, idur - 2 * ifade, 1, ifade, 0
kamp = kenvelope
; Amp Fqc Dense AmpOff PitchOff GrDur GrTable WinTable MaxGrDur
aoutl grain ip4, ifqc, gk_Blower_grainDensity, gk_Blower_grainAmplitudeRange, gk_Blower_grainFrequencyRange, gk_Blower_grainDuration, igrtab, iwintab, 5
aoutr grain ip4, ifqc, gk_Blower_grainDensity, gk_Blower_grainAmplitudeRange, gk_Blower_grainFrequencyRange, gk_Blower_grainDuration, igrtab, iwintab, 5
a_signal = aoutl + aoutr
i_attack = .002
i_release = 0.01
xtratim i_attack + i_release
a_declicking linsegr 0, i_attack, 1, i_sustain, 1, i_release, 0
a_signal = a_signal * i_amplitude * a_declicking * k_gain
prints "%-24s i %9.4f t %9.4f d %9.4f k %9.4f v %9.4f p %9.4f #%3d\n", nstrstr(p1), p1, p2, p3, p4, p5, p7, active(p1)
#ifdef USE_SPATIALIZATION
a_spatial_reverb_send init 0
a_bsignal[] init 16
a_bsignal, a_spatial_reverb_send Spatialize a_signal, k_space_front_to_back, k_space_left_to_right, k_space_bottom_to_top
outletv "outbformat", a_bsignal
outleta "out", a_spatial_reverb_send
#else
a_out_left, a_out_right pan2 a_signal, k_space_left_to_right
outleta "outleft", a_out_left
outleta "outright", a_out_right
#endif
;printks "Blower i %9.4f t %9.4f d %9.4f k %9.4f v %9.4f p %9.4f #%3d l%9.4f r%9.4f\n", 1, p1, p2, p3, p4, p5, p7, active(p1), dbamp(rms(a_out_left)), dbamp(rms(a_out_right))
endin
gk_Sweeper_midi_dynamic_range chnexport "gk_Sweeper_midi_dynamic_range", 3 ; 127
gk_Sweeper_attack chnexport "gk_Sweeper_attack", 3 ; .125
gk_Sweeper_release chnexport "gk_Sweeper_release", 3 ; .25
gk_Sweeper_britel chnexport "gk_Sweeper_britel", 3 ; 0.1
gk_Sweeper_briteh chnexport "gk_Sweeper_briteh", 3 ; 2.9
gk_Sweeper_britels chnexport "gk_Sweeper_britels", 3 ; 2
gk_Sweeper_britehs chnexport "gk_Sweeper_britehs", 3 ; 1
gk_Sweeper_level chnexport "gk_Sweeper_level", 3 ; 0
gk_Sweeper_midi_dynamic_range init 20
gk_Sweeper_attack init .125
gk_Sweeper_release init .25
gk_Sweeper_britel init .05
gk_Sweeper_briteh init 4
gk_Sweeper_britels init .25
gk_Sweeper_britehs init .5
gk_Sweeper_level init 0
gk_Sweeper_space_left_to_right chnexport "gk_Sweeper_space_left_to_right", 3
gk_Sweeper_space_left_to_right init .5
gi_Sweeper_sine ftgen 0, 0, 65537, 10, 1
gi_Sweeper_octfn ftgen 0, 0, 65537, -19, 1, 0.5, 270, 0.5
instr Sweeper
//////////////////////////////////////////////
// Original by Iain McCurdy.
// Adapted by Michael Gogins.
//////////////////////////////////////////////
i_instrument = p1
i_time = p2
i_duration = p3
i_midi_key = p4
i_midi_dynamic_range = i(gk_Sweeper_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_Sweeper_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_level_correction = 34.2
i_normalization = ampdb(-i_level_correction) / 2
i_amplitude = ampdb(i_midi_velocity) * i_normalization
k_gain = ampdb(gk_Sweeper_level)
iattack = i(gk_Sweeper_attack)
irelease = i(gk_Sweeper_release)
isustain = p3
kenvelope transegr 0.0, iattack / 2.0, 1.5, i_amplitude / 2.0, iattack / 2.0, -1.5, i_amplitude, isustain, 0.0, i_amplitude, irelease / 2.0, 1.5, i_amplitude / 2.0, irelease / 2.0, -1.5, 0
ihertz = i_frequency
icps = ihertz
kamp expseg 0.001,0.02,0.2,p3-0.01,0.001
ktonemoddep jspline 0.01,0.05,0.2
ktonemodrte jspline 6,0.1,0.2
ktone poscil3 ktonemoddep, ktonemodrte, gi_Sweeper_sine
kbrite rspline gk_Sweeper_britel, gk_Sweeper_briteh, gk_Sweeper_britels, gk_Sweeper_britehs
ibasfreq init icps
ioctcnt init 3
iphs init 0
a1 hsboscil kenvelope, ktone, kbrite, ibasfreq, gi_Sweeper_sine, gi_Sweeper_octfn, ioctcnt, iphs
amod poscil3 0.25, ibasfreq*(1/3), gi_Sweeper_sine
arm = a1*amod
kmix expseg 0.001, 0.01, rnd(1), rnd(3)+0.3, 0.001
kmix=.25
a1 ntrpol a1, arm, kmix
kpanrte jspline 5, 0.05, 0.1
kpandep jspline 0.9, 0.2, 0.4
kpan poscil3 kpandep, kpanrte, gi_Sweeper_sine
;a1,a2 pan2 a1, kpan
a1,a2 pan2 a1, k_space_left_to_right
aleft delay a1, rnd(0.1)
aright delay a2, rnd(0.11)
a_signal = (aleft + aright)
; 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 = .003
i_attack = .001 / i_frequency + i_declick_minimum
i_declick_attack = i_attack
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_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 "%-24s i %9.4f t %9.4f d %9.4f k %9.4f v %9.4f p %9.4f #%3d\n", nstrstr(p1), p1, p2, p3, p4, p5, p7, active(p1)
#ifdef USE_SPATIALIZATION
a_spatial_reverb_send init 0
a_bsignal[] init 16
a_bsignal, a_spatial_reverb_send Spatialize a_signal, k_space_front_to_back, k_space_left_to_right, k_space_bottom_to_top
outletv "outbformat", a_bsignal
outleta "out", a_spatial_reverb_send
#else
a_out_left, a_out_right pan2 a_signal, k_space_left_to_right
outleta "outleft", a_out_left
outleta "outright", a_out_right
outs a_out_left, a_out_right
#endif
endin
gk_Plucked_midi_dynamic_range chnexport "gk_Plucked_midi_dynamic_range", 3 ; 127
gk_Plucked_midi_dynamic_range init 30
gk_Plucked_space_left_to_right chnexport "gk_Plucked_space_left_to_right", 3
gk_Plucked_space_left_to_right init .5
gk_Plucked_level chnexport "gk_Plucked_level", 3
gk_Plucked_level init 50
gi_Plucked_sine ftgen 0, 0, 65537, 10, 1
instr Plucked
; Author: Michael Gogins
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_Plucked_midi_dynamic_range)
i_midi_velocity = p5 ;* i_midi_dynamic_range / 127 + (63.5 - i_midi_dynamic_range / 2)
i_midi_velocity ampmidid i_midi_velocity, i_midi_dynamic_range
k_space_front_to_back = p6
if p7 == 0 then
k_space_left_to_right = gk_Plucked_space_left_to_right
else
k_space_left_to_right = p7
endif
k_space_bottom_to_top = p8
i_phase = p9
i_detune_cents = 1.5
i_detune = i_detune_cents / 100
i_frequency1 = cpsmidinn(i_midi_key - i_detune)
i_frequency2 = cpsmidinn(i_midi_key)
i_frequency3 = cpsmidinn(i_midi_key + i_detune)
; Adjust the following value until "overall amps" at the end of performance is about -6 dB.
i_overall_amps = 26
i_normalization = ampdb(-(i_overall_amps)) / 2
i_amplitude = ampdb(i_midi_velocity) * i_normalization
k_gain = ampdb(gk_Plucked_level)
asignal1 wgpluck2 0.1, 1.0, i_frequency1, 0.25, 0.222
asignal2 wgpluck2 0.1, 1.0, i_frequency2, 0.20, 0.223
asignal3 wgpluck2 0.1, 1.0, i_frequency3, 0.23, 0.225
a_signal = (asignal1 + asignal2 + asignal3)
; As with most instruments that are based upon an impulse delivered to a
; resonator, there are two envelopes, one for the physical decay with a
; fixed release ending at zero, and one with a release segment to remove
; clicks from the attack and release.
;
; 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_frequency2 + i_declick_minimum
i_exponent = 7
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 = i_attack
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, 40, 4
a_signal = a_signal * i_amplitude * a_filtered_envelope * k_gain
#ifdef USE_SPATIALIZATION
a_spatial_reverb_send init 0
a_bsignal[] init 16
a_bsignal, a_spatial_reverb_send Spatialize a_signal, k_space_front_to_back, k_space_left_to_right, k_space_bottom_to_top
outletv "outbformat", a_bsignal
outleta "out", a_spatial_reverb_send
#else
a_out_left, a_out_right pan2 a_signal, k_space_left_to_right
outleta "outleft", a_out_left
outleta "outright", a_out_right
#endif
prints "%-24s i %9.4f t %9.4f d %9.4f k %9.4f v %9.4f p %9.4f #%3d\n", nstrstr(p1), p1, p2, p3, p4, p5, p7, active(p1)
endin
//////////////////////////////////////////////
// Original by Steven Yi.
// Adapted by Michael Gogins.
//////////////////////////////////////////////
gk_FMWaterBell_level chnexport "gk_FMWaterBell_level", 3 ; 0
gi_FMWaterBell_attack chnexport "gi_FMWaterBell_attack", 3 ; 0.002
gi_FMWaterBell_release chnexport "gi_FMWaterBell_release", 3 ; 0.01
gi_FMWaterBell_sustain chnexport "gi_FMWaterBell_sustain", 3 ; 20
gi_FMWaterBell_sustain_level chnexport "gi_FMWaterBell_sustain_level", 3 ; .1
gk_FMWaterBell_index chnexport "gk_FMWaterBell_index", 3 ; .5
gk_FMWaterBell_crossfade chnexport "gk_FMWaterBell_crossfade", 3 ; .5
gk_FMWaterBell_vibrato_depth chnexport "gk_FMWaterBell_vibrato_depth", 3 ; 0.05
gk_FMWaterBell_vibrato_rate chnexport "gk_FMWaterBell_vibrato_rate", 3 ; 6
gk_FMWaterBell_midi_dynamic_range chnexport "gk_FMWaterBell_midi_dynamic_range", 3 ; 20
gk_FMWaterBell_level init -8
gi_FMWaterBell_attack init 0.002
gi_FMWaterBell_release init 0.01
gi_FMWaterBell_sustain init 20
gi_FMWaterBell_sustain_level init .1
gk_FMWaterBell_index init .5
gk_FMWaterBell_crossfade init .5
gk_FMWaterBell_vibrato_depth init 0.05
gk_FMWaterBell_vibrato_rate init 6
gk_FMWaterBell_midi_dynamic_range init 20
gk_FMWaterBell_space_left_to_right chnexport "gk_FMWaterBell_space_left_to_right", 3
gk_FMWaterBell_space_left_to_right init .5
gi_FMWaterBell_cosine ftgen 0, 0, 65537, 11, 1
instr FMWaterBell
i_instrument = p1
i_time = p2
i_duration = p3
; One of the envelopes in this instrument should be releasing, and use this:
i_sustain = 1000
xtratim gi_FMWaterBell_attack + gi_FMWaterBell_release
i_midi_key = p4
i_midi_dynamic_range = i(gk_FMWaterBell_midi_dynamic_range)
i_midi_velocity = p5 * i_midi_dynamic_range / 127 + (63.6 - i_midi_dynamic_range / 2)
k_space_front_to_back = p6