Hello people, i need help please,
Im using a TMS320C6713 DSK (spectrum digital) and my dvelopment enviorment is CCS v3.1.
My object is to aquire analog audio by the embedded codec tlv320aic23b, use McBSP1 to transfer the samples in the DSP,
filter the digital signal with an implemented IIR and then use again the codec to send out my new analog audio.
My IIR is full of decimal coefficents (like 0.5 0.003 etc).
The problem is that when i try to multiply my samples (the type i use to store my sample is Uint32, 32-bit unsigned int)
by decimal coefficents the output signal is very distorted.
example:
If i make a simple loopback with codec-McBSP there's no problem, i mean take samples with codec and then send them back trough
the DAC of the codec without manipulate these samples.
If i multiply these samples by an integer (like 1, 2, 3....) there's no problem too.
But if i take these samples, that are 32-bit integers, and with casting i try to multiply by 0.5, for example, then if i send back
these new integer samples, the result audio is distorted, when the object was only to decrease the volume.
Instead of multiply by 0.5 i tryed to simply shift to the left my 32-bit-samples, but the distortion persists.
There's no problem if i shift to the right, that means multiply by 2, that is an integer coefficent again.
Here is my simple program that performs a loopback : (please help me, i cant multiply my samples by non-integer numbers...WHY???)
----------------------------------------------------------------------------------------------------------
#include "dsk6713.h"
#include <csl.h>
#include "dsk6713_aic23.h"
#include <stdio.h>
#include "MyConfigDSPbioscfg.h"
void main()
{
Uint32 sample, dxchannel, sxchannel, heyhomie=1;
MCBSP_Config myMCBSPconf;
DSK6713_AIC23_CodecHandle hCodec;
DSK6713_AIC23_Config myConfAic={
0x0117, //adjust the left LINEinput volume.
0x0117, //adjust the right LINEinput volume.
0x00FF, //adjust the left Headphone volume.
0x00FF, //adjust the right Headphone volume.
0x0012, //AnalogAudioPathControl...enable the DAC, disable the Bypass, set the LINEinput as mine input instead of the micropone.
0x0000, //DigitalAudioPathControl...I don't know...
0x0002, //PowerDownControl...turn on the various things that i need, like DAC, ADC, etc..
0x0043, //DigitalAudioInterface...AIC = master mode, data format = DSP mode, lenght of a word = 16 bit, etc..
0x0023, //SamplingRateControl...i use USB mode so master clock is 12MHz, remaining bits are used to set the sample rate.
0x0001 //DigitalInterfaceActivation...enable the interface.
};
DSK6713_init();
CSL_init();
hCodec=DSK6713_AIC23_openCodec(0,&myConfAic);
MCBSP_getConfig(_MCBSP_hDev1,&myMCBSPconf);
myMCBSPconf.rcr=0x1A0; //McBSP works with one phase and one word (32 bits), in this way i can easily recognize left channel and right channel.(respectively first 16 bit and last 16 bits)
myMCBSPconf.xcr=0x1A0;
MCBSP_config(_MCBSP_hDev1,&myMCBSPconf);
while(1){
while(!MCBSP_rrdy(_MCBSP_hDev1)){
}
sample=MCBSP_read(_MCBSP_hDev1);
rhchannel=sample&(0x0000FFFF); // mask used to separate rhchannel to the lfchannel
lfchannel=sample&(0xFFFF0000);
//rhchannel>>=1; doesn't work
//rhchannel=(float)(rhchannel*0.5); doesn't work
rhchannel*=1; //if i multiply by integers simply the output volume is increased
lfchannel*=1;
sample=rhchannel|lfchannel;
while(!MCBSP_xrdy(_MCBSP_hDev1)){
}
MCBSP_write(_MCBSP_hDev1,sample);
}
}
I'VE CONNECTED THE AUDIO OUTPUT OF MY COMPUTER TO THE LINE-INPUT OF THE CODEC, AND A HEADPHONE ON THE HEADPHONE-OUTPUT OF THE CODEC.
WHEN THIS PROGRAM RUN I CAN HEAR MUSIC FROM MY COMPUTER USING THE HEADPHONE CONNECTED TO THE DSK BOARD. BUT IF I MULTIPLY SAMPLES BY
NON INTEGER VALUES THE AUDIO I HEARD BECOME VERY DISTORTED. I DON'T KNOW WHY !!!
IF SOMEONE WANT TO TRY THIS PROGRAM HE WILL NEED A CONFIGURATION DSP/BIOS FILE (.CDB), that in my progect it name is MyConfigDSPbios.cdb
I simply create that file choosing the dsk6713 config.file seed without modify it.
PLEASE HEEELLLPPPPPPPP
THANKS.