Debian Codegraph @

examples/tab2array.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 </CsOptions>
4 <CsInstruments>
5
6 sr = 44100
7 ksmps = 128
8 nchnls = 2
9 0dbfs = 1.0
10
11 ; Example file tab2array
12
13 /*
14
15 tab2array: copy a slice of a table to an array
16
17 kout[] tab2array ifn, kstart=0, kend=0, kstep=1
18 iout[] tab2array ifn, istart=0, iend=0, istep=1
19
20 ifn: the table index to copy from
21 start: the index to start copying from
22 end: the end index to stop copying. This is NOT inclusive. 0=end of table
23 step: how many elements to skip
24
25 */
26
27 instr 1
28 ifn ftgentmp 0,0,-13,-2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
29 ; copy everything at i-time, similar to copyf2array, but no need
30 ; to predefine the array
31 islice[] tab2array ifn
32 printarray islice, "", "islice"
33
34 ; copy the slice [1::2] to an array, at k-time
35 kslice[] tab2array ifn, 1, 0, 2
36 printarray kslice, 1, "", "kslice"
37
38 ; copy into a predefined array. If the number of elements to copy
39 ; excede the capacity of the array, the array is enlarged
40 kxs[] init 3
41 kxs tab2array ifn, 0, 10
42 printarray kxs, 1, "", "kxs"
43 turnoff
44 endin
45
46
47 </CsInstruments>
48 <CsScore>
49 i 1 0 0.1
50
51 </CsScore>
52 </CsoundSynthesizer>