Making filters more efficient (CPU)?

For general discussion related FlowStone
Post Reply
User avatar
guyman
Posts: 207
Joined: Fri Mar 02, 2018 8:27 pm

Making filters more efficient (CPU)?

Post by guyman »

Hellooooooo . I hope the quarantine treateth you kindly.


I am fooling with both RBJ shelves, and Martin's 1 pole matched shelf filters... I am going to have static settings on the filters, no modulation of slope,res, cutoff nor amplitude. I know that stages and hop can make static calculation save a huge load on cpu, but some of these are in assembly, and I've never really implemented stages as of yet...

Would anyone like to chime in on the best way to make filter's super efficient on cpu? I'd love to have dozens of these running at any given moment. How would I go about altering a filter that's already in assem? it's latin to me.
User avatar
tektoog
Posts: 141
Joined: Sat Oct 30, 2010 11:49 pm
Location: Geneva - Switzerland

Re: Making filters more efficient (CPU)?

Post by tektoog »

hey,
Hope you're doing good yourself! ;)
IMHO, you have 3 choices...
Get help, learn latin or ... learn ASM... ;) :? Latin being a dead language you're better off learning ASM ;)
Most reasonable one would be to wait for someone willing to help...
Most pragmatic one would be to learn the languages you wanna write with...
But first thing to do, is to post what you would like people to help you with...
I'm no good at ASM, I just copy and paste most of the ASM code I use, and then suit it to my needs...
But I'm pretty sure you can find the original filter which was probably first coded with FS code... that's the case most of the time, and then, it's ported to ASM... that's easier (at least for me) to read, understand and then to alter ;)
I'm pretty sure some good soul(s) over here will give you a hand...
Take care
"Essential random order for chaotic repetitive sequences"
User avatar
guyman
Posts: 207
Joined: Fri Mar 02, 2018 8:27 pm

Re: Making filters more efficient (CPU)?

Post by guyman »

thanks for the response. my concern is static filter optimization, without a loss of quality.
juha_tp
Posts: 60
Joined: Fri Nov 09, 2018 10:37 pm

Re: Making filters more efficient (CPU)?

Post by juha_tp »

If those are static filters then why calculate anything in runtime ... use static coefficients.

EDIT:
Dunno if this would be an efficient way but worth to try (one filter fc@1000Hz):

Code: Select all

switch x
  case { 44100, 88200, 176400, 352800 }
    b(1) = x * ((1.71962425129703E-11 - 2.60013231898188E-17 * x) * x - 3.53741686355636E-06) + 1.67970352331451;
    b(2) = x * ((1.7196242512970E-11 - 2.6001323189818E-17 * x) * x - 3.5374168635563E-06) - 1.145371565931;
    a(1) = x * ((8.6185372138594E-12 - 1.3031531240154E-17 * x) * x - 1.7729081720323E-6) + 1.5464377224026;
    a(2) = x * ((8.6185372138593E-12 - 1.3031531240154E-17 * x) * x - 1.7729081720323E-6) - 1.27863736684291;

  case { 48000, 96000, 192000, 384000 }
    b(1) = x * ((1.33279187011394E-11 - 1.85142995570431E-17 * x) * x - 2.98433575868698E-6) + 1.65790207111673;
    b(2) = x * ((1.3327918701139E-11 - 1.8514299557042E-17 * x) * x - 2.9843357586869E-6) - 1.16717301812879;
    a(1) = x * ((6.67978270383326E-12 - 9.27913057754111E-18 * x) * x - 1.49571098311128E-6) + 1.53551111288653;
    a(2) = x * ((6.67978270383326E-12 - 9.27913057754111E-18 * x) * x - 1.49571098311128E-6) - 1.28956397635897;
  otherwise
    b = [1 0 ];
    a = [1 0 ];
  end


This calculation supports those commonly used sample rates but, you would need to make separate function for each filter.
Last edited by juha_tp on Sat Apr 25, 2020 6:44 am, edited 1 time in total.
User avatar
guyman
Posts: 207
Joined: Fri Mar 02, 2018 8:27 pm

Re: Making filters more efficient (CPU)?

Post by guyman »

I think I got it... I'll report back
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: Making filters more efficient (CPU)?

Post by martinvicanek »

When I post filters I often include a static and a dynamic version. In the static version the filter coefficients are evayluated in green (or Ruby), while the filter iteration is optimized in ASM. Additional CPU gains can be had from Mono4 packing.
Post Reply