Demo window 5. Asynchronous play

If you select a Sound and execute the command

Play

Praat will play the whole sound before proceeding to the next line of your script. You will often instead want Praat to continue running your script while the sound is playing. To accomplish that, use the asynchronous directive:

Create Sound as pure tone: “tone”, 1, 0, 0.2, 44100, 440, 0.2, 0.01, 0.01
asynchronous Play
Remove

The sound will continue to play, even after the Sound object has been removed.

Please note that a following Play command will interrupt the playing of the first:

while demoWaitForInput ()
if demoClicked ()
Create Sound as pure tone: “tone”, 1, 0, 3.0, 44100,
... randomGauss (440, 100), 0.2, 0.01, 0.01
asynchronous Play
Remove
endif
endwhile

The first sound will stop playing soon after the user clicks for the second time.

Links to this page


© Paul Boersma 2009–2023