Debian Codegraph @

examples/convolve.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 ; Select audio/midi flags here according to platform
4 -odac ;;;RT audio out
5 ;-iadc ;;;uncomment -iadc if RT audio input is needed too
6 ; For Non-realtime ouput leave only the line below:
7 ;-o convolve.wav -W ;;; for file output any platform
8 </CsOptions>
9 <CsInstruments>
10 ; NB: 'Small' reverbs often require a much higher percentage of wet signal to sound interesting. 'Large'
11 ; reverbs seem require less. Experiment! The wet/dry mix is very important - a small change can make a large difference.
12
13 sr = 44100
14 ksmps = 32
15 nchnls = 2
16 0dbfs = 1
17
18 ; by Menno Knevel - 2021
19
20 ires1 system_i 1,{{ cvanal rv_mono.wav rv_mono.con }} ; analyze mono spring reverb
21 ires2 system_i 1,{{ cvanal rv_stereo.wav rv_stereo.con }} ; analyze stereo spring reverb
22
23 instr 1
24
25 imix = 0.25 ;wet/dry mix. Vary as desired.
26 ivol = .8 ;Overall volume level of reverb. Adjust to avoid clipping.
27
28 idel filelen p4 ;calculate length and number of channels of soundfile
29 ichnls filenchnls p4
30 prints "\n**this reverb file = %f seconds and has %d channel(s)**\n", idel, ichnls
31
32 if (ichnls == 1) then ; if mono
33 adry soundin "fox.wav" ; input (dry) audio
34 awet convolve adry,"rv_mono.con" ; mono convolved (wet) audio
35 awet1 diff awet ; brighten sound
36 awet2 = awet1 ; as it is a mono file played stereo
37 adrydel delay (1-imix)*adry, idel ; Delay dry signal to align it with convolved signal
38 else ; if stereo
39 adry soundin "fox.wav" ; input (dry) audio
40 awet1, awet2 convolve adry,"rv_stereo.con" ; stereo convolved (wet) audio
41 awet1 diff awet1 ; brighten left sound
42 awet2 diff awet2 ; and brighten right sound
43 adrydel delay (1-imix)*adry, idel ; Delay dry signal to align it with convolved signal
44 endif
45 outs ivol*(adrydel+imix*awet1),ivol*(adrydel+imix*awet2) ; Mix wet & dry signals
46
47 endin
48
49 </CsInstruments>
50 <CsScore>
51
52 i 1 0 4 "rv_mono.wav"
53 i 1 5 4 "rv_stereo.wav"
54 e
55 </CsScore>
56 </CsoundSynthesizer>