Sorry, the timer needs to reset even when no new peaks are detected, so something like this:
peak_hold(HT, x) = loop ~ _ with { loop(fb) = ba.sAndH(reset | (timer == 0), abs(x)) with { reset = abs(x) >= fb; timer = % (rint(HT * ma.SR)) ~ (+ (1) * (1 - reset)); }; }; Although, the hold time is correct when the timer cycles around, but it is one sample behind when it is reset by a new peak. For example, if the step function is 10 samples and the hold period is longer, "reset" is 1 from n=0 to n=9, timer is 0 for those samples, but then it starts at 1 at n=10. I'll think of a better way. Cheers, Dario On Sun, 21 Jun 2020 at 15:44, Dario Sanfilippo <sanfilippo.da...@gmail.com> wrote: > Hello, list. > > I noticed that the step response of ba.peakholder and the step function > itself are the same when the step size and the hold time are the same. > > In other words, an input that is equal to the output is not detected as a > new peak and it doesn't reset the countdown. Is that the desired behaviour? > > I would have thought that, if the input is 1 for 48 samples, and the hold > time is 48 samples, we should see 1s from n = 0 to n = 95. > > This is how I'm doing it: > > peak_hold(HT, x) = loop > > ~ _ > > with { > > loop(fb) = ba.sAndH(reset | timer, abs(x)) > > with { > > reset = abs(x) >= fb; > > timer = fi.pole(1 - reset, 1 - reset) > HT * ma.SR; > > }; > > }; > > > Best, > Dario >
_______________________________________________ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users