Hi Oleg, Thank you for these elements, you are obviously welcome to join the discussion!
Y Le mar. 11 mai 2021 à 15:40, Oleg Nesterov <o...@redhat.com> a écrit : > Hi, > > I noticed by accident your discussion in > https://github.com/grame-cncm/faustlibraries/pull/80 > > =========== > From @orlarey: > > Your ADSR uses a variable slope for the release. This induces a > different > behavior when the gate is shorter than the AD part. That can make > sense, > but replacing the ADSR function with yours would potentially break > the > users' code that relies on the actual behavior. > > Yann, please note that (afaics) the current behaviour was introduced > by a70abf508322 ("New faster ADSR envelop generator."), the fix from > Andrey seems to restore the old behaviour before that commit. > > Please see the test-case below, the last 2 outputs are the same. > > IIR I too tried to report that after a70abf508322 adsr() reacts > to gate=0 differently... probably > https://sourceforge.net/p/faudiostream/mailman/message/36643370/ > > Oleg. > > > ------------------------------------------------------------------------------- > import("stdfaust.lib"); > > // adsr before a70abf508322 ("New faster ADSR envelop generator.") > old(a,d,s,r,t) = on*(ads) : ba.sAndH(on) : rel > with{ > on = t>0; > off = t==0; > attTime = ma.SR*a; > decTime = ma.SR*d; > relTime = ma.SR*r : max(0.001); > sustainGain = t*s; > ads = ba.countup(attTime+decTime,off) : ba.bpf.start(0,0) : > ba.bpf.point(attTime,1) : > ba.bpf.end(attTime+decTime,sustainGain); > rel = _,ba.countup(relTime,on) : ba.bpf.start(0) : > ba.bpf.end(relTime,0); > }; > > // adsr with Andrey Bundin's fix applied > new(at,dt,sl,rt,gate) = ADS : *(1-R) : max(0) > with { > > // Durations in samples > an = max(1, at*ma.SR); > dn = max(1, dt*ma.SR); > rn = max(1, rt*ma.SR); > > // Deltas per samples > adelta = 1/an; > ddelta = (1-sl)/dn; > > > // Attack time (starts when gate changes and raises until gate == 0) > atime = +(gate) ~ *(gate' >= gate); > > // Attack curve > A = atime * adelta; > > // Decay curve > D0 = 1 + an * ddelta; > D = D0 - atime * ddelta; > > // ADS part > ADS = min(A, max(D, sl)); > > // Release time starts when gate is 0 > rtime = (+(1) : *(gate == 0)) ~ _; > > // Release curve starts when gate is 0 with the current value of the > envelope > R = rtime/rn; > }; > > process = ba.pulsen(ba.sec2samp(.09), ba.sec2samp(1/2)) : @(1000) > <: _, en.adsr(0.1,0.1,0.1, 1), old(0.1,0.1,0.1, 1), > new(0.1,0.1,0.1, 1); > >
_______________________________________________ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users