Debian Codegraph @

examples/pindex-2.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 ; Select audio/midi flags here according to platform
4 -odac ;;;realtime audio
5 ;-iadc ;;;uncomment -iadc if realtime audio input is needed too
6 ; For Non-realtime ouput leave only the line below:
7 ; -o pindex-2.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 ; This UDO returns a pfield value but returns 0 if it does not exist.
17 opcode mypvalue, i, i
18 index xin
19 inum pcount
20 if (index > inum) then
21 iout = 0.0
22 else
23 iout pindex index
24 endif
25
26 xout iout
27 endop
28
29 ; Envelope UDO that reads parameters from a flexible number of pfields
30 ; Syntax: kenv flexlinseg ipstart
31 ; ipstart is the first pfield of the envelope
32 ; parameters. Reads remaining pfields (up to 21 of them).
33 ; kenv is the output envelope.
34
35 opcode flexlinseg, k, i
36 ipstart xin
37
38 iep1 mypvalue ipstart
39 iep2 mypvalue ipstart + 1
40 iep3 mypvalue ipstart + 2
41 iep4 mypvalue ipstart + 3
42 iep5 mypvalue ipstart + 4
43 iep6 mypvalue ipstart + 5
44 iep7 mypvalue ipstart + 6
45 iep8 mypvalue ipstart + 7
46 iep9 mypvalue ipstart + 8
47 iepa mypvalue ipstart + 9
48 iepb mypvalue ipstart + 10
49 iepc mypvalue ipstart + 11
50 iepd mypvalue ipstart + 12
51 iepe mypvalue ipstart + 13
52 iepf mypvalue ipstart + 14
53 iepg mypvalue ipstart + 15
54 ieph mypvalue ipstart + 16
55 iepi mypvalue ipstart + 17
56 iepj mypvalue ipstart + 18
57 iepk mypvalue ipstart + 19
58 iepl mypvalue ipstart + 20
59
60 kenv linseg iep1, iep2, iep3, iep4, iep5, iep6, iep7, iep8, \
61 iep9, iepa, iepb, iepc, iepd, iepe, iepf, iepg, \
62 ieph, iepi, iepj, iepk, iepl
63 xout kenv
64 endop
65
66 instr 1
67 ; This instrument only requires 3 pfields but can accept up to 24.
68 ; (You will still get warnings about more than 3).
69 kenv flexlinseg 4 ; envelope params start at p4
70 aout oscili kenv*.5, 256, 1
71 outs aout, aout
72
73 endin
74 </CsInstruments>
75 <CsScore>
76 f1 0 8192 10 1
77
78 i1 0 2 0.0 1.0 1.0 1.0 0.0
79 i1 2 2 0.0 0.1 1.0 1.0 1.0 0.1 0.0
80 i1 4 2 0.0 0.5 0.0 ; one problem is that "missing" pfields carry
81 i1 6 2 0.0 0.5 0.0 ! ; now we can fix this problem with !
82 i1 8 10 0.0 3.0 1.0 0.3 0.1 0.3 1.0 0.3 0.1 0.3 1.0 0.3 0.1 0.8 0.9 5.0 0.0
83
84 e
85 </CsScore>
86 </CsoundSynthesizer>