Hot answers tagged

8

The two solutions in a floating point implementation are assumed to be identical, with the two BiQuads being a factored version of the standard difference equation. The BiQuad is the better way to go for fixed point as you isolate two 2nd order systems and in doing so will be easier to keep stable under variations due to the quantization involved. For more ...


7

You want to have an interpolation with a equal number of weights on both sides of the points you want to interpolate in between. So you choose either one or two weights on each side, resulting in an interpolation of two (linear) or four (cubic) points. An quadratic interpolation would need three points, which would only make sense at the border of a grid, ...


5

You are confusing "processing time" with "latency". Real-time filters are able to generate output samples at the same rate as they receive inputs. They would however induce latency, meaning that the bulk of the energy generated for an input appears later in time with respect to that input. Consider for example the following input/output: time : 0 1 2 3 4 ...


5

alright, there are a couple of different issues that may (or may not) need to be de-conflated. i'm gonna try to keep the number of symbols minimized. $dB_\text{gain}$ is the number of dB gain of the peak (for $dB_\text{gain} > 0$) or cut (for $dB_\text{gain} < 0$). it appears to be 6 dB in the plots. $$A^2 \triangleq 10^{dB_\text{gain}/20}$$ is ...


5

Tricky problem. Not sure I can answer this but here are a few pointers: Direct Form II is the worst biquad for audio processing. The transfer function between the input and the state is given just by the poles. The gain can be really large, I have seen gains of in excess of a 100 dB for reasonable audio filters. This makes real time switching of Direct Form ...


4

Possible, yes. But higher-order IIR filters tend to be less stable and more susceptible to various numerical problems (lost precision, underflow, overflow, etc.), compared to a cascade or bank of suitable partitioned biquad filters.


3

Of course an SOS matrix is capable of completely describing the filter including the gain. However, in the Matlab SOS matrix the $b_0$ coefficients are all equal to $1$ by default (if no extra scaling is used), which is a kind of "neutral" scaling (and gets rid of one multiplication per second-order section). The gain factor $G$ is the overall gain necessary ...


3

More expensive computationally with marginal results. Most images don't require such interpolation technique. You can also look at this question: Higher order spline interpolation


3

A biquad is simply a two-pole IIR filter, where both the numerator and denominator of the transfer function are quadratic equations. Thus, you can factor the coefficient equations, and then use any reference regarding a filter's behavior related to pole/zero placements in the Z-plane to determine the behavior. One tutorial method I recall was a software ...


3

According to the Audio EQ Cookbook the transfer function of a second-order band-pass filter with 0dB peak gain is given by $$H(z)=\frac{\alpha-\alpha z^{-2}}{(1+\alpha)-2\cos(\omega_0)z^{-1}+(1-\alpha)z^{-2}}\\=\frac{\alpha}{1+\alpha}\cdot\frac{1-z^{-2}}{1-\frac{2}{1+\alpha}\cos(\omega_0)z^{-1}+\frac{1-\alpha}{1+\alpha}z^{-2}}\tag{1}$$ where $\omega_0$ is ...


3

there is an earlier answer regarding how to more cheaply evaluate functions like sin() and log() and such. they're approximations, but very good ones.


3

