怎么把处理后的数据保存为磁盘文件
时间:10-02
整理:3721RD
点击:
我现在在做一个基于dsp的语音录放系统,但是在将输入后的语音信号保存时出现问题,一直无法保存,求高手帮助
{
PC55XX_MCSP pMCBSP0 = (PC55XX_MCSP)C55XX_MSP0_ADDR;
int left, right,bCode,speaker;
int *pWork,nAudioCount;
int i;
unsigned int uWork;
unsigned char cWork;
// unsigned char audio0513; //0515
FILE *fp,*out;
speaker=1;
bCode=1;
pAudio=pWork=(int *)AUDIODATA;
nAudioCount=0;
for ( i=0;i spcr2, SPCR2_XRDY)); // 等待数据传输完成
left = Read(pMCBSP0 -> ddr1); // 读入左声道数据
right = Read(pMCBSP0 -> ddr2); // 读入右声道数据
if ( bCode==1 )
{
uWork=G711ALawEncode(left,right);
(*pWork)=uWork;
/****0513****
cWork=uWork>>8;
left=ALawToInt(cWork);
cWork=uWork&0x0ff;
right=ALawToInt(cWork);
****0513****/
}
/********************************0515******************************/
fp=fopen("D:\CCStudio_v3.3\MyProjects\20130513\Lindsey Ray - Better Off.mp3","ab+");
if(fp==NULL)
{printf("\nError opening file!\n");exit(0);}
fputc(uWork,fp);
out=fp;
cWork=fgetc(fp);
if(feof(fp)==0)
*out++;
/********************************0515******************************/
/********************************0513******************************
if(speaker==1)
{
wait(600);
Write(pMCBSP0 -> dxr1, left);
Write(pMCBSP0 -> dxr2, right);
}
********************************0513******************************/
nAudioCount++; pWork++;
if ( nAudioCount>=1024 )
{
nAudioCount=0;
pWork=pAudio;
}
}
/********************************0513******************************/
//cWork=uWork>>44;
left=ALawToInt(cWork);
// cWork=uWork&0x0ff;
right=ALawToInt(cWork);
if(speaker==1)
{
wait(60);
Write(pMCBSP0 -> dxr1, left);
Write(pMCBSP0 -> dxr2, right);
}
fclose(fp);
}
我这边的开发平台是CCS3.3和瑞泰创新的ICETEK-5509-A教学实验系统,仿真器是ICETEK-5100USBV2.0A
void AIC23_Mixer(){
PC55XX_MCSP pMCBSP0 = (PC55XX_MCSP)C55XX_MSP0_ADDR;
int left, right,bCode,speaker;
int *pWork,nAudioCount;
int i;
unsigned int uWork;
unsigned char cWork;
// unsigned char audio0513; //0515
FILE *fp,*out;
speaker=1;
bCode=1;
pAudio=pWork=(int *)AUDIODATA;
nAudioCount=0;
for ( i=0;i spcr2, SPCR2_XRDY)); // 等待数据传输完成
left = Read(pMCBSP0 -> ddr1); // 读入左声道数据
right = Read(pMCBSP0 -> ddr2); // 读入右声道数据
if ( bCode==1 )
{
uWork=G711ALawEncode(left,right);
(*pWork)=uWork;
/****0513****
cWork=uWork>>8;
left=ALawToInt(cWork);
cWork=uWork&0x0ff;
right=ALawToInt(cWork);
****0513****/
}
/********************************0515******************************/
fp=fopen("D:\CCStudio_v3.3\MyProjects\20130513\Lindsey Ray - Better Off.mp3","ab+");
if(fp==NULL)
{printf("\nError opening file!\n");exit(0);}
fputc(uWork,fp);
out=fp;
cWork=fgetc(fp);
if(feof(fp)==0)
*out++;
/********************************0515******************************/
/********************************0513******************************
if(speaker==1)
{
wait(600);
Write(pMCBSP0 -> dxr1, left);
Write(pMCBSP0 -> dxr2, right);
}
********************************0513******************************/
nAudioCount++; pWork++;
if ( nAudioCount>=1024 )
{
nAudioCount=0;
pWork=pAudio;
}
}
/********************************0513******************************/
//cWork=uWork>>44;
left=ALawToInt(cWork);
// cWork=uWork&0x0ff;
right=ALawToInt(cWork);
if(speaker==1)
{
wait(60);
Write(pMCBSP0 -> dxr1, left);
Write(pMCBSP0 -> dxr2, right);
}
fclose(fp);
}