/
clm-ins.fs
4192 lines (4053 loc) · 135 KB
/
clm-ins.fs
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
\ clm-ins.fs -- clm-ins.scm|rb -> clm-ins.fs
\ Translator/Author: Michael Scholz <mi-scholz@users.sourceforge.net>
\ Created: 06/02/03 10:36:51
\ Changed: 17/12/22 07:52:33
\
\ @(#)clm-ins.fs 1.51 12/22/17
\ jc-reverb ( keyword-args -- )
\ violin ( start dur freq amp keyword-args -- )
\ fm-violin ( start dur freq amp keyword-args -- )
\
\ clm-ins.scm|rb instruments
\
\ pluck ( start dur freq amp :optional weighting lossfact -- )
\ vox ( start dur freq amp ampfun freqfun freqscl ... -- )
\ fofins ( start dur freq amp vib f0 a0 f1 a1 f2 a2 :optional ae ve -- )
\ fm-trumpet ( start dur keyword-args -- )
\ pqw-vox ( start dur freq spacing-freq amp ampfun freqfun ... -- )
\ stereo-flute ( start dur freq flow keyword-args -- )
\ fm-bell ( start dur freq amp :optional amp-env index-env index -- )
\ fm-insect ( start dur freq amp amp-env ... -- )
\ fm-drum ( start dur freq amp index :optional high degr dist rev-amt -- )
\ gong ( start dur freq amp -- )
\ attract ( start dur amp c -- )
\ pqw ( start dur sfreq cfreq amp ampfun indexfun parts -- )
\ tubebell ( start dur freq amp :optional base --)
\ wurley ( start dur freq amp -- )
\ rhodey ( start dur freq amp :optional base -- )
\ hammondoid ( start dur freq amp -- )
\ metal ( start dur freq amp -- )
\ drone ( start dur freq amp ampfun synth ampat ampdc ... -- )
\ canter ( start dur pitch amp ampfun ranfun skewfun ... -- )
\ nrev ( keyword-args -- )
\ reson ( start dur pitch amp indxfun skewfun ... -- )
\ cellon ( start dur pitch0 amp ampfun betafun ... -- )
\ jl-reverb ( keyword-args -- )
\ gran-synth ( start dur freq grain-dur interval amp -- )
\ touch-tone ( numbers keyword-args -- )
\ spectra ( start dur freq amp :optional ... -- )
\ two-tab ( start dur freq amp :optional ... -- )
\ lbj-piano ( start dur freq amp -- )
\ resflt ( start dur driver ... -- )
\ scratch-ins ( start file src-ratio turntable -- )
\ pins ( file start dur keyword-args -- )
\ zc ( start dur freq amp len1 len2 feedback -- )
\ zn ( start dur freq amp len1 len2 feedforward -- )
\ za ( start dur freq amp len1 len2 fb ffw -- )
\ clm-expsrc ( start dur in-file exp-ratio src-ratio amp :optional ... -- )
\ exp-snd ( file start dur amp :optional ... -- )
\ expfil ( start dur hopsecs rampsecs steadysecs file1 file2 -- )
\ graph-eq ( file start dur keyword-args -- )
\ anoi ( fname start dur :optional fftsize amp-scaler R -- )
\ fullmix ( in-file :optional ... -- )
\ bes-fm ( start dur freq amp ratio index -- )
require clm
require env
\ General input function for src, granulate etc.
: readin-cb { gen -- prc; dir self -- val }
1 proc-create ( prc )
gen ,
does> { dir self -- val }
self @ ( gen ) readin
;
hide
: (jc-reverb-simple) { flts allpasses combs volume dur -- }
flts length 1 = if
flts 0 array-ref { gen }
dur run-reverb ( in-val )
allpasses swap all-pass-bank ( val )
combs swap comb-bank ( val )
volume f* ( val )
gen swap 0.0 delay ( samp )
end-run-reverb-out-1
else
flts 0 array-ref { gen1 }
flts 1 array-ref { gen2 }
0.0 { val }
dur run-reverb ( in-val )
allpasses swap all-pass-bank ( val )
combs swap comb-bank ( val )
volume f* to val
gen2 val 0.0 delay ( samp2 )
gen1 val 0.0 delay ( samp1 samp2 )
end-run-reverb-out-2
then
;
: (jc-reverb-env) { envA flts allpasses combs volume dur -- }
flts length 1 = if
flts 0 array-ref { gen }
dur run-reverb ( in-val )
allpasses swap all-pass-bank ( val )
combs swap comb-bank ( val )
envA env f* ( val )
gen swap 0.0 delay ( samp )
end-run-reverb-out-1
else
flts 0 array-ref { gen1 }
flts 1 array-ref { gen2 }
0.0 { val }
dur run-reverb ( in-val )
allpasses swap all-pass-bank ( val )
combs swap comb-bank ( val )
envA env f* to val
gen2 val 0.0 delay ( samp2 )
gen1 val 0.0 delay ( samp1 samp2 )
end-run-reverb-out-2
then
;
: (jc-reverb-fir) { flt envA flts allpasses combs volume dur -- }
flts length 1 = if
flts 0 array-ref { gen }
dur run-reverb ( in-val )
allpasses swap all-pass-bank ( val )
combs swap comb-bank ( val )
flt swap fir-filter ( val )
envA env f* ( val )
gen swap 0.0 delay ( samp )
end-run-reverb-out-1
else
flts 0 array-ref { gen1 }
flts 1 array-ref { gen2 }
0.0 { val }
dur run-reverb ( in-val )
allpasses swap all-pass-bank ( val )
combs swap comb-bank ( val )
flt swap fir-filter ( val )
envA env f* to val
gen2 val 0.0 delay ( samp2 )
gen1 val 0.0 delay ( samp1 samp2 )
end-run-reverb-out-2
then
;
set-current
\ clm/jcrev.ins and snd/jcrev.scm
instrument: jc-reverb <{ :key low-pass #f volume 1.0 amp-env #f -- }>
doc" The Chowning reverb.\n\
0 1 440 0.2 <'> fm-violin :reverb <'> jc-reverb with-sound\n\
0 1 440 0.2 <'> fm-violin\n\
:reverb-data #( :low-pass #t ) :reverb <'> jc-reverb :channels 2 with-sound."
:feedback -0.7 :feedforward 0.7 :size 1051 make-all-pass { allpass1 }
:feedback -0.7 :feedforward 0.7 :size 337 make-all-pass { allpass2 }
:feedback -0.7 :feedforward 0.7 :size 113 make-all-pass { allpass3 }
:scaler 0.742 :size 4799 make-comb { comb1 }
:scaler 0.733 :size 4999 make-comb { comb2 }
:scaler 0.715 :size 5399 make-comb { comb3 }
:scaler 0.697 :size 5801 make-comb { comb4 }
*output* channels { chans }
*reverb* ws-framples samples->seconds *decay-time* f+ { dur }
chans 1 = if
\ XXX: Building arrays like this
\ #( :size 0.013 seconds->samples make-delay )
\ doesn't work well with keyword functions.
:size 0.013 seconds->samples make-delay { dl }
#( dl )
else
:size 0.013 seconds->samples make-delay { dl1 }
:size 0.011 seconds->samples make-delay { dl2 }
#( dl1 dl2 )
then { flts }
#( comb1 comb2 comb3 comb4 ) make-comb-bank { combs }
#( allpass1 allpass2 allpass3 ) make-all-pass-bank { allpasses }
amp-env low-pass || if
amp-env unless
'( 0 1 1 1 ) to amp-env
then
:envelope amp-env :scaler volume :duration dur make-env { envA }
low-pass if
3 vct( 0.25 0.5 0.25 ) make-fir-filter ( flt )
envA flts allpasses combs volume dur (jc-reverb-fir)
else
envA flts allpasses combs volume dur (jc-reverb-env)
then
else
flts allpasses combs volume dur (jc-reverb-simple)
then
;instrument
previous
\ snd/fm.html
instrument: violin <{ start dur freq amp :key
fm-index 1.0
amp-env #( 0 0 25 1 75 1 100 0 )
index-env #( 0 1 25 0.4 75 0.6 100 0 )
degree 0.0
distance 1.0
reverb-amount 0.01 -- }>
doc" Violin example from snd/fm.html.\n\
0 3 440 0.5 :fm-index 0.5 <'> violin with-sound"
freq hz->radians { frq-scl }
frq-scl fm-index f* { maxdev }
5.0 freq flog f/ maxdev f* { index1 }
8.5 freq flog f- 3.0 freq 1000.0 f/ f+ f/ maxdev 3.0 f* f* { index2 }
4.0 freq fsqrt f/ maxdev f* { index3 }
:frequency freq make-oscil { carrier }
:frequency freq make-oscil { fmosc1 }
:frequency freq 3.0 f* make-oscil { fmosc2 }
:frequency freq 4.0 f* make-oscil { fmosc3 }
:envelope amp-env :scaler amp :duration dur make-env { ampf }
:envelope index-env :scaler index1 :duration dur make-env { indf1 }
:envelope index-env :scaler index2 :duration dur make-env { indf2 }
:envelope index-env :scaler index3 :duration dur make-env { indf3 }
:frequency 5.0
:amplitude 0.0025 frq-scl f* make-triangle-wave { pervib }
:frequency 16.0
:amplitude 0.005 frq-scl f* make-rand-interp { ranvib }
start dur
#{ :degree degree :distance distance :reverb reverb-amount }
run-instrument
pervib 0.0 triangle-wave ranvib 0.0 rand-interp f+ { vib }
carrier vib
fmosc1 vib 0.0 oscil indf1 env f* f+
fmosc2 3.0 vib f* 0.0 oscil indf2 env f* f+
fmosc3 4.0 vib f* 0.0 oscil indf3 env f* f+
0.0 oscil ampf env f*
end-run
;instrument
: violin-test <{ :optional start 0.0 dur 1.0 -- }>
start now!
now@ dur 440 0.5 violin
dur 0.2 f+ step
;
\ === FM-Violin (clm/v.ins, snd/v.scm|rb) ===
instrument: fm-violin <{ start dur freq amp :key
fm-index 1.0
amp-env #( 0 0 25 1 75 1 100 0 )
periodic-vibrato-rate 5.0
periodic-vibrato-amplitude 0.0025
random-vibrato-rate 16.0
random-vibrato-amplitude 0.005
noise-freq 1000.0
noise-amount 0.0
ind-noise-freq 10.0
ind-noise-amount 0.0
amp-noise-freq 20.0
amp-noise-amount 0.0
gliss-env #( 0 0 100 0 )
glissando-amount 0.0
fm1-env #( 0 1 25 0.4 75 0.6 100 0 )
fm2-env #( 0 1 25 0.4 75 0.6 100 0 )
fm3-env #( 0 1 25 0.4 75 0.6 100 0 )
fm1-rat 1.0
fm2-rat 3.0
fm3-rat 4.0
fm1-index #f
fm2-index #f
fm3-index #f
base 1.0
degree 0.0
distance 1.0
reverb-amount 0.01
index-type 'violin -- }>
doc" FM-Violin from clm/v.ins|snd/v.scm|rb.\n\
0 3 440 0.5 :fm-index 0.5 <'> fm-violin with-sound."
freq fabs 1.0 f<= if
"freq = %s? reset to 440.0" #( freq ) fth-warning
440.0 to freq
then
freq hz->radians { frq-scl }
fm-index f0<> { modulate }
frq-scl fm-index f* { maxdev }
index-type 'violin = { vln }
freq flog { logfreq }
freq fsqrt { sqrtfreq }
fm1-index unless
maxdev vln if
5.0
else
7.5
then logfreq f/ f* pi fmin to fm1-index
then
fm2-index unless
maxdev 3.0 f* vln if
8.5 logfreq f- 3.0 freq 0.001 f* f+ f/
else
15.0 sqrtfreq f/
then f* pi fmin to fm2-index
then
fm3-index unless
maxdev vln if
4.0
else
8.0
then sqrtfreq f/ f* pi fmin to fm3-index
then
noise-amount f0=
fm1-env fm2-env equal? &&
fm1-env fm3-env equal? &&
fm1-rat fm1-rat floor f- f0= &&
fm2-rat fm1-rat floor f- f0= &&
fm2-rat fm2-rat floor f- f0= &&
fm3-rat fm1-rat floor f- f0= &&
fm3-rat fm3-rat floor f- f0= && { easy-case }
easy-case modulate && 1.0 && fm1-index || { norm }
:frequency freq make-oscil { carrier }
:envelope amp-env :scaler amp :duration dur :base base make-env { ampf }
#f #f #f { fmosc1 fmosc2 fmosc3 }
#f #f #f { indf1 indf2 indf3 }
modulate if
easy-case if
:frequency freq fm1-rat f*
:coeffs #( fm1-rat f>s fm1-index
fm2-rat fm1-rat f/ fround->s fm2-index
fm3-rat fm1-rat f/ fround->s fm3-index )
1 partials->polynomial make-polyshape
else
:frequency freq fm1-rat f* make-oscil
then to fmosc1
easy-case unless
:frequency freq fm2-rat f* make-oscil to fmosc2
:frequency freq fm3-rat f* make-oscil to fmosc3
:envelope fm1-env
:scaler norm
:duration dur make-env to indf1
:envelope fm2-env
:scaler fm2-index
:duration dur make-env to indf2
:envelope fm3-env
:scaler fm3-index
:duration dur make-env to indf3
then
then
:envelope gliss-env
:scaler glissando-amount frq-scl f*
:duration dur make-env { frqf }
:frequency periodic-vibrato-rate
:amplitude periodic-vibrato-amplitude frq-scl f*
make-triangle-wave { pervib }
:frequency random-vibrato-rate
:amplitude random-vibrato-amplitude frq-scl f*
make-rand-interp { ranvib }
#f #f #f { fm-noi ind-noi amp-noi }
noise-amount f0<> if
:frequency noise-freq
:amplitude noise-amount pi f*
make-rand to fm-noi
then
ind-noise-freq f0<>
ind-noise-amount f0<> && if
:frequency ind-noise-freq
:amplitude ind-noise-amount
make-rand-interp to ind-noi
then
amp-noise-freq f0<>
amp-noise-amount f0<> && if
:frequency amp-noise-freq
:amplitude amp-noise-amount
make-rand-interp to amp-noi
then
0.0 0.0 1.0 1.0 { vib fuzz ind-fuzz amp-fuzz }
modulate if
easy-case if
start dur
#{ :degree degree
:distance distance
:reverb reverb-amount } run-instrument
fm-noi if
fm-noi 0.0 rand to fuzz
then
frqf env pervib 0.0 triangle-wave f+
ranvib 0.0 rand-interp f+ to vib
ind-noi if
ind-noi 0.0 rand-interp
1.0 f+ to ind-fuzz
then
amp-noi if
amp-noi 0.0 rand-interp
1.0 f+ to amp-fuzz
then
carrier ( gen )
fmosc1 1.0 vib polyshape
ind-fuzz f* vib f+ ( fm )
0.0 ( pm ) oscil
ampf env f* amp-fuzz f*
end-run
else
start dur
#{ :degree degree
:distance distance
:reverb reverb-amount } run-instrument
fm-noi if
fm-noi 0.0 rand to fuzz
then
frqf env pervib 0.0 triangle-wave f+
ranvib 0.0 rand-interp f+ to vib
ind-noi if
ind-noi 0.0 rand-interp
1.0 f+ to ind-fuzz
then
amp-noi if
amp-noi 0.0 rand-interp
1.0 f+ to amp-fuzz
then
carrier ( gen )
fmosc1 fm1-rat vib f* fuzz f+ 0.0 oscil
indf1 env f*
fmosc2 fm2-rat vib f* fuzz f+ 0.0 oscil
indf2 env f* f+
fmosc3 fm3-rat vib f* fuzz f+ 0.0 oscil
indf3 env f* f+
ind-fuzz f* vib f+ ( fm )
0.0 ( pm ) oscil
ampf env f* amp-fuzz f*
end-run
then
else
start dur
#{ :degree degree :distance distance :reverb reverb-amount }
run-instrument
fm-noi if
fm-noi 0.0 rand to fuzz
then
frqf env pervib 0.0 triangle-wave f+
ranvib 0.0 rand-interp f+ to vib
ind-noi if
ind-noi 0.0 rand-interp 1.0 f+ to ind-fuzz
then
amp-noi if
amp-noi 0.0 rand-interp 1.0 f+ to amp-fuzz
then
carrier vib 0.0 oscil ampf env f* amp-fuzz f*
end-run
then
;
: fm-violin-test <{ :optional start 0.0 dur 1.0 -- }>
start now!
now@ dur 440 0.5 fm-violin
dur 0.2 f+ step
;
\ === CLM-INS.(RB|SCM) ===
\ (with original comments from clm-ins.scm)
hide
: get-optimum-c { s o p -- t c }
o 1/f s o fsin f* 1.0 s f- s o fcos f* f+ fatan2 f* { pa }
p pa f- f>s { tmp_int }
tmp_int unless
1 to tmp_int
then
p pa f- tmp_int f- { pc }
begin
pc 0.1 f<
while
tmp_int 1 - to tmp_int
pc 1.0 f+ to pc
repeat
tmp_int ( t )
o fsin o pc f* fsin f- o o pc f* f+ fsin f/ ( c )
;
: tune-it { f s1 -- s c t }
mus-srate f f/ { p }
s1 f0= if
0.5
else
s1
then { s }
f hz->radians { o }
s o p get-optimum-c { t1 c1 }
1.0 s f- o p get-optimum-c { t2 c2 }
s 0.5 f<>
c1 fabs c2 fabs f< && if
1.0 s f- c1 t1
else
s c2 t2
then
;
set-current
\ PLUCK
\
\ The Karplus-Strong algorithm as extended by David Jaffe and Julius
\ Smith -- see Jaffe and Smith, "Extensions of the Karplus-Strong
\ Plucked-String Algorithm" CMJ vol 7 no 2 Summer 1983, reprinted in
\ "The Music Machine". translated from CLM's pluck.ins
instrument: pluck <{ start dur freq amp :optional
weighting 0.5
lossfact 0.9 -- }>
doc" Implement the Jaffe-Smith plucked string physical model. \
WEIGHTING is the ratio of the once-delayed to the twice-delayed samples. \
It defaults to 0.5 = shortest decay. \
Anything other than 0.5 = longer decay. \
Must be between 0 and less than 1.0. \
LOSSFACT can be used to shorten decays. \
Most useful values are between 0.8 and 1.0.\n\
0 1 330 0.3 0.95 0.95 <'> pluck with-sound"
freq weighting tune-it { wt0 c dlen }
lossfact f0= if
1.0
else
1.0 lossfact fmin
then { lf }
wt0 f0= if
0.5
else
1.0 wt0 fmin
then { wt }
lf 1.0 wt f- f* lf wt f* make-one-zero { allp }
c 1.0 make-one-zero { feedb }
dlen 0.0 make-vct map
1.0 2.0 mus-random f-
end-map { tab }
start dur #{ :degree 90.0 random } run-instrument
tab cycle-ref { val }
tab i dlen mod 1.0 c f-
feedb allp val one-zero one-zero f* vct-set! drop
amp val f*
end-run
;instrument
previous
: pluck-test <{ :optional start 0.0 dur 1.0 -- }>
start now!
now@ dur 330 0.3 0.95 0.95 pluck
dur 0.2 f+ step
;
\ formant center frequencies for a male speaker (vox and pqw-vox)
#{ :I: #( 390.0 1990.0 2550.0 )
:UH: #( 520.0 1190.0 2390.0 )
:U: #( 440.0 1020.0 2240.0 )
:W: #( 300.0 610.0 2200.0 )
:Y: #( 300.0 2200.0 3065.0 )
:L: #( 300.0 1300.0 3000.0 )
:D: #( 300.0 1700.0 2600.0 )
:N: #( 280.0 1700.0 2600.0 )
:T: #( 200.0 1700.0 2600.0 )
:TH: #( 200.0 1400.0 2200.0 )
:V: #( 175.0 1100.0 2400.0 )
:ZH: #( 175.0 1800.0 2000.0 )
:E: #( 530.0 1840.0 2480.0 )
:A: #( 730.0 1090.0 2440.0 )
:OO: #( 300.0 870.0 2240.0 )
:LL: #( 380.0 880.0 2575.0 )
:EE: #( 260.0 3500.0 3800.0 )
:I2: #( 350.0 2300.0 3340.0 )
:G: #( 250.0 1350.0 2000.0 )
:NG: #( 280.0 2300.0 2750.0 )
:K: #( 350.0 1350.0 2000.0 )
:S: #( 200.0 1300.0 2500.0 )
:THE: #( 200.0 1600.0 2200.0 )
:ZZ: #( 900.0 2400.0 3800.0 )
:AE: #( 660.0 1720.0 2410.0 )
:OW: #( 570.0 840.0 2410.0 )
:ER: #( 490.0 1350.0 1690.0 )
:R: #( 420.0 1300.0 1600.0 )
:LH: #( 280.0 1450.0 1600.0 )
:B: #( 200.0 800.0 1750.0 )
:M: #( 280.0 900.0 2200.0 )
:P: #( 300.0 800.0 1750.0 )
:F: #( 175.0 900.0 4400.0 )
:SH: #( 200.0 1800.0 2000.0 )
:Z: #( 200.0 1300.0 2500.0 )
:VV: #( 565.0 1045.0 2400.0 ) } value clm-ins-formants
\ MLBVOI
\
\ translation from MUS10 of Marc LeBrun's waveshaping voice instrument
\ (using FM here) this version translated (and simplified slightly)
\ from CLM's mlbvoi.ins
instrument: vox <{ start dur freq amp ampfun freqfun freqscl voxfun index
:optional vibscl 0.1 -- }>
voxfun length { size }
size make-array { f1 }
size make-array { f2 }
size make-array { f3 }
size 1- 0 ?do
clm-ins-formants voxfun i 1+ object-ref hash-ref { phon }
voxfun i object-ref { n }
f1 i n array-set!
phon 0 array-ref f1 i 1+ rot array-set!
f2 i n array-set!
phon 1 array-ref f2 i 1+ rot array-set!
f3 i n array-set!
phon 2 array-ref f3 i 1+ rot array-set!
2 +loop
:frequency 0.0 make-oscil { car-os }
6 make-array map
:frequency 0.0 make-oscil
end-map { ofs }
:envelope ampfun :scaler amp :duration dur make-env { ampf }
:envelope f1 :duration dur make-env { frmf1 }
:envelope f2 :duration dur make-env { frmf2 }
:envelope f3 :duration dur make-env { frmf3 }
:envelope freqfun
:duration dur
:scaler freqscl freq f*
:offset freq make-env { freqf }
:frequency 6.0 :amplitude freq vibscl f* make-triangle-wave { per-vib }
:frequency 20.0 :amplitude freq 0.01 f* make-rand-interp { ran-vib }
6 0.0 make-vct { freqs }
6 0.0 make-vct { amps }
start dur #{ :degree 90.0 random } run-instrument
freqf env per-vib 0.0 triangle-wave f+
ran-vib 0.0 rand-interp f+ { frq }
frmf1 env { frm }
frm frq f/ { frm0 }
frm0 floor dup f>s { frm-fint frm-int }
frm-int 2 mod unless
freqs 0 frm-fint frq f* hz->radians vct-set! drop
freqs 1 frm-fint 1.0 f+ frq f* hz->radians vct-set! drop
amps 1 frm0 frm-fint f- vct-set! drop
amps 0 1.0 amps 1 vct-ref f- vct-set! drop
else
freqs 1 frm-fint frq f* hz->radians vct-set! drop
freqs 0 frm-fint 1.0 f+ frq f* hz->radians vct-set! drop
amps 0 frm0 frm-fint f- vct-set! drop
amps 1 1.0 amps 0 vct-ref f- vct-set! drop
then
frmf2 env to frm
frm frq f/ to frm0
frm0 floor to frm-fint
frm-fint f>s to frm-int
frm-int 2 mod unless
freqs 2 frm-fint frq f* hz->radians vct-set! drop
freqs 3 frm-fint 1.0 f+ frq f* hz->radians vct-set! drop
amps 3 frm0 frm-fint f- vct-set! drop
amps 2 1.0 amps 3 vct-ref f- vct-set! drop
else
freqs 3 frm-fint frq f* hz->radians vct-set! drop
freqs 2 frm-fint 1.0 f+ frq f* hz->radians vct-set! drop
amps 2 frm0 frm-fint f- vct-set! drop
amps 3 1.0 amps 2 vct-ref f- vct-set! drop
then
frmf3 env to frm
frm frq f/ to frm0
frm0 floor to frm-fint
frm-fint f>s to frm-int
frm-int 2 mod unless
freqs 4 frm-fint frq f* hz->radians vct-set! drop
freqs 5 frm-fint 1.0 f+ frq f* hz->radians vct-set! drop
amps 5 frm0 frm-fint f- vct-set! drop
amps 4 1.0 amps 5 vct-ref f- vct-set! drop
else
freqs 5 frm-fint frq f* hz->radians vct-set! drop
freqs 4 frm-fint 1.0 f+ frq f* hz->radians vct-set! drop
amps 4 frm0 frm-fint f- vct-set! drop
amps 5 1.0 amps 4 vct-ref f- vct-set! drop
then
car-os frq hz->radians 0.0 oscil index f* { caros }
ofs 0 array-ref caros 0.2 f*
freqs 0 vct-ref f+ 0.0 oscil amps 0 vct-ref f*
ofs 1 array-ref caros 0.2 f*
freqs 1 vct-ref f+ 0.0 oscil amps 1 vct-ref f*
f+ 0.80 f*
ofs 2 array-ref caros 0.5 f*
freqs 2 vct-ref f+ 0.0 oscil amps 2 vct-ref f*
ofs 3 array-ref caros 0.5 f*
freqs 3 vct-ref f+ 0.0 oscil amps 3 vct-ref f*
f+ 0.15 f* f+
ofs 4 array-ref caros
freqs 4 vct-ref f+ 0.0 oscil amps 4 vct-ref f*
ofs 5 array-ref caros
freqs 5 vct-ref f+ 0.0 oscil amps 5 vct-ref f*
f+ 0.05 f* f+
ampf env f*
end-run
;instrument
: vox-test <{ :optional start 0.0 dur 1.0 -- }>
start now!
#( 0 0 25 1 75 1 100 0 ) { amp-env }
#( 0 0 5 0.5 10 0 100 1 ) { frq-env }
#( 0 :E: 25 :AE: 35 :ER: 65 :ER: 75 :I: 100 :UH: ) { examp1 }
#( 0 :I: 5 :OW: 10 :I: 50 :AE: 100 :OO: ) { examp2 }
now@ dur 170 0.4 amp-env frq-env 0.1 examp1 0.05 0.1 vox
dur 0.2 f+ step
now@ dur 300 0.4 amp-env frq-env 0.1 examp2 0.02 0.1 vox
dur 0.2 f+ step
now@ 5.0 600 0.4 amp-env frq-env 0.1 examp2 0.01 0.1 vox
5.0 0.2 f+ step
;
\ FOF example
\
\ snd/sndclm.html, section wave-train
instrument: fofins <{ start dur freq amp vib f0 a0 f1 a1 f2 a2 :optional
ae #( 0 0 25 1 75 1 100 0 )
ve #( 0 1 100 1 ) -- }>
doc" Produce FOF synthesis.\n\
0 1 270 0.2 0.001 730 0.6 1090 0.3 2440 0.1 <'> fofins with-sound."
:envelope ae :scaler amp :duration dur make-env { ampf }
:frequency 6.0 make-oscil { vibr }
:envelope ve :scaler vib :duration dur make-env { vibenv }
f0 hz->radians { frq0 }
f1 hz->radians { frq1 }
f2 hz->radians { frq2 }
mus-srate 22050.0 f= if
100
else
200
then { foflen }
two-pi foflen f/ { win-freq }
foflen 0.0 make-vct map
a0 i frq0 f* fsin f*
a1 i frq1 f* fsin f* f+
a2 i frq2 f* fsin f* f+ f2/
1.0 i win-freq f* fcos f- f*
end-map { foftab }
:frequency freq :wave foftab make-wave-train { wt0 }
start dur #{ :degree 90.0 random } run-instrument
ampf env wt0 vibenv env vibr 0.0 0.0 oscil f* wave-train f*
end-run
;instrument
: fofins-test <{ :optional start 0.0 dur 1.0 -- }>
start now!
now@ dur 270 0.2 0.001 730 0.6 1090 0.3 2440 0.1 fofins
dur 0.2 f+ step
;
\ FM TRUMPET
\
\ Dexter Morrill's FM-trumpet: from CMJ feb 77 p51
instrument: fm-trumpet <{ start dur :key
frq1 250
frq2 1500
amp1 0.5
amp2 0.1
ampatt1 0.03
ampdec1 0.35
ampatt2 0.03
ampdec2 0.3
modfrq1 250
modind11 0
modind12 2.66
modfrq2 250
modind21 0
modind22 1.8
rvibamp 0.007
rvibfrq 125
vibamp 0.007
vibfrq 7
vibatt 0.6
vibdec 0.2
frqskw 0.03
frqatt 0.06
ampenv1 #( 0 0 25 1 75 0.9 100 0 )
ampenv2 #( 0 0 25 1 75 0.9 100 0 )
indenv1 #( 0 0 25 1 75 0.9 100 0 )
indenv2 #( 0 0 25 1 75 0.9 100 0 ) -- }>
doc" 0 2 <'> fm-trumpet with-sound."
:envelope #( 0 1 25 0.1 75 0 100 0 )
25.0
vibatt dur f/ 100.0 f* 45.0 fmin
75.0
1.0 vibdec dur f/ f- 100.0 f* 55.0 fmax stretch-envelope
:scaler vibamp
:duration dur make-env { per-vib-f }
:frequency rvibfrq :amplitude rvibamp make-rand-interp { ran-vib }
:frequency vibfrq make-oscil { per-vib }
1.0 0.01 dur f/ f- 100.0 f* 75.0 fmax { dec-01 }
:envelope #( 0 0 25 1 75 1 100 0 )
25.0
frqatt dur f/ 100.0 f* 25.0 fmin
75.0
dec-01 stretch-envelope
:scaler frqskw
:duration dur make-env { frq-f }
ampatt1 dur f/ 100.0 f* 25.0 fmin { ampattpt1 }
1.0 ampdec1 dur f/ f- 100.0 f* 75.0 fmax { ampdecpt1 }
ampatt2 dur f/ 100.0 f* 25.0 fmin { ampattpt2 }
1.0 ampdec2 dur f/ f- 100.0 f* 75.0 fmax { ampdecpt2 }
:envelope indenv1 25.0 ampattpt1 75.0 dec-01 stretch-envelope
:scaler modfrq1 modind12 modind11 f- f*
:duration dur make-env { mod1-f }
:frequency 0.0 make-oscil { mod1 }
:frequency 0.0 make-oscil { car1 }
:envelope ampenv1 25 ampattpt1 75 ampdecpt1 stretch-envelope
:scaler amp1
:duration dur make-env { car1-f }
:envelope indenv2 25 ampattpt2 75 dec-01 stretch-envelope
:scaler modfrq2 modind22 modind21 f- f*
:duration dur make-env { mod2-f }
:frequency 0.0 make-oscil { mod2 }
:frequency 0.0 make-oscil { car2 }
:envelope ampenv2 25.0 ampattpt2 75.0 ampdecpt2 stretch-envelope
:scaler amp2
:duration dur make-env { car2-f }
start dur #{ :degree 90.0 random } run-instrument
ran-vib 0.0 rand-interp 1.0 f+
1.0 per-vib-f env per-vib 0.0 0.0 oscil f* f+ f*
1.0 frq-f env f+ f* hz->radians { frq-change }
car1
mod1 modfrq1 frq-change f* 0.0 oscil mod1-f env f*
frq1 f+ frq-change f* 0.0 oscil car1-f env f*
car2
mod2 modfrq2 frq-change f* 0.0 oscil mod2-f env f*
frq2 f+ frq-change f* 0.0 oscil car2-f env f*
f+
end-run
;instrument
: fm-trumpet-test <{ :optional start 0.0 dur 1.0 -- }>
start now!
now@ dur fm-trumpet
dur 0.2 f+ step
;
#( "pqw-sin-evens"
"pqw-sin-odds"
"pqw-cos-evens"
"pqw-cos-odds"
"pqw-cos-coeffs"
"pqw-sin-coeffs"
"pqw-frmfs"
"pqw-amps" ) create-struct make-pqw-vox-struct
\ PQWVOX
\
\ translation of CLM pqwvox.ins (itself translated from MUS10 of MLB's
\ waveshaping voice instrument (using phase quadrature waveshaping))
instrument: pqw-vox <{ start dur
freq spacing-freq
amp ampfun
freqfun freqscl
phonemes
formant-amps formant-shapes -- }>
:frequency 0.0 make-oscil { car-sin }
:frequency 0.0 :initial-phase half-pi make-oscil { car-cos }
:envelope ampfun :scaler amp :duration dur make-env { ampf }
:envelope freqfun
:scaler freqscl freq f*
:duration dur :offset freq
make-env { freqf }
:frequency 6.0 :amplitude freq 0.1 f* make-triangle-wave { per-vib }
:frequency 20.0 :amplitude freq 0.05 f* make-rand-interp { ran-vib }
phonemes length { plen }
plen make-array { phone1 }
plen make-array { phone2 }
plen make-array { phone3 }
plen 1- 0 ?do
phonemes i object-ref { ph }
phone1 i ph array-set!
phone2 i ph array-set!
phone3 i ph array-set!
clm-ins-formants phonemes i 1+ object-ref hash-ref { ary }
phone1 i 1+ ary 0 object-ref array-set!
phone2 i 1+ ary 1 object-ref array-set!
phone3 i 1+ ary 2 object-ref array-set!
2 +loop
#( phone1 phone2 phone3 ) { phones }
nil 0 { pv shape }
formant-amps map
make-pqw-vox-struct to pv
pv :frequency 0.0 :initial-phase 0.0 make-oscil pqw-sin-evens!
pv :frequency 0.0 :initial-phase 0.0 make-oscil pqw-sin-odds!
pv
:frequency 0.0 :initial-phase half-pi make-oscil
pqw-cos-evens!
pv
:frequency 0.0 :initial-phase half-pi make-oscil
pqw-cos-odds!
formant-shapes i object-ref normalize-partials to shape
pv
shape mus-chebyshev-first-kind partials->polynomial
pqw-cos-coeffs!
pv
shape mus-chebyshev-second-kind partials->polynomial
pqw-sin-coeffs!
:envelope phones i array-ref :duration dur make-env
pv swap pqw-frmfs!
pv formant-amps i object-ref pqw-amps!
pv
end-map { values }
4 0.0 make-vct { vals }
spacing-freq freq f/ { frq-ratio }
start dur #{ :degree 90.0 random } run-instrument
freqf env per-vib 0.0 triangle-wave f+
ran-vib 0.0 rand-interp f+ { frq }
frq frq-ratio f* hz->radians { frqscl }
car-sin frqscl 0.0 oscil { carsin }
car-cos frqscl 0.0 oscil { carcos }
0.0 ( sum )
values each to pv
pv pqw-frmfs@ env frq f/ { frm0 }
frm0 floor { frm-fint }
frm-fint f>s 2 mod unless
vals 0
frm-fint frq f* hz->radians
vct-set! drop ( even-freq )
vals 1
frm-fint 1.0 f+ frq f* hz->radians
vct-set! drop ( odd-freq )
vals 3
frm0 frm-fint f-
vct-set! drop ( odd-amp )
vals 2
1.0 vals 3 vct-ref f-
vct-set! drop ( even-amp )
else
vals 1
frm-fint frq f* hz->radians
vct-set! drop ( odd-freq )
vals 0
frm-fint 1.0 f+ frq f* hz->radians
vct-set! drop ( even-freq )
vals 2
frm0 frm-fint f-
vct-set! drop ( even-amp )
vals 3
1.0 vals 2 vct-ref f-
vct-set! drop ( odd-amp )
then
pv pqw-cos-coeffs@ carcos polynomial { fax }
pv pqw-sin-coeffs@ carcos polynomial carsin f* { yfax }
pv pqw-sin-evens@ vals 0 vct-ref 0.0 oscil yfax f*
pv pqw-cos-evens@
vals 0 vct-ref 0.0 oscil fax f* f-
vals 2 vct-ref f*
pv pqw-sin-odds@ vals 1 vct-ref 0.0 oscil yfax f*
pv pqw-cos-odds@
vals 1 vct-ref 0.0 oscil fax f* f-
vals 3 vct-ref f*
f+ pv pqw-amps@ f* f+
end-each ( sum )
ampf env f*
end-run
;instrument
: pqw-vox-test <{ :optional start 0.0 dur 1.0 -- }>
start now!
#( 0 0 50 1 100 0 ) { ampfun }
#( 0 0 100 0 ) { freqfun }
#( 0 0 100 1 ) { freqramp }
#( #( 1 1 2 0.5 )
#( 1 0.5 2 0.5 3 1 )
#( 1 1 4 0.5 ) ) { sh1 }
#( #( 1 1 2 0.5 )
#( 1 1 2 0.5 3 0.2 4 0.1 )
#( 1 1 3 0.1 4 0.5 ) ) { sh2 }
#( #( 1 1 2 0.5 )
#( 1 1 4 0.1 )
#( 1 1 2 0.1 4 0.05 ) ) { sh3 }
#( #( 1 1 2 0.5 3 0.1 4 0.01 )
#( 1 1 4 0.1 )
#( 1 1 2 0.1 4 0.05 ) ) { sh4 }
#( 0.8 0.15 0.05 ) { amps }
now@ dur 300 300 0.5 ampfun freqfun 0.00
#( 0 :L: 100 :L: ) #( 0.33 0.33 0.33 ) sh1 pqw-vox
dur 0.2 f+ step
now@ dur 200 200 0.5 ampfun freqramp 0.10
#( 0 :UH: 100 :ER: ) amps sh2 pqw-vox
dur 0.2 f+ step
now@ dur 100 314 0.5 ampfun freqramp 0.10
#( 0 :UH: 100 :ER: ) amps sh2 pqw-vox
dur 0.2 f+ step
now@ dur 200 314 0.5 ampfun freqramp 0.01
#( 0 :UH: 100 :ER: ) amps sh3 pqw-vox
dur 0.2 f+ step
now@ dur 100 414 0.5 ampfun freqramp 0.01
#( 0 :OW: 50 :E: 100 :ER: ) amps sh4 pqw-vox
dur 0.2 f+ step
;
\ STEREO-FLUTE
instrument: stereo-flute <{ start dur freq flow :key
flow-envelope #( 0 1 100 1 )
decay 0.01
noise 0.0356
embouchure-size 0.5
fbk-scl1 0.5
fbk-scl2 0.55
out-scl 1.0
a0 0.7
b1 -0.3
vib-rate 5.0
vib-amount 0.03
ran-rate 5.0
ran-amount 0.03 -- }>
doc" A physical model of a flute.\n\
0 1 440 0.55 :flow-envelope #( 0 0 1 1 2 1 3 0 ) <'> stereo-flute with-sound."
:envelope flow-envelope
:scaler flow
:duration dur decay f- make-env { flowf }
:frequency vib-rate make-oscil { p-vib }
:frequency ran-rate make-rand-interp { ran-vib }
:frequency mus-srate f2/ :amplitude 1.0 make-rand { breath }
mus-srate freq f/ fround->s { periodic-samples }
embouchure-size periodic-samples f* fround->s make-delay { emb }
periodic-samples make-delay { bore }
a0 b1 make-one-pole { rlf }
0.0 0.0 0.0 0.0 { emb-sig delay-sig out-sig prev-out-sig }
0.0 0.0 0.0 { cur-exit cur-diff cur-flow }
0.0 0.0 { dc-blocked prev-dc-blocked }
start dur #{ :degree 90.0 random } run-instrument
bore out-sig 0.0 delay to delay-sig
emb cur-diff 0.0 delay to emb-sig