MATLAB Answers

Is there a way to open music and play it?

158 views (last 30 days)
Is there a way for MATLAB to read all music files and work like a music player

Accepted Answer

Anton Semechko
Anton Semechko on 5 Jul 2018
Yeah, there is a way. Here is an example:
% Get sample audio file from the web
% Create a 'player' object
% Play audio
% Stop audio
You can find more info about 'audioplayer' here
Walter Roberson
Walter Roberson on 17 Oct 2018
fullname = 'C:\Users\rain\Documents\MATLAB\ProjectGreen\abalone_sound7.wav'; %change as required
[y, Fs] = audioread(fullname);
% Play audio
catch ME
uiwait(msgbox('Could not open that file with audioread'));

Sign in to comment.

More Answers (1)

Rainaire Hansford
Rainaire Hansford on 21 Oct 2018
Yes I got it thank you. Now next step is to implement pause and stop and play in this code cause I really need it lol But Walter your the best
  1 Comment
Walter Roberson
Walter Roberson on 21 Oct 2018
Use play() instead of playblocking() . Then put in a button that uses the pause() method on the audioplayer object.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!