By: John Ernsberger
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 2 nd Order IIR Filter … Individual Gains Master Gain Output Input
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 + f f f f 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 Output b 1 d[n-1] b 2 d[n-2] a 1 d[n-1] a 2 d[n-2] b0b0 D D … To add more sections repeat process
IMPLEMENTATION void IIRFilter100( short *pIn, short *pOut ) { int i = 0, k = 0 ;// initializes the counters static double input = 0 ; double wn = 0, yn = 0 ;// initializes variables used within the filter doublea1, a2, b1, b2, b3 ;// initializes the variables to hold the filter coefficients doublewn1, 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 <= (section ) ; 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
THE END