Play a wav sound in a loop without blocking it
Mostrar comentarios más antiguos
Hi, i'm new to matlab and am still unclear on what it can and cannot do.
The program I am working on has a loop that displays a flickering pattern at 100Hz. I tried to include the option to trigger a wav sound with a keypress, but it appears that Matlab freezes the loop for the duration of the sound, and restarts it once it's finished.
Is it possible to trigger the sound in a non-blocking way ? Thanks
My code
[y,Fs] = wavread('_path_');
while ( ~program.params.kd(program.params.key.ExitKey))
% frame refresh
if program.params.kd(program.params.key.SoundKey)
wavplay(y, Fs, 'sync');
end
end
Respuesta aceptada
Más respuestas (1)
Vitali Roubtsov
el 14 de Mayo de 2012
0 votos
1 comentario
Jan
el 14 de Mayo de 2012
There are some bugs in AUDIOPLAYER in Matlab 2011b. E.g. when you store an AUDIOPLAYER object persistently, shutting down Matlab causes a crash. See: http://www.mathworks.com/matlabcentral/answers/18530-audioplayer
Categorías
Más información sobre Audio I/O and Waveform Generation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!