Sie sind auf Seite 1von 48

CMPT 889: Lecture 5 Filters

Tamara Smyth, tamaras@cs.sfu.ca School of Computing Science, Simon Fraser University October 7, 2009

Digital Filters

Any medium through which a signal passes may be regarded as a lter. Typically however, a lter is viewed as something which modies the signal in some way. Examples include: stereo speakers our vocal tract our musical instruments A digital lter is a formula for going from one digital signal to another.

x(n)

1111111111 0000000000 1111111111 0000000000 0000000000 1111111111 1111111111 0000000000 0000000000 1111111111 0000000000 1111111111 0000000000 111111111111111 00000 11111 00000 0000000000 1111111111 1111111111 0000000000 0000000000 1111111111 0000000000 1111111111 0000000000 1111111111 0000000000 1111111111 0000000000 1111111111
Figure 1: A black box lter.

y(n)

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

Linearity and Time Invariance

A lter is linear if it satises the following two properties: 1. Scaling: the amplitude of the output is proportional to the amplitude of the input (i.e., scaling can be done either at the input or the output) L{gx()} = g L{x()}

2. Superposition: the output due to a sum of input signals is equal to the sum of outputs due to each signal alone. L{x1() + x2()} = L{x1()} + L{x2()}

A lter is time-invariant if its behaviour is not dependent on time: if the input signal is delayed by N samples, the output waveform is simply delayed by N samples: L{x( N )} = LnN {x()} = y (n N )

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

Linear Time-Invariant (LTI) Filters:

Liner Time-Invariant (LTI) lters modify the amplitude and/or phase of the spectral components of an input signal. LTI lters are guaranteed to produce a sinusoid in response to a sinusoid, without altering the frequency. They may only attenuate, reject, amplify (boost) or leave unchanged, any existing frequency components of the input signal.

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

Filter Frequency Response

The characteristic of a lter is described by its frequency response which consists of both a magnitude and a phase response: 1. magnitude response Describes the gain of a lter at every frequency: a positive gain boosts the signal while a negative gain attenuates the signal. Determined by the ratio of the peak output amplitude to the peak input amplitude at a given frequency. 2. phase response: Determined by subtracting the input phase from the output phase at a particular frequency. A frequency response describes how the amplitude and phase of a sounds spectral components are changed by the lter.

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

Dierent Filter Types


The region where frequencies are permitted to pass is called the pass band and the region where frequencies are attenuated is called the stop band. There are four (4) basic types of lters: 1. Low-pass: permits frequencies below a cuto frequency fc to pass with little change while attenuating or rejecting frequencies above fc. 2. High-pass: permits frequencies above fc to pass while attenuating those frequencies which fall below. 3. Band-pass: passes frequencies within a certain frequency band. 4. Band-reject: attenuates or rejects frequencies within a certain frequency band (also called a notch lter).

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

Magnitude Response of Basic Filters


No digital lter is ideal and therefore they will always a have smooth (rather than a clearly dened or discontinuous ) transition between the pass and stop bands at the cuto frequency fc.
LowPass
magnitude (dB) magnitude (dB) 0 3 0 3

HighPass

fc

frequency

fc

frequency

Bandpass
magnitude (dB) magnitude (dB) 0 3 0 3

Bandreject (notch)

fc BW

frequency

fc frequency BW

Figure 2: Amplitude response of dierent lter types.

The cuto frequency is typically dened as the frequency at which the power transmitted by the lter drops to one-half (by -3 dB) of the maximum power transmitted in the passband.
CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5 7

Quality Factor
A pass-band lter is characterized by its quality factor Q which is inversely proportional to its bandwidth fc Q= BW where fc is the center frequency of the band. A high quality factor (a high Q) denotes a lter with a narrow bandwidth and a low Q denotes a lter with a wide bandwidth.

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

Delay Review

Recall that whenever a signal can be expressed in the form x(t) = s(t t1), we say that x(t) is a time-shifted version of s(t).

