Hi i have this code for taking as input a wav file and then putting the wah header into a struct and then output it. Everything is good except audioFormat and numChannels but i can't understand why.For example it should output audioFormat: 1 and numChannels: 2 but it outputs audioFormat:0 and numChannels: 1 . I can't understand why this happens.
typedef struct wavHeader
{
byte chunckID[4];
dword chunckSize;
byte format[4];
byte subchunk1ID[4];
word subchunk1Size;
word audioFormat;
word numChannels;
dword sampleRate;
dword byteRate;
word blockAlign;
word bitsPerSample;
byte subchunk2ID[4];
dword subchunk2Size;
}wav_header;
int check_file_name(char *filename);
void list(char **array) //argv
{
wav_header wavHeader;
FILE *pFile;
if(check_file_name(array[2]) == 0)
{
printf("wrong file name\n");
exit(1);
}
pFile = fopen (array[2] ,"r");
if( pFile != NULL)
{
fread(&wavHeader, sizeof(wav_header), 1, pFile);
fclose(pFile);
printf("ChunkID: %c%c%c%c\n",wavHeader.chunckID[0],wavHeader.chunckID[1],wavHeader.chunckID[2],wavHeader.chunckID[3]);
printf("ChunkSize: %d\n",wavHeader.chunckSize);
printf("Format: %c%c%c%c\n",wavHeader.format[0],wavHeader.format[1],wavHeader.format[2],wavHeader.format[3]);
printf("SubChunk1ID: %c%c%c%c\n",wavHeader.subchunk1ID[0],wavHeader.subchunk1ID[1],wavHeader.subchunk1ID[2],wavHeader.subchunk1ID[3]);
printf("Subchunk1Size: %d\n",wavHeader.subchunk1Size);
printf("AudioFormat: %d\n",wavHeader.audioFormat);
printf("NumChannels: %d\n",wavHeader.numChannels);
printf("SampleRate: %d\n",wavHeader.sampleRate);
printf("ByteRate: %d\n",wavHeader.byteRate);
printf("BlockAlign: %d\n",wavHeader.blockAlign);
printf("BitsPerSample: %d\n",wavHeader.bitsPerSample);
printf("Subchunk2ID: %c%c%c%c\n",wavHeader.subchunk2ID[0],wavHeader.subchunk2ID[1],wavHeader.subchunk2ID[2],wavHeader.subchunk2ID[3]);
printf("Subchunk2Size: %d\n",wavHeader.subchunk2Size);
}
else
{
printf("This file doesn't exit\n");
exit(1);
}
}