Debian Codegraph @

examples/adsynt.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 adsynt.wav -W ;;; for file output any platform
8 </CsOptions>
9 <CsInstruments>
10
11 sr = 44100
12 ksmps = 32
13 nchnls = 2
14 0dbfs = 1
15 ; Generate a sinewave table.
16 giwave ftgen 1, 0, 1024, 10, 1
17 ; Generate two empty tables for adsynt.
18 gifrqs ftgen 2, 0, 32, 7, 0, 32, 0
19 ; A table for freqency and amp parameters.
20 giamps ftgen 3, 0, 32, 7, 0, 32, 0
21
22 ; Generates parameters at init time
23 instr 1
24 ; Generate 10 voices.
25 icnt = 10
26 ; Init loop index.
27 index = 0
28
29 ; Loop only executed at init time.
30 loop:
31 ; Define non-harmonic partials.
32 ifreq pow index + 1, 1.5
33 ; Define amplitudes.
34 iamp = 1 / (index+1)
35 ; Write to tables.
36 tableiw ifreq, index, gifrqs
37 ; Used by adsynt.
38 tableiw iamp, index, giamps
39
40 index = index + 1
41 ; Do loop/
42 if (index < icnt) igoto loop
43
44 asig adsynt 0.3, 150, giwave, gifrqs, giamps, icnt
45 outs asig, asig
46 endin
47
48 ; Generates parameters every k-cycle.
49 instr 2
50 ; Generate 10 voices.
51 icnt = 10
52 ; Reset loop index.
53 kindex = 0
54
55 ; Loop executed every k-cycle.
56 loop:
57 ; Generate lfo for frequencies.
58 kspeed pow kindex + 1, 1.6
59 ; Individual phase for each voice.
60 kphas phasorbnk kspeed * 0.7, kindex, icnt
61 klfo table kphas, giwave, 1
62 ; Arbitrary parameter twiddling...
63 kdepth pow 1.4, kindex
64 kfreq pow kindex + 1, 1.5
65 kfreq = kfreq + klfo*0.006*kdepth
66
67 ; Write freqs to table for adsynt.
68 tablew kfreq, kindex, gifrqs
69
70 ; Generate lfo for amplitudes.
71 kspeed pow kindex + 1, 0.8
72 ; Individual phase for each voice.
73 kphas phasorbnk kspeed*0.13, kindex, icnt, 2
74 klfo table kphas, giwave, 1
75 ; Arbitrary parameter twiddling...
76 kamp pow 1 / (kindex + 1), 0.4
77 kamp = kamp * (0.3+0.35*(klfo+1))
78
79 ; Write amps to table for adsynt.
80 tablew kamp, kindex, giamps
81
82 kindex = kindex + 1
83 ; Do loop.
84 if (kindex < icnt) kgoto loop
85
86 asig adsynt 0.25, 150, giwave, gifrqs, giamps, icnt
87 outs asig, asig
88 endin
89
90
91 </CsInstruments>
92 <CsScore>
93
94 ; Play Instrument #1 for 2.5 seconds.
95 i 1 0 2.5
96 ; Play Instrument #2 for 2.5 seconds.
97 i 2 3 2.5
98 e
99
100
101 </CsScore>
102 </CsoundSynthesizer>