Noj ·
I am using IIR filter up to 4rd order, but the IIR filtering with code module is VERY slow... is it possible to have a more optimized 4P4Z module, like the biquad filter coeff 2P2Z module?
Thanks!
Jean LEUNG.
From the original SynthMaker forum (2004–2014), with its members’ names and dates.
Noj ·
I am using IIR filter up to 4rd order, but the IIR filtering with code module is VERY slow... is it possible to have a more optimized 4P4Z module, like the biquad filter coeff 2P2Z module?
Thanks!
Jean LEUNG.
theun ·
Maybe I don't understand your idea quite right.
But similar like you can make a 2 pole filter by cascading two 1 pole (=6 dB/oct) filters, you can make a 4 pole filter by cascading two 2 pole filters, for example using two cascaded 2P2Z primitives.
Or do I overlook something?
Andrew J ·
Noj wrote: I am using IIR filter up to 4rd order, but the IIR filtering with code module is VERY slow... is it possible to have a more optimized 4P4Z module, like the biquad filter coeff 2P2Z module?
Thanks!
Jean LEUNG.
If you wanted to post your code, I could try ASM optimising it for you...
Noj ·
Yes, you can cascade lower order filters, but I want to use very specific filters and I only have the equations for the coefficients a1, a2, a3, a4, a5 and b2, b3, b4, b5 (b1 = 1). You can of course make a polynomial division to get coefficients for a 2nd order IIR but it is quite complicated (with lots of roundoff errors).
The code is just an IIR implementation code : something like : (without declaration and initialization)
differential form : z4 = a5*in - b5*out ; z3 = a4*in + z4 - b4*out ; z2 = a3*in + z3 - b3*out ; z1 = a2*in + z2 - b2*out ; out = a1*in + z1 ;
or the direct form : out = (a1*in)+(a2*in1)+(a3*in2)+(a4*in3)+(a5*in4)-(b2*out1)-(b3*out2)-(b4*out3)-(b5*out4) ; out4 = out3; out3 = out2; out2 = out1; out1 = out; in4 = in3; in3 = in2; in2 = in1; in1 = in;
but using the code module, it runs 10x slower than 10 biquad filters...
oddson ·
Are you calculating the coefficients in your code? That can be a much bigger hit on CPU than the direct form stuff.
If you can calc in green modules that would save you big time, if not at least make sure you're using hop() to lower the load from the coefficient calculations.
With dummy coefficients fed as green data I'm getting about 0.1% additional CPU for each instance added on my P4 2.8GHz at SR=44.1 KHz.
Noj ·
No, the code contains just IIR filtering. The coefficients are calculated "visually in green", which is quite pain in the ***... But the coefficients are declared as "streamin" as I do not know how to declare float inputs.
oddson ·
They have to be streamin.
What kind of load are you seeing?
Try adding a second instance of the filter and determine what the CPU increase is. This will give you a pretty good idea of how much of the load is from the filter itself.
Andrew J ·
Noj wrote: but using the code module, it runs 10x slower than 10 biquad filters...
See how you go with this ASM optimised version of the code. On my system this is running at 38 cycles, compared to 19 for an optimised biquad.
streamin in;streamout out; streamin a1;streamin a2;streamin a3; streamin a4;streamin a5;streamin b2; streamin b3;streamin b4;streamin b5; float in1=0;float in2=0;float in3=0;float in4=0; float out1=0;float out2=0;float out3=0;float out4=0;
movaps xmm7,in3;movaps xmm6,in2;movaps xmm5,in1; movaps xmm4,a5;mulps xmm4,in4; movaps in4,xmm7; movaps xmm3,a4;mulps xmm3,xmm7; movaps in3,xmm6;movaps xmm7,in; movaps xmm2,a3;mulps xmm2,xmm6; addps xmm4,xmm3; movaps in2,xmm5; movaps xmm1,a2;mulps xmm1,xmm5; addps xmm4,xmm2; movaps in1,xmm7; movaps xmm0,a1;mulps xmm0,xmm7; addps xmm1,xmm4;
movaps xmm7,out3;movaps xmm6,out2;movaps xmm5,out; movaps xmm4,b5;mulps xmm4,out4; addps xmm0,xmm1; movaps out4,xmm7; movaps xmm3,b4;mulps xmm3,xmm7; subps xmm0,xmm4; movaps out3,xmm6; movaps xmm2,b3;mulps xmm2,xmm6; subps xmm0,xmm3; movaps out2,xmm5; movaps xmm1,b2;mulps xmm1,xmm5; subps xmm0,xmm2; subps xmm0,xmm1; movaps out,xmm0;
-Andrew
MyCo ·
You've good chances to run into denormals... And when you've got them, the CPU has much to do because of the "4th order"...
Andrew J ·
MyCo wrote: You've good chances to run into denormals... And when you've got them, the CPU has much to do because of the "4th order"...
Yeah, this occured to me after my previous post too. Note that the ASM code above doesn't do anything to avoid denormals.
Noj ·
Thanks Andrew,
I'll try your code this evening. My previous code did also run into denormals. Is there any way to avoid this with SM? If I remember well, there is a denormal detector / cleaner module under synthedit.
aliasant ·
Noj wrote: Thanks Andrew,
I'll try your code this evening. My previous code did also run into denormals. Is there any way to avoid this with SM? If I remember well, there is a denormal detector / cleaner module under synthedit.
Just place a low leveled noise osc before your modules in the mono chain. You can set it to something like -120dB
Noj ·
Hi Andrew,
See how you go with this ASM optimised version of the code. On my system this is running at 38 cycles, compared to 19 for an optimised biquad.
I have just tried your code. It works pretty well! My VST module uses 2*4P4Z filters (yours) with mono4 signals (8 channels overall). On my main computer (Athlon64 3200+) it does not make much difference with the code version (3.4% instead of 3.5%). But on my VST box (pentium4 2.6GHz), it went from 16-18% down to 6-6.5%! Btw, the pentium4 has the denormal issues whereas the AMD does not.
Andrew J ·
I'm not sure why you see little improvement on the Athlon, as I saw a 50% reduction in cycles on my Athlon X2 4400+. Maybe infuzion could explain that for us?
Also, SM has it's own Denormal Remover in the Modifier section of the toolbox. It can truncate and/or add noise.
-Andrew
Noj ·
Andrew J wrote: I'm not sure why you see little improvement on the Athlon, as I saw a 50% reduction in cycles on my Athlon X2 4400+. Maybe infuzion could explain that for us?
The bench is not really accurate because I used some old delay modules (1 per channel = 8) which is quite cpu consuming. Using the code version of the delay module (which accepts mono4 signals), the cpu consumption has gone from 3.5% down to 1.2%.
Just for your information, the module is a crossover for loudspeaker management. The purpose of the VST is to compare the sonic quality of the "best" analog crossovers (at least known as best), and some of them need a delay between lp and hp filter. If you have a yahoo account, the module is available here :
http://fr.groups.yahoo.com/group/son-qc ... n%20Leung/
(french group, sorry guys 😉 )
Wrote something here? To have a post removed or your name hidden, write to [email protected].