Debian Codegraph @

src/Examples/FLOSS Manual Examples/12 Csound and other Languages/12G03_Extended_HTML.csd

raw
1 <CsoundSynthesizer>
2 ; Example about using CSS in html section of CSD
3 ; By Michael Gogins 2016
4 ; Reformatted for flossmanual by Hlödver Sigurdsson
5
6 <CsOptions>
7 -odac
8 </CsOptions>
9 <CsInstruments>
10
11 sr = 44100
12 ksmps = 32
13 nchnls = 2
14
15 iampdbfs init 32768
16 prints "Default amplitude at 0 dBFS: %9.4f\n", iampdbfs
17 idbafs init dbamp(iampdbfs)
18 prints "dbA at 0 dBFS: %9.4f\n", idbafs
19 iheadroom init 6
20 prints "Headroom (dB): %9.4f\n", iheadroom
21 idbaheadroom init idbafs - iheadroom
22 prints "dbA at headroom: %9.4f\n", idbaheadroom
23 iampheadroom init ampdb(idbaheadroom)
24 prints "Amplitude at headroom: %9.4f\n", iampheadroom
25 prints "Balance so the overall amps at the end of performance -6 dbfs.\n"
26
27 connect "ModerateFM", "outleft", "Reverberation", "inleft"
28 connect "ModerateFM", "outright", "Reverberation", "inright"
29 connect "Reverberation", "outleft", "MasterOutput", "inleft"
30 connect "Reverberation", "outright", "MasterOutput", "inright"
31
32 alwayson "Reverberation"
33 alwayson "MasterOutput"
34 alwayson "Controls"
35
36 gk_FmIndex init 0.5
37 gk_FmCarrier init 1
38
39 //////////////////////////////////////////////
40 // By Michael Gogins.
41 //////////////////////////////////////////////
42 instr ModerateFM
43 i_instrument = p1
44 i_time = p2
45 i_duration = p3
46 i_midikey = p4
47 i_midivelocity = p5
48 i_phase = p6
49 i_pan = p7
50 i_depth = p8
51 i_height = p9
52 i_pitchclassset = p10
53 i_homogeneity = p11
54 iattack = 0.002
55 isustain = p3
56 idecay = 8
57 irelease = 0.05
58 iHz = cpsmidinn(i_midikey)
59 idB = i_midivelocity
60 iamplitude = ampdb(idB) * 4.0
61 kcarrier = gk_FmCarrier
62 imodulator = 0.5
63 ifmamplitude = 0.25
64 kindex = gk_FmIndex * 20
65 ifrequencyb = iHz * 1.003
66 kcarrierb = kcarrier * 1.004
67 aindenv transeg 0.0, iattack, -11.0, 1.0, idecay, -7.0, 0.025, isustain, \
68 0.0, 0.025, irelease, -7.0, 0.0
69 aindex = aindenv * kindex * ifmamplitude
70 isinetable ftgenonce 0, 0, 65536, 10, 1, 0, .02
71
72 ; ares foscili xamp, kcps, xcar, xmod, kndx, ifn [, iphs]
73 aouta foscili 1.0, iHz, kcarrier, imodulator, kindex / 4., isinetable
74 aoutb foscili 1.0, ifrequencyb, kcarrierb, imodulator, kindex, isinetable
75
76 ; Plus amplitude correction.
77 asignal = (aouta + aoutb) * aindenv
78 adeclick linsegr 0, iattack, 1, isustain, 1, irelease, 0
79 asignal = asignal * iamplitude
80 aoutleft, aoutright pan2 asignal * adeclick, i_pan
81 outleta "outleft", aoutleft
82 outleta "outright", aoutright
83 prints "instr %4d t %9.4f d %9.4f k %9.4f v %9.4f p %9.4f\n", \
84 p1, p2, p3, p4, p5, p7
85 endin
86
87 gkReverberationWet init .5
88 gk_ReverberationDelay init .6
89
90 instr Reverberation
91 ainleft inleta "inleft"
92 ainright inleta "inright"
93 aoutleft = ainleft
94 aoutright = ainright
95 kdry = 1.0 - gkReverberationWet
96 awetleft, awetright reverbsc ainleft, ainright, gk_ReverberationDelay, 18000
97 aoutleft = ainleft * kdry + awetleft * gkReverberationWet
98 aoutright = ainright * kdry + awetright * gkReverberationWet
99 outleta "outleft", aoutleft
100 outleta "outright", aoutright
101 prints "instr %4d t %9.4f d %9.4f k %9.4f v %9.4f p %9.4f\n", \
102 p1, p2, p3, p4, p5, p7
103 endin
104
105 gk_MasterLevel init 1
106
107 instr MasterOutput
108 ainleft inleta "inleft"
109 ainright inleta "inright"
110 aoutleft = gk_MasterLevel * ainleft
111 aoutright = gk_MasterLevel * ainright
112 outs aoutleft, aoutright
113 prints "instr %4d t %9.4f d %9.4f k %9.4f v %9.4f p %9.4f\n", \
114 p1, p2, p3, p4, p5, p7
115 endin
116
117 instr Controls
118 gk_FmIndex_ chnget "gk_FmIndex"
119 if gk_FmIndex_ != 0 then
120 gk_FmIndex = gk_FmIndex_
121 endif
122
123 gk_FmCarrier_ chnget "gk_FmCarrier"
124 if gk_FmCarrier_ != 0 then
125 gk_FmCarrier = gk_FmCarrier_
126 endif
127
128 gk_ReverberationDelay_ chnget "gk_ReverberationDelay"
129 if gk_ReverberationDelay_ != 0 then
130 gk_ReverberationDelay = gk_ReverberationDelay_
131 endif
132
133 gk_MasterLevel_ chnget "gk_MasterLevel"
134 if gk_MasterLevel_ != 0 then
135 gk_MasterLevel = gk_MasterLevel_
136 endif
137 endin
138
139 </CsInstruments>
140 <CsScore>
141 </CsScore>
142 </CsoundSynthesizer>