| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
; Select audio/midi flags here according to platform |
| 4 |
-odac ;;;realtime audio out |
| 5 |
;-iadc ;;;uncomment -iadc if realtime audio input is needed too |
| 6 |
; For Non-realtime ouput leave only the line below: |
| 7 |
; -o gen34.wav -W ;;; for file output any platform |
| 8 |
</CsOptions> |
| 9 |
<CsInstruments> |
| 10 |
|
| 11 |
sr = 44100 |
| 12 |
ksmps = 32 |
| 13 |
nchnls = 2 |
| 14 |
0dbfs = 1 |
| 15 |
|
| 16 |
instr 1 ; partials 1, 4, 7, 10, 13, 16, etc. with base frequency of 400 Hz |
| 17 |
|
| 18 |
ibsfrq = 400 |
| 19 |
inumh = int(1.5 + sr * 0.5 / (3 * ibsfrq)) ; estimate number of partials |
| 20 |
isrcln = int(0.5 + exp(log(2) * int(1.01 + log(inumh * 3) / log(2)))) ; source table length |
| 21 |
itmp ftgen 1, 0, isrcln, -2, 0 ; create empty source table |
| 22 |
ifpos = 0 |
| 23 |
ifrq = ibsfrq |
| 24 |
inumh = 0 |
| 25 |
l1: |
| 26 |
tableiw ibsfrq / ifrq, ifpos, 1 ; amplitude |
| 27 |
tableiw ifrq, ifpos + 1, 1 ; frequency |
| 28 |
tableiw 0, ifpos + 2, 1 ; phase |
| 29 |
ifpos = ifpos + 3 |
| 30 |
ifrq = ifrq + ibsfrq * 3 |
| 31 |
inumh = inumh + 1 |
| 32 |
if (ifrq < (sr * 0.5)) igoto l1 |
| 33 |
|
| 34 |
itmp ftgen 2, 0, 262144, -34, 1, inumh, 1, -1 ; store output in ftable 2 (size = 262144) |
| 35 |
asig poscil .5, ibsfrq, itmp |
| 36 |
outs asig, asig |
| 37 |
|
| 38 |
endin |
| 39 |
</CsInstruments> |
| 40 |
<CsScore> |
| 41 |
|
| 42 |
i 1 0 2 |
| 43 |
|
| 44 |
e |
| 45 |
</CsScore> |
| 46 |
</CsoundSynthesizer> |
| 47 |
|