How to remove header of a wavfile in Matlab

时间秒杀一切 提交于 2019-12-07 11:05:31

问题


I need to remove first 1024 bytes of a wave file. I tried to do but I got corrupted/distorted wavfile:

wavFile = fopen(fullFileName, 'r'); % Open file for reading 
fseek (wavFile, 1024, -1);% Skip past header, which is 1024 bytes long.
wF = fread (wavFile, inf, 'int16');% 16-bit signed integers
wF = wF(:)';
newWavFile = fopen(strcat('new_',fileNames(fileNo).name), 'w+');% Open file for reading
fwrite(newWavFile,wF);
fclose(wavFile);

What can be the problem?


回答1:


I could manage to remove header and correct the distortion by :

            wavFile = fopen(fullFileName, 'r');% Open file for reading 
            fseek (wavFile, 1024, -1);% Skip past header, which is 1024 bytes long.
            wF = fread (wavFile, inf, 'int16');% 16-bit signed integers
            wF = wF(:)';
            wF = 0.8*wF/max(abs(wF));
            newWavFile =strcat('1_',fileNames(fileNo).name);% Open file for reading
            wavwrite(wF,16000,16,newWavFile);


来源:https://stackoverflow.com/questions/5369762/how-to-remove-header-of-a-wavfile-in-matlab

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!