Debian Codegraph @

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

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 -o dac -m128
4 </CsOptions>
5 <CsInstruments>
6 sr = 44100
7 ksmps = 32
8 nchnls = 2
9 0dbfs = 1
10 seed 0
11
12 opcode AddSynth,a,i[]i[]iooo
13 /* iFqs[], iAmps[]: arrays with frequency ratios and amplitude multipliers
14 iBasFreq: base frequency (hz)
15 iPtlIndex: partial index (first partial = index 0)
16 iFreqDev, iAmpDev: maximum frequency (cent) and amplitude (db) deviation */
17 iFqs[], iAmps[], iBasFreq, iPtlIndx, iFreqDev, iAmpDev xin
18 iFreq = iBasFreq * iFqs[iPtlIndx] * cent(rnd31:i(iFreqDev,0))
19 iAmp = iAmps[iPtlIndx] * ampdb(rnd31:i(iAmpDev,0))
20 aPartial poscil iAmp, iFreq
21 if iPtlIndx < lenarray(iFqs)-1 then
22 aPartial += AddSynth(iFqs,iAmps,iBasFreq,iPtlIndx+1,iFreqDev,iAmpDev)
23 endif
24 xout aPartial
25 endop
26
27 ;frequency and amplitude multipliers for 11 partials of Risset's bell
28 giFqs[] fillarray .56, .563, .92, .923, 1.19, 1.7, 2, 2.74, 3, 3.74, 4.07
29 giAmps[] fillarray 1, 2/3, 1, 1.8, 8/3, 5/3, 1.46, 4/3, 4/3, 1, 4/3
30
31 instr Risset_Bell
32 ibasfreq = p4
33 iamp = ampdb(p5)
34 ifqdev = p6 ;maximum freq deviation in cents
35 iampdev = p7 ;maximum amp deviation in dB
36 aRisset AddSynth giFqs, giAmps, ibasfreq, 0, ifqdev, iampdev
37 aRisset *= transeg:a(0, .01, 0, iamp/10, p3-.01, -10, 0)
38 out aRisset, aRisset
39 endin
40
41 instr PlayTheBells
42 iMidiPitch random 60,70
43 schedule("Risset_Bell",0,random:i(2,8),mtof:i(iMidiPitch),
44 random:i(-30,-10),30,6)
45 if p4 > 0 then
46 schedule("PlayTheBells",random:i(1/10,1/4),1,p4-1)
47 endif
48 endin
49
50 </CsInstruments>
51 <CsScore>
52 ; base db frequency amplitude
53 ; freq deviation deviation
54 ; in cent in dB
55 r 2 ;unchanged sound
56 i 1 0 5 400 -6 0 0
57 r 2 ;variations in frequency
58 i 1 0 5 400 -6 50 0
59 r 2 ;variations in amplitude
60 i 1 0 5 400 -6 0 10
61 s
62 i "PlayTheBells" 0 1 50 ;perform sequence of 50 bells
63 </CsScore>
64 </CsoundSynthesizer>
65 ;example by joachim heintz