Skip to content

Commit

Permalink
tools: Add support of reading WAV file with metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
asoulier committed Nov 8, 2023
1 parent 7552605 commit 59cfa05
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tools/wave.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ int wave_read_header(FILE *fp, int *bitdepth, int *samplesize,

fseek(fp, sizeof(format) - (8 + format.size), SEEK_CUR);

if (fread(&data, sizeof(data), 1, fp) != 1
|| data.id != WAVE_DATA_ID)
return -1;
for ( ; fread(&data, sizeof(data), 1, fp) == 1 && data.id != WAVE_DATA_ID
; fseek(fp, data.size, SEEK_CUR) );

if (feof(fp))
return -1;

*bitdepth = format.bitdepth;
*samplesize = format.framesize / format.channels;
Expand Down

0 comments on commit 59cfa05

Please sign in to comment.