Debian Codegraph @

examples/farey7shuffled-old.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 -odac -+rtaudio=alsa --midioutfile=farey7.mid
4 </CsOptions>
5 <CsInstruments>
6 sr=48000
7 ksmps=10
8 nchnls=1
9 0dbfs = 1
10
11 gidelta init 100
12 gimult init 101
13
14 ;-------- loop and trigger instrument 901 using a Farey Sequence polyrhythm
15 instr 1
16 kindx init 0
17 kindx2 init 0
18 ktrigger init 0
19 ktime_unit init p6
20 kstart init p4
21 kloop init p5
22 kinitndx init 0
23 kfn_times init gidelta
24 knote init 60
25 kbasenote init p8
26 ifundam init p7
27 ktrigger seqtime ktime_unit, kstart, kloop, kinitndx, kfn_times
28 if (ktrigger > 0 ) then
29 kpitch = cpspch(ifundam)
30 kmult tab kindx2, gimult
31 kpitch = kpitch * kmult
32 knote = kbasenote + kmult
33 event "i", 901, 0, .4, .1, kpitch, kpitch * .9, .4, 5, .75, .8, 1.0, .15, .0, .125, .125, .25, .5, 1.0, .0, .0, .0, .0, .125, .25, .25, .25, knote
34 kindx = kindx + 1
35 kindx = kindx % kloop
36 kindx2 = kindx2 + 1
37 kindx2 = kindx2 % kloop
38 if (kindx2 == 0) then
39 tableshuffle gimult
40 endif
41
42 endif
43 endin ; 1
44
45 ;------ basic 2 Operators FM algorithm ----------------
46 instr 901
47 inotedur = p3
48 imaxamp = p4 ;ampdb(p4)
49 icarrfreq = p5
50 imodfreq = p6
51 ilowndx = p7
52 indxdiff = p8-p7
53 knote = p27
54 aampenv linseg p9, p14*p3, p10, p15*p3, p11, p16*p3, p12, p17*p3, p13
55 adevenv linseg p18, p23*p3, p19, p24*p3, p20, p25*p3, p21, p26*p3, p22
56 amodosc oscili (ilowndx+indxdiff*adevenv)*imodfreq, imodfreq, 10
57 acarosc oscili imaxamp*aampenv, icarrfreq+amodosc, 10
58 out acarosc
59 ;------ we also write down a midi track here ----------
60 midion 1, knote, 100
61 endin ; 901
62
63 </CsInstruments>
64
65 <CsScore>
66 f10 0 4096 10 1
67 f100 0 -18 "farey" 7 1
68 f101 0 -18 "farey" 7 2
69
70 ; p4 kstart := index offset into the Farey Sequence
71 ; p5 kloop := end index into Farey Seq.
72 ; p6 timefac := time in seconds for one loop to complete
73 ; p7 fundam := fundamental of the FM instrument
74 ; p8 basenote:= root pitch of the midi voice output
75 ; note that pitch structures of the midi file output are not equivalent to the
76 ; ones used for the FM real-time synthesis.
77
78 ; start dur kstart kloop timefac fundam. basenote
79 i1 0.0 44 0 18 1 6.05 60
80 i1 4 40 0 18 3 7.05 72
81 i1 10 38 0 18 1.5 8 84
82 i1 15 50 0 18 1 5 48
83 i1 22 75 5 17 1.7 4 36
84 e
85 </CsScore>
86
87 </CsoundSynthesizer>