各位大神,小的初学DSP,想用TI的AIC23语音芯片读入一段语音数据,然后想将这段音频数据存储到片外SDRAM中,之后再将存储的音频数据作算法处理,再用AIC23输出音频数据。现在遇到的问题是,不会将从McBSP读到的数据存储到自己void AIC23_Mixer()
{
PC55XX_MCSP pMCBSP0 = (PC55XX_MCSP)C55XX_MSP0_ADDR;//pMCBSP0=0x2800
int left, right; //int,16bits
int *pWork,nAudioCount;
int i;
unsigned int uWork;
unsigned char cWork;
//bCodec=0;
pAudio=pWork=(int *)AUDIODATA;
nAudioCount=0;
unsigned int right_speech[44100]={0};
unsigned int left_speech[44100]={0};
//这个for循环想干啥
for ( i=0;i<1024;i++,pWork++ ) (*pWork)=0;
pWork=pAudio;
while ( 1 )
{
while (!ReadMask(pMCBSP0 -> spcr2, SPCR2_XRDY)); // 等待数据传输完成
//试试能不能截取一段语音数据,再播放,缓冲区是怎么一回事
for(i=0;i<44100;i++)
{
left_speech[i]=Read(pMCBSP0 -> ddr1) ;
right_speech[i]=Read(pMCBSP0 -> ddr2);
}
// left = Read(pMCBSP0 -> ddr1); // 读入左声道数据
// right = Read(pMCBSP0 -> ddr2); // 读入右声道数据
// uWork=G711ALawEncode(left,right);
// (*pWork)=uWork;
// cWork=uWork>>8;
// left=ALawToInt(cWork);
// cWork=uWork&0x0ff;
// right=ALawToInt(cWork);
nAudioCount++; pWork++;
if ( nAudioCount>=1024 )
{
nAudioCount=0;
pWork=pAudio;
}
break;
/*
for(i=0;i<1024;i++)
{
Write(pMCBSP0 -> dxr1, left_speech[i]);
Write(pMCBSP0 -> dxr2, right_speech[i]);
}
*/
//nAudioCount计算采样点个数,pWork为指针变量,指向
//pAudio也是指针变量,
// Write(pMCBSP0 -> dxr1, left);
// Write(pMCBSP0 -> dxr2, right);
/* if ( nAudioCount>=1024 )
{
nAudioCount=0;
pWork=pAudio;
}
}*/
}
for(i=0;i<44100;i++)
{
Write(pMCBSP0 -> dxr1, left_speech[i]);
Write(pMCBSP0 -> dxr2, right_speech[i]);
}
}
定义的数组中,请各位大神帮忙解答,小弟先拜谢大伙了! |