0
$\begingroup$

I'm writing a biquad filter program in C++, using the LBJ Cookbook as the source for the formulas. https://webaudio.github.io/Audio-EQ-Cookbook/audio-eq-cookbook.html The lowpass filter that I've made seems to half work. The frequencies above the cutoff are being attenuated, however, it is causing aliasing similar to what happens with frequencies above Nyquist's limit.

double output, a0, a1, a2, b0, b1, b2, w, alpha; 
double pi = 3.14159265359;
w = (2 * pi) * (cutoff / sampleRate);
alpha = (sin(w)) / 2 * q;
a0 = 1 + alpha;
a1 = -2 * cos(w);
a2 = 1 - alpha;
b0 = (1 - cos(w)) / 2;
b1 = 1 - cos(w);
b2 = (1 - cos(w)) / 2;

output = (b0 / a0) * inSamples[0] + (b1 / a0) * inSamples[1] + (b2 / a0) * inSamples[2]
  - (a1 / a0) * outSamples[0] - (a2 / a0) * outSamples[1];

I'm not sure where my error is, so any help is greatly appreciated!

$\endgroup$
0
1
$\begingroup$

your output is definitely a linear combination of previous in- and output samples.

That means it's a linear time-invariant operation.

That means it can't introduce aliases.

What you see is something else than an alias, and I'll venture the guess you're interpreting sidelobes as aliases.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.