Debian Codegraph @

examples/genfarey-2.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 ; Select audio/midi flags here according to platform
4 -odac ;;;realtime audio out
5 ;-iadc ;;;uncomment -iadc for RT audio input as well
6 ; For Non-realtime ouput leave only the line below:
7 ; -o genfarey.wav -W ;;; for file output any platform
8 </CsOptions>
9 <CsInstruments>
10 sr = 44100
11 ksmps = 32
12 nchnls = 2
13 0dbfs = 1
14
15 ; GENfarey creates table gidelta.
16 ; The table contains the delta values of Farey Sequence 7 (p5=7).
17 ; They are used as Inter Onset Intervals (IOIs) or event durations.
18 ; If p6 is set to 1 for IOI output then the length of the table (p3=-18) is -(|F_7| - 1)
19 ; Remember that a negative sign is for non-power-of-2 table lengths.
20 ; The negative sign in front of the GEN number prevents post-normalisation of its values.
21
22 gidelta ftgen 0,0,-18,"farey",7,1
23
24 ; Use GENfarey with p6 set to 2 to generate the denominators of fractions of F_7
25 ; this is used in this example as factors to create a series of pitches:
26 gimult ftgen 0,0,-18,"farey",7,2
27
28 ;-------- loop and trigger instrument 901 using a Farey Sequence polyrhythm
29 instr 1
30 kindx init 0
31 kindx2 init 0
32 ktrigger init 0
33 ktime_unit init p6
34 kstart init p4
35 kloop init p5
36 kinitndx init 0
37 kfn_times init gidelta
38 knote init 60
39 kbasenote init p8
40 ifundam init p7
41 ktrigger seqtime ktime_unit, kstart, kloop, kinitndx, kfn_times
42 if (ktrigger > 0 ) then
43 kpitch = cpspch(ifundam)
44 kmult tab kindx2, gimult
45 kpitch = kpitch * kmult
46 knote = kbasenote + kmult
47 event "i", 901, 0, .4, .10, kpitch, kpitch * .9, 0.4, 5, .75, .8, 1.0, .15, .0, .125, .125, .25, .5, 1.0, .0, .0, .0, .0, .125, .25, .25, .25, knote
48 kindx = kindx + 1
49 kindx = kindx % kloop
50 kindx2 = kindx2 + 1
51 kindx2 = kindx2 % kloop
52 endif
53 endin
54
55 ;------ basic 2 Operators FM algorithm ----------------
56 instr 901
57 inotedur = p3
58 imaxamp = p4 ;ampdb(p4)
59 icarrfreq = p5
60 imodfreq = p6
61 ilowndx = p7
62 indxdiff = p8-p7
63 knote = p27
64 aampenv linseg p9, p14*p3, p10, p15*p3, p11, p16*p3, p12, p17*p3, p13
65 adevenv linseg p18, p23*p3, p19, p24*p3, p20, p25*p3, p21, p26*p3, p22
66 amodosc oscili (ilowndx+indxdiff*adevenv)*imodfreq, imodfreq, 10
67 acarosc oscili imaxamp*aampenv, icarrfreq+amodosc, 10
68 outs acarosc, acarosc
69 endin
70 </CsInstruments>
71 <CsScore>
72 f10 0 4096 10 1 ;sine wave
73 ; p4 kstart := index offset into the Farey Sequence
74 ; p5 kloop := end index into Farey Seq.
75 ; p6 timefac := time in seconds for one loop to complete
76 ; p7 fundam := fundamental of the FM instrument
77 ; p8 basenote:= root pitch of the midi voice output
78 ; note that pitch structures of the midi file output are not equivalent to the
79 ; ones used for the FM real-time synthesis.
80
81 ; start dur kstart kloop timefac fundam. basenote
82 i1 0.0 44 0 18 2 6.05 60
83 i1 4 30 0 18 3 7.05 72
84 i1 34 12 9 18 3 7.05 72
85 i1 10 12 0 18 1.5 8 84
86 i1 22 12 0 9 1.5 8 84
87 i1 15 16 0 18 1 5 48
88 i1 22 20 5 17 1.7 4 36
89
90 i1 46 20 3 11 2.5 7.04 71
91 i1 51 20 5 13 2.5 7.06 72
92
93 i1 73.5 1.5 11 18 1.5 5.05 48
94 i1 75 1 12 18 1 6.03 58
95 e
96 </CsScore>
97 </CsoundSynthesizer>
98