Question Details

(solution) can you help me write this code? i need help as soon as possible.

can you help me write this code? i need help as soon as possible. this is due friday

Electrical and Computer Engineering Dept.


Dr. Monty A. Escabi


EE 3101, Fall 2015 MATLAB Application Project


Due: Dec. 11, 2015


Digital Audio Crossover Design


The goal of this project is to build and test a digital audio crossover network. A crossover is a filterbank that is


used to separate out sounds so that they are efficiently delivered to a speaker array. Audible sounds cover a


frequency range from 20 Hz ? 20 kHz (for human hearing). Individual speaker drivers (e.g., tweeter, midrange


and woofer), however, can only faithfully reproduce a portion of this spectrum. Therefore, speaker drivers of


different sizes can be combined to reproduce the entire hearing range. The crossover divides the sound spectrum


into the frequencies that each driver faithfully reproduces.


In this project you are to implement a digital crossover in MATLAB for a three-way speaker system. The


schematic for this design is illustrated below: The input sound waveform, x(t) , is decomposed by three filters and these outputs are routed to each individual


speaker drivers. The lowpass (LP) filter encompasses frequencies below 500 Hz. The output from this filter is


used to drive the woofer (low frequency speaker). The midrange driver is driven by the output from a bandpass


(BP) filter. This filter only allows frequencies in the range 500Hz-5 kHz to pass through. The highpass filter


(HP) encompasses the remainder of the audible range (5-22.05 kHz). This output drives the high frequency


speaker (the tweeter).


You are allowed to work in groups of two or three. However, each student is required to hand in their own


independent report and is required to implement his/her own code. Reports using copied code or text will


be returned without a grade! (Yes, we will check for this! Code needs to be uploaded onto HUSKYCT). Group


members who worked on the project should be identified in the writeup. Filter Design


For this project you will use a Kaiser window FIR (Finite Impulse Response) filters to implement the


crossover network. In general, windowed FIR filters are implemented as the product of an ideal filter impulse response ( hideal [ k ] , for a lowpass, bandpass or highpass) and a window function ( w [ k ] ) that is used to


smoothly truncate the ideal filter impulse response to a total of 2N+1 samples


h [ k ] = hideal [ k ] ? w [ k ] Here N is a filter parameter referred to as the filter order where the total number of coefficients in the discrete


time impulse response of the filter is 2N+1. Conceptually, note that any ?ideal? filter requires an infinite amount


of time and therefore an infinite amount of coefficients to implement. As we have discussed in class, practically


this is not possible and the ideal filters cannot be implemented. To overcome this, the window function is used


to truncate the filter in a smooth fashion in order to 1) require only finite number of time samples (2N+1) and 2)


minimize filter distortions (or errors) in the passband and stopband.


There are a variety of window functions that can be used to generate an FIR filter as above. In this


project we will be using a Kaiser window. For the Kaiser window, there is an additional parameter ( ? ) that is


used to control the filter ?smoothness? in the time domain or equivalently, it serves to adjust the passband and


stopband specifications (error and frequencies) in the frequency domain.


In the above equation, each of the ideal filter impulse responses are given by




hideal [ k ] = ! 2? Fc $




sinc #






" Fs % where Fc is the cutoff frequency of the idel lowpass filter and Fs =44100 Hz is the sampling rate of the data.




hideal [ k ] = ! BW $




sinc #


? k & ? cos ( 2? ( Fc1 + BW / 2 ) k Fs )




" Fs


% where Fc1 and Fc2 are the lower and upper cutoff frequencies of the ideal bandpass filter and BW = Fc2 ? Fc1 is


the filter bandwidth.




hideal [ k ] = ? [ k ] ? " 2? Fc %




sinc $






# Fs & where Fc is the ideal highpass filter cutoff frequency and ? [ k ] is the discrete time Diract delta function (i.e., 1


for k=0 and zero otherwise). Note that this highpass filter impulse response is simply the difference between an


allpass filter ( ? [ k ] ) and an ideal lowpass filter (the sinc function term).


In all of the above filters k spans the integers (from - ? to ? ), however, in the actual filter


implementation described below the filters will be truncated from ?N to N (for a total of 2N+1 coefficients). Also, note that in MATLAB the sinc function is defined as sin (? x ) / (? x ) whereas above and in the book it is


