Filters

From DSPWiki

Jump to: navigation, search

Digital filters are defined as a "computational process or algorithm by which a digital signal or sequence of numbers (acting as input) is transformed into a second sequence of numbers termed the output digital signal". However, the common usage of the word 'filter' implies frequency-dependent attenuators that enhance some frequencies while diminishing others. Reverberators and delay lines are also filters, so a filter can change not only the spectrum of an input signal, but also its temporal structure.

Amplitude Response:

lecture12_image1.gif

By convention, the cutoff frequency is the point in the frequency range at which the filter reduces the signal to 0.707 of its maximum value. This is because 0.707² is equal to 0.5, so .707 is the half-power point, where the power of the signal is reduced by half, or 3 dB. This, of course is on a linear scale — 3dB is barely audible in terms of auditory perception. The cutoff frequency can also be referred to as the 3dB point.

Spectral components that are attenuated below the cutoff point of a filter are said to be in the stopband of a filter, whereas those above the cutoff point are said to be in the passband. Since real-world filters aren't ideally sharp (perfect brick-wall filters), the area between the passband and the stopband is called the transition band. The steepness of the slope is specified in dB/octave, where a larger number of dB per 1 octave indicates a sharper cutoff.

lecture12_image2.gif

Bandpass filters have a bandwidth which is adjusted by varying Q, which is defined as the ratio of the center frequency to the spread of its -3dB (cutoff point) bandwidth.

Q = ƒcenter / ( ƒhighcutoff - ƒlowcutoff)

or

Q = frequency / bandwidth

A constant Q filter has the musical quality that the musical interval it spans does not change as the center frequency changes. To do this it varies its bandwidth as a function of the center frequency. This means that a bandpass filter that spans an octave at 40 Hz still spans an octave at 10 kHz, even though it has to span a much larger frequency distribution.

lecture12_image3.gif

What a filter produces depends on the source. The individual partial components of a signal will be attenuated based on the filter shape.

lecture12_image4.gif

Contents

How are Filters Perceived?

In speech, the perception of vowel sounds are characterized by the perception of filtering in the vocal chords.

If the cutoff frequency of a filter is moving, we perceive the filter as separate from the source material. However, if the filter is static we perceive it as all part of the sound that we're hearing.

We tend to hear the cutoff point as the pitch of the filter.

A narrow notch filter is mostly inaudible unless it goes down to 0, where a phase-shift is produced as anti-resonance. This is a technique used for standard flanging effects. With a wider notch filter, we tend to track the cutoff frequencies, and hear them as pitched, just as we would with high- or low-pass filters.

lecture12_image5.gif

Special Signals

lecture12_image6.gif

While an impulse is impossible to produce perfectly, in the digital domain, it is just one sample, and has equal energy at all frequencies. Fourier showed that an inverse relationship exists between the duration of a signal and its frequency content. A sine wave of infinite duration expresses a sole frequency, but as we shrink the duration, its spectrum becomes more complex. Thus, the shorter the signal, the wider the spectrum.

A filter can be characterized by its Impulse Response (IR), and by its frequency response (the latter can be measured with white noise). The frequency response is a frequency-domain representation, while the IR is a time-domain representation.

In general, a narrow frequency response corresponds to a long IR, which is called "lag time", or "time-smearing". This effect of narrow filters becomes problematic with spectrum analysis.

lecture12_image7.gif

Graphic Symbols

