| 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 gen14.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 |
;after the example from The Csound Book, page 83 |
| 16 |
|
| 17 |
instr 1 ;compare results from GEN13 & GEN14 |
| 18 |
|
| 19 |
iwshpfn = p6 |
| 20 |
inrmfn = p7 |
| 21 |
aswp linseg 0.01, p3*.5, .49, p3*.5, 0.01 ;index sweep function |
| 22 |
aindex poscil aswp, p5, 2 ;sound to waveshape |
| 23 |
atable tablei aindex, iwshpfn, 1, .5 ;waveshape index |
| 24 |
anrm tablei aswp*2, inrmfn, 1 ;normalization |
| 25 |
aenv linen p4, .01, p3, .02 ;amplitude envelope |
| 26 |
asig = (atable*anrm)*aenv ;normalize and impose envelope |
| 27 |
asig dcblock2 asig ;get rid of DC |
| 28 |
outs asig, asig |
| 29 |
|
| 30 |
endin |
| 31 |
</CsInstruments> |
| 32 |
<CsScore> |
| 33 |
|
| 34 |
f 2 0 8192 10 1 ;sine wave |
| 35 |
|
| 36 |
f 28 0 4097 13 1 1 1 0 .8 0 .5 0 .2 ;waveshaping function: GEN13 - odd harmonics |
| 37 |
f 280 0 2049 4 28 1 ;normalization function for f28 |
| 38 |
f 29 0 4097 14 1 1 1 0 .8 0 .5 0 .2 ;waveshaping function: GEN14 - same harmonics |
| 39 |
f 290 0 2049 4 29 1 ;normalization function for f29 |
| 40 |
|
| 41 |
|
| 42 |
f 30 0 4097 13 1 1 0 1 0 .6 0 .4 0 .1 ;waveshaping function: GEN13 - even harmonics |
| 43 |
f 301 0 2049 4 30 1 ;normalization function for f30 |
| 44 |
f 31 0 4097 14 1 1 0 1 0 .6 0 .4 0 .1 ;waveshaping function: GEN13 - even harmonics |
| 45 |
f 310 0 2049 4 31 1 ;normalization function for 31 |
| 46 |
s |
| 47 |
i1 0 3 .7 440 28 280 |
| 48 |
i1 4 . .7 . 29 290 |
| 49 |
i1 8 . .7 . 30 301 |
| 50 |
i1 12 3 .7 . 31 310 |
| 51 |
|
| 52 |
e |
| 53 |
</CsScore> |
| 54 |
</CsoundSynthesizer> |
| 55 |
|