Stop audio from playing using sound()
古いコメントを表示
Matlab Online (ver R2018b)
I'm playing some audio using sound(y,Fs) but I can't find a way to stop the audio from playing. You can guess that it gets even worse when you (accidentally) execute the command twice (yes it plays the music over eachother instead of replacing it). Refreshing the page is the only option for now.
p.s.
I know you can use audioplayer(y,Fs) for offline versions but it won't work online.
1 件のコメント
Jan
2022 年 3 月 11 日
The sound() command does call audioplayer() internally in R2018b. So I cannot see a reason to prefer sound() instead or using audioplayer() directly.
採用された回答
その他の回答 (2 件)
Joe V
2019 年 6 月 27 日
The command
clear sound;
works but isn't documented (h/t Li Kang: https://www.mathworks.com/matlabcentral/answers/99704-how-can-i-interrupt-the-playback-of-an-audio-file-that-has-been-initiated-using-wavplay-in-matlab-7#answer_246119)
6 件のコメント
Gabriel Rantung
2020 年 4 月 4 日
Thank you so much!
Kiana Maillet
2020 年 12 月 1 日
thank you !!!!
Marcel-Dennis Boerzel
2022 年 2 月 22 日
works. Thanks!!!
Nguyen Nam
2024 年 4 月 13 日
Thanks.
Alberth Tamo
2024 年 5 月 3 日
Works very well
Theodore
2025 年 9 月 22 日
Thank you.
MUHAMMAD HAIDIEL SHAFIS BIN MAZELAN
2021 年 1 月 6 日
lol u guys can also use this too...
[a, fs] = audioread('yourfilehere.mp3');
plot (a(1:100000,1))
fs =1.0*fs; %%We can adjust our speed of our song by multiplying our fs with any desired numbers.
sound (a,fs);
y = input ('Press 1 to stop the music: ');
while y~=1
fprintf ('You didn''t enter 1 ');
fprintf ('\n');
end
clear sound;
2 件のコメント
Walter Roberson
2021 年 1 月 6 日
If the person does not enter 1, then your while is an infinite loop.
Rik
2021 年 1 月 6 日
Also, the relevant code is equivalent to the other answer. What does this one add?
カテゴリ
ヘルプ センター および File Exchange で Audio and Video Data についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!