Detect playback completion in script??


Is there any way to detect from a script that playback has completed?

I’ve noticed that some commands terminate playback while others do not. And it loos like some commands that return results don’t get a response until after playback has completed.

But I’ve not found any way for my script to detect either:

  • playback has completed.
    Ideal - a dedicated ‘completed’ flag/event of some sort.
  • how far playback has got.
    I can get the length of the track/clip with GetInfo. If I could read how far playback had got I could infer playback completion.
  • Audacity ‘status’
    If there was some Audacity status indicator that showed if it was playing or idle, for example, again, I could just monitor that.

Anyone know any way my script can know when playback has finished?


If you are scripting with Audacity’s built in “Macros”, then no.

If you are scripting from an external language such as Python, then the answer is still no, except that in this case it will probably be possible to calculate how long play will last, and tell the scripting language to “sleep” for the required duration.

I would also like a way to know when Audacity becomes idle, and I’m hopeful that such a feature will be added in due course.

It would be nice if a normal Macro could “sleep”, but we’re not likely to see that any time soon as it’s rather tricky to implement. The way that Macros currently work, if the Macro “sleeps”, then it blocks Audacity from doing anything (including playback) until the Macro wakes up again. The Macro code would need to be rewritten to run in a separate “non-blocking” thread from the rest of Audacity.