[chbot] Software filter. Fast attack, slow decay

Synco Reynders synco.reynders at gmail.com
Sun Jun 19 08:56:16 BST 2022


attack_rate = 0.8
decay_rate = 0.1
decay_method = 1
# Full-wave rectify the input signal is probably what you actually want, so
suggest using the absolute value function.
diff = abs(in) - out
if diff > 0 then:
    out = out + diff * attack_rate
else:
    if decay_method:
        out = out * (1 - decay_rate)     # for constant decay
    else:
        out = out + diff * decay_rate    # for proportional decay



On Sun, 19 Jun 2022 at 16:35, Robin Gilks <gb7ipd at gmail.com> wrote:

> Here's another question for you all!!
>
> I'm trying to implement "something like" a VU Meter in software (in an
> embedded system so it has to be small & fast).
> The hardware equivalent to a diode running into an RC filter
>
>           |\ |             R
>    in ----|  |----------vvvvvv--------- out
>           |/ |                    |
>                                  ___
>                                  ___  C
>                                   |
>                                   |
>  common ----------------------------------------
>
> 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.
>
> 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 ;)
>
> Cheers - hopefully see you tomorrow.
>
> --
> Robin Gilks
>
> _______________________________________________
> Chchrobotics mailing list Chchrobotics at lists.ourshack.com
> https://lists.ourshack.com/mailman/listinfo/chchrobotics
> Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/
> Meetings usually 3rd Monday each month. See http://kiwibots.org for
> venue, directions and dates.
> When replying, please edit your Subject line to reflect new subjects.



-- 
Synco Reynders
  m: +64 21 1825332
  e: synco.reynders at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ourshack.com/pipermail/chchrobotics/attachments/20220619/4446b27e/attachment.html>


More information about the Chchrobotics mailing list