tab2array
Copy a slice from an f-table to an array
Plugin opcode in emugens.
The tab2array opcode takes an f-table and copies a slice to an array, possibly allocating it or changing its size
Syntax
kout[] tab2array ifn [, kstart, kend, kstep ]
iout[] tab2array ifn [, istart, iend, istep ]
Initialization
ifn - The table index to copy data from
kstart / istart - The index to start copying from. Defaults to 0
kend / iend - The end index to stop cpying. This is NOT inclusive. 0 means copy to the end of the table. Defaults to length of table
kstep / istep - How many elements to skip. Defaults to 1
Examples
Here is an example of the tab2array opcode. It uses the file tab2array.csd.
Example of the tab2array opcode. |
---|
| <CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 128
nchnls = 2
0dbfs = 1.0
; Example file tab2array
/*
tab2array: copy a slice of a table to an array
kout[] tab2array ifn, kstart=0, kend=0, kstep=1
iout[] tab2array ifn, istart=0, iend=0, istep=1
ifn: the table index to copy from
start: the index to start copying from
end: the end index to stop copying. This is NOT inclusive. 0=end of table
step: how many elements to skip
*/
instr 1
ifn ftgentmp 0,0,-13,-2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
; copy everything at i-time, similar to copyf2array, but no need
; to predefine the array
islice[] tab2array ifn
printarray islice, "", "islice"
; copy the slice [1::2] to an array, at k-time
kslice[] tab2array ifn, 1, 0, 2
printarray kslice, 1, "", "kslice"
; copy into a predefined array. If the number of elements to copy
; excede the capacity of the array, the array is enlarged
kxs[] init 3
kxs tab2array ifn, 0, 10
printarray kxs, 1, "", "kxs"
turnoff
endin
</CsInstruments>
<CsScore>
i 1 0 0.1
</CsScore>
</CsoundSynthesizer>
|
See also
Array opcodes
Credits
By: Eduardo Moguillansky 2018
New plugin in version 6.12