If you know the structure of the RIFF file, you may already know how PCM sound is stored in it.
- 16- pcm. 2 , ( + ). . , 16- wcm wcm wcm.
16- (short, _int16, int16_t). , , . 2, , . . .
, RIFF , .
, , riff.
, , 10- , 9 * 4 = 36 , 4 , 36 . - , . - . , . , , , (FFT).
:
. ++ Binary File I/O -. , RIFF, , . 44 . .
, 12 ( , , ).
. , ('fmt' 'data'), , .
, :
ifstream myFile ("example.wav", ios::in | ios::binary);
char buffer[12];
myFile.read (buffer, 12);
char chunkName[5];
unsigned long chunksize;
while (myFile.read (chunkName, 4)) {
chunkName[4]='\0';
myFile.read((char*)&chunksize, 4);
myFile.seekg(chunksize, ios_base::cur);
}