Debian Codegraph @

examples/gen15.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 ; Select audio/midi flags here according to platform
4 -odac ;;;realtime audio out
5 ;-iadc ;;;uncomment -iadc if realtime audio input is needed too
6 ; For Non-realtime ouput leave only the line below:
7 ; -o gen15.wav -W ;;; for file output any platform
8 </CsOptions>
9 <CsInstruments>
10 ;example from the Csound Book, page 85
11 sr = 44100
12 ksmps = 32
13 nchnls = 2
14 0dbfs = 1
15
16 instr 1
17
18 idur = p3
19 iamp = p4
20 ifrq = cpspch(p5) ;pitch
21 iswp1 = p6
22 iswp2 = p7
23 kswp line iswp1, p3, iswp2 ;amplitude sweep values
24 acosi oscili kswp*.5, ifrq, 2 ;f2=cosine wave
25 asine oscili kswp, ifrq, 1 ;f1=sine wave
26 atab1 tablei acosi, 33, 1, .5 ;tables a1 to GEN13
27 atab2 tablei acosi, 34, 1, .5 ;tables a1 to GEN14
28 knrm1 tablei kswp, 35, 1 ;normalizing f35
29 knrm2 tablei kswp, 36, 1 ;normalizing f36
30 anrm1 = atab1*knrm1 ;normalize GEN13 signal
31 anrm2 = atab2*knrm2*asine ;normalize GEN14 signal
32 amix = anrm1+anrm2 ;mix GEN13 and GEN14
33 kenv expseg .001, idur*.1, iamp, idur*.1, iamp*.8, idur*.8, .001
34 asig = amix*kenv
35 outs asig, asig
36
37 endin
38
39 </CsInstruments>
40 <CsScore>
41 f 1 0 8193 10 1 ;sine wave
42 f 2 0 8193 9 1 1 90 ;cosine wave
43
44 ; Note that all the f33 tables in the following sections are defined with p4=-15,
45 ; which means that tables 33 and 34 will not be normalized. Thus if we display
46 ; tables when running this example, we'll get correct diagrams even if one table
47 ; has very small values instead of 0 values, due to cpu approximations in processing
48 ; sin(180), as in sections 2, 4, and 5. This has no consequence on the audio result,
49 ; because of the use of amp normalization (tables 35 and 36).
50
51 f 33 0 8193 -15 1 1 1 0 1 180 .8 45 .6 270 .5 90 .4 225 .2 135 .1 315 ;makes function tables 33 and 34
52 f 35 0 4097 4 33 1 ;amp normalization for f33
53 f 36 0 4097 4 34 1 ;amp normalization for f34
54 i 1 0 5 .6 8.00 0 1
55 i 1 + . .6 8.00 1 0
56 s
57 ;even harmonics with no phase shift, odd harmonics with phase shift
58 f 33 0 8193 -15 1 1 1 0 1 0 1 180 1 180 1 0 1 0 1 180 1 180 1 0 1 0 1 180 1 180
59 f 35 0 4097 4 33 1 ;amp normalization for f33
60 f 36 0 4097 4 34 1 ;amp normalization for f34
61 i 1 0 5 .6 8.00 0 1
62 i 1 + . .6 8.00 1 0
63 s
64 ;different harmonic strenghts and phases
65 f 33 0 8193 -15 1 1 1 0 1 0 .9 180 .5 270 .75 90 .4 45 .2 225 .1 0
66 f 35 0 4097 4 33 1 ;amp normalization for f33
67 f 36 0 4097 4 34 1 ;amp normalization for f34
68 i 1 0 5 .6 8.00 0 1
69 i 1 + . .6 8.00 1 0
70 s
71 ;lower harmonics no phase shift, upper harmonics with phase shift
72 f 33 0 8193 -15 1 1 1 0 1 0 .5 0 .9 0 .3 0 .75 0 .2 180 .6 180 .15 180 .5 180 .1 180
73 f 35 0 4097 4 33 1 ;amp normalization for f33
74 f 36 0 4097 4 34 1 ;amp normalization for f34
75 i 1 0 5 .6 8.00 0 1
76 i 1 + . .6 8.00 1 0
77
78 s
79 ;lower harmonics with phase shift, upper harmonics no phase shift
80 f 33 0 8193 -15 1 1 1 180 1 180 .5 180 .9 180 .3 180 .75 180 .2 0 .6 0 .15 0 .5 0 .1 0
81 f 35 0 4097 4 33 1 ;amp normalization for f33
82 f 36 0 4097 4 34 1 ;amp normalization for f34
83 i 1 0 5 .6 8.00 0 1
84 i 1 + . .6 8.00 1 0
85 e
86 </CsScore>
87 </CsoundSynthesizer>