DSPRelated.com
Free Books

Time-Varying Two-Pole Filters

It is quite common to want to vary the resonance frequency of a resonator in real time. This is a special case of a tunable filter. In the pre-digital days of analog synthesizers, filter modules were tuned by means of control voltages, and were thus called voltage-controlled filters (VCF). In the digital domain, control voltages are replaced by time-varying filter coefficients. In the time-varying case, the choice of filter structure has a profound effect on how the filter characteristics vary with respect to coefficient variations. In this section, we will take a look at the time-varying two-pole resonator.

Evaluating the transfer function of the two-pole resonator (Eq.$ \,$(B.1)) at the point $ e^{j\theta_c}$ on the unit circle (the filter's resonance frequency $ \omega_c=\theta_c/T$) yields a gain at resonance equal to

$\displaystyle H(e^{j\theta_c})$ $\displaystyle =$ $\displaystyle \frac{b_0}{(1-Re^{j\theta_c}e^{-j\theta_c})(1-Re^{-j\theta_c}e^{-j\theta_c})}$  
  $\displaystyle =$ $\displaystyle \frac{b_0}{1-R}\cdot \frac{1}{1-Re^{-j2\theta_c}}
\protect$ (B.11)

For simplicity, let $ b_0 = 1$ in what follows. In the special cases $ \theta_c=0$ (resonance at dc) and $ \theta_c=\pi$ (resonance at $ f=f_s/2$), we have

$\displaystyle H(\pm1) = \frac{1}{(1-R)^2} \protect$ (B.12)

Since $ R$ is real, we have already found the gain (amplitude response) at a dc or $ f_s/2$ resonance:

$\displaystyle G(0) = G(\pi/T) \isdef \left\vert H(\pm1)\right\vert = \left\vert\frac{1}{(1-R)^2}\right\vert = \frac{1}{(1-R)^2}
$

In the middle frequency between dc and $ f_s/2$, $ \theta_c = \omega_c T
= \pi/2$, Eq.$ \,$(B.11) with $ b_0 = 1$ becomes

$\displaystyle H(j) = \frac{1}{(1-Re^{j2\frac{\pi}{2}})(1-R)} = \frac{1}{(1+R)(1-R)} = \frac{1}{1-R^2}
$

and, since $ H(j)$ is real and positive, it coincides with the amplitude response, i.e., $ H(j)=G(\pi/2)=1/(1-R^2)$.

An important fact we can now see is that the gain at resonance depends markedly on the resonance frequency. In particular, the ratio of the two cases just analyzed is

$\displaystyle \left\vert\frac{H(1)}{H(j)}\right\vert = \frac{1-R^2}{(1-R)^2} = ...
...R}{1-R} =
\frac{\hbox{maximum resonance gain}}{\hbox{minimum resonance gain}}
$

We did not show that resonance gain is maximized at $ e^{j\theta_c}=\pm
1$ and minimized at $ e^{j\theta_c}=\pm j$, but this is straightforward to show, and strongly suggested by Fig.B.17 (and Fig.B.9).

Note that the ratio of the dc resonance gain to the $ f_s/4$ resonance gain is unbounded! The sharper the resonance (the closer $ R$ is to 1), the greater the disparity in the gain.

Figure B.17 illustrates a number of resonator frequency responses for the case $ R=0.99$. (Resonators in practice may use values of $ R$ even closer to 1 than this--even the case $ R=1$ is used for making recursive digital sinusoidal oscillators [90].) For resonator tunings at dc and $ f_s/2$, we predict the resonance gain to be $ 20\log_{10}[1/(1-R)^2] = -20\log_{10}[(1-0.99)^2] =
-40\log_{10}(0.01) = 80$ dB, and this is what we see in the plot. When the resonance is tuned to $ f_s/4$, the gain drops well below 40 dB. Clearly, we will need to compensate this gain variation when trying to use the two-pole digital resonator as a tunable filter.

Figure B.17: Frequency response overlays for the two-pole resonator $ H(z)=1/(1-2R\cos (\theta _c)z^{-1}+ R^2z^{-2})$, for $ R=0.99$ and 10 values of $ \theta _c$ uniformly spaced from 0 to $ \pi $. The 5th case is plotted using thicker lines.
\includegraphics[width=\twidth ]{eps/resgain}

