issue with running several sound statements...only last statement will play sound
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Franklin
el 16 de Oct. de 2014
Comentada: Franklin
el 16 de Oct. de 2014
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 comentarios
Respuesta aceptada
Geoff Hayes
el 16 de Oct. de 2014
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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Audio and Video Data en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!