| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
-odac |
| 4 |
</CsOptions> |
| 5 |
<CsInstruments> |
| 6 |
|
| 7 |
sr = 44100 |
| 8 |
ksmps = 32 |
| 9 |
nchnls = 1 |
| 10 |
0dbfs = 1 |
| 11 |
|
| 12 |
; simple damped nonlinear resonator |
| 13 |
opcode nonlin_reson, a, akki |
| 14 |
setksmps 1 |
| 15 |
avel init 0 ;velocity |
| 16 |
adef init 0 ;deflection |
| 17 |
ain,kc,kdamp,ifn xin |
| 18 |
aacel tablei adef, ifn, 1, .5 ;acceleration = -c1*f1(def) |
| 19 |
aacel = -kc*aacel |
| 20 |
avel = avel+aacel+ain ;vel += acel + excitation |
| 21 |
avel = avel*(1-kdamp) |
| 22 |
adef = adef+avel |
| 23 |
xout adef |
| 24 |
endop |
| 25 |
|
| 26 |
instr 1 |
| 27 |
kenv oscil p4,.5,1 |
| 28 |
aexc rand kenv |
| 29 |
aout nonlin_reson aexc,p5,p6,p7 |
| 30 |
out aout |
| 31 |
endin |
| 32 |
|
| 33 |
</CsInstruments> |
| 34 |
<CsScore> |
| 35 |
f1 0 1024 10 1 |
| 36 |
f2 0 1024 7 -1 510 .15 4 -.15 510 1 |
| 37 |
f3 0 1024 7 -1 350 .1 100 -.3 100 .2 100 -.1 354 1 |
| 38 |
; p4 p5 p6 p7 |
| 39 |
; excitation c1 damping ifn |
| 40 |
i1 0 20 .0001 .01 .00001 3 |
| 41 |
;i1 0 20 .0001 .01 .00001 2 |
| 42 |
</CsScore> |
| 43 |
</CsoundSynthesizer> |
| 44 |
;example by martin neukom |