Error when trying to play mp3 file

24 vues (au cours des 30 derniers jours)
Rohan Thomas
Rohan Thomas le 1 Déc 2022
So for some reason this was working perfectly a couple hours ago, but now it seems like I cant play any audio files at all. Whenever I run the code, I get "Device error: invalid number of channels". Anyone know why?
heres the code:
A test I did with 1 file (same error)
[y, Fs] = audioread('old-victory-sound-roblox.mp3');
Error using audioread>readaudio
The filename specified was not found in the MATLAB path.

Error in audioread (line 160)
[y, Fs] = readaudio (filename, range, datatype);
player = audioplayer(y, Fs);
play(player)
this is my og code that was working before:
[y,Fs]=audioread('old-victory-sound-roblox.mp3');
pw =audioplayer(y,Fs);
[y,Fs]=audioread('gaming-sound-effect-hd.mp3');
pl =audioplayer(y,Fs);
[y,Fs]=audioread('Kids Cheering - Gaming Sound Effect (HD).mp3');
wn =audioplayer(y,Fs);

Réponse acceptée

Walter Roberson
Walter Roberson le 2 Déc 2022
Your current directory is not one where old-victory-sound-roblox.mp3 can be found.
It is recommended that you construct fully qualified file names. For example,
sounddir = 'C:\Users\Rohan\Desktop\MATLAB\project7b\samples';
file1 = fullfile(sounddir, 'old-victory-sound-roblox.mp3');
file2 = fullfile(sounddir, 'gaming-sound-effect-hd.mp3' );
file3 = fullfile(sounddir, 'Kids Cheering - Gaming Sound Effect (HD).mp3');
[y1, Fs1] = audioread(file1);
pw = audioplayer(y1, Fs1);
[y2, Fs2] = audioread(file2);
pl = audioplayer(y2, Fs2);

Plus de réponses (0)

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by