Debian Codegraph @

examples/endop.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 endop.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 /* example opcode 1: simple oscillator */
17
18 opcode Oscillator, a, kk
19
20 kamp, kcps xin ; read input parameters
21 a1 vco2 kamp, kcps ; sawtooth oscillator
22 xout a1 ; write output
23
24 endop
25
26 /* example opcode 2: lowpass filter with local ksmps */
27
28 opcode Lowpass, a, akk
29
30 setksmps 1 ; need sr=kr
31 ain, ka1, ka2 xin ; read input parameters
32 aout init 0 ; initialize output
33 aout = ain*ka1 + aout*ka2 ; simple tone-like filter
34 xout aout ; write output
35
36 endop
37
38 /* example opcode 3: recursive call */
39
40 opcode RecursiveLowpass, a, akkpp
41
42 ain, ka1, ka2, idep, icnt xin ; read input parameters
43 if (icnt >= idep) goto skip1 ; check if max depth reached
44 ain RecursiveLowpass ain, ka1, ka2, idep, icnt + 1
45 skip1:
46 aout Lowpass ain, ka1, ka2 ; call filter
47 xout aout ; write output
48
49 endop
50
51 /* example opcode 4: de-click envelope */
52
53 opcode DeClick, a, a
54
55 ain xin
56 aenv linseg 0, 0.02, 1, p3 - 0.05, 1, 0.02, 0, 0.01, 0
57 xout ain * aenv ; apply envelope and write output
58
59 endop
60
61 /* instr 1 uses the example opcodes */
62
63 instr 1
64
65 kamp = .6 ; amplitude
66 kcps expon 50, p3, 500 ; pitch
67 a1 Oscillator kamp, kcps ; call oscillator
68 kflt linseg 0.4, 1.5, 0.4, 1, 0.8, 1.5, 0.8 ; filter envelope
69 a1 RecursiveLowpass a1, kflt, 1 - kflt, 10 ; 10th order lowpass
70 a1 DeClick a1
71 outs a1, a1
72
73 endin
74 </CsInstruments>
75 <CsScore>
76
77 i 1 0 4
78 e
79
80 </CsScore>
81 </CsoundSynthesizer>