フィルターのクリア

issue with running several sound statements...only last statement will play sound

1 回表示 (過去 30 日間)
Franklin
Franklin 2014 年 10 月 16 日
コメント済み: Franklin 2014 年 10 月 16 日
I have 4 sound statements in a row. When program is run, only the last sound statement plays wav file. However if I place a breakpoint at first sound statement and then stepthru, all of them play wav file. Is there a statement that needs to go in between sound statements?
%Listen to the sound at the different stages... sound(anlgSig,origSampRate,resolution); %play the original sound sound(sampledSig, reSampRate,resolution); %play the resampled sound signal sound(quantizedSig,reSampRate,resolution); %play the quantized signal sound(recoveredSig(1:length(quantizedSig)),reSampRate,resolution);%play the recovered sound at the receiver

採用された回答

Geoff Hayes
Geoff Hayes 2014 年 10 月 16 日
Franklin - since your four sound function calls follow one after the other, all four sounds are playing at roughly the same time. You have a couple of options. The first is to put a pause in between each call to sound given the number of samples being played and the sample rate.
% play the original sound
sound(sampledSig, reSampRate,resolution);
pause(ceil(length(sampledSig)/reSampRate));
% play the resampled sound signal
sound(quantizedSig,reSampRate,resolution);
pause(ceil(length(quantizedSig)/reSampRate));
% etc.
The other option is to use the audioplayer
% play the original sound
player = audioplayer(sampledSig, reSampRate,resolution);
playblocking(player);
% play the resampled sound signal
player = audioplayer(quantizedSig,reSampRate,resolution);
playblocking(player);
% etc.
We use the playblocking function to play the sound and not return control until the playback has completed. A nicer alternative to a pause.
  1 件のコメント
Franklin
Franklin 2014 年 10 月 16 日
Thanks for the answer, Geoff!
The plablocking function works great.

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

その他の回答 (0 件)

カテゴリ

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