issue with running several sound statements...only last statement will play sound
조회 수: 4 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
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.
% 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.
추가 답변 (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!