Figure B.18 shows the same type of plot for the complex one-pole resonator $ H(z)=1/(1-Re^{j\theta _c}z^{-1})$, for $ R=0.99$ and 10 values of $ \theta _c$. In this case, we expect the frequency response evaluated at the center frequency to be $ H(e^{j\omega_c T})
=1/(1-Re^{j\theta_c}e^{-j\theta_c})=1/(1-R)$. Thus, the gain at resonance for the plotted example is $ 1/(1-0.99)=100=40$ db for all tunings. Furthermore, for the complex resonator, the resonance gain is also exactly equal to the peak gain.

Figure B.18: Frequency response overlays for the one-pole complex resonator $ H(z)=1/(1-Re^{j\theta _c}z^{-1})$, for $ R=0.99$ and 10 values of $ \theta _c$ uniformly spaced from 0 to $ \pi $. The 5th case is plotted using thicker lines.
\includegraphics[width=\twidth ]{eps/cresgain}

Normalizing Two-Pole Filter Gain at Resonance

The question we now pose is how to best compensate the tunable two-pole resonator of §B.1.3 so that its peak gain is the same for all tunings. Looking at Fig.B.17, and remembering the graphical method for determining the amplitude response,B.6 it is intuitively clear that we can help matters by adding two zeros to the filter, one near dc and the other near $ f_s/2$. A zero exactly at dc is provided by the term $ (1-z^{-1})$ in the transfer function numerator. Similarly, a zero at half the sampling rate is provided by the term $ (1+z^{-1})$ in the numerator. The series combination of both zeros gives the numerator $ B(z)=(1-z^{-1})(1+z^{-1})=1-z^{-2}$. The complete second-order transfer function then becomes

$\displaystyle H(z) = \frac{B(z)}{A(z)} = \frac{1 - z^{-2}}{1-2R\cos(\theta_c)z^{-1}+ R^2z^{-2}}
$

corresponding to the difference equation

$\displaystyle y(n) = x(n) - x(n-2) + [2R\cos(\theta_c)] y(n-1) - R^2 y(n-2). \protect$ (B.13)

Checking the gain for the case $ \theta_c=\pi/2$, we have

\begin{eqnarray*}
H(\pm1) &=& 0\\
\left.H(e^{j\theta_c})\right\vert _{\theta_c=\pi/2} &=& \frac{2}{1-R^2}
\end{eqnarray*}

which is better behaved, but now the response falls to zero at dc and $ f_s/2$ rather than being heavily boosted, as we found in Eq.$ \,$(B.12).


Constant Resonance Gain

It turns out it is possible to normalize exactly the resonance gain of the second-order resonator tuned by a single coefficient [89]. This is accomplished by placing the two zeros at $ z=\pm \sqrt{R}$, where $ R$ is the radius of the complex-conjugate pole pair . The transfer function numerator becomes $ B(z)=(1-\sqrt{R}z^{-1})(1+\sqrt{R}z^{-1}) = (1-Rz^{-2})$, yielding the total transfer function

$\displaystyle H(z) = \frac{B(z)}{A(z)} = \frac{1 - Rz^{-2}}{1-2R\cos(\theta_c)z^{-1}+ R^2z^{-2}}
$

which corresponds to the difference equation

$\displaystyle y(n) = x(n) - R\, x(n-2) + [2R\cos(\theta_c)] y(n-1) - R^2 y(n-2).
$

We see there is one more multiply-add per sample (the term $ -R x(n-2)$) relative to the unnormalized two-pole resonator of Eq.$ \,$(B.13). The resonance gain is now

\begin{eqnarray*}
H(e^{j\theta_c}) &=& \frac{1 - R e^{-j2\theta_c}}{1-2R\cos(\th...
...\theta_c}}{(1-R) - (1-R)Re^{-j2\theta_c}}\\
&=& \frac{1}{1 - R}
\end{eqnarray*}

Thus, the gain at resonance is $ 1/(1-R)$ for all resonance tunings $ \theta _c$.

Figure B.19 shows a family of amplitude responses for the constant resonance-gain two-pole, for various values of $ \theta _c$ and $ R=0.99$. We see an excellent improvement in the regularity of the amplitude response as a function of tuning.

