Debian Codegraph @

examples/frac2.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 ; Select audio/midi flags here according to platform
4 -odac ;;;RT audio out
5 ;-iadc ;;;uncomment -iadc if RT audio input is needed too
6 ; For Non-realtime ouput leave only the line below:
7 ; -o frac.wav -W ;;; for file output any platform
8
9 ; By Stefano Cucchi 2024
10 </CsOptions>
11 <CsInstruments>
12
13 sr = 44100
14 ksmps = 32
15 0dbfs = 1
16 nchnls = 2
17
18 instr 1
19
20 gkrandom randomh 1, 45, 300, 2, 3 ; generate some random numbers
21 gkrandomFLOOR = floor (gkrandom) ; take the integer part
22 gkrandomFRAC = frac (gkrandom) ; take the fractional part
23
24 endin
25
26 instr 10
27
28 ktrigger metro 4
29 kmintim = 0
30 kmaxnum = 10
31 kinsnum = 20
32 kwhen = 0
33 kdur = ktrigger*0.25
34
35 schedkwhen ktrigger, kmintim, kmaxnum, kinsnum, kwhen, kdur
36
37 endin
38
39 instr 20
40
41 irandomFLOOR = i(gkrandomFLOOR)
42 irandomFRAC = i(gkrandomFRAC)
43
44 ; Use the integer part to control the number of harmonics of every note
45 ; after converting (k) value to (i)
46 prints "generated value = %f\n", i(gkrandom)
47 prints "fractional part = %f\n", irandomFRAC
48 a1 buzz 0.5, 120, irandomFLOOR, 1
49 kenvelope linseg 0, p3*0.1, 1, p3*0.8, 1, p3*0.1, 0
50 a1 = a1*kenvelope
51 aL, aR pan2 a1, irandomFRAC, 1 ; use the fractional part to control the pan position
52 outs aL, aR
53
54 endin
55
56 </CsInstruments>
57 <CsScore>
58
59 f 1 0 16384 10 1
60
61 i 1 0 10
62 i 10 0 10
63 e
64 </CsScore>
65 </CsoundSynthesizer>