[Clam-devel] IIR BiQuad LPF/BPF/HPF
Xavier
xavier at amatriain.net
Wed Jan 14 01:45:58 PST 2009
Hi Karsten,
I was trying to remember what ever happened to our TD Filter
implementation. There was a student working on this for some time and as
far as I can remember they were fully functional. David, do you remember
what happened to this?
As far as your problems with your implementation, all I can say is that
the rbj's recipe is fully tested and should work out of the box. If you
are having some issues I think the best is to post a mail to music-dsp
mailing list where you are likely to get rbj to reply to the mail himself.
X
Karsten Krispin wrote:
> Hello!
>
> ... and a happy new year!
>
> I'm searching for a IIR implementation for LP, BP and HP filters. Does CLAM
> already implemented such things?
>
> Currently I'm implementing it via SpectralAnalysis/Synth. Unfortunately this
> implementation consumes much cpu power.
>
> Is there already something available in CLAM?
>
> If not: I tried to implement it with the reference of
>
> http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt
>
> So far so good. It works. As far as I understand, the only tricky part is to
> calculate the coefficients.
>
> For now, all refers to a LP implementation:
>
> That I have done and it is working.. some how:
>
> I have pushed a rectangle-wave throug the filter to explain:
>
> The result is represented in the attached "biquad_nonzerophase.png"
> Here you can see that the right edge of the rectangle is somhow flipped.
>
> In "biquad_zerophase.png" you could see how I would expect the filtered signal
> to be. It was created with a SpectralLowPass in the signal-chain.
>
> This flipped edge is caused by a nonzero phased filter as I read somewhere.
> This nonzero phase behaviour could be erased by applying the same filter
> backwards to the signal.
>
> But if I do this, the result is "biquad_nonzerophase_backwards.png". Some
> weird peaks at the corner of each AudioBuffer occour.
>
> If I apply the same filter forwards, everything is fine, like in
> "biquad_nonzerophase.png".
>
>
> The filter-code is:
>
> You apply CLAM::Audio Buffer to the filter class and it does the magic within
> filter() - function:
>
> All variables prefixed with an underscore are class-private variables.
> Those with an "_bx*" and "_by*" are variables for the backward filter.
>
> The biquad coefficients are applied, of course.
>
> Has someone an particular idea?
>
> Code below.
>
> Thanks in advance,
> Karsten Krispin
>
>
> Code:
>
> void BiQuadFilter::Generic::filter(CLAM::Audio & buffer)
> {
>
> CLAM::TData * buf = buffer.GetBuffer().GetPtr();
> CLAM::TSize bufSize = buffer.GetSize();
>
> CLAM_ASSERT(buf, "Pointer to AudioBuffer is empty");
>
> /* Forward Filter */
> for(int i = 0; i < bufSize; i++)
> {
> _y = _b0 * buf[i] + _b1*_x1 + _b2*_x2 - _a1*_y1 - _a2*_y2;
> _x2 = _x1;
> _x1 = buf[i];
> _y2 = _y1;
> _y1 = _y;
>
> buf[i] = _y;
> }
> */
>
> /* Backward Filter */
> for(int i = bufSize-1; i >= 0; i--)
> {
> _by = _b0*buf[i] + _b1*_bx1 + _b2*_bx2 - _a1*_by1 - _a2*_by2;
>
> _bx2 = _bx1;
> _bx1 = buf[i];
>
> _by2 = _by1;
> _by1 = _by;
>
> buf[i] = _by;
> }
> }
>
>
>
>
>
>
>
>
>
>
>
>
> ------------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Clam-devel mailing list
> Clam-devel at llistes.projectes.lafarga.org
> https://llistes.projectes.lafarga.org/cgi-bin/mailman/listinfo/clam-devel
>
More information about the clam-devel
mailing list