M
magnus.moraberg
Hi,
I wish to read a wave file header which uses different amounts of
bytes to store different pieces of information. For example -
two bytes for the number of channels
four bytes for the length of the raw data.
But since the basic types in c++ are system independent, I'm unsure
how to store these. This is currently how I read the data length -
waveFile.seekg(40);
waveFile.read(reinterpret_cast<char*>(&dataLength), 4);
where dataLength is an unsigned int. This is all well and good while
an int is four bytes, but how would you guys do this?
Am I right in saying that a char is always one byte?
Also, the actually data samples can themselves have different byte
sizes. So lets say I store 10 samples in memory, each 4 bytes in size.
I would use this code to point to a particular sample -
byteSize = 4;
char* sampleBufferPtr = populate(/**/);
sampleBufferPtr(byteSize*sampleIndex)
but how would I convert the sample to a float?
Thanks for your help,
Barry.
I wish to read a wave file header which uses different amounts of
bytes to store different pieces of information. For example -
two bytes for the number of channels
four bytes for the length of the raw data.
But since the basic types in c++ are system independent, I'm unsure
how to store these. This is currently how I read the data length -
waveFile.seekg(40);
waveFile.read(reinterpret_cast<char*>(&dataLength), 4);
where dataLength is an unsigned int. This is all well and good while
an int is four bytes, but how would you guys do this?
Am I right in saying that a char is always one byte?
Also, the actually data samples can themselves have different byte
sizes. So lets say I store 10 samples in memory, each 4 bytes in size.
I would use this code to point to a particular sample -
byteSize = 4;
char* sampleBufferPtr = populate(/**/);
sampleBufferPtr(byteSize*sampleIndex)
but how would I convert the sample to a float?
Thanks for your help,
Barry.