I have too few points for to comment so I try give you at least a partial answer. You can't change those b coefficients using equal multiplier with a's. As those final coefficients comes from transformation there might be some ratios you loose in that process. In my MZT based example below, you get the final coefficients from equations b1 = -(pole1 + ...


3

So, sox defines its biquad operation parameters as follows: biquad b0 b1 b2 a0 a1 a2 Apply a biquad IIR filter with the given coefficients. Where b* and a* are the numerator and denominator coefficients respectively. See http://en.wikipedia.org/wiki/Digital_biquad_filter (where a0 = 1). This effect supports the −−plot global option. A biquad ...


3

Another possibility is to send the coefficients as poles and zeros and interpolate/smooth in the z-plane instead of the coefficient domain. This is always guaranteed to be stable. You can either interpolate in real/imaginary presentation or, if you want to get fancy, in magnitude and phase. The first one is a lot easier, since the phase interpolation has to ...


3

Let's try this in Octave/Matlab: a = [1,-1.601089848140876,0.668366341586459]; b = [0.016819123361395717,0.033638246722791434,0.016819123361395717]; r = roots(a); abs(r) ans = 0.81754 0.81754 Since the roots are all inside the unit circle, your filter is stable. The magnitude response looks like it should for a Butterworth filter. However, as you'...


2

Let me refer to the denominator coefficients as the pole coefficients, and the numerator coefficients as the zero coefficients. This is for those who visualize poles as able to peak magnitude, and zeros able to dip magnitude magnitude. For instance, if the biquad were all-pole (numerator = 1), the max magnitude could be found at the pole’s phase angle. ...


2

in this previous answer, the squared-magnitude of a biquad frequency response is shown to be: $$\begin{align} f(\phi) \triangleq |H(e^{j\omega})|^2 & = \left| \frac{b_0 + b_1 e^{-j\omega} + b_2 e^{-j2\omega}}{a_0 + a_1 e^{-j\omega} + a_2 e^{-j2\omega}} \right|^2 \\ & = \frac{B_0 + B_1 \phi + B_2 \phi^2}{A_0 + A_1 \phi + A_2 \phi^2} \\ \end{align}$$...


2

To get the frequency response, replace $z$ in $H(z)$ by $e^{j2\pi f/f_s}=\cos(2\pi f/f_s)+j\sin(2\pi f/f_s)$ where $f_s$ is the sampling frequency in Hz and $f$ is the desired frequency in Hz. This will give you the value of the frequency response at frequency $f$. Note that the frequency response is a complex function, so you might want to look at its ...


2

It looks like you got your a and b coefficients swapped. The feedback terms: b0,b1,b2, should be tiny (around 0.00x), and a0,a1,a2 can be close to 1 or 2 in magnitude.


2

I was unable to get a stable filter using your coefficients. You did not state, but am assuming this is a lowpass filter. Using the calculator here, I got: coeffs = dict( a0=0.0010232172047183973, a1=0.0020464344094367946, a2=0.0010232172047183973, b1=-1.9075008174364765, b2=0.91159368625535, ) Filter Code: I recast to a Transposed ...


2

What I can see from the code is the following mapping between the array coeffs[] and the filter coefficients $a_i$ and $b_i$ (note that $a_0=1$ and is not stored in coeffs[]): $b_0=$coeffs[2], $b_1=$coeffs[1], $b_2=$coeffs[0] $a_1=$coeffs[4], $a_2=$coeffs[3] For the time being choose the scaling equal to $1$ (scalefactor=0) to check if everything else ...


2

The reason why interpolating the coefficients would cause instability is that intermedite set of coefficients values could potentially produce poles outside the unit circle, thus making your filter unstable. Moreover, the values of the coefficients is not linearly related to the parameters of your filter, which means that it's not even going to avoid the ...


2

Consider a discrete-time LTI system (that's your second order stage) described by a LCCDE in the form of a recursion equation: $$y[n] = a y[n-1] + b y[n-2] + c x[n] + d x[n-1] $$ where $a,b,c,d$ are real or complex constants (coefficients of your IIR filter) and the values $y[n-1],y[n-2]$ are previous values of the output, where as $y[n]$ is the current ...


2

There is (at least) one error in your routine. It concerns the definition of alpha. The correct formula is $$\alpha=\frac{\sin(\omega_0)}{2Q}$$ However, you implemented $$\alpha=\frac{\sin(\omega_0)\cdot Q}{2}$$ But that shouldn't influence the function of the filter as a high pass filter; it just implements the inverse of the given $Q$ value. Other ...


2

Note that a biquad has $5$ degrees of freedom (not $6$), because $a_0$ can always be chosen as $a_0=1$ without loss of generality: $$\begin{align}H(z)&=\frac{b_0+b_1z^{-1}+b_2z^{-2}}{1+a_1z^{-1}+a_2z^{-2}}\\&=b_0\cdot\frac{1+\hat{b}_1z^{-1}+\hat{b}_2z^{-2}}{1+a_1z^{-1}+a_2z^{-2}},\qquad \hat{b}_1=\frac{b_1}{b_0},\;\;\hat{b}_2=\frac{b_2}{b_0}\tag{1}\...


2

You need to do partial fraction expansion. Most of the time, the result will be 3 parallel sections with the same poles as the original filter but only with a real zero in each parallel section. The first section is just a single real scale factor. $$H(z) = r0_0 + \frac{r0_1 + r1_1 \cdot z^{-1}}{a0_1 + a1_1 \cdot z^{-1} + a2_1 \cdot z^{-2}} + \frac{r0_2 + ...


1

Sorry, that doesn't work. You have to scale all numerator (the "b") or all denominator coefficients (the "a") at the same time. That doesn't work for the denominator since you all practical implementations require $a_0=1$. Scaling $a_1$ and $a_2$ without scaling $a_1$ will move the poles and change the overall shape of the transfer function and not just the ...


1

The states should be declared outside the method and be members of your class so they are actually state-full: class Filter { double xb[2] = { 0, 0 }; double yb[2] = { 0, 0 }; public: void process(int size, double *in, double *out) { for (int n = 0; n < size; n++) { out[n] = (coeffs->a0 * in[n]) + (coeffs-&...


1

Maybe this thread helps you in this Q - Prewarping both resonant frequency $f_0$ and bandwidth (or $Q$) when using bilinear transform H(s) is the s-plane transfer function Analog prototype of RBJ peak filter (Octave): K = 10^(gain/40); w0 = 2*pi*fc; % H(s) = (s^2 + (K w0/Q)*s + w0^2) / (s^2 + w0 s/(K*Q) + w0^2) BC = [1 K*w0/Q w0^2]; AC = [1 w0/(K*Q) w0^2];...


1

You could also implement a 2nd order IIR filter which has response of 1st order filter by using some other TF but one used in RBJ's cookbook. Here's one way to do it using MZT (C++). double Fs = 44100; // higher sample rate results better filter accuracy double T1 = 0.000075; // time constant double p1 = -exp(-1.0/(Fs*T1)); double z1 = 1 + z1; a0 = 1.0; ...


Only top voted, non community-wiki answers of a minimum length are eligible