defined as sin(x)/x. You will thus need to remove ? from the sinc function during implementation in


MATLAB. Filter Implementation


To generate the Kaiser filter you will


1) first generate the desired ideal filter impulse as described above but truncate the filter for a total of 2N+1


coefficients (i.e., k=-N ? N). In matlab, you can assign the vectors h_low, h_band, h_high for each of


these filters.


2) You need to determine the Kaiser order (N) and smoothness parameter ( ? ). As described in the class for


the Butterworth filter, the filter paramters are obtain with a mapping equation that converts the filter


specifications to filter parameters. For a Kaiser filter, there are two filter specifications of interest.


a) ATT = is the filter attenuation. Simply speaking, this is the amount of allowed error in the


passband and stopband in units of dB. For Kaiser filters, the stopband and passband errors


are symmetric so we don?t need separate errors to describe each and we can use a single


number. For example, if the error in the passband is ? =0.01 (relative to a passband gain of


1), then ATT = ?20 log10 (? ) = ?20 log10 ( 0.01) = 40 dB (in the graph below ATT=As). For the


case of a bandpass filter, two errors may be provided, one for the stopband and one for the


passband. Choose the more stringent of the two for the Kaiser filter design.


b) TW= is the transition width of the filter in units of Hz. Conceptually, TW is the frequency


range over which the filter transitions from the passband to the stopband (or vise versa for a


highpass filter). If f p is the passband frequency in Hz and fs is the stopband frequency, then


TW= f - f . The filter specifications are shown graphically below for a lowpass filter. p






polynomials on the interval


where, as indicated in Fig. 2.


is obtained by applyIt is


ral for


result may be expressed as (6) ction that is nonzero on the


Equation (6) is valid for






is recognized to


lter function.


onse of the ?lter is obtained


formula (1) and using the




(7) is noted that the magnitude


lse response in (7) approach


or as




types, such as bandpass and


similar fashion.


hese prototypes continue to Fig. 3. De?nitions of stopband attenuation


, transition width


, and


cutoff frequency


for the (real-valued) ?lter function


associated with


Note that convolution series (2).


the truncated the cutoff frequency is directly in the center frequencies ( fc = ( fs + f p ) between the stopband and passband


2 ) (normalized to units of radians in the above graph). For the are no additional parameters, and therefore no control is case of aover stopband attenuation may be provided,of for the stopband and one for the


bandpass filter, two TW or over the shape one




passband. Choose the more stringent of the two for the Kaiser filter design.


the magnitude response.


In 1974, Kaiser [3] introduced a window function that


approximated the prolate spheroidal wave function [18] while


being computationally easier to determine. Using the Kaiser


window, stopband attenuation of the magnitude response may


to a parameter of the window,


be controlled by mapping Given the above filter specification (ATT and TW or alternately the stopband and passband frequencies


and errors), you will obtain the filter parameters N and ? using the following transformation #










? = $ 0.5842 ( ATT ? 21) + 0.07886 ( ATT ? 21)




0.1102 ( ATT ? 8.7)




& ATT <21


21 ? ATT ? 50


ATT > 50 # F ( ATT ? 7.95) &


N = ceil% s




$ 28.72 TW ' Once you obtain the filter parameters, the Kaiser window is obtain as a vector containing 2N+1 coefficients


using the following command in MATLAB:




If you generate the ideal filter impulse response as described above, the final filter is then generated as




where h_ideal is a vector containing the filter coefficients from the above equations.


Crossover Network Specifications


The filters will be designed to satisfy the following specifications.


Lowpass Filter:


G p = 0.9


f p = 250 Hz Gs = 0.01


fs = 750 Hz Bandpass Filter:


G p1 = G p2 = 0.9


f p1 = 700 Hz


f p2 = 4.5 kHz Gs1 = Gs2 = 0.01


fs1 = 300 Hz


fs2 = 5.5 kHz Highpass Filter:


G p = 0.9 f p = 5.5 kHz Gs = 0.01


fs = 4.5 kHz All sound waveform are sampled at a sampling rate of 44.1 kHz. Once you generate the Kaiser impulse


response as described above you can simply convolve the impulse response with the sound waveform to


generate the output:




where h is the impulse response vector, x is the input sound vector, and y is the output sound vector. Simulation


You are to simulate the crossover filtering procedure for two separate signals.


1) White noise ? similar to the hissing noise you hear when your FM radio is not tuned to a station


2) Music sound sample provided


I will provide a short music sound sample as a MATLAB data file (to load type: ?load filename.mat?). To


generate a sample of white noise simply use the command:




This generates a 5 second white noise signal.


Note that once your code is written for white noise you simply have to change the array x to resimulate the


crossover filterbank for music. No additional work is necessary! Plotting Results


You are required to plot the results both in the time and frequency domain for both the input and the output. To


plot the time-waveforms simply use the command:




where taxis is a time axis array containing the sample time points and x is an array containing the waveform. To


plot the magnitude spectrum of the input or output signals simply use the power spectral density command


(PSD; type ?help psd? for details). The syntax will typically be something as follows:




where Fs=44100 is the sampling rate.


Note that there are a total of 12 graphs to plot (2 sounds x 3 filters/sound * (1 time domain graph/filter + 1 freq.


domain graph/filter) = 12 graphs) Generating WAV Sound File and playing the sound:


You are expected to listen to each of the sound files at each filter output stage of the crossover so that you gain


some insight into the transformations that are being performed at each stage. In order to do this, you need to


convert each data array into a WAV sound file. You can do this with the WAVWRITE command in MATLAB.


The syntax for the command is as follows:






Y= is the signal vector


Fs= is the sampling frequency in Hz


nbits=is the number of bits (i.e. The resolution) of each sample


wavfile=is the output file name For additional information in MATLAB you can type: help wavwrite


For this project, you will use the parameters






Lets say you want to write the data of an array X to a WAV file named: test.wav. You can use the syntax:




Alternately, on some computers, you can also listen to the sound using the SOUNDSC command. For the sound


vector X, you can play the sound using the syntax: soundsc(X,Fs). You can use this as an alternative approach


(to WAVWRITE) assuming that it works on your computer. Writeup


A short writeup describing the methods and results is required. At minimal it should include.


1) A brief introduction describing the project objective (~ 1 page).


2) A brief description of the methods (~1-2 pages).


3) A discussion of the results. Focus on describing:


a) How each filter modifies the time waveforms for music and white noise.


b) How each filter modifies the magnitude spectrum of music and white noise.


c) Compare and contrast the input and output waveforms.


d) Listen to the input and output sounds using the wavwri routine and compare and contrast the


audible differences between the input and output.


4) Program code.


5) Figures. Honors Student Requirements


In addition to implementing the filterbank using the Kaiser filters, also implement the above filterbank


(identical passband and stopband parameters) using a Butterworth filter. Details for the implementation of the


Butterworth filters in MATLAB can be found in section 7.5 of the book (e.g., see example C7.5). As for the


Kaiser filter, plot the same set of results (time and frequency domain), but only do so for white noise.


a) Contrast and compare the filters (Kaiser vs. Butterworht). Do they sound similar or are there audible


differences when you implement the crossover for the music. Visually, do the spectrums look similar or


different when you use white noise. Describe any discrepancies or similarities.


Solution details:

This question was answered on: Jan 30, 2021

PRICE: $15 (25.37 KB)

Buy this answer for only: $15

This attachment is locked

We have a ready expert answer for this paper which you can use for in-depth understanding, research editing or paraphrasing. You can buy it or order for a fresh, original and plagiarism-free solution (Deadline assured. Flexible pricing. TurnItIn Report provided)

Pay using PayPal (No PayPal account Required) or your credit card . All your purchases are securely protected by .

About this Question






Jan 30, 2021





We have top-notch tutors who can do your essay/homework for you at a reasonable cost and then you can simply use that essay as a template to build your own arguments.

You can also use these solutions:

  • As a reference for in-depth understanding of the subject.
  • As a source of ideas / reasoning for your own research (if properly referenced)
  • For editing and paraphrasing (check your institution's definition of plagiarism and recommended paraphrase).
This we believe is a better way of understanding a problem and makes use of the efficiency of time of the student.


Order New Solution. Quick Turnaround

Click on the button below in order to Order for a New, Original and High-Quality Essay Solutions. New orders are original solutions and precise to your writing instruction requirements. Place a New Order using the button below.


Order Now