| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
-odac |
| 4 |
</CsOptions> |
| 5 |
<CsInstruments> |
| 6 |
sr = 44100 |
| 7 |
ksmps = 16 |
| 8 |
nchnls = 1 |
| 9 |
0dbfs = 1 |
| 10 |
|
| 11 |
gisine ftgen 0,0,2^10,10,1 |
| 12 |
|
| 13 |
; define the macro |
| 14 |
#define ADDITIVE_TONE(Frq'Ratio1'Ratio2'Ratio3'Ratio4'Ratio5'Ratio6) # |
| 15 |
iamp = 0.1 |
| 16 |
aenv expseg 1,p3*(1/$Ratio1),0.001,1,0.001 |
| 17 |
a1 poscil iamp*aenv,$Frq*$Ratio1,gisine |
| 18 |
aenv expseg 1,p3*(1/$Ratio2),0.001,1,0.001 |
| 19 |
a2 poscil iamp*aenv,$Frq*$Ratio2,gisine |
| 20 |
aenv expseg 1,p3*(1/$Ratio3),0.001,1,0.001 |
| 21 |
a3 poscil iamp*aenv,$Frq*$Ratio3,gisine |
| 22 |
aenv expseg 1,p3*(1/$Ratio4),0.001,1,0.001 |
| 23 |
a4 poscil iamp*aenv,$Frq*$Ratio4,gisine |
| 24 |
aenv expseg 1,p3*(1/$Ratio5),0.001,1,0.001 |
| 25 |
a5 poscil iamp*aenv,$Frq*$Ratio5,gisine |
| 26 |
aenv expseg 1,p3*(1/$Ratio6),0.001,1,0.001 |
| 27 |
a6 poscil iamp*aenv,$Frq*$Ratio6,gisine |
| 28 |
a7 sum a1,a2,a3,a4,a5,a6 |
| 29 |
out a7 |
| 30 |
# |
| 31 |
|
| 32 |
instr 1 ; xylophone |
| 33 |
; expand the macro with partial ratios that reflect those of a xylophone |
| 34 |
; the fundemental frequency macro argument (the first argument - |
| 35 |
; - is passed as p4 from the score |
| 36 |
$ADDITIVE_TONE(p4'1'3.932'9.538'16.688'24.566'31.147) |
| 37 |
endin |
| 38 |
|
| 39 |
instr 2 ; vibraphone |
| 40 |
$ADDITIVE_TONE(p4'1'3.997'9.469'15.566'20.863'29.440) |
| 41 |
endin |
| 42 |
|
| 43 |
</CsInstruments> |
| 44 |
<CsScore> |
| 45 |
i 1 0 1 200 |
| 46 |
i 1 1 2 150 |
| 47 |
i 1 2 4 100 |
| 48 |
i 2 3 7 800 |
| 49 |
i 2 4 4 700 |
| 50 |
i 2 5 7 600 |
| 51 |
e |
| 52 |
</CsScore> |
| 53 |
</CsoundSynthesizer> |
| 54 |
; example written by Iain McCurdy |