原创 WAV导入Matlab"incorrect chunk size"错误的解决

2009-9-8 11:25 5708 3 3 分类: 通信

我在看《Telecommunication Breakdown Consepts od Communication Transmitted via Software-Defined Radio》第七章 数字滤波和离散傅立叶变换 时遇到了对音频WAV文件进行频谱分析的实例,运行书附光盘的例程,出现了下错误,Google之,从官方寻找解决答案。


Problem Description:


Using the following code:
wavread('myfile.wav')

I receive the following error:
??? Error using ==> wavread
Error using ==> wavread
Incorrect chunk size information in WAV file.


 




Solution:


The WAV-file that you are trying to read is most likely constructed improperly. There are two numbers written into WAV-files that are related to the size of the file itself. If these numbers are incorrect, you will receive this error. 

The following function can fix your WAV-file. However, you should create a backup copy of your file before running the following function since it modifies the file.

function wavchunksizefix( filename )

d = dir(filename);
fileSize = d.bytes;
fid=fopen(filename,'r+','l');
fseek(fid,4,-1);
fwrite(fid,fileSize-8,'uint32');
fseek(fid,40,-1);
fwrite(fid,fileSize-44,'uint32');
fclose(fid);

The function is run this way:

wavchunksizefix('filename.wav')

引用自:http://www.mathworks.com/support/solutions/data/1-1BZMF.html
PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
EE直播间
更多
我要评论
0
3
关闭 站长推荐上一条 /3 下一条