If t1 is a positive number, then the shift is to the right and we say that the signal has been delayed in time. If t1 is a negative number, x(t) eectively becomes x(t) = s(t + t1), the shift is to the left and the signal has been advanced in time.

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

The Ideal Low-Pass Filter

Recall that a lowpass lter is one that allows low frequencies to pass, while attenuating anything above a specied cuto frequency fc. The amplitude response of the ideal low-pass lter is given in the gure below:
1 Gain 0 0 Frequency fc fs/2
Figure 3: Amplitude Response for an ideal low-pass lter.

Unfortunately such an ideal amplitude response is not realizable in discrete time. How close we come depends on the complexity of the lter.

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

10

A Simple Low-Pass Filter

The simplest low-pass lter (and therefore furthest from ideal) is given by the dierence equation y (n) = x(n) + x(n 1). The corresponding system diagram is given below:
x(n) z 1 y(n)

Figure 4: System diagram for the simple low-pass lter y (n) = x(n) + x(n 1).

This lter is really just a running averager (2-point averager) with a factor of two. That is, it takes the average of two adjacent samples. Why is it a Low-Pass Filter?

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

11

Intuitive Analyis at Low Frequencies

The running average of an input signal with little or no variation from sample to sample is very close to the input signal. Consider an input to this lter at the lowest possible frequency 0 Hz (DC), where the signal has a single value over time: x1(n) = [A, A, A, ...]. The output of the lowpass lter is y (n) = x1(n) + x1(n 1) = 2A.

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

12

Intuitive Analyis at High Frequencies

The running average of an input signal with signicant variation from sample to sample will be very dierent than the input signal. Consider a second input x2(n) at the highest possible frequency fs/2 (the Nyquist limit), which swings more signicantly from sample to sample: x2(n) = [A, A, A, ...]. The output of the lowpass lter is y (n) = x2(n) + x2(n 1) = A A = 0.

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

13

What about all the frequencies in between?

This lter seems to boost low frequencies while rejecting components at higher frequencies. We may nd the frequency response of the lter by checking the behaviour of the lter at every possible frequency between 0 and fs/2 Hz, a method called sinewave analysis. Alternatively, we can use an input signal that contains all of those frequencies, and then we only have to do the checking operation once. If we use an input signal with the broadest possible spectrum, i.e. an impulse, we will obtain an output from the lter, called an impulse response, which is a time domain description of the lters response to all frequencies from DC to the Nyquist limit. The spectrum of the impulse response gives us the the frequency response of the lter.

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

14

Matlab (C-style) Low-pass Filter Implementation


N = 1024; % signal length x = [1 zeros(1, N-1)]; % impulse y = [1 zeros(1, N-1)]; % output buffer for n=2:N y(n) = x(n)+x(n-1); % impulse response end Y = fft(y); Y = abs(Y(1:N/2)); fn = [0:N/2-1]/N; % frequency response % amplitude response (positive frequencies) % frequency axis

subplot(211); plot(fn, Y); grid; title(Amplitude Response y(n) = x(n) + x(n-1)); xlabel(Frequency (normalized)); ylabel(Magnitude (linear));
Amplitude Response y(n) = x(n) + x(n1) 2

Magnitude (linear)

1.5

0.5

0.05

0.1

0.15

0.2 0.25 0.3 Frequency (normalized)

0.35

0.4

0.45

0.5

Figure 5: Magnitude response for the lter y(n) = x(n) + x(n-1).

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

15

Filter Frequency Response


Lets test the simple lowpass lters response at frequency f by setting its input to the complex sinusoid x(n) = Aej (2f nT +) Because of: 1. Time-invariance: the frequency response will not depend on , so we may set it to 0; 2. Linearity: we may set A to 1.

The output of the lter in response to x(n) = ej (2f nT ) is given by y (n ) = = = = = x(n) + x(n 1) ejnT + ej(n1)T ejnT + ejnT ejT (1 + ejT )ejnT (1 + ejT )x(n) H (ejT )x(n)

where H (ejT ) = (1 + ejT ), a complex multiply, is the frequency response of the lter.
CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5 16

