69 halp_meta(name,
"Envelope Follower (audio)")
70 halp_meta(c_name,
"EnvelopeFollowerAudio")
71 halp_meta(category,
"Analysis/Envelope")
72 halp_meta(author,
"Kevin Ferguson")
73 halp_meta(manual_url,
"https://ossia.io/score-docs/processes/analysis.html#envelope")
76 "Sample-level envelope Follower\n"
77 "(https://kferg.dev/posts/2020/audio-reactive-programming-envelope-followers/)")
78 halp_meta(uuid,
"0a262706-1216-44f4-85ca-52f1f25785bc")
82 halp::knob_f32<
"Millis (up)", halp::range{0., 1000., 50.}> a;
83 halp::knob_f32<
"Millis (down)", halp::range{0., 1000., 15.}> b;
88 void prepare(halp::setup s) { rate = s.rate; }
92 double operator()(
double x,
struct inputs inputs, outputs)
noexcept
95 const auto abs_x = abs(x);
98 const auto a = exp(log(0.5) / (rate * (inputs.a.value / 1000.0)));
99 const auto b = exp(log(0.5) / (rate * (inputs.b.value / 1000.0)));
101 const auto coeff = (abs_x > y) ? a : b;
102 y = coeff * y + (1. - coeff) * abs_x;