问题
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