Frequency Response
The lters frequency response is acting as a complex multiply, which means a gain scaling and phase shift on the input signal. The complex lter gain in polar form is given by H (ejT ) = G( )ej () and ( ) where the amplitude and phase response are given by G ( ) |H (ejT )| H (ejT ).

To solve, we may balance the exponents to obtain H (ejT ) = (1 + ejT ) = (ejT /2 + ejT /2)ejT /2 = 2 cos(T /2)ejT /2, G( ) = 2 cos(T /2)ejT /2 = 2 cos(f T ), and the phase response is given by f T = , |f | fs/2. ( ) = 2 fs
CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5 17

where the amplitude response is then given by |f | fs/2,

Other simple non-recursive lters


Test the following lter at DC and fs/2: y (n) = x(n) x(n 1). What type of lter is this? Verify that the following lter passes both DC and the Nyquist limit (1/2 the sampling rate): y (n) = x(n) + x(n 2). What about at a frequency in between, f = f s/4? x(n) = [A, 0, A, 0, A, 0, A, . . .], At this frequency the lter produces no output. We may therefore assume this is a band-reject, or notch lter, with a notch at fs/4. Verify that the following lter rejects both DC and the Nyquist limit, yes boosts a frequency at fs/4. y (n) = x(n) x(n 2). What kind of lter is it?

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

18

Plots of simple lters

Amplitude Response for y(n) = x(n)+x(n1) 2 Magnitude (linear) 1.5 1 0.5 0 Magnitude (linear) 0 0.1 0.2 0.3 0.4 Frequency (normalized)

Amplitude Response for y(n) = x(n)x(n1) 2 1.5 1 0.5 0

0.1 0.2 0.3 0.4 Frequency (normalized)

Amplitude Response for y(n) = x(n)+x(n2) 2 Magnitude (linear) 1.5 1 0.5 0 Magnitude (linear) 0 0.1 0.2 0.3 0.4 Frequency (normalized)

Amplitude Response for y(n) = x(n)x(n2) 2 1.5 1 0.5 0

0.1 0.2 0.3 0.4 Frequency (normalized)

Figure 6: Amplitude Responses for simple lters

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

19

Generalized FIR
Several dierent nonrecursive lters can be made by changing the delay (and thus order) and the coecients of the lter terms. The general equation for an FIR (Finite Impulse Response) lter is given by
M

y (n ) =
k =0

b k x (n k )

where M is the order of the lter. A lter can be dened simply by a set of coecients. For example if bk = [1, 3, 3, 1] the lter is third order, (i.e. M = 3), and can be expanded into the dierence equation y (n) = x(n) + 3x(n 1) + 3x(n 2) + x(n 3); When the input to the FIR lter is a unit impulse sequence, (n) = 1 if n = 1 and (n) = 0 otherwise, the output is the unit impulse response.

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

20

Matlabs filter function

The Matlab implementation for the lter is most easily accomplished using the filter function y = filter(B, A, x). The filter function takes three (3) arguments: 1. feedforward coecients B, 2. feedback coecients A, 3. and the input signal x.

If the lter doesnt have feedback coecients, as is the case with an FIR lter, A = 1. Our simple low-pass lter, y (n) = x(n) + x(n 1), is a rst order lter with 2 feedforward coecients (B = [1, 1]). In matlab: B = [1 1]; A = 1; y = filter(B, A, x);
CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5 21

Increasing the Filter Order


Lets return now to the simple low-pass lter y (n) = x(n) + x(n 1) which is just a two point running average (with a factor of 2). If we increase the number of samples averaged, i.e. increase the lter order, the waveform will be smoothed (with a more gentle slope to zero), which corresponds to a lowered cuto frequency
Producing new filters with a cascade of simple low pass filters 2 1.8 1.6 1.4 Magnitude (linear) 1.2 1 0.8 0.6 0.4 0.2 0 first order second order (scaled by 1/2) third order (scaled by 1/4) fourth order (scaled by 1/8)

y (n) = x(n) + x(n 1) + x(n 2),

