Multiple sounds played simultaneously
9 ビュー (過去 30 日間)
古いコメントを表示
I have 2 or 3 sounds played in GUI by button. When I push it for the first time sounds aren´t simultaneous.
But when I push the same button for the second time(without closing the app), sounds play at once.
Can anybody tell me why and help me to fix it? I want them to be played at once from the first push.
This is part of my code.. may help.
function HraButton_3Pushed(app, event)
load gong.mat;
fs = 8000;
dt = 1/fs;
t = (0:dt:1);
y1 = sin(2*pi*b1*t);
y2 = sin(2*pi*b2*t);
y3 = sin(2*pi*b3*t); %b1,b2,b3 are some selected frequencies
sound(y1,fs)
sound(y2,fs)
sound(y3,fs)
end
Thank youuuu!
0 件のコメント
採用された回答
Walter Roberson
2020 年 3 月 16 日
sound() never guarantees synchronization.
The first time in a session that you use sound(), it takes time to initialize and start playing. The second time, some of the initialization is already done.
You should be using a single sound() call with the mean() of all of the tones you want to play at the same time.
その他の回答 (0 件)
参考
カテゴリ
Help Center および 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!