sound is coming after the picture has disappeared

1 回表示 (過去 30 日間)
Muazma Ali
Muazma Ali 2022 年 3 月 11 日
コメント済み: Muazma Ali 2022 年 3 月 11 日
Hi
The sound is still coming up though the picture has disappeared. I want the sound to be there as long as the picture is displayed. How can I manage that? :)
function welcome()
img=imread('Borehole_collapse_ny.png');
image(img);
x=0;
y=0;
width=1.0 ;% measured relative to the figure width
height=1.0; % measured relative to figure height
set(gca, 'units', 'normalized','position',[x y width height])
n=5;
x=rand(1,7000);
sound(x,8000);
pause(n);
close
end
  2 件のコメント
KSSV
KSSV 2022 年 3 月 11 日
You can clear the signal used in sound to stop it.
Muazma Ali
Muazma Ali 2022 年 3 月 11 日
I didnt understand it; clear by writing what and where..?

サインインしてコメントする。

回答 (1 件)

Jan
Jan 2022 年 3 月 11 日
編集済み: Jan 2022 年 3 月 11 日
x = (rand(1, 70000) - 0.5) * 0.1;
sound(x, 8000);
pause(1)
clear('sound'); % Undocumented
The sound() command calls the modern audioplayer internally. So it is cleaner to use it directly:
a = audioplayer(x, 8000, 16);
play(a)
pause(1);
stop(a)
  1 件のコメント
Muazma Ali
Muazma Ali 2022 年 3 月 11 日
Thanks I will try this , :)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by