0.05

0.1

0.15

0.2 0.25 0.3 Frequency (normalized)

0.35

0.4

0.45

0.5

Figure 7: A Cascade of Simple Lowpass lters.

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

22

Coecients as Impulse Response


If we look at the response of the lter to an impulse >> x(1:10) ans = 1 0 0 0 0 0 0 0 0 0 >> y(1:10) ans = 1 1 0 0 0 0 0 0 0 0 we see the impulse response y is equivalent to coecients of our FIR lter. This can be expressed using the general FIR equation, with an input of x(n) = (n):
M

h(n) =
k =0

b k (n k ) = b n ;

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

23

Cascade Connection
An order can be increased by using a lter cascade.

Each time the previous output y is input to the lter, a new impulse response representing is created.
x(n) = {1, 0, 0, ...} y(n) = x(n)+x(n1) y(n) = {1,1,0,0...}

y(n) = x(n)+x(n1) y(n) = {1, 2, 1, 0, 0, ...}

y(n) = x(n)+x(n1) y(n) = {1, 3, 3, 1, 0, 0, ...}

y(n) = x(n)+x(n1) y(n) = {1, 4, 6, 4, 1, 0, 0, ...}

y(n) = x(n)+x(n1) y(n) = {1, 5, 10, 10, 5, 1, 0, 0, ...}

Figure 8: A cascade of simple low-pass lters.

The new output always has a nite number of non-zero components and a nite impulse response. For each lter in the cascade, the impulse response increases by one.
CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5 24

Matlab LPF Cascade Implementation

x = [1 zeros(1, N-1)];

Cascade...
B = [1 1]; A = [1]; y1 = filter(B, y2 = filter(B, y3 = filter(B, y4 = filter(B, A, A, A, A, x); y1); y2); y3);

Or Simply...
B = [1 5 10 10 5 1]; A = [1]; y = filter(B, A, x);

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

25

Recursive Filters

Using FIR lters often required signicant computation and coecients to reproduce a desired frequency response. It is often possible to reduce the number of feedforward coecients needed to obtain a frequency response by introducing feedback coecients. A simple example of a rst order recursive low-pass lter is given by y (n) = b0x(n) + a1y (n 1) The general dierence equation for LTI lter therefore, is given by y (n) = b0x(n) + b1x(n 1) + + bM x(n m) a1y (n 1) aN y (n N )

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

26

FIR vs IIR Simple Low-Pass Filters


Amplitude Response y(n) = x(n) + x(n1) 10 0 Magnitude (linear) 10 20 30 40 50 0 0.05 0.1 0.15 0.2 0.25 0.3 Frequency (normalized) 0.35 0.4 0.45 0.5

Amplitude Response y(n) = x(n) + y(n1) 50 40 Magnitude (linear) 30 20 10 0 10 0 0.05 0.1 0.15 0.2 0.25 0.3 Frequency (normalized) 0.35 0.4 0.45 0.5

Figure 9: Simple Non-recursive low-pass y (n) = x(n)+ x(n 1) (top) and Recursive low-pass y (n) = x(n) + y (n 1) (bottom).

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

27

Z Transforms
The bilateral z transform of the discrete-time signal x(n) is given by X (z )
n=

x(n)z n.

Since most signals well be using are causal, we will typically see the unilateral z transform given by X (z )
n=0

x(n)z n.

The z transform is a generalization of the DTFT (the DFT in the limit as the number of its samples approaches innity). The carrier term is a generalized sampled complex sinusoid z n = e(+j)t with an exponential envelope rather than a constant modulus. The DTFT equals the z transform evaluated on the unit circle in the z plane. The z transform of a signal x is given by Z{x()} = X (z ) also notated Z{x(n)} = X (z ).
28

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

Z Transform Properties

Two (2) important properties of z transforms: 1. The z transform Z{} is a linear operator which means, by denition Z{x1(n) + x2(n)} = Z{x1(n)} + Z{x2(n)} X1(z ) + X2(z ). 2. From the shift theorem for z transforms, the z transform of a signal delayed by M samples is given by Z{x(n M )} = z M X (z ). Shift Theorem: A delay of M samples in the time domain corresponds to a multiplication by z M in the frequency domain.

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

