I want to read a wav file & change its bit per sample rate(from 16 to 32). But my program is not copying entire file. Source file is 175KB where as destination file is only 2KB. Bits per sample is at 34 bytes from beginning.
My code is:-
#include<stdio.h>
void main()
{
FILE *fp,*fo;
char ch,ch1;
int j=0,s=0,arr[4],k=0;
long int i=0;
fp=fopen("msoft.wav","rb");
fo=fopen("dest.wav","wb");
while(1)
{
i=i+1;
ch=fgetc(fp);
if(ch==EOF)break;
else
{
if(i==34)
{
while(i<=35)
{
ch=fgetc(fp);
arr[j]=ch;
i++;
j++;
}
for(k=0;k<2;k++)
printf("\n%d",arr[k]);
s=arr[1];
s=(s<<8)+arr[0];
printf("\n\nS=%d",s);
s=s*2;
printf("\n new s=%d",s);
ch1=s & 255;
fputc(ch1,fo);
ch1=s & (255<<8);
fputc(ch1,fo);
}
else
fputc(ch,fo);
}
}
printf("\nOk");
getch();
}
Please help.