| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
-nm0 |
| 4 |
</CsOptions> |
| 5 |
<CsInstruments> |
| 6 |
|
| 7 |
giFt ftgen 0, 0, 12, 2, 0 |
| 8 |
|
| 9 |
instr 1; calculates first 12 fibonacci values and writes them to giFt |
| 10 |
istart = 1 |
| 11 |
inext = 2 |
| 12 |
indx = 0 |
| 13 |
while indx < 12 do |
| 14 |
tableiw istart, indx, giFt ;writes istart to table |
| 15 |
istartold = istart ;keep previous value of istart |
| 16 |
istart = inext ;reset istart for next loop |
| 17 |
inext = istartold + inext ;reset inext for next loop |
| 18 |
indx += 1 |
| 19 |
od |
| 20 |
endin |
| 21 |
|
| 22 |
instr 2; prints the values of the table |
| 23 |
prints "%nContent of Function Table:%n" |
| 24 |
indx init 0 |
| 25 |
while indx < 12 do |
| 26 |
ival table indx, giFt |
| 27 |
prints "Index %d = %f%n", indx, ival |
| 28 |
indx += 1 |
| 29 |
od |
| 30 |
endin |
| 31 |
|
| 32 |
</CsInstruments> |
| 33 |
<CsScore> |
| 34 |
i 1 0 0 |
| 35 |
i 2 0 0 |
| 36 |
</CsScore> |
| 37 |
</CsoundSynthesizer> |
| 38 |
;example by joachim heintz |