| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
-odac |
| 4 |
</CsOptions> |
| 5 |
<CsInstruments> |
| 6 |
sr = 44100 |
| 7 |
ksmps = 1 |
| 8 |
nchnls = 2 |
| 9 |
0dbfs = 1 |
| 10 |
|
| 11 |
instr MassSpring |
| 12 |
;initial values |
| 13 |
a0 init 0 |
| 14 |
a1 init 0.05 |
| 15 |
ic = 0.01 ;spring constant |
| 16 |
;calculation of the next value |
| 17 |
a2 = a1+(a1-a0) - ic*a1 |
| 18 |
outs a0, a0 |
| 19 |
;actualize values for the next step |
| 20 |
a0 = a1 |
| 21 |
a1 = a2 |
| 22 |
endin |
| 23 |
</CsInstruments> |
| 24 |
<CsScore> |
| 25 |
i "MassSpring" 0 10 |
| 26 |
</CsScore> |
| 27 |
</CsoundSynthesizer> |
| 28 |
;example by joachim heintz, after martin neukom |