| 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 gen23.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 |
;"spectrum.txt" is created by the spectrum plotter of Audacity (set at size 128), using "fox.wav". |
| 16 |
|
| 17 |
instr 1 ;performs additive synthesis based on spectrum.txt |
| 18 |
|
| 19 |
indx =0 ;start reading at first value |
| 20 |
loop: |
| 21 |
ifreq tab_i indx, 2 ;take odd values of list (= frequency) |
| 22 |
iamp tab_i indx+1, 2 ;take even values of list (= amplitude) |
| 23 |
event_i "i", 10, 0, p3, iamp, ifreq ;use "event_i" to trigger instr. 10 |
| 24 |
loop_lt indx, 2, 126, loop ;use all 126 frequency and amplitude values |
| 25 |
|
| 26 |
endin |
| 27 |
|
| 28 |
instr 10 ;generate sound |
| 29 |
|
| 30 |
iamp = p4 |
| 31 |
ifreq = p5 |
| 32 |
asig poscil ampdb(iamp), ifreq, 1 |
| 33 |
asig linen asig, .01, p3, p2 |
| 34 |
outs asig, asig |
| 35 |
|
| 36 |
endin |
| 37 |
</CsInstruments> |
| 38 |
<CsScore> |
| 39 |
f 1 0 16384 10 1 ;sine wave |
| 40 |
f 2 0 128 -23 "spectrum.txt" ;"spectrum.txt" can be found in /manual/examples |
| 41 |
|
| 42 |
i1 0 2 |
| 43 |
|
| 44 |
e |
| 45 |
</CsScore> |
| 46 |
</CsoundSynthesizer> |
| 47 |
|