| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
-odac --env:SSDIR+=../../SourceMaterials |
| 4 |
</CsOptions> |
| 5 |
<CsInstruments> |
| 6 |
|
| 7 |
sr = 44100 |
| 8 |
ksmps = 32 |
| 9 |
nchnls = 2 |
| 10 |
0dbfs = 1 |
| 11 |
|
| 12 |
; the name of the sound file used is defined as a string variable - |
| 13 |
; - as it will be used twice in the code. |
| 14 |
; This simplifies adapting the orchestra to use a different sound file |
| 15 |
gSfile = "ClassGuit.wav" |
| 16 |
|
| 17 |
; waveform used for granulation |
| 18 |
giSound ftgen 1,0,0,1,gSfile,0,0,0 |
| 19 |
|
| 20 |
; window function - used as an amplitude envelope for each grain |
| 21 |
giWFn ftgen 2,0,16384,9,0.5,1,0 |
| 22 |
|
| 23 |
seed 0 ; seed the random generators from the system clock |
| 24 |
gaSendL init 0 ; initialize global audio variables |
| 25 |
gaSendR init 0 |
| 26 |
|
| 27 |
instr 1 ; triggers instrument 2 |
| 28 |
ktrigger metro 1/12.5 ;metronome of triggers. One every 12.5s |
| 29 |
schedkwhen ktrigger,0,0,2,0,40 ;trigger instr. 2 for 40s |
| 30 |
endin |
| 31 |
|
| 32 |
instr 2 ; generates granular synthesis textures |
| 33 |
;define the input variables |
| 34 |
ifn1 = giSound |
| 35 |
ilen = nsamp(ifn1)/sr |
| 36 |
iPtrStart random 1,ilen-1 |
| 37 |
iPtrTrav random -1,1 |
| 38 |
ktimewarp line iPtrStart,p3,iPtrStart+iPtrTrav |
| 39 |
kamp linseg 0,p3/2,0.2,p3/2,0 |
| 40 |
iresample random -24,24.99 |
| 41 |
iresample = semitone(int(iresample)) |
| 42 |
ifn2 = giWFn |
| 43 |
ibeg = 0 |
| 44 |
iwsize random 400,10000 |
| 45 |
irandw = iwsize/3 |
| 46 |
ioverlap = 50 |
| 47 |
itimemode = 1 |
| 48 |
; create a stereo granular synthesis texture using sndwarp |
| 49 |
aSigL,aSigR sndwarpst kamp,ktimewarp,iresample,ifn1,ibeg,\ |
| 50 |
iwsize,irandw,ioverlap,ifn2,itimemode |
| 51 |
; envelope the signal with a lowpass filter |
| 52 |
kcf expseg 50,p3/2,12000,p3/2,50 |
| 53 |
aSigL moogvcf2 aSigL, kcf, 0.5 |
| 54 |
aSigR moogvcf2 aSigR, kcf, 0.5 |
| 55 |
; add a little of our audio signals to the global send variables - |
| 56 |
; - these will be sent to the reverb instrument (2) |
| 57 |
gaSendL = gaSendL+(aSigL*0.4) |
| 58 |
gaSendR = gaSendR+(aSigR*0.4) |
| 59 |
outs aSigL,aSigR |
| 60 |
endin |
| 61 |
|
| 62 |
instr 3 ; reverb (always on) |
| 63 |
aRvbL,aRvbR reverbsc gaSendL,gaSendR,0.85,8000 |
| 64 |
outs aRvbL,aRvbR |
| 65 |
;clear variables to prevent out of control accumulation |
| 66 |
clear gaSendL,gaSendR |
| 67 |
endin |
| 68 |
|
| 69 |
</CsInstruments> |
| 70 |
<CsScore> |
| 71 |
; p1 p2 p3 |
| 72 |
i 1 0 3600 ; triggers instr 2 |
| 73 |
i 3 0 3600 ; reverb instrument |
| 74 |
</CsScore> |
| 75 |
</CsoundSynthesizer> |
| 76 |
;example written by Iain McCurdy |