filter design - code problem

If you require help or assistance with anything then please post here

Moderators: electrogear, exonerate

Re: filter design - code problem

Postby kaj on Sun Aug 28, 2011 3:16 pm

Hello.
***************************
prewarped freq = 2/T*tan(2*pi*freq*T/2), where T is sample time.
***************************
when cutoff freq = 5000 and T= 1/44100, then
prewarped freq = 32815.591 (which is the actual input value)

H(z) =

0.0174349 + 0.0523047z^-1 + 0.0523047z^-2 + 0.0174349z^-3
-----------------------------------------------------------------------------------------
1 - 1.8823263z^-1 + 1.4150742z^-2 - 0.3932688z^-3

legendrefilter5000.osm
lengendre filter cutoff 5000hz
(8.71 KiB) Downloaded 82 times
kaj
essemer
 
Posts: 40
Joined: Sun Jan 02, 2011 9:02 am

Re: filter design - code problem

Postby MegaHurtz on Sun Aug 28, 2011 5:19 pm

I ment that the z transform would be differentiating, given that multiplying a differentiated result would create a filter. And multiplying an integrated signal would create gain. So i wasnt able to see where it would get integrated again. Wich would be needed somewhere..
Visit my website at: http://www.schlukhash.nl
User avatar
MegaHurtz
smaniac
 
Posts: 1504
Joined: Mon Aug 11, 2008 5:29 pm
Location: Eindhoven/Netherlands

Re: filter design - code problem

Postby kaj on Sun Aug 28, 2011 10:54 pm

I generalized the filter. Maybe It's OK.

Code: Select all
streamin in;
streamin wo;
streamout out;
float x0, x1, x2, x3;
float y0, y1, y2, y3;
float a, b, c, d, e, f, g, r;
float w, ww, www;

w = 2*44100 * tan1(0.5*wo/44100); // prewarping the digital freq
ww = w * w;
www = ww * w;

r = (99316848847*www+20618754192943200*ww+1753981684186662000000*w+118029161812506173712000000);
a = (297950546541*www+20618754192943200*ww-1753981684186662000000*w-354087485437518521136000000);
b = (297950546541*www-20618754192943200*ww-1753981684186662000000*w+354087485437518521136000000);
c = (99316848847*www-20618754192943200*ww+1753981684186662000000*w-118029161812506173712000000);
a = a/r;
b = b/r;
c = c/r;
d = 99316848847*www/r;
e = 297950546541*www/r;
f = 297950546541*www/r;
g = 99316848847*www/r;

x0 = in;
y0 = -1*a*y1 - b*y2 - c*y3 + d*x0 + e*x1 + f*x2 + g*x3;
y3 = y2;
y2 = y1;
y1 = y0;
x3 = x2;
x2 = x1;
x1 = x0;
out = y0;


legendre_general.osm
legendre generalized
(15.55 KiB) Downloaded 84 times
kaj
essemer
 
Posts: 40
Joined: Sun Jan 02, 2011 9:02 am

Re: filter design - code problem

Postby tor on Mon Aug 29, 2011 1:55 am

firmament wrote:I'll try and find the ported rbj thread as the example you gave me isnt loading.
the 64bit stuff seems . . useless? if you can only feed it 32 bit values then round them back off to 32 bit at the end . .


ok?
lets just say that numbers with one decimal represent 32 bit and two decimal represent 64 bit
in 64 bit with conversion after calculations:
1.2*1.2+1.2*1.2=1.44+1.44=2.88≃2.9 (0.02 in diff)
in 32 bit with no conversion:
1.2*1.2+1.2*1.2=1.4+1.4=2.8 (0.08 in diff)