Figure: Frequency response overlays for the constant resonance-gain two-pole filter $ H(z)=(1-R)(1-Rz^{-2})/(1-2R\cos(\theta_c)z^{-1}+R^2z^{-2})$, for $ R=0.99$ and 10 values of $ \theta _c$ uniformly spaced from 0 to $ \pi $. The 5th case is plotted using thicker lines.
\includegraphics[width=\twidth ]{eps/cgresgain}


Peak Gain Versus Resonance Gain

While the constant resonance-gain filter is very well behaved, it is not ideal, because, while the resonance gain is perfectly normalized, the peak gain is not. The amplitude-response peak does not occur exactly at the resonance frequencies $ \omega
T=\pm\theta_c$ except for the special cases $ \theta_c=0$, $ \pm\pi/2$, and $ \pi $. At other resonance frequencies, the peak due to one pole is shifted by the presence of the other pole. When $ R$ is close to 1, the shifting can be negligible, but in more damped resonators, e.g., when $ R<0.9$, there can be a significant difference between the gain at resonance and the true peak gain.

Figure B.20 shows a family of amplitude responses for the constant resonance-gain two-pole, for various values of $ \theta _c$ and $ R=0.9$. We see that while the gain at resonance is exactly the same in all cases, the actual peak gain varies somewhat, especially near dc and $ f_s/2$ when the two poles come closest together. A more pronounced variation in peak gain can be seen in Fig.B.21, for which the pole radii have been reduced to $ R=0.5$.

Figure: Frequency response overlays for the constant resonance-gain two-pole filter $ H(z)=(1-R)(1-Rz^{-2})/(1-2R\cos(\theta_c)z^{-1}+R^2z^{-2})$, for $ R=0.9$ and 10 values of $ \theta _c$ uniformly spaced from 0 to $ \pi $. The 5th case is plotted using thicker lines.
\includegraphics[width=\twidth ]{eps/cgresgaindamped}

Figure: Frequency response overlays for the constant resonance-gain two-pole filter $ H(z)=(1-R)(1-Rz^{-2})/(1-2R\cos(\theta_c)z^{-1}+R^2z^{-2})$, for $ R=0.5$ and 10 values of $ \theta _c$ uniformly spaced from 0 to $ \pi $. The 5th case is plotted using thicker lines. Note the more pronounced variation in peak gain (the resonance gain does not vary).
\includegraphics[width=\twidth ]{eps/cgresgaindampedp5}


Constant Peak-Gain Resonator

It is surprisingly easy to normalize exactly the peak gain in a second-order resonator tuned by a single coefficient [94]. The filter structure that accomplishes this is the one we already considered in §B.6.1:

$\displaystyle H(z) = \frac{B(z)}{A(z)} = \frac{1 - z^{-2}}{1-2R\cos(\theta_c)z^{-1}+ R^2z^{-2}}
$ (B.14)

That is, the two-pole resonator normalized by zeros at $ z=\pm 1$ has the constant peak-gain property when it has resonant peaks in its response at all. Note, however, that the peak-gain frequency and the pole-resonance frequency (cf. §B.6.3), are generally two different things, as elaborated below. This structure has the added bonus that its difference equation requires only one more addition relative to the unnormalized two-pole resonator, and no new multiply.

Real-time audio ``plugins'' based on the constant-peak-gain resonator are developed in Appendix K.

The peak gain is $ 2/(1-R^2)$, so multiplying the transfer function by $ (1-R^2)/2$ normalizes the peak gain to one for all tunings. It can also be shown [94] that the peak gain coincides with the variance gain when the resonator is driven by white noise. That is, if the variance of the driving noise is $ \sigma^2$, the variance of the noise at the resonator output is $ 2\sigma^2/(1-R^2)$. Therefore, scaling the resonator input by $ g=\sqrt{(1-R^2)/2}$ will normalize the resonator such that the output signal power equals the input signal power when the input signal is white noise.

