160 likes | 409 Views
By: John Ernsberger. Digital Equalizer. PURPOSE. The purpose of this project is to design an equalizer with both user controlled and hard set gains. THEORY. Digital Equalizers Second Order IIR Filters. DIGITAL EQUALIZERS.
E N D
By: John Ernsberger Digital Equalizer
PURPOSE • The purpose of this project is to design an equalizer with both user controlled and hard set gains
THEORY • Digital Equalizers • Second Order IIR Filters
DIGITAL EQUALIZERS • A Digital Equalizer functions by using two or more Band Pass Filters • After being multiplied by an individual gain the filters are added together and multiplied by a master gain • This produces an augmented output where specific frequencies are boosted
VISUAL REPRESENTATION Input 2ndOrder IIR Filter 2nd Order IIR Filter Output 2nd Order IIR Filter 2nd Order IIR Filter Master Gain … Individual Gains
IMPLEMENTATION IIRFilter100( pIn , buff100 ) ; IIRFilter200( pIn , buff200 ) ; IIRFilter400( pIn , buff400 ) ; IIRFilter800( pIn , buff800 ) ; IIRFilter1500( pIn , buff1500 ) ; IIRFilter3000( pIn , buff3000 ) ; IIRFilter5000( pIn , buff5000 ) ; IIRFilter7000( pIn , buff7000 ) ; IIRFilter10000( pIn , buff10000 ) ; for( l = 0 ; l < BUFLEN * 2 ; l++ ) { f100 = buff100[l] ; f200 = buff200[l] ; f400 = buff400[l] ; f800 = buff800[l] ; f1500 = buff1500[l] ; f3000 = buff3000[l] ; f5000 = buff5000[l] ; f7000 = buff7000[l] ; f10000 = buff10000[l] ; pOut[l] = 0.11 * ( f100 + f200 + f400 + f800 + f1500 + f3000 + f5000 + f7000 + f10000 ); }
SECOND ORDER IIR FILTERS • IIR Filters are perfect for equalizer design because they are very specific with a low coefficient order • These filters can be designed using the fdatool in MATLAB
MATHEMATICS • Basic Equation: • Here we see that multiplying the input and previous inputs by coefficients will obtain the filtered output H(z) • This can be reduced too: wn = ( input ) - ( a1 * wn1 ) - ( a2 * wn2 ) ; yn = ( b1 * wn ) + ( b2 * wn1 ) + ( b3 * wn2 ) ; • Here wn1 and wn2 are the previous modified inputs and wn is the currently being modified input
MATHEMATICS • When dealing with a multi sectioned IIR Filter use the following equation
VISUAL REPRESENTATION • One section second order … Input b0 Output D To add more sections repeat process a1d[n-1] b1d[n-1] D a2d[n-2] b2d[n-2]
IMPLEMENTATION void IIRFilter100( short *pIn , short *pOut ) { inti = 0, k = 0 ; // initializes the counters static double input = 0 ; double wn = 0 , yn = 0 ; // initializes variables used within the filter double a1 , a2 , b1 , b2 , b3 ; // initializes the variables to hold the filter coefficients double wn1 , wn2 ; // initializes variables to hold w(n -1) and w(n-2) values for( i = 0 ; i < BUFLEN ; i++ ) { input = (double)(pIn[i * 2]) ; // passes the input value from pIn to the filter for( k = 0 ; k <= (section100 - 1) ; k++ ) { a1 = DEN100[k][1] ; // uses the variable to hold the coefficient values a2 = DEN100[k][2] ; // uses the variable to hold the coefficient values b1 = NUM100[k][0] ; // uses the variable to hold the coefficient values b2 = NUM100[k][1] ; // uses the variable to hold the coefficient values b3 = NUM100[k][2] ; // uses the variable to hold the coefficient values wn1 = w100[k][0] ; // uses a variable to hold w(n-1) value wn2 = w100[k][1] ; // uses a variable to hold w(n-2) value wn = ( input ) - ( a1 * wn1 ) - ( a2 * wn2 ) ; // calculates wn value yn yn = ( b1 * wn ) + ( b2 * wn1 ) + ( b3 * wn2 ) ; // calculates the output value w100[k][1] = w100[k][0] ; // passes w(n-1) to w(n-2) w100[k][0] = wn ; // passes wn to w(n-1) input = yn ; // copies the new output to the new output } pOut[i * 2] = (short)(yn) ; // copies yn to the output pOut[i * 2 + 1] = (short)(yn) ; // copies yn to the output } }
IMPROVEMENTS • Have a fully functioning equalizer with a clean output • Have more preset settings for different types of music • Have different types of equalizers with different ranges