I would like to record in ADPCM in my project and play it on my computer.
The problem is that the wav file does not play.
The wav file causes the following error code in the Groove Player for Windows 10: 0xc00d5213
My header file is as follows.
Do you have any idea what I'm doing wrong?
Code: Select all
//ATMEGA128
unsigned char adpcm0[504] = {
'R', 'I', 'F', 'F',
0x70, 0X70, 0X70, 0X70,
'W', 'A', 'V', 'E',
'f', 'm', 't', ' ',
0x14, 0, 0, 0, /* 20 */
0x11, 0, /* IMA ADPCM */
0x01, 0, /* chan */
0x0, 0x0, 0x0, 0x0, /* sampleRate */
0x0, 0x0, 0x0, 0x0, /* byteRate */
0, 1, /* blockAlign */
4, 0, /* bitsPerSample */
2, 0, /* byteExtraData */
0xf9, 0x1, /* samplesPerBlock = 505 */
'f', 'a', 'c', 't', /* subChunk2Id */
0xc8, 0x01, 0, 0, /* subChunk2Size */
0xFF, 0xFF, 0xFF, 0xFF, /* numOfSamples */
};
const unsigned char adpcm504[]={
'd', 'a', 't', 'a',
0xFF, 0xFF, 0xFF, 0xFF
};
void recordtest(){
unsigned char *rbp=file.buf;
int i,k,j=0,l;
vs_write(0x0c,8000);
vs_write(0x0d,0);
vs_write(0x0e,4096);
vs_write(0x0f,0);
delay_ms(500);
create_file();
//header file write
set16(adpcm0+22,1);
set32(adpcm0+24,8000);
set32(adpcm0+28,8000*2*256/505);
set16(adpcm0+32,512);
for(i=52;i<504;i++){
adpcm0[i]=0;
}
f_write(&file,adpcm0,sizeof(adpcm0),&nbyte);
vs_write(0x00,(0<<14)|(1<<12)|(1<<2));
delay_ms(500);
LoadPlugin(plugin,sizeof(plugin)/sizeof(plugin[0]));
delay_ms(500);
f_lseek(&file,512);
while(1){
if(vs_read1(0x09)>512){
rbp=file.buf;
for(i=0;i<256;i++){
k=vs_read1(0x08);
*rbp++=(unsigned char)(k&0xff);
*rbp++=(unsigned char)(k>>8);
}
f_write(&file,file.buf,sizeof(file.buf),&nbyte);
j++;
}
delay_us(100);
if((!sw2)) break;
}
vs_write(0x00,(1<<2));
delay_ms(100);
f_lseek(&file,0);
set32(adpcm0+4, j*512+52);
set32(adpcm0+48, j*505);
f_write(&file,adpcm0,sizeof(adpcm0),&nbyte);
set32(adpcm504+4, j*512);
f_write(&file,adpcm504,sizeof(adpcm504),&nbyte);
vs_write(0x00,(1<<2));
f_close(&file))==FR_OK);
while(1);
}