Debian Codegraph @

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

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 -o dac
4 </CsOptions>
5 <CsInstruments>
6 sr = 44100
7 ksmps = 32
8 nchnls = 2
9 0dbfs = 1
10
11 instr 1 ;harmonic additive synthesis
12 ;receive general pitch and volume from the score
13 ibasefrq = cpspch(p4) ;convert pitch values to frequency
14 ibaseamp = ampdbfs(p5) ;convert dB to amplitude
15 ;create 8 harmonic partials
16 aOsc1 poscil ibaseamp, ibasefrq
17 aOsc2 poscil ibaseamp/2, ibasefrq*2
18 aOsc3 poscil ibaseamp/3, ibasefrq*3
19 aOsc4 poscil ibaseamp/4, ibasefrq*4
20 aOsc5 poscil ibaseamp/5, ibasefrq*5
21 aOsc6 poscil ibaseamp/6, ibasefrq*6
22 aOsc7 poscil ibaseamp/7, ibasefrq*7
23 aOsc8 poscil ibaseamp/8, ibasefrq*8
24 ;apply simple envelope
25 kenv linen 1, p3/4, p3, p3/4
26 ;add partials and write to output
27 aOut = aOsc1 + aOsc2 + aOsc3 + aOsc4 + aOsc5 + aOsc6 + aOsc7 + aOsc8
28 outs aOut*kenv, aOut*kenv
29 endin
30
31 instr 2 ;inharmonic additive synthesis
32 ibasefrq = cpspch(p4)
33 ibaseamp = ampdbfs(p5)
34 ;create 8 inharmonic partials
35 aOsc1 poscil ibaseamp, ibasefrq
36 aOsc2 poscil ibaseamp/2, ibasefrq*1.02
37 aOsc3 poscil ibaseamp/3, ibasefrq*1.1
38 aOsc4 poscil ibaseamp/4, ibasefrq*1.23
39 aOsc5 poscil ibaseamp/5, ibasefrq*1.26
40 aOsc6 poscil ibaseamp/6, ibasefrq*1.31
41 aOsc7 poscil ibaseamp/7, ibasefrq*1.39
42 aOsc8 poscil ibaseamp/8, ibasefrq*1.41
43 kenv linen 1, p3/4, p3, p3/4
44 aOut = aOsc1 + aOsc2 + aOsc3 + aOsc4 + aOsc5 + aOsc6 + aOsc7 + aOsc8
45 outs aOut*kenv, aOut*kenv
46 endin
47
48 </CsInstruments>
49 <CsScore>
50 ; pch amp
51 i 1 0 5 8.00 -13
52 i 1 3 5 9.00 -17
53 i 1 5 8 9.02 -15
54 i 1 6 9 7.01 -15
55 i 1 7 10 6.00 -13
56 s
57 i 2 0 5 8.00 -13
58 i 2 3 5 9.00 -17
59 i 2 5 8 9.02 -15
60 i 2 6 9 7.01 -15
61 i 2 7 10 6.00 -13
62 </CsScore>
63 </CsoundSynthesizer>
64 ;example by Andrés Cabrera