How to read a “.wav” file into MATLAB?

假如想象 提交于 2019-12-09 23:34:23

问题


I wanted to input a wave file in the MATLAB so that I could process it using filters, when I come to input the wave file called wave.wav, this file is located on my desktop, and then I used

[y, fs, nb] = wavread('wave.wav');

to read the wave file but always gives me an error cannot open file, the only thing I can think of is that the function doesnt know the path of the wave.wav, any help? And how can I play the file also using MATLAB after read, sound()?


回答1:


Yes, you are correct on both counts. Use the full path to the file, and use the sound function to play it back. See this reference page for a thorough example. The documentation from the Mathworks is quite comprehensive.




回答2:


This works: [y,Fs]=wavread('filename'); sound(y,Fs);

note: the filename could be any audio file. but use a converter from .mp3 to .wav coz filename must be in wav format( few even say that waveread converts the file automatically into .wav file but in my case it did not!! ) :)




回答3:


Use the full path to the file and you can play the sound using soundsc(y,fs) instead sound



来源:https://stackoverflow.com/questions/6319870/how-to-read-a-wav-file-into-matlab

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