How can I stop the graph , and how can it stip when the song stops?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
function MusicPlay(InfoSongName)
PlayPlaySong = InfoSongName +".mp3";
[VariableSong, Variable] = audioread(PlayPlaySong);
Song = audioplayer(VariableSong, Variable);
PlaySong = input(' Will you like to play the song Yes or No ','s');
while strcmpi(PlaySong, 'Yes') ~= 1 && strcmpi(PlaySong, 'No') ~=1
fprintf(' Selected Yes or No!!! \n')
PlaySong = input(' Will you like to play the song Yes or No ','s');
end
%%
if strcmpi(PlaySong, "Yes")
% NewVariable = audioread(PlayPlaySong);
% plot(NewVariable)
% soundsc(VariableSong, Variable);
filename = PlayPlaySong;
[Y,Fs] = audioread(filename);
TotalTime = length(Y) ./Fs;
t = 0:TotalTime/(length(Y)):TotalTime-TotalTime/length(Y);
sound(Y,Fs)
Y = Y';
var = 50000;
figure
a = 1;
for i = var:1000:length(Y(1, :))
subplot(2,1,1);
plot(t(a:i), Y(1,a:i));
title("Left")
subplot(2,1,2);
plot(t(a:i), Y(2,a:i));
title("Right")
a = i;
% fprintf("%f \n",a);
pause(.75);
end
StopSong = input(' Would you like to stop the song? (Type Yes to stop or anything else to continue) ','s');
while isempty(StopSong) || strcmpi(StopSong, 'Yes') ~= 1
pause(12)
StopSong = input(' Would you like to stop the song? (Type Yes to stop or anything else to continue) ','s');
end
if strcmpi(StopSong ,'Yes')
clear sound
end
elseif strcmpi(PlaySong, "No")
fprintf("\t \n");
fprintf('\t\t "Thank you for using MusicLive". \n');
fprintf('\t \n');
end
% It plays the song and the plots the grpah but it will not stop the
% plotting (graph) when the song ends.
% Also the following code is not printing in the command window!
%{
StopSong = input(' Would you like to stop the song? (Type Yes to stop or anything else to continue) ','s');
while isempty(StopSong) || strcmpi(StopSong, 'Yes') ~= 1
pause(12)
StopSong = input(' Would you like to stop the song? (Type Yes to stop or anything else to continue) ','s');
end
if strcmpi(StopSong ,'Yes')
clear sound
end
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!