| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
</CsOptions> |
| 4 |
<CsInstruments> |
| 5 |
|
| 6 |
; Example file ftslice |
| 7 |
|
| 8 |
/* |
| 9 |
|
| 10 |
ftslice: |
| 11 |
|
| 12 |
Copy slice from source table to destination table |
| 13 |
|
| 14 |
Syntax: |
| 15 |
|
| 16 |
ftslice ifnsource, ifndest, kstart=0, kend=0, kstep=1 |
| 17 |
|
| 18 |
ifnsource: source table |
| 19 |
ifndest: destination table |
| 20 |
kstart: the index to start copying from |
| 21 |
kend: the end index to stop copying. This is NOT inclusive. 0=end of table |
| 22 |
kstep: how many elements to skip |
| 23 |
|
| 24 |
See also: tablecopy, tableicopy, tab2array |
| 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 |
idest ftgentmp 0, 0, -11, -2, 0 ; empty table of size 11 |
| 30 |
|
| 31 |
; copy only even elements |
| 32 |
ftslice ifn, idest, 0, 0, 2 |
| 33 |
ftprint idest |
| 34 |
|
| 35 |
; copy too many elements - only the elements which fit in the dest table |
| 36 |
; are copyed |
| 37 |
|
| 38 |
ftslice ifn, idest |
| 39 |
ftprint idest |
| 40 |
|
| 41 |
turnoff |
| 42 |
endin |
| 43 |
|
| 44 |
|
| 45 |
</CsInstruments> |
| 46 |
<CsScore> |
| 47 |
i 1 0 0.1 |
| 48 |
|
| 49 |
</CsScore> |
| 50 |
</CsoundSynthesizer> |