Debian Codegraph @

src/Examples/FLOSS Manual Examples/04 Sound Synthesis/04A07_Risset_variations.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 -o dac -m0
4 </CsOptions>
5 <CsInstruments>
6 sr = 44100
7 ksmps = 32
8 nchnls = 2
9 0dbfs = 1
10 seed 0
11
12 ;frequency and amplitude multipliers for 11 partials of Risset's bell
13 giFqs[] fillarray .56, .563, .92, .923, 1.19, 1.7, 2, 2.74, 3, 3.74, 4.07
14 giAmps[] fillarray 1, 2/3, 1, 1.8, 8/3, 5/3, 1.46, 4/3, 4/3, 1, 4/3
15 gSComments[] fillarray "unchanged sound", "slight variations in frequency",
16 "slight variations in amplitude", "slight variations in duration",
17 "slight variations combined", "heavy variations"
18 giCommentsIndx[] fillarray 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
19 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5
20 giCommentsCounter init 0
21
22 instr 1 ;master instrument
23 ibasfreq = 400
24 ifqdev = p4 ;maximum freq deviation in cents
25 iampdev = p5 ;maximum amp deviation in dB
26 idurdev = p6 ;maximum duration deviation in %
27 indx = 0 ;count variable for loop
28 iMsgIndx = giCommentsIndx[giCommentsCounter]
29 puts gSComments[iMsgIndx], 1
30 giCommentsCounter += 1
31 while indx < 11 do
32 ifqmult = giFqs[indx] ;get frequency multiplier from array
33 ifreq = ibasfreq * ifqmult
34 iampmult = giAmps[indx] ;get amp multiplier
35 iamp = iampmult / 20 ;scale
36 event_i "i", 10, 0, p3, ifreq, iamp, ifqdev, iampdev, idurdev
37 indx += 1
38 od
39 endin
40
41 instr 10 ;subinstrument for playing one partial
42 ;receive the parameters from the master instrument
43 ifreqnorm = p4 ;standard frequency of this partial
44 iampnorm = p5 ;standard amplitude of this partial
45 ifqdev = p6 ;maximum freq deviation in cents
46 iampdev = p7 ;maximum amp deviation in dB
47 idurdev = p8 ;maximum duration deviation in %
48 ;calculate frequency
49 icent random -ifqdev, ifqdev ;cent deviation
50 ifreq = ifreqnorm * cent(icent)
51 ;calculate amplitude
52 idb random -iampdev, iampdev ;dB deviation
53 iamp = iampnorm * ampdb(idb)
54 ;calculate duration
55 idurperc random -idurdev, idurdev ;duration deviation (%)
56 iptdur = p3 * 2^(idurperc/100)
57 p3 = iptdur ;set p3 to the calculated value
58 ;play partial
59 aenv transeg 0, .01, 0, iamp, p3-.01, -10, 0
60 apart poscil aenv, ifreq
61 outs apart, apart
62 endin
63
64 </CsInstruments>
65 <CsScore>
66 ; frequency amplitude duration
67 ; deviation deviation deviation
68 ; in cent in dB in %
69 ;;unchanged sound (twice)
70 r 2
71 i 1 0 5 0 0 0
72 s
73 ;;slight variations in frequency
74 r 4
75 i 1 0 5 25 0 0
76 ;;slight variations in amplitude
77 r 4
78 i 1 0 5 0 6 0
79 ;;slight variations in duration
80 r 4
81 i 1 0 5 0 0 30
82 ;;slight variations combined
83 r 6
84 i 1 0 5 25 6 30
85 ;;heavy variations
86 r 6
87 i 1 0 5 50 9 100
88 </CsScore>
89 </CsoundSynthesizer>
90 ;Example by joachim heintz