29

Z Transform of the Dierence Equation


Recall, the general dierence equation for LTI lters is given by y (n) = b0x(n) + b1x(n 1) + + bM x(n m) a1y (n 1) aN y (n N ). Taking the z transform of both sides yields Z{y ()} = Z{b0x(n) + b1x(n 1) + + bM x(n m) a1y (n 1) aN y (n N )}

Apply the linearity property to obtain

Z{y ()} = b0Z{x(n)} + b1Z{x(n 1)} + + bM Z{x(n M )} a1Z{y (n 1)} aN Z{x(n N )}

Apply the shift theorem to obtain Y (z ) = b0X (z ) + b1z 1X (z ) + + bM z M X (z ) a1z 1Y (z ) aN z N Y (z )

Grouping the Y (z ) terms together on the left hand side and factoring out common terms X (z ) and Y (z ) yields
Y (z )[1 + a1z 1 + + aN z N ] = X (z )[b0 + b1z 1 + + bM z M ]

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

30

Transfer Function
Beginning with the equation from the previous slide:
Y (z )[1 + a1z 1 + + aN z N ] = X (z )[b0 + b1z 1 + + bM z M ]

We may dene the following polynomials: A(z ) B (z ) 1 + a1z 1 + + zN z N b0 + b1z 1 + + bM z M A(z )Y (z ) = B (z )X (z ) In solving for Y (z )/X (z ) we obtain the transfer function H (z ) of a digital LTI lter H (z ) = Y (z ) , X (z )

The z transform of the dierence equation becomes

where X (z ) and Y (z ) are the z transforms of the input and output signal, respectively, and H (z ) is the z transform of the impulse response describing the lter.

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

31

More on the Transfer Function


A transfer function provides an algebraic representation of a LTI lter in the frequency domain. Recall, that we can determine the frequency response by observing the eects of the lter at dierence frequencies, a technique called sine-wave analysis. The gain or amplitude response of the lter at a given frequency is determined by the ratio of the the peak output amplitude to the peak input amplitude at this frequency. The phase response of the of the lter at a given frequency is determined by the dierence between the output and input phases at a given frequency. The transfer function of an LTI lter is given by Y (z ) H (z ) = X (z ) where Y (z ) is the z transform of the output signal y (n) and X (z ) is the z transform of the input signal x (n ). The transfer function is equal to the z transform of the impulse response.
CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5 32

Pole Zero Analysis

Recall the transfer function for the recursive LTI digital lter 1 + 1z 1 + + M z M H (z ) = g 1 + a1z 1 + + zN z N We can factor the numerator and denominator to obtain (1 q1z 1)(1 q2z 1) (1 qM z 1) H (z ) = g (1 p1z 1)(1 p2z 1) (1 pN z 1) Every polynomial can be characterized by its roots plus a scale factor. We may therefore characterize a transfer function, by its 1. Numerator roots, called the zeros of the lter 2. Denominator roots, called poles of the lter 3. Constant gain factor
CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5 33

Poles and Zeros cont.

The factored transfer function is given by (1 q1z 1)(1 q2z 1) (1 qM z 1) H (z ) = g (1 p1z 1)(1 p2z 1) (1 pN z 1) Zeros The roots of the numerator polynomial are given by {q1, q2, . . . , qM }. When z takes on any of these values, the transfer function evaluates to zero and thus they are called the zeros of the lter. Poles The roots of the denominator polynomial are given by {p1, p2, . . . , pM } When z approaches any of these values, the transfer function becomes larger and larger, approaching innity. Thus these are called the poles of the lter.
CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5 34

Imagining Poles and Zeros

Recall, the magnitude H (z ) is a function of z :

Since z is complex, it lies in the z plane. Since the magnitude H (z ) is real, it can be represented a distance above the z plane. The plot appears as an innitely thin surface spanning in all directions over the z plane. The zeros are the points where the surface dips down to touch the z plane. The poles look just like poles that rise forever from the z plane, getting thinner the higher they go.

