1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
enum ChunkIds
{
CKID_RIFF = MAKEFOURCC('R','I','F','F'),
CKID_WAVE = MAKEFOURCC('W','A','V','E'),
CKID_CUES = MAKEFOURCC('C','U','E','S')
};
...
FILE* f = fopen(....,"rb");
int32 rifftype;// <= ou tout autre type de 32 bits
if (fread(&rifftype,4,1,f) != 1) // <= error
if (rifftype != CKID_RIFF) // <= error
int32 filetype;
if (fread(&filetype,4,1,f) != 1) // <= error
if (filetype != CKID_WAVE) // <= not a WAV file error
// now reading chunks
while(true) {
int32 chunkid;
int32 chunklength;
if (fread(&chunkid,4,1,f) != 1) {
if (feof(f)) break; // <= end of file
// otherwise error
}
if (fread(&chunklength,4,1,f) != 1) // <= error
if (chunkid == CKID_CUES)
readCuesChunk(f,chunklength); // <= will read necessary data
else if (chunkid == CKID_????)
read????Chunk(f,chunklength); // <= will read necessary data
else
fseek(f,chunklength,SEEK_CUR);
} |
Partager