如何读取“.wav”文件文件存入 MATLAB 中?
我想在 MATLAB 中输入一个波形文件,以便我可以使用过滤器对其进行处理,当我输入名为 wave.wav
的波形文件时,该文件位于我的桌面上,然后我用来
[y, fs, nb] = wavread('wave.wav');
读取wave文件但总是给我一个错误无法打开文件
,我唯一能想到的是该函数不知道wave.wav
的路径,有什么帮助吗? 读取后如何使用 MATLAB 播放该文件,sound()
?
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()
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,你在这两点上都是正确的。使用文件的完整路径,并使用
sound
函数来播放它。有关完整示例,请参阅此参考页。 Mathworks 的文档非常全面。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.这有效:
[y,Fs]=wavread('文件名');
声音(y,Fs);
注意:文件名可以是任何音频文件。但使用从 .mp3 到 .wav 的转换器,因为文件名必须是 wav 格式(很少有人说 waveread 会自动将文件转换为 .wav 文件,但在我的情况下它没有!!)
:)
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!! )
:)
使用文件的完整路径,您可以使用
soundsc(y,fs)
代替sound
来播放声音Use the full path to the file and you can play the sound using
soundsc(y,fs)
insteadsound