run a loop until a sound plays
Mostrar comentarios más antiguos
Hi,
I have written the following code to play a little music while images keep appearing in random order.
The loop now has a simple index going from 1 to 50. However I would like that the random show goes on until the music stops. In other words, I would like to index the loop to the actual duration of the mucis played. There is any way to do that?
Thanks, g.
fullname = 'C:\path of the music file';
[y, Fs] = audioread(fullname);
PO=audioplayer(y,Fs);
play(PO)
for i=1:50
red_shirts = dir('*.png');
numberOfImages = length(red_shirts);
randomIndex = randi(numberOfImages);
randomImage = imread(red_shirts(randomIndex).name);
imshow(randomImage);
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Audio and Video Data en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!