Can someone help me with some filter coding questions?


#1

Never mind, I just went ahead and hacked the JUCE IIR Filter code and got something much better, thanks again Jules for such incredible work!!!

 

class WFilter1PAJ // Based on JUCE's IIR Filter code
{
public:
    WFilter1PAJ() : SampleRate(nullptr) { zeromem(co, sizeof(co)); reset(); };
    inline paramptr process(paramptr Input)
    {
        #define processPole(pole, input) out = co[0] * input + v1[pole]; SNAP_TO_ZERO(out); v1[pole] = co[1] * input - co[3] * out + v2[pole]; v2[pole] = co[2] * input - co[4] * out;
        //
        processPole(0, Input); prevOut = out;
        processPole(1, prevOut); prevOut = out;
        processPole(2, prevOut);
        //
        return out;
    };
    void frequency(paramptr aFrequency = wv0)
    {
        if (SampleRate != nullptr)
        {
            n = wv1 / tan(double_Pi * ((aFrequency*aFrequency)*MAX_FREQ) / paramptr(*SampleRate));
            nSquared = n * n;
            co[0] = wv1 / (wv1 + std::sqrt(wv2) * n + nSquared);
            //
            co[2] = co[0];
            co[1] = co[0] * wv2;
            co[3] = co[1] * (wv1 - nSquared);
            co[4] = co[0] * (wv1 - std::sqrt(wv2) * n + nSquared);
        }
    }
    void reset() { for (int x = 0; x < 3; x++) { v1[x] = v2[x] = wv0; } };
    //
    int32 *SampleRate;
    audioptr out, v1[3], v2[3], co[5], prevOut;
    paramptr n, nSquared, a;
};