How do you keep the sound going? help me please
Mostrar comentarios más antiguos
I saved this code in a script
f = 770;
fs = 24000;
t = 0:1/fs:3;
sori = sin(2*pi*f*t);
sound(sori,fs);
i = input('Please enter a number from 1 to 5.');
com = randi(5)
while i <= com
sound(sori,fs);
i = input('Please enter a number from 1 to 5.');
com = randi(5)
end
if i > com % If you look at the code above, the sound stops when the 'i' number is greater than the 'com' number.
break
end
I hope the sound will continue if the 'i' number is less than or equal to 'com' number.
However, after the duration of the sound is 3 seconds, it will no longer be heard (until you enter a new 'i' number).
So I set the duration of the sound to 10 seconds.
But I set it to 10 seconds,
when the 'i' number entered is greater than 'com' number, the sound does not stop immediately.
Help me. I'm self-taught. Thank you.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Audio and Video Data 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!