This lab requires you to use C++ class composition to implement a single pole-fi
ID: 3537077 • Letter: T
Question
This lab requires you to use C++ class composition to implement a single pole-filter design program. The program will allow the user to specify resistor and capacitor values and filter type. Once all the user parameters are specified, the program will return the cutoff frequency values for the filter.
Composition may be thought of as a has-a relationship for objects, as compared to inheritance, which may be described as an is-a relationship for objects.
You are required to use two component classes: one for a resistor object and one for a capacitor object. You are then to define and implement a filter class that will contain one object of each the resistor and the capacitor classes in order to create the filter and its characteristics.
The Resistor class created in the Week 2 iLab may be used both as the class definition for the resistor object and as a template or a guide for the capacitor-class definition.
The lab also requires you to implement your program in a multiple-file project and create both cpp and h files for each class defined. In addition, the program will have the capacity to save all filter parameters to a text file and read previously designed filter parameters from a text file.
Each lab exercise should have a separate section in the lab-report document.
Your lab grade will be based upon
STEP 1: Create a Multifile Project for the Composition Lab
STEP 2: Filter-Class Definition
The Filter class should have, at a minimum, the following capabilities.
STEP 3: Test-Program Operation
DeliverablesExplanation / Answer
Code :
First prewarp the frequency of both poles:
K1 = tan(0.5*Pi*20.6 / SampleRate) // for 20.6Hz
K2 = tan(0.5*Pi*12200 / SampleRate) // for 12200Hz
Then calculate the both biquads:
b0 = 1
b1 = 0
b2 =-1
a0 = ((K1+1)*(K1+1)*(K2+1)*(K2+1));
a1 =-4*(K1*K1*K2*K2+K1*K1*K2+K1*K2*K2-K1-K2-1)*t;
a2 =- ((K1-1)*(K1-1)*(K2-1)*(K2-1))*t;
and:
b3 = 1
b4 = 0
b5 =-1
a3 = ((K1+1)*(K1+1)*(K2+1)*(K2+1));
a4 =-4*(K1*K1*K2*K2+K1*K1*K2+K1*K2*K2-K1-K2-1)*t;
a5 =- ((K1-1)*(K1-1)*(K2-1)*(K2-1))*t;
Now use an equation for calculating the biquads like this:
Stage1 = b0*Input + State0;
State0 = + a1/a0*Stage1 + State1;
State1 = b2*Input + a2/a0*Stage1;
Output = b3*Stage1 + State2;
State2 = + a4/a3*Output + State2;
State3 = b5*Stage1 + a5/a3*Output;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.