I need to separate data and Subchunk2Size in a Wav file.
I'm trying to use a ready code for this part of my MATLAB code but I can't understand what's going on here.
This is my source for analyzing a Wav file. enter link description here
In this part, I understand that the 40bytes header is stored in header
.
%first 40 bytes make wav header,store the header
header=fread(fid,40);
My problem is here with Subchunk2Size
. It's 4 bytes but here we are reading 1
. When I use 4 I get a wrong result.
%41st byte to 43rd byte,length of wav data samples
data_size=fread(fid,1);
I can't understand this part either.
%copy the 16 bit wav data samples starting from 44th byte
[dta,count]=fread(fid,inf,'uint16');
The second argument of
fread
is a dimension, not a size. Use the third argument instead.