Notice M + 1 feedforward coecients gives rise to M zeros while N feedback coecients gives rise to N poles. The lter order is given by the maximum of the numerator and denominator polynomial orders.

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

35

Relating Amplitude Response to Poles and Zeros

The frequency response of the transfer function (factored form) is given by H (e


jt

(1 q1ejT )(1 q2ejT ) (1 qM ejT ) )=g (1 p1ejT )(1 p2ejT ) (1 pN ejT ) |H (ejT )|

Consider the amplitude response G( )

|1 q1ejT | |1 q2ejT | |1 qM ejT | G ( ) = | g | |1 p1ejT | |1 p2ejT | |1 pN ejT | |ejMT | |ejT q1| |ejT qM | = |g | jN T |e | |ejT p1| |ejT pM | |ejT q1| |ejT q2| |ejT qM | = |g | jT . jT jT |e p 1 | |e p2| |e pM | The amplitude response is the product of the dierence between two complex numbers.

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

36

Dierence of Two Complex Numbers

In the complex plane, the number z = x + jy is plotted at the coordinates (x, y ). The dierence of two vectors u = x1 + jy1 and v = x2 + jy2 is given by u v = (x1 x2) + j (y1 y2).
imaginary

uv u real

Figure 10: Treatment of complex numbers as vectors in a plane.

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

37

Poles and Zeros and the Unit Circle


Recall the amplitude response |ejT q1| |ejT q2| |ejT qM | G( ) = |g | jT . jT jT |e p 1 | |e p2| |e pM |
imaginary

p1 d2 q2

d3

1 0 0 1

d1 q1 d4 real

p2

Figure 11: Measurement of amplitude response from a pole-zero diagram (a bi-quad section).

Thus the term ejT qi may be drawn as an arrow from the ith zero to the point ejT on the unit circle, and ejT pi is an arrow from the ith pole. The amplitude response at frequency is given by d1 d2 G ( ) = d3 d4
CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5 38

The Biquad Section

The term biquad is short for bi-quadratic, and is a common name for a two-pole, two-zero digital lter. The transfer function of the biquad can be dened as 1 + 1z 1 + 2z 2 H (z ) = g 1 + a1z 1 + a2z 2 When the coecients a1 and a2 are real (as we typically assume), the poles must be either 1. real (when (a1/2)2 a2) 2. form a complex conjugate pair (when (a1/2)2 < a2). When the poles form a complex pair, we may express them in polar form as p1 = Rejc p2 = Rejc R is the pole radius, or distance from the origin in the z -plane.

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

39

Stability
A lter is said to be stable if its impulse response h(n) decays to 0 as n goes to innity. Recall, the transfer function is the z transform of the impulse response. H (z ) Z{h(n)}

Consider a causal impulse response of the form h(n) = Rn ejnT , n = 0, 1, 2, . . . which is a damped complex sinusoid when 0 < R < 1 and is exponentially increasing when R > 1.

The signal h(n) has the z transform H (z ) = = Rn ejnT z n RejT z 1


n n=0 n=0

1 = 1 RejT z 1 where the last step is a closed form representation of a geometric series and holds for |RejT z 1| < 1, which is true whenever R < |z |.
CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5 40

Stability cont.
The transfer function H (z ) =

has a single pole at RejT .

1 1 RejT z 1

If R > 1 the pole of H (z ) moves outside the unit circle, and the impulse response h(n) has an exponentially increasing amplitude (|h(n)| = Rn ). That is, it is unstable. A pole lying on the unit circle is considered marginally stable, that is, it neither decays nor grows in amplitude. In physically modelling synthesis, marginally stable poles often occur in lossless systems such as ideal vibrating strings. Therefore, to verify stability, we may nd the roots of the denominator polynomial and ensure their roots are less than 1. For the stability of any nite order LTI lter, all its poles must lie strictly inside the unit circle.
CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5 41

