How do I delay a function ?
Mostrar comentarios más antiguos
Hi, I really need some help with this project. I am making a sequence of frequencies and they are all playing at once when I run the script. I need a way to delay or stop each function so that each function doesn't go until the the preceding one finishes. Thanks. -Thomas
2 comentarios
Stephen23
el 15 de Dic. de 2015
It sounds like these are callback functions, or something similar. Without seeing your code it is impossible for us to know how you are calling these functions. You can upload your code editng your question, clicking the paperclip button, and then clicking both the Choose file and Attach file buttons.
Thomas Lindstaedt
el 16 de Dic. de 2015
Respuestas (1)
Geoff Hayes
el 17 de Dic. de 2015
Thomas - you may want to consider using the audioplayer object to play your audio data as it has the playblocking function call which will play the audio and block (or hold control) until the playback completes (so subsequent lines of code will not execute until the audio has fully played). For example, we can replace your
sound(y);
call with
player = audioplayer(y,Fs);
playblocking(player);
where Fs is the sampling rate (which appears to be 10000 for many of your "notes" to the Star Wars theme). Try integrating the above into your code and see (or hear) what happens!
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!