If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
Process nth order filter
3 posts
• Page 1 of 1
Process nth order filter
Lets say one have a nth order (n>2) filter ... how to process it without breaking it to SOS?
Are there any ready to use implementations available (I checked quite a many examples but didn't find one (bypassed some asm listings there cause of I'm not good in reading asm code))?
Are there any ready to use implementations available (I checked quite a many examples but didn't find one (bypassed some asm listings there cause of I'm not good in reading asm code))?
- juha_tp
- Posts: 60
- Joined: Fri Nov 09, 2018 10:37 pm
Re: Process nth order filter
SOS means second order sections aka biquads, right?
You could use a direct form like
y = b0*x + b1*x1 + ... + bn*xn;
y = y - a1*y1 - a2*y2 - ... - an*yn;
xn = xn-1;
...
x1 = x;
yn = yn-1;
...
y1 = y;
However, in single precision rounding errors will quickly make it unstable even for moderate order n. That's why we moslty use biquads.
A minor remark on why I broke the filter equation y = ... in two lines: Flowstone's code compiler has a limitation regarding the size of single line formulas it can handle. (It won`t throw an error if you exceed this limit).
You could use a direct form like
y = b0*x + b1*x1 + ... + bn*xn;
y = y - a1*y1 - a2*y2 - ... - an*yn;
xn = xn-1;
...
x1 = x;
yn = yn-1;
...
y1 = y;
However, in single precision rounding errors will quickly make it unstable even for moderate order n. That's why we moslty use biquads.
A minor remark on why I broke the filter equation y = ... in two lines: Flowstone's code compiler has a limitation regarding the size of single line formulas it can handle. (It won`t throw an error if you exceed this limit).
-
martinvicanek - Posts: 1328
- Joined: Sat Jun 22, 2013 8:28 pm
Re: Process nth order filter
OK, yes, second order sections.
I found my own SM example for biquad case:
so, extending that would then be the way to go.
I found my own SM example for biquad case:
- Code: Select all
monoin inL;
monoin inR;
monoout outL;
monoout outR;
float a0, a1, a2;
float b0, b1, b2;
float inL1, inL2, inR1, inR2;
float outL1, outL2, outR1, outR2;
a0= ...
a1= ...
a2= ...
b1= ...
b2= ...
// Proces left channel
outL = a0*inL + a1*inL1 + a2*inL2 - b1*outL1 - b2*outL2;
// Process right channel
outR = a0*inR + a1*inR1 + a2*inR2 - b1*outR1 - b2*outR2;
// save previous I/Os
outL2 = outL1;
outL1 = outL;
inL2 = inL1;
inL1 = inL;
outR2 = outR1;
outR1 = outR;
inR2 = inR1;
inR1 = inR;
so, extending that would then be the way to go.
- juha_tp
- Posts: 60
- Joined: Fri Nov 09, 2018 10:37 pm
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 70 guests