Upload
emmett
View
28
Download
0
Embed Size (px)
DESCRIPTION
EE599-020 Audio Signals and Systems. Digital Signal Processing (Synthesis) Kevin D. Donohue Electrical and Computer Engineering University of Kentucky. Filters. Filter are designed based on specifications given by: spectral magnitude emphasis - PowerPoint PPT Presentation
Citation preview
EE599-020Audio Signals and Systems
Digital Signal Processing (Synthesis)
Kevin D. DonohueElectrical and Computer Engineering
University of Kentucky
FiltersFilter are designed based on specifications given by:spectral magnitude emphasisdelay and phase properties through the group delay and
phase spectrumimplementation and computational structures
Matlab functions for filter design(IIR) besself, butter, cheby1, cheby2, ellip, prony, stmcb(FIR) fir1, fir2, kaiserord, firls, remez, remezord, fircls,
fircls1, cremez(Implementation) filter, filtfilt, dfilt(Analysis) freqz, FDAtool, SPtool
Filter SpecificationsExample:Low-pass filter frequency response
0 0.2 0.4 0.6 0.8 10
0.2
0.4
0.6
0.8
1
Normalize Frequency (fs/2 = 1)
Am
plit
ud
e S
cale
Passband
Transitionband
Stopband
Cutoff Frequency
Ripple
Filter SpecificationsExample Low-pass filter frequency response (in dB)
0 0.2 0.4 0.6 0.8 1-70
-60
-50
-40
-30
-20
-10
0
10
Normalized Frequency (fs/2 = 1)
Sca
le in
dB Passband
Transitionband
Stopband
Cutoff Frequency
Ripple
Filter SpecificationsExample Low-pass filter frequency response (in dB) with ripple in both bands
0 0.2 0.4 0.6 0.8 1-50
-40
-30
-20
-10
0
Normalize Hz
dB
Filter Magnitude Response
Passband Ripple
Stopband Ripple
Transition
Filter Spec Functions
The transfer function magnitude or magnitude response:
The transfer function phase or phase response:
The group delay:
)2exp()H()(H
fjzM zf
)2exp()H()(H
fjzP zf
df
fdf P
P
)(H)(G
Basic Filter DesignThe following commands generate filter coefficients for basic low-pass, high-pass, band-pass, band-stop filters:For linear phase FIR filters: fir1For non-linear phase IIR filter: besself, butter,
cheby1, cheby2, ellipExample: With function “fir1”, design an FIR high-pass
filter for signal sampled at 8 kHz with cutoff at 500 Hz. Use order 10 and order 50 and compare phase and magnitude spectra with “freqz” command. Use “grpdelay” to examine delay properties of the filter. Also use command “filter” to filter a frequency swept signal from 20 to 2000 Hz over 4 seconds with unit amplitude.
Basic Filter DesignExample: With function “cheby2” design an IIR Chebyshev
Type II high-pass filter for signal sampled at 8 kHz with cutoff at 500 Hz. And stop band ripple of 30 dB down. Use order 5 and order 10 and compare phase and magnitude spectra with freqz command. Use grpdelay to examine delay characteristics. Also use command filter to filter a frequency swept signal from 20 to 2000 Hz over 2 seconds with unit amplitude.
Example: With function “butter” design an IIR Butterworth band-pass filter for signal sampled at 20 MHz with with a sharp passband from 3.5 MHz to 9MHz. Use order 5 and verify design of phase and magnitude spectra with freqz command. Also use command filter and filtfilt to filter a an ultrasonic signal received from a medical imaging probe.
Filtfilt = Zero Phase Filtering
)(ˆ)( kXnxDFT)(ˆ)( kHnh
DFT
)(ˆ)(ˆ)( kHkXnwDFT )(ˆ)(ˆ)( ** kXkHnNw
DFT
)(ˆ)(ˆ)(ˆ)( * kXkHkHnyDFT )(ˆ)(ˆ)(ˆ)( ** kXkHkHnNy
DFT
Consider and N point signal x(n) and filter impulse response h(n)
Convolve sequences to obtain w(n) and reverse the order of w(n)
Convolve w(N-n) with h(n) and reverse results to obtain y(n)
Note the effective filter of x(n) is H*(k)H(k), which has zero phase and the magnitude of H(k) magnitude squared.
Homework (1)a) Create a tone at 350 Hz with sampling rate 8000,
amplitude .8, and duration 4 seconds. Add white noise (use the “randn” function) with a signal to noise ratio of 10 dB. Use the “fir1” command to design a 20 and 100th order band-pass filter from 300 Hz to 400 Hz. Plot the magnitude response of the filters. Plot the mean spectra of the signal (use the “psd” function). Use “filter” to filter the signal and Listen to the sound before and after filtering. Describe and explain the differences you hear between the 3 signals.
b) Repeat part (a) comparing a 5th order elliptical filter with passband ripple of .5 dB and stopband ripple of 30 dB and a 5th order Butterworth filter.
Filter Design with Spectral Magnitude Criteria
The follow commands generate filter coefficients for an arbitrary filter shape or impulse response. For linear phase FIR filters: fir2, firls
The frequency points are specified with a vector of points of the normalized frequency axis and a corresponding vector indicating the amplitude at each of those points.
For non-linear phase IIR filter: prony, stmcbThe filter is specified in terms an impulse response
and the IIR filter model (with numerator and denominator order specified) is fitted to the response to minimize error.
Basic Filter DesignExample: Record a voice repeating vowel sounds for about
10 seconds at fs = 11025 Hz, and compute its average spectrum. From the picture of the average spectrum magnitude, determine a spectral shape vector for use with function “fir2” to create a filter that matches the voice spectrum. Add white noise to another voice signal from the same person to achieve a 6dB SNR and use filter to see how well the noise can be reduced with the filter you designed.
Example: Generate an approximate impulse response of a room and record it with fs=11025 Hz. Use the “prony” function to attempt to model the room distortion as an IIR filter (you have to guess some the orders and test to see if it works).
Homework(2)Record room noise for about 10 seconds at fs = 11025 Hz, and compute its average spectrum (use the ‘psd’ function). From the picture of the average spectrum magnitude, determine a spectral shape vector for use with function “fir2” to create a filter that matches the noise spectrum. Filter a white noise sequence with the FIR filter you designed and compare the sound of white noise before and after filtering with the room noise filter. Briefly describe your observation.
Useful Filter FunctionsThe sinc function and the rectangular pulse form a Fourier transform pair.
Sketch these functions and label the null points of the sinc function. What would a shift of the rect function in frequency do to the sinc function in the time domain?
elsewhere for 0 22
B-for 1
f
BfBf );rect(
tBtB
BBtBsin
;sinc
Useful Filter FunctionsThe sinc function and the rectangular pulse form a Fourier transform pair.
Sketch these function and label the null points of the sinc function. What would a shift of the rect function in time do to the sinc function in the frequency domain?
elsewhere for 0 22
T-for 1
t
TtTt ),rect(
fTfT
TTfTsin
),sinc(
Ideal Low-Pass FilterThe rect function in the frequency domain represents the ideal low-pass filter.
If the ideal low-pass filter were implemented in the time domain, what would the convolution kernel look like? Comment on the causality of this filter.
elsewhere for 0 22
B-for 1
f
BfBf ),rect(
Ideal Interpolation FunctionIf the rect function in the frequency domain has B/2 equal to the Nyquist frequency. Then the time domain sinc null fall on sampling increments and the following convolution becomes the reconstruction or interpolation filter to restore a sampled band-limited signal from its samples:
where T = 1/B.
nn
BnTtnTxnTt
T
nTtT
nTxty )(sinc)()(
)(sin
)()(
Homework(3)Use the interpolation function on the previous page to upsample by a factor of 10 the band-limited function given in terms of its samples below, with band limit .5 Hz. The sampling rate (B) was 1 Hz.
F = [1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0]
Note: a) Matlab has a sinc function (see help sinc), b) your upsampled function should have 150 samples in it, and c) a step edge is not bandlimited so the interpolated bandlimited function will have overshoot and undershoot between the given samples (i.e. it will not look like a sharper step).