Unable to play the "audiowrite" file from the folder

9 次查看(过去 30 天)
I have written a downsampled wav file via audiowrite to a folder. I am able to play the sound signal in matlab using "sound(file)". However, I am unable to play it from the folder.
% Code:
Fs = 16000;
Fd=1600;
old = audioread(file);
new = resample(old, Fd, Fs);
sound(new,Fd);
audiowrite(file1, new, Fd);
  2 个评论
Jan
Jan 2017-11-29
Please explain what "playing from a folder" means. Maybe it matters that you use "file" and "file1"? Perhaps you forgot to specify the folder for saving? "sound(file)" does not occur in the posted code, so are you sure that this works?
Prithvi Pani
Prithvi Pani 2017-11-29
编辑:Prithvi Pani 2017-11-29
file (and file1) is already specified to be a wav file (whose path I have not mentioned as it is irrelevant here). Playing from folder means that I am going manually to that path and trying to play it using VLC player (which shows a duration of 2 seconds but plays no sound out) I meant to say "sound(new, Fd)"

请先登录,再进行评论。

回答(1 个)

Jan
Jan 2017-11-29
编辑:Jan 2017-11-29
It does not matter where the data are coming from. So let's narrow down the problem:
Fd = 1600;
new = 1 - 2 * rand(1, 3200);
sound(new, Fd);
audiowrite(file1, new, Fd);
If now Matlab does play the sound, but VLC does not, it is a problem of VLC. Try it:
new2 = audioread(file1);
sound(new2, Fd);
Does it work in Matlab? Then try a different external tool to play the sound. Maybe you have reduced the volume in VLC or "file1" is in a different folder than you expect it to be and you feed VLC with an old (silent) file?

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by