I have a header RiffWav
which stores all the info of the wav file
typedef struct {
unsigned char ChunkID[4];
long ChunkSize;
unsigned char Format[4];
unsigned char SubChunk1ID[4];
unsigned long SubChunk1Size;
unsigned short AudioFormat;
unsigned short NumChannels;
unsigned long SampleRate;
unsigned long BytesRate;
unsigned short BlockAlign;
unsigned short BitsPerSample;
unsigned char SubChunk2ID[4];
unsigned long SubChunk2Size;
} RiffWav;
I use the following functions in order to read the header information about the wav file
RiffWav Header;
InFile = fopen(m_strFileName, "rb");
uint64_t Header_Size = 44;// sizeof(InFile);
CHAR* HeaderBuffer = new CHAR[Header_Size];
fread(HeaderBuffer, 0x01, Header_Size, InFile);
int NumChannels = HeaderBuffer[22] + HeaderBuffer[23];
int BitsPerSample = HeaderBuffer[34] + HeaderBuffer[35];
uint64_t BUFFER_SIZE = HeaderBuffer [40]+ HeaderBuffer[41]+ HeaderBuffer[42]+ HeaderBuffer[43]/ (NumChannels* (BitsPerSample / 8));
CHAR* buffer = new CHAR[BUFFER_SIZE];
The info read thou is mostly wrong like the number of channels returned is 25153 and not 2
EDIT: So after testing with a few different wav files I'm pretty sure that the main issue is that the data read into the buffer is not always in the same order (most wav files are with a few exceptions), so my question now is there a way I can scan the header array after assigning it all the info about the file for the number of channels and all that important stuff