| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
-dm128 -odac |
| 4 |
</CsOptions> |
| 5 |
<CsInstruments> |
| 6 |
sr = 44100 |
| 7 |
ksmps = 32 |
| 8 |
nchnls = 2 |
| 9 |
0dbfs = 1 |
| 10 |
; this is a necessary definition, |
| 11 |
; otherwise amplitude will be -32768 to 32767 |
| 12 |
|
| 13 |
instr 1 |
| 14 |
aSig diskin "fox.wav", 1 ; read sound file |
| 15 |
kRms rms aSig ; scan rms |
| 16 |
iThreshold = 0.1 ; rms threshold |
| 17 |
kGate = kRms > iThreshold ? 1 : 0 ; gate either 1 or zero |
| 18 |
aGate interp kGate ; interpolate to create smoother on->off->on switching |
| 19 |
aSig = aSig * aGate ; multiply signal by gate |
| 20 |
out aSig, aSig ; send to output |
| 21 |
endin |
| 22 |
|
| 23 |
</CsInstruments> |
| 24 |
<CsScore> |
| 25 |
i 1 0 10 |
| 26 |
</CsScore> |
| 27 |
</CsoundSynthesizer> |
| 28 |
;example by Iain McCurdy |