Bi-quadratic Resonant Filter


The dierence for a 2nd-order parametric bandpass lter is given by y (n) = x(n) Rx(n 2) + 2R cos(2fcT )y (n 1) R2y (n 2) where fc is the resonant (or center) frequency, and R, is set according to the desired bandwidth of the resonator using the following approximate relation R = eBw T , where Bw is the bandwidth at -3dB in Hz given by fc Bw = , Q and T is the sampling period. This function is often called bi-quadratic or simply a biquad because both the numerator and denominator of its transfer function are quadratic polynomials. If a resonator requires more than one mode, multiple bi-quad lters can be placed in parallel (one for each mode), with the overall output being the sum of the lter outputs.
CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5 42

Matlab Implementation of the Biquad

The two control parameters for this lter are 1. the center frequency fc 2. the quality factor Q (or alternatively, the bandwidth).

T = 1/44100; Q = 20; fc = 400; Bw = fc/Q; R = exp(-pi*Bw*T); B = [1 0 -R]; A = [1 -2*R*cos(2*pi*fc*T) R*R]; [h, w] = freqz(B,A); N = length(h); plot([0:N-1]/T/N/1000, ... max(20*log10(abs(h)/max(abs(h))), -40)); grid;

These parameters determine the characteristic of the resonator, and can be changed in real-time, making this an ecient and ideal implementation for performance situations.
CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5 43

FIR/Convolution

Since the feedforward coecients of the FIR lter are the same as the non-zero elements of the impulse response, a general expression for the FIR lters output can also be given by y (n ) =
N 1 k =0

h(k )x(n k ),

where h() is the impulse responses and replaces the coecients bk . When the relation between the input and the output of the FIR lter is expressed in terms of the input and impulse response, we say the the output is obtained by convolving the sequences x(n) and h(n). Note that this is circular or cyclic convolution. To simulate acyclic convolution (as we do when simulating sampled continuous-time systems), we need to zero-pad suciently (N + M 1) so that non-zero samples do not wrap around as a resulting of shifting x.
CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5 44

Visulalizing the convolution sum

The convolution sum is given by y (n ) =


N 1 k =0

h(k )x(n k ).

n x(n) h(n) h(0)x(n-0) h(1)x(n-1) h(2)x(n-2) h(3)x(n-3) y(n)

0 1 1 1

3 0 1 0 0 3 1 1 4 6 4

1 1 3 1 3

2 0 3 0 3 3

4 0 0 0 0 0 1 1

5 0 0 0 0 0 0 0

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

45

Convolution

The operation of convolution performed on two signals in the time domain is equivalent to the multiplication of their spectrum in the frequency domain. That is, the convolution of two time domain signals x(n) and w (n), with Fourier transforms X ( ) and W ( ) respectively, is given by Y ( ) = X ( )W ( ) where y (n), the result of the convolution, is obtained through the inverse Fourier Transform of Y ( ).

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

46

First-Order Shelf Filter


The rst-order shelf lter is specied by a transition frequency ft and a band-edge gain g 0 (at the Nyquist limit). The lter has unity gain at DC, and a gain of g at the transition frequency. The transfer function of the rst-order shelf lter is given by b0 + b1z 1 , H (z ; ft, g ) = 1 + a1z 1 with coecients given by 0 + 1 1 + 0 + 1 b0 = , b1 = , a1 = , 1 + 1 1 + 1 1 + 1 where and and 0 = (1 + g )/2 + (1 g )1/2, 1 = (1 g )/2 + (1 g + )1/2, 1 = 0, g = 1
2
1 2

sign( )( 1) ,

g = 1.
47

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

To form the coecients of a prototype shelf lter with a transition frequency of /2, is set to the following: = (g + 1)/(g 1), The parameter = sin(ft/2 /4)/ sin(ft/2 + /4) is the coecient of the rst-order allpass transformation warping the prototype lter to the proper transition frequency. g = 1.

CMPT 889: Computational Modelling for Sound Synthesis: Lecture 5

48

Das könnte Ihnen auch gefallen