Audio Equalizer Instructor: Prof. Andy Wu ACCESS IC LAB
Basic Network Structure for FIR System M y[ n] = h[ k] x[ n k] k = 0 Direct-form Transposition of direct-form P2
Cascade Form Cascade 2nd-ordered direct-form FIR filter to get a polynomial system function. M Ms n 1 2 0k 1k 2k n= 0 k = 1 H( z) = h[ n] z = ( b + b z + b z ) P3
Coding for FIR at High-Level Programming Language P4
Use FIR Function in DSP Library #include <filter.h> const fract16 x[]; /* Input sample vector x */ fract16 y[]; /* Output sample vector y */ int inum; /* Number of input samples */ fir_state_fr16 *state; /* Pointer to filter state structure */ int main() { fir_init(state,coeffs_array,delayline,num_coeffs interpolation_idx); fir_fr16(x,y,inum,state) ; } The function uses the following structure to maintain the state of filter. typedef struct { fract16 *h, /* filter coefficients */ fract16 *d, /* start of delay line */ fract16 *p, /* read/write pointer */ int k; /* number of coefficients */ int l; /* interpolation/decimation index */ } fir_state_fr16; P5
Note Blackfin BF533 is a fixed-point DSP, there is no floating-point data type. frac16 is used to for fraction number representation. -1~1, resolution is 2/2 16 Data obtained from ADC is integer, not fraction, remember to do proper normalization P6
Obtain FIR Filter Coefficients from MATLAB Filter Design Toolbox Filter Design & Analysis Tool (FDATool) P7
5. 1. 2. 3. 4. 6. P8
1. Type Step-by by-step (1) FIR or IIR, Low-pass or Band-pass 2. Order 7, 8 or more 3. Frequency Specification Fs, Fpass, Fstop 頻率響應的參數 4. Magnitude Specification 邊緣變化情形 P9
5. 選擇不同的 view Step-by by-step (2) Magnitude response, Filter coefficient 6. Design Filter 得到實驗所需的 Filter coefficient P10
Implement Filter at Frequency Domain Spectrum analysis Transform input audio signal from time-domain magnitude to frequency domain coefficients. Determine filter frequency response directly. P11
1D Discrete Cosine Transform N-point 1D DCT and Inverse DCT DCT F( k) = c( k) N x= 0 kπ (2x + 1) f ( x)cos( ) 2N Time domain signal IDCT f ( x) = N k = 0 kπ (2x + 1) c( k) F( k)cos( ) 2N Coefficient of cosine wave c( i) = { 1/ N, 2 / N, i = 0 otherwise P12
Mix Stereo Audio Note the weighting should be normalized [4] P13
Exercise Lab Run FIR example @..\Analog Devices\VisualDSP 3.5 16-Bit\Blackfin\Examples\FIR\ Add equalizer function to your audio talk-through system Design at least 3 FIR filter coefficients sets (such as bass enhance, treble enhance, bandpass, notch ), implement them in your system. You should use the button on EVB to switch between those preset equalizer modes. Bonus: Design a transform-based equalizer and allow user to adjust its frequency response at runtime. Add left/right channel mixing function to your system and allow user to choose enable or not at runtime. P14
Submission Due: 2004/11/11 Thursday Mailto: tommy@access.ee.ntu.edu.tw Requirement: Architecture of your system Plot input and output signal (time and frequency domain) and compare Discussion Suggest to this slide: content, teaching skill anything you feel inadequate. P15
Reference [1] Alan V. Oppenheim, Ronald W. Schafer, John R. Buck, Discrete-Time Signal Processing, 2 nd edition, Prentice Hall, ISBN 0-13-083443-2 [2] MATLAB Help [3] Visual DSP++ 3.5 Compiler and Library Manual for Blackfin Processors, Revision 2.2, October 2003 [4] http://www.enel.ucalgary.ca/people/smith/ece-adi- Project/AudioProject/AudioLectureMaterial/Lecture_AudioCourseInfoFr ame.htm P16