필터 지우기
필터 지우기

How can I stop the graph , and how can it stip when the song stops?

조회 수: 1 (최근 30일)
Enrico
Enrico 2023년 4월 2일
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개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by