# Discrete-Time Signals & Digital Filtering

This course is fundamentally concerned with the manipulation and/or synthesis of audio or other physical signals. Because we work with computers, these signals are uniformly sampled, or discretized, in time and/or space.

## Discrete-Time Signals:

• Signals typically represent physical variables such as displacement, velocity, pressure, energy, ...

• In most cases, we are concerned with variables that are time-dependent.

• The discrete-time or digital time index is generally specified by tn = n T, where n is an integer and T is the sampling interval or period.

• It is common to drop the explicit reference to T (or assume T = 1) and index discrete-time signals by the letter n.

• A discrete-time signal that is only dependent on time can be represented by x[n] for n = 0, 1, 2, ...

• We typically assume our systems are causal or do not depend on future inputs (they should have zero activity'' before a non-zero input is applied). This can also be stated as for n < 0.

## Digital Filtering:

Digital filters are fundamental to digital audio processing. While we only have time here for a cursory overview of the essential features of filters, students are encouraged to pursue more advanced courses and references in filter analysis and design.

• In general, we need to manipulate our signals. Even if we only seek to measure and analyze real world'' signals, we still typically need to process'' these signals in order to compensate for measurement system biases''.

• The processing of signals is called filtering. When applied to discrete-time signals, this processing is called digital filtering.

• Digital filters are defined by their impulse response, h[n], or the filter output given a unit sample impulse input signal. A discrete-time unit impulse signal is defined by:

• Digital filters are often best described in terms of their frequency response. That is, how is a sinusoidal signal of a given frequency affected by the filter.

• The frequency response of a filter consists of its magnitude and phase responses. The magnitude response indicates the ratio of a filtered sine wave's output amplitude to its input amplitude. The phase reponse describes the phase offset'' or time delay experienced by a sine wave passing through a filter.

## Finite Impulse Response (FIR) Filters:

• Finite Impulse Response (FIR) filters are defined by scaled and time-delayed versions of the filter input signal only, as given by the following difference equation:

where the input and output for n < 0.

• An FIR filter can be represented by a block diagram as shown in Fig. 1 below.

• The z-1 terms represent unit delays. Note that while this representation for a delay element is common and widely accepted in the signal processing community, the specification of delay in terms of powers of z is a z-domain characterization (to be described below) while the block diagram itself is a time-domain representation.

• With respect to the filter block diagram, FIR filters make use of feed-forward terms only.

• The impulse response of an FIR filter is only as long as the maximum delayed input term in its difference equation.

• The summation of feedforward input terms can result in destructive signal interference, or cancellations, at certain frequency values.

• The FIR filter is said to have an order equivalent to the number of unit delays in its difference equation.

## Infinite Impulse Response (IIR) Filters:

• Infinite Impulse Response (IIR) filters include delayed and scaled versions of the output signal that are fed back into the current output.

• IIR filters are described by the following difference equation:

where the input and output for n < 0.

• An IIR filter can be represented by a block diagram as shown in Fig. 2 below.

• With respect to the filter block diagram, IIR filters make use of both feed-forward and feedback terms.

• Given these feedback terms, IIR filters can become unstable based on the values of the feedback coefficients (ak terms).

• Because of this constructive feedback, an IIR filter can produce strong peaks, or resonances, in its frequency magnitude response.

• The feedback terms also result in a long filter impulse response. Though a stable filter's impulse response will decay toward zero over time, it technically never exactly reaches zero (ignoring issues of finite precision arithmetic).

• The order of an IIR filter is equivalent to the greater of the number of its delayed input or output terms.

## Steady State and Transient Response:

• Before a signal is applied to the input of a digital filter, the filter's internal state'' is assumed equal to zero.

• Digital filters are linear systems. One property of linear systems is that a sinusoidal input will produce a sinusoidal output of the same frequency.

• However, when a sinusoidal signal is first applied to the input of a digital filter, the output initially exhibits a region of transition (referred to as its transient response).

• For FIR filters, this transition region (or warm-up'' period) has a duration in samples equal to the filter order.

• For IIR filters, the length of the transition region is dependent on the filter order and the feedback coefficient values.

• Assuming a continued application of the sinusoidal input, the filter will subsequently settle into its steady-state region.

• If the input changes frequency or displays a discontinuity of any sort, another transient region will occur in the filter output.

• The frequency response of a digital filter is understood to represent its steady-state behavior.

## The Discrete Fourier Transform (DFT):

• Given a discrete-time signal x[n], we can determine its frequency response using the Discrete Fourier Transform (DFT):

• The complementary inverse DFT is given by:

• The DFT can be interpreted as the sum of projections of x[n] onto a set of N sampled complex sinusoids or sinusoidal basis functions at (normalized) radian frequencies given by with .

• In this way, the DFT and its inverse provide a recipe'' for reconstructing a given discrete-time signal in terms of sampled complex sinusoids.

• Various computational tools exist that allow for the transformation of a discrete-time signal into its frequency-domain representation.

• The frequency response of a digital filter can be found by taking the DFT of the filter impulse response.

## The z-Transform:

• The unilateral z-Transform of a discrete-time signal x[n] is given by:

where z is a complex variable.

• The z-transform maps a discrete-time signal to a function of the complex variable z.

• A convenient property of the z-transform is given by the Shift Theorem,

