Retiming audioclips - how to know when processing is complete?

Hey there

How do we check to see if Tracktion Engine is processing a time stretch, or setup a callback to be notified when time stretch processing is complete?

What I’m trying to solve: You are playing the timeline, you perform a function that time stretches an audio clip. I would like to automatically pause and resume when SoundTouch has finished dealing with the setLength/setPitchChange/setSpeedRatio combo that causes said time stretch. Pause is easy, but restarting playback - how will I know when it’s ready? isRendering() reports zero, so I guess this kind of processing doesnt count as a render.

Currently, the timeline just keep rolling with the clip thats being processed staying silent. This is what I’d expect, it to do which is cool. But in my case I want to halt playback, and only resume when everything is ready - to avoid a user being confused.

Any thoughts or suggestions are much appreciated :slight_smile:
Cheers, J

I figured this out. Happy to share if anyone is interested :slight_smile:

Please share, I have a similar scenario which can benefit a lot from this.
Thanks!

Hey @dikadk13
Nothing too fancy on my end, but what I’m using for now is basically a copy of the delete proxy jobs method but returning true if a proxy generation is in progress.

namespace te = tracktion_engine;


bool isGeneratingProxies()
{
    auto& apg = engine.getAudioFileManager().proxyGenerator;

    for (auto t : te::getClipTracks (*edit))
    {
        for (auto& c : t->getClips())
        {
            if (auto acb = dynamic_cast<te::AudioClipBase*> (c))
            {
                auto af = acb->getPlaybackFile();

                if (apg.isProxyBeingGenerated (af))
                    return true;
            }
        }
    }
}

std::unique_ptr<te::Edit> edit;

This will return true until there are no proxies being generated - so an easy enough way to test what’s happening.

There is also engine.getAudioFileManager().proxyGenerator.getProportionComplete which returns a float, which is promising.

I’m probably going to make some timer method that runs until number of proxies being generated hits 0, and proportions complete == 1.

I didn’t spot any lambdas or broadcasters on the proxy jobs that I could assign or listen to. I might not have been looking properly though.

Hope this helps but also very happy to hear of a better way to do it.

Cheers, Jeff

1 Like