Debian Codegraph @

examples/cos.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 cos.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
16 instr 1
17 icos1 = cos(0) ;cosine of 0 is 1
18 icos2 = cos($M_PI_2) ;cosine of pi/2 (1.5707...) is 0
19 icos3 = cos($M_PI) ;cosine of pi (3.1415...) is -1
20 icos4 = cos($M_PI_2 * 3) ;cosine of 3/2pi (4.7123...) is 0
21 icos5 = cos($M_PI * 2) ;cosine of 2pi (6.2831...) is 1
22 icos6 = cos($M_PI * 4) ;cosine of 4pi is also 1 as it is periodically to 2pi
23 print icos1, icos2, icos3, icos4, icos5, icos6
24 endin
25
26 instr 2 ;cos used in panning, after an example from Hans Mikelson
27 aout vco2 0.8, 220 ; sawtooth
28 kpan linseg p4, p3, p5 ;0 = left, 1 = right
29 kpan = kpan*$M_PI_2 ;range 0-1 becomes 0-pi/2
30 kpanl = cos(kpan)
31 kpanr = sin(kpan)
32 outs aout*kpanl, aout*kpanr
33 endin
34
35 </CsInstruments>
36 <CsScore>
37 i 1 0 0
38 i 2 0 5 0 1 ;move left to right
39 i 2 6 5 1 0 ;move right to left
40 e
41 </CsScore>
42 </CsoundSynthesizer>