which says that a delay of samples in the time domain corresponds to a multiplication by in the z domain.

• From the shift theorem, we can easily calculate the z-transform of a digital filter's difference equation. Given the following second-order difference equation,

y[n] = b0 x[n] + b1 x[n-1] + b2 x[n-2] - a1 y[n-1] - a2 y[n-2],

the z-transform can immediately be written (assuming the system is linear)

Y(z) = b0 X(z) + b1 z-1 X(z) + b2 z-2 X(z) - a1 z-1 Y(z) - a2 z-2 Y(z).

• From this expression, we can determine the transfer function, H(z) = Y(z) / X(z), of the filter:

• It is convenient to evaluate the z-transform of a system in the complex z-plane, as shown below:

• The z-transform is a more general version of the Discrete-Time Fourier Transform, which itself can be viewed as the limiting form of the DFT when its length N is allowed to approach infinity.

• We can determine the frequency response of a system from its z-transform by setting , where is in radians per second and T is the sample period. In the complex z-plane, this is equivalent to evaluating the z-transform on the unit circle'' defined by .

## Filters in Matlab

• Filter coefficients in Matlab are specified in terms of the following general filter difference equation:

• In this way, a filter with difference equation y[n] = x[n] + x[n-1] would be specified with feedforward coefficients b = [1 1] and a feedback coefficient a = 1.

• Likewise, a filter with difference equation y[n] = x[n] + 0.9 y[n-1] would be specified with a feedforward coefficient b = 1 and feedback coefficients a = [1 -0.9].

• In Matlab, we can filter an input signal x with a filter specified by coefficients b and a as y = filter(b, a, x).

• In Matlab, we can plot a filter's frequency response using the freqz function: freqz(b, a).

## Transfer Function & Pole-Zero Analysis:

• The z-transform is extensively used to evaluate the properties of discrete-time systems such as digital filters. In particular, it is convenient for determining the stability of a system.

• The numerator and denominator of a system's transfer function are polynomials in z. The roots of these polynomials can be determined by factorization.

• Roots of the numerator polynomial indicate values of z at which the transfer function evaluates to zero. These are called zeros.

• Roots of the denominator polynomial indicate values of z at which the transfer function evaluates to infinity. These are called poles.

• The zeros and poles of a transfer function can be plotted in the z-plane. Their locations with respect to the unit circle indicate radian frequencies at which the system's magnitude response has local minima (near zeros) or maxima (near poles).

• In Matlab, the functions roots and zplane can be used to determine and plot the poles and zeros of a system.

• When the coefficients of a transfer function are all real, complex roots are given by complex-conjugate pairs.

• For a system to have a stable frequency response, all of its poles must lie within the unit circle in the z-plane.

## Filter Types and Descriptions

• Lowpass filters do not allow sinusoids above a certain cutoff frequency'' (fc) to pass through them.

• Highpass filters only allow sinusoids above a certain cutoff frequency'' to pass through them.

• The cutoff frequency of a filter is defined as the frequency at which the power transmitted is 1/2 the maximum power transmitted in the passband. This corresponds to a -3dB drop on a decibel scale. As the power of a signal is related to its amplitude squared, the cutoff frequency corresponds to an amplitude reduction of .

• Bandpass filters only allow sinusoids above and below a certain frequency region to pass through them.

• Bandstop filters are designed to pass all sinusoids except those within a certain frequency region.

• Resonance filters accentuate sinusoids within a certain frequency region. They may or may not pass sinusoidal frequencies outside that region.

• Resonance filters are typically described in terms of their center frequency and quality factor (Q), which is given by the center frequency divided by the -3dB bandwidth. A higher Q indicates a sharper'' resonance.

• Allpass filters do not affect the magnitude characteristics of a signal (their magnitude response is equal to 1 for all frequencies) but have frequency-dependent phase characteristics.

## Filter Combinations

• What happens when we cascade digital filters in series or parallel?

• The time-domain operation of a filter is referred to as convolution (and typically denoted with the symbol ). From the properties of linear systems, convolution in the time domain corresponds to multiplication in the frequency domain.

• Thus, the series combination of filter responses H1(z) and H2(z) in Fig. 4 above would produce a new response given in the frequency domain by H1 H2 or in the time domain by .

• The response of filters in parallel is given by simple addition (in both the time- and frequency-domains).

• In this way, the filter combination shown in Fig. 4 could be replaced by a single filter with frequency-domain response (H1 H2) + H3 or time-domain response .

## Resonance Filters

• A second-order IIR filter ( y[n] = x[n] - a1 y[n-1] - a2 y[n-2]) can be designed with a single peak in its frequency magnitude response using coefficients of the form:
 a1 = (1) a2 = r2, (2)

where fc is the center frequency of the resonance peak, Ts = 1 / fs is the sample period, and 0 < r < 1.0. The closer r is to 1.0, the narrower the bandwidth of the resonance peak.

• As a further refinement, we can design the resonance filter such that the resonance peak always has a gain of 1.0 by specifing numerator (or feedforward) coefficients as:

in a difference equation of the form y[n] = b0 x[n] + b1 x[n-1] + b2 x[n-2] - a1 y[n-1] - a2 y[n-2].

• An example digital resonance filter magnitude response is shown in Fig. 5. The coefficients were determined as indicated above with a 5000 Hz center frequency.