Debian Codegraph @

examples/gen13.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 gen13.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 ;example by Russell Pinkston - Univ. of Texas (but slightly modified)
16
17 gisine ftgen 0, 0, 16384, 10, 1 ;sine wave
18
19 instr 1
20
21 ihertz = cpspch(p4)
22 ipkamp = p5
23 iwsfn = p6 ;waveshaping function
24 inmfn = p7 ;normalization function
25 agate linen 1, .01, p3, .1 ;overall amp envelope
26 kctrl linen .99, 2, p3, 2 ;waveshaping index control
27 aindex poscil kctrl/2, ihertz, gisine ;sine wave to be distorted
28 asignal tablei .5+aindex, iwsfn, 1 ;waveshaping
29 knormal tablei kctrl, inmfn, 1 ;amplitude normalization
30 asig = asignal*knormal*ipkamp*agate
31 outs asig, asig
32
33 endin
34 </CsInstruments>
35 <CsScore>
36 ; This proves the statement in Dodge (p. 147) that Chebyshev polynomials
37 ; of order K have "only the kth harmonic." This is only true when the
38 ; waveshaping index is at the maximum - i.e., when the entire transfer
39 ; function is being accessed. RP.
40 ;--------------------------------------------------------------------------------------------------------------------------------------------
41 ; quasi sawtooth transfer function:
42 ; h0 h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 h12 h13 h14 h15 h16 h17 h18 h19 h20
43 f1 0 513 13 1 1 0 100 -50 -33 25 20 -16.7 -14.2 12.5 11.1 -10 -9.09 8.333 7.69 -7.14 -6.67 6.25 5.88 -5.55 -5.26 5
44 f2 0 257 4 1 1 ; normalizing function with midpoint bipolar offset
45
46 ; st dur pch amp wsfn nmfn
47 i1 0 4 6.00 .7 1 2
48 i1 4 . 7.00 .
49 i1 8 . 8.00 .
50 ;--------------------------------------------------------------------------------------------------------------------------------------------
51 ; quasi square wave transfer function:
52 ; h0 h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 h12 h13 h14 h15 h16 h17 h18 h19
53 f3 0 513 13 1 1 0 100 0 -33 0 20 0 -14.2 0 11.1 0 -9.09 0 7.69 0 -6.67 0 5.88 0 -5.26
54 f4 0 257 4 3 1 ; normalizing function with midpoint bipolar offset
55
56 ; st dur pch amp wsfn nmfn
57 i1 16 4 6.00 .7 3 4
58 i1 20 . 7.00 .
59 i1 24 . 8.00 .
60 ;--------------------------------------------------------------------------------------------------------------------------------------------
61 ; quasi triangle wave transfer function:
62 ; h0 h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 h12 h13 h14 h15 h16 h17 h18 h19
63 f5 0 513 13 1 1 0 100 0 -11.11 0 4 0 -2.04 0 1.23 0 -.826 0 .59 0 -.444 0 .346 0 -.277
64 f6 0 257 4 5 1 ; normalizing function with midpoint bipolar offset
65 ; st dur pch amp wsfn nmfn
66 i1 32 4 6.00 .7 5 6
67 i1 36 . 7.00 .
68 i1 40 . 8.00 .
69 ;--------------------------------------------------------------------------------------------------------------------------------------------
70 ; transfer function1: h0 h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 h12 h13 h14 h15 h16
71 f7 0 513 13 1 1 0 1 -.8 0 .6 0 0 0 .4 0 0 0 0 .1 -.2 -.3 .5
72 f8 0 257 4 7 1 ; normalizing function with midpoint bipolar offset
73 ; st dur pch amp wsfn nmfn
74 i1 48 4 5.00 .7 7 8
75 i1 52 . 6.00 .
76 i1 56 . 7.00 .
77 ;--------------------------------------------------------------------------------------------------------------------------------------------
78 ;=========================================================================;
79 ; This demonstrates the use of high partials, sometimes without a ;
80 ; fundamental, to get quasi-inharmonic spectra from waveshaping. ;
81 ;=========================================================================;
82 ; transfer function2: h0 h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 h12 h13 h14 h15 h16
83 f9 0 513 13 1 1 0 0 0 -.1 0 .3 0 -.5 0 .7 0 -.9 0 1 0 -1 0
84 f10 0 257 4 9 1 ; normalizing function with midpoint bipolar offset
85 ; st dur pch amp wsfn nmfn
86 i1 64 4 5.00 .7 9 10
87 i1 68 . 6.00 .
88 i1 72 . 7.00 .
89 ;--------------------------------------------------------------------------------------------------------------------------------------------
90 ; transfer function3: h0 h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 h12 h13 h14 h15 h16 h17 h18 h19 h17 h18 h19 h20
91 f11 0 513 13 1 1 0 0 0 0 0 0 0 -1 0 1 0 0 -.1 0 .1 0 -.2 .3 0 -.7 0 .2 0 -.1
92 f12 0 257 4 11 1 ; normalizing function with midpoint bipolar offset
93
94 ; st dur pch amp wsfn nmfn
95 i1 80 4 5.00 .7 11 12
96 i1 84 . 5.06 .
97 i1 88 . 6.00 .
98 ;--------------------------------------------------------------------------------------------------------------------------------------------
99 ;=========================================================================;
100 ; split a sinusoid into 3 odd-harmonic partials of relative strength 5:3:1
101 ;=========================================================================;
102 ;--------------------------------------------------------------------------------------------------------------------------------------------
103 ; transfer function4: h0 h1 h2 h3 h4 h5
104 f13 0 513 13 1 1 0 5 0 3 0 1
105 f14 0 257 4 13 1 ; normalizing function with midpoint bipolar offset
106
107 ; st dur pch amp wsfn nmfn
108 i1 96 4 5.00 .7 13 14
109 i1 100 . 5.06 .
110 i1 104 . 6.00 .
111 e
112 </CsScore>
113 </CsoundSynthesizer>
114