| User-Defined Opcode Database |
|---|
An envelope generator modelling the classic analogue ADSD envelopes
Download UDO FileThis UDO models the classic Attack-Decay-Sustain-Decay envelope generators found in analogue synthesisers. The envelope operation depends on a control signal. When this is high (1) the envelope cycles through its stages, when it is low (2), the envelope output is zero.
ksig ADSD imax, iatt, idec, isus, ktrig
imax - max output level of envelope after attack
iatt - attack time in seconds
idec - decay time in seconds
isus - sustain output level
ktrig - trigger control signal. When high (1), the envelope cycles through its stages, holding at the sustain level. When 0, the output of the envelope is 0. The decay time controls the time from max amp to sus levels, as well as from sus to 0, after ktrig becomes 0.
opcode ADSD,k,iiiik
imax,iatt,idec,isus,ktrig xin
ktime init 0
kv init 0
iper = 1/kr
if (ktrig == 1) then
ktime = ktime + iper
if ktime < iatt then
kt = iatt
kv = imax
else
kt = idec
kv = isus
endif
else
kv = 0
ktime = 0
endif
kenv portk kv, kt
xout kenv
endop
<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>
0dbfs = 1
opcode ADSD,k,iiiik
imax,iatt,idec,isus,ktrig xin
ktime init 0
kv init 0
iper = 1/kr
if (ktrig == 1) then
ktime = ktime + iper
if ktime < iatt then
kt = iatt
kv = imax
else
kt = idec
kv = isus
endif
else
kv = 0
ktime = 0
endif
kenv portk kv, kt
xout kenv
endop
instr 1
ktrig init 1
kti timeinsts
if kti < 2 then
ktrig = 1
elseif kti < 4 then
ktrig = 0
elseif kti < 6 then
ktrig = 1
else
ktrig = 0
endif
k1 ADSD 1,0.01,0.1,0.8, ktrig
a1 vco2 k1, 440
out a1
endin
</CsInstruments>
<CsScore>
i1 0 7
</CsScore>
</CsoundSynthesizer>
| Previous | Home | Next |
| ampdbN |