EE599-020Audio Signals and Systems Digital Signal Processing (Synthesis) Kevin D. DonohueElectrical and Computer EngineeringUniversity of Kentucky
Filters Filter are designed based on specifications given by: • spectral magnitude emphasis • delay and phase properties through the group delay and phase spectrum • implementation 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 Specifications Example:Low-pass filter frequency response
Filter Specifications Example Low-pass filter frequency response (in dB)
Filter Specifications Example Low-pass filter frequency response (in dB) with ripple in both bands
Filter Spec Functions The transfer function magnitude or magnitude response: The transfer function phase or phase response: The group delay:
Basic Filter Design The following commands generate filter coefficients for basic low-pass, high-pass, band-pass, band-stop filters: • For linear phase FIR filters: fir1 • For non-linear phase IIR filter: besself, butter, cheby1, cheby2, ellip Example: 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 Design Example: 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 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, stmcb • The 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 Design Example: 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 Functions The 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?
Useful Filter Functions The 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?
Ideal Low-Pass Filter The 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.
Ideal Interpolation Function If 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.
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).