Frequency response overlays for the constant-peak-gain resonator are shown in Fig.B.23 ($ R=0.99$), Fig.B.20 ($ R=0.9$), and Fig.B.21 ($ R=0.5$). While the peak frequency may be far from the resonance tuning in the more heavily damped examples, the peak gain is always normalized to unity. The normalized radian frequency $ \psi\in[-\pi,\pi]$ at which the peak gain occurs is related to the pole angle $ \theta_c\in[-\pi,\pi]$ by [94]

$\displaystyle \cos(\theta_c) = \frac{1+R^2}{2R}\cos(\psi). \protect$ (B.15)

When the right-hand side of the above equation exceeds 1 in magnitude, there is no (real) solution for the pole frequency $ \theta _c$. This happens, for example, when $ R$ is less than 1 and $ \psi$ is too close to 0 or $ \pi $. Conversely, given any pole angle $ \theta_c\in(0,\pi)$, there always exists a solution for the peak frequency $ \psi = \arccos[2R\cos(\omega_c)/(1+R^2)]$, since $ \vert 2R/(1+R^2)\vert\leq1$ when $ R\in[0,1]$. However, when $ R$ is small, the peak frequency can be far from the pole resonance frequency, as shown in Fig.B.22.

Figure B.22: Upper and lower peak-gain frequency limits as a function of pole radius $ R$ ( $ \arccos[\pm2R/(1+R^2)]$).
\includegraphics[width=\twidth ]{eps/psivsthetac}

Thus, $ R$ must be close to 1 to obtain a resonant peak near dc (a case commonly needed in audio work) or half the sampling rate (rarely needed in practice). When $ R$ is much less than 1, the peak frequency $ \psi$ cannot leave a small interval near one-fourth the sampling rate, as can be seen at the far left in Fig.B.22.

Figure B.22 predicts that for $ R=0.5$, the lowest peak-gain frequency should be around $ \psi\geq 0.515$ radian per sample. Figure B.21 agrees with this prediction.

As Figures B.23 through B.25 show, the peak gain remains constant even at very low and very high frequencies, to the extent they are reachable for a given $ R$. The zeros at dc and $ f_s/2$ preclude the possibility of peaks at exactly those frequencies, but for $ R$ near 1, we can get very close to having a peak at dc or $ f_s/2$, as shown in Figures B.19 and B.20.

Figure: Frequency response overlays for the constant peak-gain two-pole filter $ H(z)=[(1-R^2)/2](1-z^{-2})/(1-2R\cos(\theta_c)z^{-1}+R^2z^{-2})$, for $ R=0.99$ and 10 values of $ \theta _c$ uniformly spaced from 0 to $ \pi $. The 5th case is plotted using thicker lines.
\includegraphics[width=\twidth ]{eps/cpgresgain}

Figure: Frequency response overlays for the constant peak-gain two-pole filter $ H(z)=[(1-R^2)/2](1-z^{-2})/(1-2R\cos(\theta_c)z^{-1}+R^2z^{-2})$, for $ R=0.9$ and 10 values of $ \theta _c$ uniformly spaced from 0 to $ \pi $. The 5th case is plotted using thicker lines.
\includegraphics[width=\twidth ]{eps/cpgresgaindamped}

Figure: Frequency response overlays for the constant peak-gain two-pole filter $ H(z)=[(1-R^2)/2](1-z^{-2})/(1-2R\cos(\theta_c)z^{-1}+R^2z^{-2})$, for $ R=0.5$ and 10 values of $ \theta _c$ uniformly spaced from 0 to $ \pi $. The 5th case is plotted using thicker lines.
\includegraphics[width=\twidth ]{eps/cpgresgaindampedp5}


Four-Pole Tunable Lowpass/Bandpass Filters

As a practical note, it is worth mentioning that in popular analog synthesizers (both real and virtualB.7), VCFs are typically fourth order rather than second order as we have studied here. Perhaps the best known VCF is the Moog VCF. The four-pole Moog VCF is configured to be a lowpass filter with an optional resonance near the cut-off frequency. When the resonance is strong, it functions more like a resonator than a lowpass filter. Various methods for digitizing the Moog VCF are described in [95]. It turns out to be nontrivial to preserve all desirable properties of the analog filter (such as frequency response, order, and control structure), when translated to digital form by standard means.


Next Section:
Elementary Filter Problems
Previous Section:
Peaking Equalizers