Skip to content

Instantly share code, notes, and snippets.

@jpcima
Last active August 6, 2021 11:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpcima/eb4d36a3e77096919688dd22ecc18d20 to your computer and use it in GitHub Desktop.
Save jpcima/eb4d36a3e77096919688dd22ecc18d20 to your computer and use it in GitHub Desktop.
Linear smoother
import("stdfaust.lib");
// a linear smoother
lfsmooth(tau, flush, tgt) =
((+:(_,tgt):select2(flush))~_)~((tgt-_)<:(abs,(/(tau*ma.SR):(select2(sc)~_):abs),_):(min,_):copysign)
with {
sc = (tgt!=tgt')|(tau!=tau');
copysign(x,s) = abs(x)*select2(s<0.0,1.0,-1.0);
//copysign = ffunction(float copysignf|copysign|copysignl(float,float),<math.h>,"");
};
lsmooth(tau) = lfsmooth(tau, 0);
process = lsmooth(t,x) with {
x = hslider("[1] target",0.0,-1.0,1.0,0.001);
t = hslider("[2] time",0.1,0.0,1.0,0.001);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment