Debian Codegraph @

examples/liveconv.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 -odac ;realtime audio out
4 </CsOptions>
5 <CsInstruments>
6
7 sr = 44100
8 nchnls = 2
9 0dbfs = 1
10
11 ; empty IR table
12 giIR_record ftgen 0, 0, 131072, 2, 0
13
14 ; Record impulse response
15 instr 13
16
17 p3 = ftlen(giIR_record)/sr
18 iskip = p4
19 irlen = p5
20 a1 diskin2 "fox.wav", 1, iskip
21
22 ; Fill IR table with segment from audio file
23 amp linseg 0, 0.1, 1, irlen, 1, 0.1, 0, 1, 0
24 andx_IR line 0, 1, 1/(ftlen(giIR_record)/sr)
25 tablew a1*amp, andx_IR, giIR_record, 1
26 outch 1, a1*amp ; output the IR
27 ktrig init 1
28 if ktrig > -1 then
29 chnset ktrig, "conv_update"
30 ktrig -= 1
31 endif
32
33 endin
34
35 ; The convolver
36 instr 14
37
38 ain diskin2 "drumsMlp.wav", 1, 0, 1
39 kupdate chnget "conv_update"
40 aconv liveconv ain, giIR_record, 2048, kupdate, 0
41 outch 2, aconv*0.009 ; output the convolution response
42 endin
43
44
45 </CsInstruments>
46 <CsScore>
47 ; record impulse response
48 ; skip IR_dur
49 i13 0 1 0.0 0.5
50 i13 2 1 0.5 0.5
51 i13 4 1 1.0 0.5
52 i13 6 1 1.5 0.5
53 i13 8 1 2.0 0.75
54 i13 10 1 2.38 0.25
55
56 ; convolve
57 i14 0.0 11.65
58
59 e
60
61 </CsScore>
62 </CsoundSynthesizer>
63