<div dir="ltr"><div><br></div><div>attack_rate = 0.8<br></div><div>decay_rate = 0.1</div><div><div>decay_method = 1</div><div># Full-wave rectify the input signal is probably what you actually want, so suggest using the absolute value function.</div><div></div></div><div>diff = abs(in) - out</div><div>if diff > 0 then:</div><div>    out = out + diff * attack_rate</div><div>else:</div><div>    if decay_method:</div><div><div>        out = out * (1 - decay_rate)     # for constant decay</div></div><div>    else:</div><div><div><div>        out = out + diff * decay_rate    # for proportional decay</div></div><div><br></div></div><div><br class="gmail-Apple-interchange-newline"></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 19 Jun 2022 at 16:35, Robin Gilks <<a href="mailto:gb7ipd@gmail.com">gb7ipd@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Here's another question for you all!!<div><br></div><div>I'm trying to implement "something like" a VU Meter in software (in an embedded system so it has to be small & fast).</div><div>The hardware equivalent to a diode running into an RC filter</div><div><font face="monospace"><br></font></div><div><font face="monospace">          |\ |             R<br>   in ----|  |----------vvvvvv--------- out<br>          |/ |                    |<br>                                 ___ <br>                                 ___  C<br>                                  |<br>                                  |<br> common ----------------------------------------  <br> </font><br><div>My first port of call for filters is an IIR but that does not have the fast attack I'm after, especially if I want the long tail.</div><div><br></div><div>Does anyone have any magic that doesn't disappear into a morass of DFTs and FFTs and 3 page equations summing integrals from 0 to infinity ;)</div><div><br></div><div>Cheers - hopefully see you tomorrow.</div><div><br></div>-- <br><div dir="ltr"><div dir="ltr">Robin Gilks<div><br></div></div></div></div></div>
_______________________________________________<br>
Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.ourshack.com" target="_blank">Chchrobotics@lists.ourshack.com</a><br>
<a href="https://lists.ourshack.com/mailman/listinfo/chchrobotics" rel="noreferrer" target="_blank">https://lists.ourshack.com/mailman/listinfo/chchrobotics</a><br>
Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" rel="noreferrer" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a><br>
Meetings usually 3rd Monday each month. See <a href="http://kiwibots.org" rel="noreferrer" target="_blank">http://kiwibots.org</a> for venue, directions and dates.<br>
When replying, please edit your Subject line to reflect new subjects.</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">Synco Reynders<div>  m: +64 21 1825332</div><div>  e: <a href="mailto:synco.reynders@gmail.com" target="_blank">synco.reynders@gmail.com</a></div></div></div>