找到你要的答案

Q:Analyzing Wav file format

Q:WAV文件格式分析

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');   

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);

我的问题是在subchunk2size。这是4字节,但我们在这里阅读1。当我使用4,我得到一个错误的结果。

 %41st byte to 43rd byte,length of wav data samples 
    data_size=fread(fid,1);

我也不理解这部分。

  %copy the 16 bit wav data samples starting from 44th byte
    [dta,count]=fread(fid,inf,'uint16');   
answer1: 回答1:

The second argument of fread is a dimension, not a size. Use the third argument instead.

中的第二个参数是一个维度,不是一个尺寸。使用第三个参数代替。

matlab  audio  wav  file-format