Debian Codegraph @

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

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 --env:SSDIR+=../../SourceMaterials -odac
4 </CsOptions>
5 <CsInstruments>
6
7 sr = 44100
8 ksmps = 128
9 nchnls = 2
10 0dbfs = 1
11
12 ; impulse responses stored as mono GEN01 function tables
13 giStairwell ftgen 1,0,131072,1,"Stairwell.wav",0,0,0
14 giDish ftgen 2,0,131072,1,"dish.wav",0,0,0
15
16 gasig init 0
17
18 ; reverse function table UDO
19 opcode tab_reverse,0,i
20 ifn xin
21 iTabLen = ftlen(ifn)
22 iTableBuffer ftgentmp 0,0,-iTabLen,-2, 0
23 icount = 0
24 loop:
25 ival table iTabLen-icount-1, ifn
26 tableiw ival,icount,iTableBuffer
27 loop_lt icount,1,iTabLen,loop
28 icount = 0
29 loop2:
30 ival table icount,iTableBuffer
31 tableiw ival,icount,ifn
32 loop_lt icount,1,iTabLen,loop2
33 endop
34
35 instr 3 ; reverse the contents of a function table
36 tab_reverse p4
37 endin
38
39 instr 1 ; sound file player
40 gasig diskin p4,1,0,1
41 endin
42
43 instr 2 ; convolution reverb
44 ; buffer length
45 iplen = 1024
46 ; derive the length of the impulse response
47 iirlen = nsamp(p4)
48 aconv ftconv gasig, p4, iplen,0, iirlen
49 ; delay compensation. Add extra delay if reverse reverb is used.
50 adel delay gasig,(iplen/sr) + ((iirlen/sr)*p6)
51 ; create a dry/wet mix
52 aMix ntrpol adel,aconv*0.1,p5
53 outs aMix, aMix
54 gasig = 0
55 endin
56
57 </CsInstruments>
58 <CsScore>
59 ; instr 1. sound file player
60 ; p4=input soundfile
61 ; instr 2. convolution reverb
62 ; p4=impulse response file
63 ; p5=dry/wet mix (0 - 1)
64 ; p6=reverse reverb switch (0=off,1=on)
65 ; instr 3. reverse table contents
66 ; p4=function table number
67
68 ; 'stairwell' impulse response
69 i 1 0 8.5 "loop.wav"
70 i 2 0 10 1 0.3 0
71
72 ; 'dish' impulse response
73 i 1 10 8.5 "loop.wav"
74 i 2 10 10 2 0.8 0
75
76 ; reverse the impulse responses
77 i 3 20 0 1
78 i 3 20 0 2
79
80 ; 'stairwell' impulse response (reversed)
81 i 1 21 8.5 "loop.wav"
82 i 2 21 10 1 0.5 1
83
84 ; 'dish' impulse response (reversed)
85 i 1 31 8.5 "loop.wav"
86 i 2 31 10 2 0.5 1
87 </CsScore>
88 </CsoundSynthesizer>
89 ;example by Iain McCurdy