How do I delay a function ?
Ältere Kommentare anzeigen
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 Kommentare
Stephen23
am 15 Dez. 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
am 16 Dez. 2015
Antworten (1)
Geoff Hayes
am 17 Dez. 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!
Kategorien
Mehr zu Audio and Video Data finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!