Debian Codegraph @

src/Examples/FLOSS Manual Examples/05 Sound Modification/05E04_schroeder_reverb.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 -odac -m128
4 ; activate real time sound output and suppress note printing
5 </CsOptions>
6 <CsInstruments>
7 sr = 44100
8 ksmps = 1
9 nchnls = 2
10 0dbfs = 1
11
12 giSine ftgen 0, 0, 2^12, 10, 1 ; a sine wave
13 gaRvbSend init 0 ; global audio variable initialized
14 giRvbSendAmt init 0.4 ; reverb send amount (range 0 - 1)
15
16 instr 1 ; trigger drum hits
17 ktrigger metro 5 ; rate of drum strikes
18 kdrum random 2, 4.999 ; randomly choose which drum to hit
19 schedkwhen ktrigger, 0, 0, kdrum, 0, 0.1 ; strike a drum
20 endin
21
22 instr 2 ; sound 1 - bass drum
23 iamp random 0, 0.5 ; amplitude randomly chosen
24 p3 = 0.2 ; define duration for this sound
25 aenv line 1,p3,0.001 ; amplitude envelope (percussive)
26 icps exprand 30 ; cycles-per-second offset
27 kcps expon icps+120,p3,20 ; pitch glissando
28 aSig oscil aenv*0.5*iamp,kcps,giSine ; oscillator
29 outs aSig, aSig ; send audio to outputs
30 gaRvbSend = gaRvbSend + (aSig * giRvbSendAmt) ; add to send
31 endin
32
33 instr 3 ; sound 3 - snare
34 iAmp random 0, 0.5 ; amplitude randomly chosen
35 p3 = 0.3 ; define duration
36 aEnv expon 1, p3, 0.001 ; amp. envelope (percussive)
37 aNse noise 1, 0 ; create noise component
38 iCps exprand 20 ; cps offset
39 kCps expon 250 + iCps, p3, 200+iCps; create tone component gliss
40 aJit randomi 0.2, 1.8, 10000 ; jitter on freq.
41 aTne oscil aEnv, kCps*aJit, giSine ; create tone component
42 aSig sum aNse*0.1, aTne ; mix noise and tone components
43 aRes comb aSig, 0.02, 0.0035 ; comb creates a 'ring'
44 aSig = aRes * aEnv * iAmp ; apply env. and amp. factor
45 outs aSig, aSig ; send audio to outputs
46 gaRvbSend = gaRvbSend + (aSig * giRvbSendAmt); add to send
47 endin
48
49 instr 4 ; sound 4 - closed hi-hat
50 iAmp random 0, 1.5 ; amplitude randomly chosen
51 p3 = 0.1 ; define duration for this sound
52 aEnv expon 1,p3,0.001 ; amplitude envelope (percussive)
53 aSig noise aEnv, 0 ; create sound for closed hi-hat
54 aSig buthp aSig*0.5*iAmp, 12000 ; highpass filter sound
55 aSig buthp aSig, 12000 ; -and again to sharpen cutoff
56 outs aSig, aSig ; send audio to outputs
57 gaRvbSend = gaRvbSend + (aSig * giRvbSendAmt) ; add to send
58 endin
59
60
61 instr 5 ; schroeder reverb - always on
62 ; read in variables from the score
63 kRvt = p4
64 kMix = p5
65
66 ; print some information about current settings gleaned from the score
67 prints "Type:"
68 prints p6
69 prints "\\nReverb Time:%2.1f\\nDry/Wet Mix:%2.1f\\n\\n",p4,p5
70
71 ; four parallel comb filters
72 a1 comb gaRvbSend, kRvt, 0.0297; comb filter 1
73 a2 comb gaRvbSend, kRvt, 0.0371; comb filter 2
74 a3 comb gaRvbSend, kRvt, 0.0411; comb filter 3
75 a4 comb gaRvbSend, kRvt, 0.0437; comb filter 4
76 asum sum a1,a2,a3,a4 ; sum (mix) the outputs of all comb filters
77
78 ; two allpass filters in series
79 a5 alpass asum, 0.1, 0.005 ; send mix through first allpass filter
80 aOut alpass a5, 0.1, 0.02291 ; send 1st allpass through 2nd allpass
81
82 amix ntrpol gaRvbSend, aOut, kMix ; create a dry/wet mix
83 outs amix, amix ; send audio to outputs
84 clear gaRvbSend ; clear global audio variable
85 endin
86
87 </CsInstruments>
88 <CsScore>
89 ; room reverb
90 i 1 0 10 ; start drum machine trigger instr
91 i 5 0 11 1 0.5 "Room Reverb" ; start reverb
92
93 ; tight ambience
94 i 1 11 10 ; start drum machine trigger instr
95 i 5 11 11 0.3 0.9 "Tight Ambience" ; start reverb
96
97 ; long reverb (low in the mix)
98 i 1 22 10 ; start drum machine
99 i 5 22 15 5 0.1 "Long Reverb (Low In the Mix)" ; start reverb
100
101 ; very long reverb (high in the mix)
102 i 1 37 10 ; start drum machine
103 i 5 37 25 8 0.9 "Very Long Reverb (High in the Mix)" ; start reverb
104 e
105 </CsScore>
106 </CsoundSynthesizer>
107 ;example by Iain McCurdy