| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
; Select audio/midi flags here according to platform |
| 4 |
; Audio out Audio in No messages |
| 5 |
-odac -iadc -d ;;;RT audio I/O |
| 6 |
; For Non-realtime ouput leave only the line below: |
| 7 |
; -o phasorbnk.wav -W ;;; for file output any platform |
| 8 |
</CsOptions> |
| 9 |
<CsInstruments> |
| 10 |
|
| 11 |
; Initialize the global variables. |
| 12 |
sr = 44100 |
| 13 |
kr = 4410 |
| 14 |
ksmps = 10 |
| 15 |
nchnls = 1 |
| 16 |
|
| 17 |
; Generate a sinewave table. |
| 18 |
giwave ftgen 1, 0, 1024, 10, 1 |
| 19 |
|
| 20 |
; Instrument #1 |
| 21 |
instr 1 |
| 22 |
; Generate 10 voices. |
| 23 |
icnt = 10 |
| 24 |
; Empty the output buffer. |
| 25 |
asum = 0 |
| 26 |
; Reset the loop index. |
| 27 |
kindex = 0 |
| 28 |
|
| 29 |
; This loop is executed every k-cycle. |
| 30 |
loop: |
| 31 |
; Generate non-harmonic partials. |
| 32 |
kcps = (kindex+1)*100+30 |
| 33 |
; Get the phase for each voice. |
| 34 |
aphas phasorbnk kcps, kindex, icnt |
| 35 |
; Read the wave from the table. |
| 36 |
asig table aphas, giwave, 1 |
| 37 |
; Accumulate the audio output. |
| 38 |
asum = asum + asig |
| 39 |
|
| 40 |
; Increment the index. |
| 41 |
kindex = kindex + 1 |
| 42 |
|
| 43 |
; Perform the loop until the index (kindex) reaches |
| 44 |
; the counter value (icnt). |
| 45 |
if (kindex < icnt) kgoto loop |
| 46 |
|
| 47 |
out asum*3000 |
| 48 |
endin |
| 49 |
|
| 50 |
|
| 51 |
</CsInstruments> |
| 52 |
<CsScore> |
| 53 |
|
| 54 |
; Play Instrument #1 for two seconds. |
| 55 |
i 1 0 2 |
| 56 |
e |
| 57 |
|
| 58 |
|
| 59 |
</CsScore> |
| 60 |
</CsoundSynthesizer> |