as you can see there is a huge difference and in a feedback structure theese errors build up quickly ;)
Any sufficiently advanced technology is indistinguishable from magic.
Arthur C. Clarke, "Profiles of The Future", 1961 (Clarke's third law)

http://www.audioteknikk.net
User avatar
tor
essemilian
 
Posts: 462
Joined: Wed Apr 14, 2010 8:52 pm

Re: filter design - code problem

Postby firmament on Mon Aug 29, 2011 12:12 pm

I've done a few ports of kaj's code to get them working in synthmaker. however because of precision issues, they arent accurate below ~300hz and break down completely sub-50

3-opt-l-filters.osm
(4.09 KiB) Downloaded 75 times

the explicit one is the full unoptimised code. asm optimised, it uses >20 cycles. the 64bit version is more accurate (thanks for the tip tor) but the difference isn't very significant
firmament
essemer
 
Posts: 16
Joined: Mon May 23, 2011 9:07 am

Re: filter design - code problem

Postby MegaHurtz on Mon Aug 29, 2011 3:03 pm

It ougta be 64 bits when it runs 64 bits ;)
Visit my website at: http://www.schlukhash.nl
User avatar
MegaHurtz
smaniac
 
Posts: 1504
Joined: Mon Aug 11, 2008 5:29 pm
Location: Eindhoven/Netherlands

Re: filter design - code problem

Postby tor on Mon Aug 29, 2011 5:19 pm

You are very welcome :)

Measurements I have done with the 2-pole biquads in VST Plugin Analyser shows a difference in prox -50dB for the noise floor. And in the bass area the altered frequencies sounds more clean and clear. But I totally agree that it should be possible to do all of the calculations in 64 bit. The speed of the digital revolution makes me think we soon will see plugs prosessing at 128 bit ;)

But they are probably not going to be created in SM
Any sufficiently advanced technology is indistinguishable from magic.
Arthur C. Clarke, "Profiles of The Future", 1961 (Clarke's third law)

http://www.audioteknikk.net
User avatar
tor
essemilian
 
Posts: 462
Joined: Wed Apr 14, 2010 8:52 pm

Re: filter design - code problem

Postby infuzion on Mon Aug 29, 2011 6:53 pm

firmament wrote:asm optimised, it uses >20 cycles.
3p Opt-L ASM2 is missing links from the green to the ASM. I assume connect in the order of the last math item?
Need help? First search the forum & WiKi, then post in the help forum with a clear topic, request, & OSM. Then please WiKi the correct solution. If you want my personal assistance, I charge by the hour or for an exchange of services.
infuzion
smstar
smstar
 
Posts: 6163
Joined: Wed May 04, 2005 8:02 pm
Location: Earth, USA, CO, Denver

Re: filter design - code problem

Postby firmament on Mon Aug 29, 2011 9:07 pm

infuzion wrote:
firmament wrote:asm optimised, it uses >20 cycles.
3p Opt-L ASM2 is missing links from the green to the ASM. I assume connect in the order of the last math item?

yeah, theyre arranged so the column of multiplies on the far right of the green mess are in the same descending order as the coefficient inputs of the asm.

In case anyone was dying to know, the filter is the "optimum" midpoint between chebyshev and butterworth, giving the steepest cutoff possible without ripple
firmament
essemer
 
Posts: 16
Joined: Mon May 23, 2011 9:07 am

Re: filter design - code problem

Postby MegaHurtz on Wed Aug 31, 2011 2:13 pm

^^ Also getting a bit steeper as it drops into infinity.
Visit my website at: http://www.schlukhash.nl
User avatar
MegaHurtz
smaniac
 
Posts: 1504
Joined: Mon Aug 11, 2008 5:29 pm
Location: Eindhoven/Netherlands

Re: filter design - code problem

Postby firmament on Thu Sep 01, 2011 6:11 pm

tor wrote:ok?
lets just say that numbers with one decimal represent 32 bit and two decimal represent 64 bit
in 64 bit with conversion after calculations:
1.2*1.2+1.2*1.2=1.44+1.44=2.88≃2.9 (0.02 in diff)
in 32 bit with no conversion:
1.2*1.2+1.2*1.2=1.4+1.4=2.8 (0.08 in diff)

as you can see there is a huge difference and in a feedback structure theese errors build up quickly ;)

haha should have thought it through before I posted really ;) and i see how 128 bit could be useful.. not sure how to get this filter to work otherwise.

attached is a minor fix, the green stuff was missing quite a bit in the asm version so ive cleared that up
Attachments
3-opt-l-filters.osm
(4.13 KiB) Downloaded 90 times
firmament
essemer
 
Posts: 16
Joined: Mon May 23, 2011 9:07 am

Previous

Return to Help

Who is online

Users browsing this forum: No registered users and 3 guests