Mercurial > hg > ishara
view dsp/synth/envadr.m @ 34:c75bb62b90a9
Imported audio synthesis tools.
author | samer |
---|---|
date | Sun, 20 Jan 2013 19:05:05 +0000 |
parents | |
children |
line wrap: on
line source
function ef=envadr(att,dec,rel) % envadr - Make an attack-decay-release envelope function % % envadr :: % natural ~'attack time in samples', % real ~'decay time constant in samples', % natural ~'release time in seconds' % -> ([[N]]->[[N]]) ~'function to apply envelope to given signal' % % Attack and release are linear, decay is exponential. e=expenv(600000,att,dec); r=linspace(0,1,rel); ef=@shape; function x=shape(x) L=length(x); if L>0, x=x.*e(1:L); I=L - (0:length(r)-1); x(I)=x(I).*r; end end end function x=expenv(t,att,decay) x=exp(-(0:t-1)/decay); x(1:att)=((0:att-1)/att).*x(1:att); end