hello. I am trying to implement a simple equilizer using three FIR filter -LPF, BPF and a HPF, on DSK6713 board using ccstudio v4.1.
The output audio I am getting is very noisy. I have generated filter coeffients using MATLAB. Here I have taken the sampli g frrequency to be 8k(for audio we take 44.1k). To start with I have put same input value to both the output channel i.e.,
l_output=l_input;
r_output=l_input;
The filter I have used is- FIR equiripple, length=95.
When this program is being executed the ouput very noisy.
I would want to know what changes or points I should take in to considerations and what steps I need to take for the same.?
Your guidance would be very helpful
Thanks in Advance
Here is the program --
*******************************************
#include
"C:\DSP\support\dsk6713.h"
#include
"C:\DSP\support\dsk6713_aic23.h"
#include
"stdlib.h"
#include
"math.h"
signed
int LPF_FIR_FILTER(float * h, signed int x);
signed
int FIR_FILTER(float * h, signed int x);
/*======================Filter coefficients for HPF==================*/
float
hpf_filter_coeff[] = {
-7.766913568768e-008,-9.900075428318e-008,3.080638964617e-007,8.794016247218e-007,
1.466105703614e-007,-2.727840495866e-006,-4.287748458356e-006,1.653975184879e-006,
1.343035552033e-005,1.393248613103e-005,-1.29494295252e-005,-4.792298807515e-005,
-3.385124117307e-005,5.583557349189e-005,0.0001374757463951,6.273970385775e-005,
-0.0001808335056419,-0.0003344524927968,-8.091876775644e-005,0.0004851618558757,
0.0007123341267946,2.824867858417e-005,-0.001131781408246,-0.001355991569058,
0.0002265270932089, 0.002364817437227, 0.002340122925688,-0.0009231574104267,
-0.004520961841846,-0.003698698120553, 0.002456578471041, 0.008050662131954,
0.005394101018351,-0.005457414095261, -0.01360120918768,-0.007298509665367,
0.01100837028542, 0.0223357072597, 0.00919910229859, -0.02142160819756,
-0.03721888296544, -0.01083194027653, 0.04401891383592, 0.07027814768834,
0.01193876307694, -0.1294732120043, -0.2806604136014, 0.654335881523,
-0.2806604136014, -0.1294732120043, 0.01193876307694, 0.07027814768834,
0.04401891383592, -0.01083194027653, -0.03721888296544, -0.02142160819756,
0.00919910229859, 0.0223357072597, 0.01100837028542,-0.007298509665367,
-0.01360120918768,-0.005457414095261, 0.005394101018351, 0.008050662131954,
0.002456578471041,-0.003698698120553,-0.004520961841846,-0.0009231574104267,
0.002340122925688, 0.002364817437227,0.0002265270932089,-0.001355991569058,
-0.001131781408246,2.824867858417e-005,0.0007123341267946,0.0004851618558757,
-8.091876775644e-005,-0.0003344524927968,-0.0001808335056419,6.273970385775e-005,
0.0001374757463951,5.583557349189e-005,-3.385124117307e-005,-4.792298807515e-005,
-1.29494295252e-005,1.393248613103e-005,1.343035552033e-005,1.653975184879e-006,
-4.287748458356e-006,-2.727840495866e-006,1.466105703614e-007,8.794016247218e-007,
3.080638964617e-007,-9.900075428318e-008,-7.766913568768e-008
};
/******************** filter coefficient for BPF********************/
float
bpf_filter_coeff[]= {
-0.006537049892988, -0.00101208566238,-0.0008631507053782,-0.0005495352514237,
-6.756668096198e-005,0.0005670380368977, 0.001326683358643, 0.002172645528609,
0.003054169964298, 0.003906847322553, 0.004666813430797, 0.005265488073615,
0.005640574492745, 0.005734972817922, 0.005510251480791, 0.004941306418854,
0.004028105944829, 0.002789236994392, 0.001270548884404,-0.0004642689154306,
-0.002327323061019,-0.004219805910315,-0.006029272984756,-0.007645202552779,
-0.008957950902011,-0.009874490389723, -0.01031667003304, -0.01023582652631,
-0.009608019794076,-0.008444236405394,-0.006784471358844,-0.004704956659893,
-0.0023057540843,0.0002869999489705, 0.002934425614991, 0.005491927339289,
0.007822443920869, 0.009792616061499, 0.01127858486869, 0.01221076200141,
0.01252925507263, 0.01221076200141, 0.01127858486869, 0.009792616061499,
0.007822443920869, 0.005491927339289, 0.002934425614991,0.0002869999489705,
-0.0023057540843,-0.004704956659893,-0.006784471358844,-0.008444236405394,
-0.009608019794076, -0.01023582652631, -0.01031667003304,-0.009874490389723,
-0.008957950902011,-0.007645202552779,-0.006029272984756,-0.004219805910315,
-0.002327323061019,-0.0004642689154306, 0.001270548884404, 0.002789236994392,
0.004028105944829, 0.004941306418854, 0.005510251480791, 0.005734972817922,
0.005640574492745, 0.005265488073615, 0.004666813430797, 0.003906847322553,
0.003054169964298, 0.002172645528609, 0.001326683358643,0.0005670380368977,
-6.756668096198e-005,-0.0005495352514237,-0.0008631507053782, -0.00101208566238,
-0.006537049892988
};
/*LPF coeff.*/
float
lpf_filter_coeff[]= {
2.334696805708e-008,-9.151950455956e-009,-2.780212797993e-008,-2.096266138452e-009,
2.737020404238e-008,-2.008316301565e-008,-1.182691890808e-007,-1.026271019745e-008,
5.0374790089e-007,7.796086425549e-007,-6.604602529232e-007,-3.532052789177e-006,
-2.867884858737e-006,6.43636366798e-006,1.632947128282e-005,3.821209750149e-006,
-3.621591938371e-005,-5.27357292705e-005,2.163092776587e-005,0.0001420263204344,
0.0001132482722209,-0.0001700046151373,-0.0004118453462941,-0.0001058255788768,
0.0006719033608461,0.0008882061515017,-0.0003109131030571,-0.001877683496101,
-0.001321429195181, 0.001878985090081, 0.004004549887244,0.0007771776518274,
-0.005664367063949,-0.006546957771539, 0.00268735441146, 0.01253627138426,
0.007476336480221, -0.01205209987099, -0.02230471651372,-0.002341674248763,
0.03165514635351, 0.03309889258194, -0.01873350186391, -0.07329291090865,
-0.04170537346808, 0.1079409274233, 0.2938449921914, 0.378339866313,
0.2938449921914, 0.1079409274233, -0.04170537346808, -0.07329291090865,
-0.01873350186391, 0.03309889258194, 0.03165514635351,-0.002341674248763,
-0.02230471651372, -0.01205209987099, 0.007476336480221, 0.01253627138426,
0.00268735441146,-0.006546957771539,-0.005664367063949,0.0007771776518274,
0.004004549887244, 0.001878985090081,-0.001321429195181,-0.001877683496101,
-0.0003109131030571,0.0008882061515017,0.0006719033608461,-0.0001058255788768,
-0.0004118453462941,-0.0001700046151373,0.0001132482722209,0.0001420263204344,
2.163092776587e-005,-5.27357292705e-005,-3.621591938371e-005,3.821209750149e-006,
1.632947128282e-005,6.43636366798e-006,-2.867884858737e-006,-3.532052789177e-006,
-6.604602529232e-007,7.796086425549e-007, 5.0374790089e-007,-1.026271019745e-008,
-1.182691890808e-007,-2.008316301565e-008,2.737020404238e-008,-2.096266138452e-009,
-2.780212797993e-008,-9.151950455956e-009,2.334696805708e-008
};
/*===========================================================*/
DSK6713_AIC23_Config configg = { \
0x0017,
/* 0 DSK6713_AIC23_LEFTINVOL Left line input channel volume */ \
0x0017,
/* 1 DSK6713_AIC23_RIGHTINVOL Right line input channel volume */\
0x00d8,
/* 2 DSK6713_AIC23_LEFTHPVOL Left channel headphone volume */ \
0x00d8,
/* 3 DSK6713_AIC23_RIGHTHPVOL Right channel headphone volume */ \
0x0011,
/* 4 DSK6713_AIC23_ANAPATH Analog audio path control */ \
0x0000,
/* 5 DSK6713_AIC23_DIGPATH Digital audio path control */ \
0x0000,
/* 6 DSK6713_AIC23_POWERDOWN Power down control */ \
0x0043,
/* 7 DSK6713_AIC23_DIGIF Digital audio interface format */ \
0x0081,
/* 8 DSK6713_AIC23_SAMPLERATE Sample rate control */ \
0x0001
/* 9 DSK6713_AIC23_DIGACT Digital interface activation */ \
};
void
main()
{
DSK6713_AIC23_CodecHandle hCodec;
Uint32 l_input, r_input,l_output, r_output,lpf_l_input,bpf_l_input,hpf_l_input;
/* Initialize the board support library, must be called first */
DSK6713_init();
/* Start the codec */
hCodec = DSK6713_AIC23_openCodec(0, &configg);
DSK6713_AIC23_setFreq(hCodec,6);
//***********************************************************
while(1)
{
/* Read a sample to the left channel */
while (!DSK6713_AIC23_read(hCodec, &l_input));
/* Read a sample to the right channel */
while (!DSK6713_AIC23_read(hCodec, &r_input));
/*#############################################################*/
lpf_l_input = FIR_FILTER(lpf_filter_coeff ,l_input);
// low frequencies
bpf_l_input = FIR_FILTER(&bpf_filter_coeff ,l_input);
//middle frequencies
hpf_l_input = FIR_FILTER(hpf_filter_coeff ,l_input);
//high frequencies
l_input=(hpf_l_input)+(hpf_l_input)+(bpf_l_input);
/*#############################################################*/
l_output=l_input;
r_output=l_input;
/*==========setting the gain===========*/
DSK6713_AIC23_outGain(hCodec, 0x79);
//========================================//
/* Send a sample to the left channel */
while (!DSK6713_AIC23_write(hCodec, l_output));
/* Send a sample to the right channel */
while (!DSK6713_AIC23_write(hCodec, r_output));
}
/* Close the codec */
DSK6713_AIC23_closeCodec(hCodec);
}
//************************************************************
signed
int FIR_FILTER(float * h, signed intx)
{
int in_buffer[95];
int
i=0;
signed
long output=0;
in_buffer[0] = x;
/* new input at buffer[0] */
for
(i=95;i>0;i--)
in_buffer[i] = in_buffer[i-1];
/* shuffle the buffer */
for
(i=0;i<95;i++)
output = output + h[i] * in_buffer[i];
return
(output);
}
*******************************************