Debian Codegraph @

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

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 --env:SSDIR+=../../SourceMaterials
4 -odac -m128
5 </CsOptions>
6 <CsInstruments>
7 sr = 44100
8 ksmps = 128
9 nchnls = 2
10 0dbfs = 1
11
12 ; empty table, live audio input buffer used for granulation
13 giTablen = 131072
14 giLive ftgen 0,0,giTablen,2,0
15
16 ; sigmoid rise/decay shape for fof2, half cycle from bottom to top
17 giSigRise ftgen 0,0,8192,19,0.5,1,270,1
18
19 ; test sound
20 giSample ftgen 0,0,0,1,"fox.wav", 0,0,0
21
22 instr 1
23 ; test sound, replace with live input
24 a1 loscil 1, 1, giSample, 1
25 outch 1, a1
26 chnmix a1, "liveAudio"
27 endin
28
29 instr 2
30 ; write live input to buffer (table)
31 a1 chnget "liveAudio"
32 gkstart tablewa giLive, a1, 0
33 if gkstart < giTablen goto end
34 gkstart = 0
35 end:
36 a0 = 0
37 chnset a0, "liveAudio"
38 endin
39
40 instr 3
41 ; delay parameters
42 kDelTim = 0.5 ; delay time in seconds (max 2.8 seconds)
43 kFeed = 0.8
44 ; delay time random dev
45 kTmod = 0.2
46 kTmod rnd31 kTmod, 1
47 kDelTim = kDelTim+kTmod
48 ; delay pitch random dev
49 kFmod linseg 0, 1, 0, 1, 0.1, 2, 0, 1, 0
50 kFmod rnd31 kFmod, 1
51 ; grain delay processing
52 kamp = ampdbfs(-8)
53 kfund = 25 ; grain rate
54 kform = (1+kFmod)*(sr/giTablen) ; grain pitch transposition
55 koct = 0
56 kband = 0
57 kdur = 2.5 / kfund ; duration relative to grain rate
58 kris = 0.5*kdur
59 kdec = 0.5*kdur
60 kphs = (gkstart/giTablen)-(kDelTim/(giTablen/sr)) ;grain phase
61 kgliss = 0
62 a1 fof2 1, kfund, kform, koct, kband, kris, kdur, kdec, 100, \
63 giLive, giSigRise, 86400, kphs, kgliss
64 outch 2, a1*kamp
65 chnset a1*kFeed, "liveAudio"
66 endin
67
68 </CsInstruments>
69 <CsScore>
70 i 1 0 20
71 i 2 0 20
72 i 3 0 20
73 </CsScore>
74 </CsoundSynthesizer>
75 ;example by Oeyvind Brandtsegg