These are the graphic symbols used when drawing diagrams of digital filter circuits. Most are pretty self explanatory, but a unit delay holds a sample for one sample period, and then releases it during the next sample period, and an m delay holds a sample for m sample periods (It's not mentioned anywhere, but this is probably FIFO).

lecture12_image8.gif


Digital Filters

FIR (Finite Impulse Response) filters, also called Non-Recursive, and Feedforward filters delay a copy of the input signal, and combine it with the original input signal. This type of filter tends to create notches in the spectrum.

IIR (Infinite Impulse Response) filters, also called Recursive, and Feedback filters, delay a copy of the output, and combine it with the input signal. This type of filter creates peaks in the spectrum.

The filter types displayed below are called first-order filters because the contain only one delay operation.

lecture12_image9.gif

lecture12_image10.gif



Complex Numbers

Complex Plane:

lecture13_image1.gif

Polar Form:

lecture13_image2.gif

lecture13_image3.gif

Addition:

(a + bi) + (c + di) = (a + c) + (b + d) i

Multiplication:

(a + bi) * (c + di) = ac + adi + bci + bdi² = (ac - bd) + (ad + bc)i

Meaning of i?

i = j = √1

i represents a 90° rotational (phase) shift

i * i = i² = -1 represents a 180° rotational shift.

Digital Spectral Information as a Function of Complex Numbers

lecture13_image4.gif

Geometric Interpretation of Magnitude Response

lecture13_image5.gif

Any time a Pole is around the frequency axis, there will be an increase in that frequency.

Any time a Zero is around the frequency axis, there will be a decrease in that frequency.

It's possible to describe and quantify the characteristics of a filter by its poles and zeros.

Simple Filter

Filters can be represented as linear difference equations, which describe the output of a filter in terms of sums, differences, and multiplications of current and past input samples.

In digital signal processing literature, the input signal is called x, and the output signal is called y, and the input and output samples are numbered in brackets.

Simple (FIR) Lowpass Filter:

y[n] = (0.5 * x[n]) + (0.5 * x[n-1])

A simple lowpass filter adds the current input sample with the previous input sample and divides by two.

lecture13_image6b.gif

Simple (FIR) Highpass Filter:

y[n] = (0.5 * x[n]) - (0.5 * x[n-1])

A simple highpass filter subtracts the previous input sample from the current input sample and divides by two.

lecture13_image6a.gif

To make either the simple highpass or simple lowpass filter more flexible, we can replace the 0.5 constant coefficients with variables a0 and a1 in the equation:

y[n] = (a0 * x[n]) - (a1 * x[n-1])

or

y[n] = (a0 * x[n]) + (a1 * x[n-1])

A general equation for FIR filters:

y[n] = (a0 * x[n]) ± (a1 * x[n-1]) ± ...(ai * x[n-i])

where ai is the last coefficient, and x[i] is the last stored sample. The coefficients can be positive for lowpass or negative for highpass applications.

A general filter of this type can be likened to a delay line--a recirculating memory unit that delays incoming signals by i samples. Since the memory of the delay line goes back a finite distance in time (i samples), this type of filter is called a finite impulse response (FIR) filter (or transversal filter).

The filter response can be controlled down to a frequency of approximately the sample rate divided by the number of stages of delay. At a sampling rate of 44.1 kHz, a 10-stage FIR lowpass filter rolls off frequencies down to 4400 Hz.

lecture13_image8.gif

Simple Infinite Impulse Response Filters:

Routing the filter's output back into its input blends more of the past history of the signal than a simple FIR filter, with fewer coefficients, and less computation. Because the length of the history is potentially infinite, a feedback or recursion filter is called an infinite impulse response filter.

One type of simple IIR filter is an exponential time average (ETA) filter, which adds the current input x[n] to its last output y[n-1], and divides by two:

y[n] = (0.5 * x[n]) + (0.5 * y[n-1])

Analysis of such a filter shows that it is equal to an infinitely long FIR filter. Variable coefficients can also be substituted in place of the constants:

y[n] = (a * x[n]) + (b * y[n-1])

As b increases, the filter cutoff frequency moves lower. The absolute value of b must always be less than 1.0, or the filter becomes unstable and produces distortion.

lecture13_image7a.gif

A simple recursive highpass filter subtracts the current input sample from the previous output sample, and divides by two:

y[n] = (a * x[n]) - (b * y[n-1])

lecture13_image7b.gif

An IIR filter is "infinite" because the response never reaches zero after removing the input signal (.9*.9*.9*.9*.9... never equals zero).

lecture13_image9.gif

Filters have a transient response period, so they take a little while to reach a steady state.

Second-Order Filters

Second-Order filters have more than one delay.

A first-order filter, for example, will reduce the signal amplitude by half (about –6 dB) every time the frequency doubles (goes up one octave). The magnitude Bode plot for a first-order filter looks like a horizontal line below the cutoff frequency, and a diagonal line above the cutoff frequency. There is also a "knee curve" at the boundary between the two, which smoothly transitions between the two straight line regions. See RC circuit.

A second-order filter does a better job of attenuating higher frequencies. The Bode plot for this type of filter resembles that of a first-order filter, except that it falls off more quickly. For example, a second-order Butterworth filter will reduce the signal amplitude to one fourth its original level every time the frequency doubles (–12 dB per octave). Other second-order filters may roll off at different rates initially depending on their Q factor, but approach the same final rate of –12 dB per octave. See RLC circuit.

Third- and higher-order filters are defined similarly. In general, the final rate of rolloff for an n-order filter is 6n dB per octave.


lecture13_image10.gif

Difference Equation: y(n) = a0 x(n) - b1 Y(n-1) - b2 y(n-2)

b1 = 2r cos θ b2 = -r²

θ is the angle associated with the frequency of the unit circle.

Some common pseudocode for second order filters is:

output = k * input - b1 * old1 - b2 * old2; old2 = old1; old1 = output;

The results of using second order filters are:

lecture13_image11.gif

With a 2-pole bandpass filter, r is defined as the distance of the pole from the origin, so r should always be between 0 and 1 to avoid infinite feedback. Also, the closer a pole is to the circle, the higher the Q.

Phase:

lecture14_image4.gif

If the 0s are on the circle, there will be a 180° phase shift. This instantaneous phase shift becomes audible, and is useful for flanging effects.

FIR versus IIF Filters

FIR filters are computationally more intensive than IIR filters, but have several benefits. First, it is easy to design an FIR filter with linear phase response which prevents phase distortion. Also, FIR filters have no feedback, and never go into oscillation. FIR filters can be more costly to produce because of the number of mathematical operations that need to take place. IIR filters suffer from phase distortion and ringing, where transients tend to excite the filter, and cause it to oscillate for some period of time, smearing the transient.

Personal tools
Ads: