Matlab Homework

ECE203: Introduction to MATLAB programming Project I In this project you are to design and implement the system described in Figure 1 (a 5 band graphic equalizer) in MATLAB. The system consists of five sub -systems: a Low Pass Filter (LPF), three Band Pass Filters (BPFs) and a High Pass Filter (HPF) Figure 1: Top level diagram of overall system (a 5 band graphic equalizer) The circuit corresponding to each of those sub -systems is shown in Figure 2. Start by calculating the values of the electrical component s (resistor, capacitor and inductor) for each subsystem and deriving the transfer function of each subsystem such that it satisfies the following characteristics : Figure 2: From far left to right are circuits corresponding to LPF, HPF and BPF respectively. Hint: you can pick an arbitrary value for one and solve for the other. 1. The LPF should have a cut -off frequency in the order of 30Hz. The cut -off frequency of the LPF can be calculated using: = 1 2 2. We desire the three BPFs to have center frequencies that are equal to 30Hz, 150Hz and 800 Hz. We also desire the BandWidth(s) (BW) of those BPFs to be approximately equal to 145Hz, 650Hz, and 3200Hz respectively. The two characteristics of a BPF can be calculated as follows: = 1 2√ = 1 2 To summarize what is required here you are to compute three different values for R, L and C for each of the 3 BPF s so as to satisfy the desired characteristics. 3. The HPF should have a cut -off frequency that is equal to 8 00Hz. The cut -off can be calculated using: = 2 Make note that these filters are not the one that we looked at in class (different configuration s but they are equivalent) . Meaning, here, in the case of the LPF the output voltage is across the capacitor and in the case of the HPF the output voltage is across the inductor (i.e., NOT across the resistor s like that for the examples that we looked at in class). Also to note is that the inductor and capacitor of BPF are in parallel and the output voltage of in terest is across those elements . In MATLAB write a function called geq_5bands .m that takes in the following input arguments : 1. Variable containing sound 2. A variable containing the t ime array in seconds corresponding to the sound in question 3. And an array containing the 5 gain values. The output argument ought to be the p rocessed sound Your function is to first evaluate and plot the frequency response of each filter/sub -system (i.e., evaluate and plot the absolute value of () … use abs() ) in the same figure window . Be sure to plot the magnitude against logarithmically scaled frequency ax is raging 0 to 22.05KHz (i.e., use semilogx() when plotting) . Make sure to apply the 5 gains supplied by the user. In other words multiply the expression obtained for () for each filter with its corresponding gain before plotting it. Make sure that your results are satisfactory (i.e., the desired characteristics are attained) before moving on to the next phase of this project. Below is a plot of the magnitude vs frequency of the 5 filters if all gains were set to be equal to 1. You sh ould more or less get something similar to it In the function implement the transfer function of each of the 5 sub -systems using tf(). Multiply those transfer functions with their corresponding gain supplied by the user (i.e., multiply each transfer function with its corresponding gain) before processing the input variable c ontaining audio via lsim(). In other words, p rocess the va riable containing sound via lsim() using each weighted transfer function so as to produce 5 different filtered outputs (as shown in figure 1). You are then to combine the 5 out puts by simply summing th em as shown in Figure 1. The output comprised of the co mbined 5 outputs essentially is the output of your function. Now in a script file (program) called run_geq_5bands .m . You are to audioread() a sound file (either gorka.wav or hootie.wav since they are sampled at a desired rate ). They are stereo so make sure to convert them to mono. Generate an array t comprised of the time stamps of each sample of the audio variable (i.e., time array that corresponds to sound in question). You are then to generate an array for the desired gai ns (a vector that contains 5 numbers). More specifically you are to examine 7 different gain setting s. For each of those 7 gain settings, you are to first soundsc() the original wave file, make use of the function that wrote to process it, and then soundsc() the output (processed so und) . Do make sure to insert an adequate pause between the two so as to avoid sound overlap. Lastly, plot the original and processed sound against time in 10 0 10 1 10 2 10 3 10 4 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 Fre que ncy in Hz Magnitude Fre que ncy re sponse of the 5 filte rs LPF BPF1 BPF2 BPF3 HPF seconds in the same figure window for comparison purposes. The 7 gains we would like to explore are: Cases 1 2 3 Comments 1 1 1 1 1 1 This is an all pass case (so original and processed should be one and the same) 2 1 0 0 0 0 This make s the system a LPF 3 0 1 0 0 0 4 0 0 1 0 0 5 0 0 0 1 0 6 0 0 0 0 1 This makes the system a HPF 7 X X X X X Setting of your choosing (note that the gains need not be w hole integers numbers. Also they could be decimal) That is to say you will be processing the audio that you chose 7 different times, have 7 different figures of the frequency response of the system and 7 different figures that shows input /original and output /processed waveforms against time axis Ensure that each plot is properly labeled and has a legend that describes the various waveforms.

In a word document, include your calcu lations for the v arious electrical components. Also include all figures and provide a brief description of them . Do ensure that y ou r function is well commented (as shown in class). Submit all files pertaining to this assignment. These include your word doc, your function called geq_5bands .m and the parent program run_ geq_5bands .m Miscellaneous: Figure 3: Frequency response and Characteristics of BPF