PositionInfo in Ableton Live

Hello everyone,

I see something strange when reading the AudioPlayHead::PositionInfo: in an audio plugin in Ableton Live. The first render buffer after a clip start has a wrong position info, the second and all following ones have correct position infos.

Here is a logging that shows the render buffers directly after a play start.
The entry [ 0.021 , 0.043] is the ppq position at the beginning and end of the render buffer.

Process    512  positionInSamples:   156160 buffer start/stop: [  6.492  ,   6.513]  playingHasStarted
Process    512  positionInSamples:      512 buffer start/stop: [  0.021  ,   0.043]  
Process    512  positionInSamples:     1024 buffer start/stop: [  0.043  ,   0.064]  
Process    512  positionInSamples:     1536 buffer start/stop: [  0.064  ,   0.085]  
Process    512  positionInSamples:     2048 buffer start/stop: [  0.085  ,   0.106]  

The funny thing is, when I start in the Arrangement View e.g. in a loop, the position information in the first render buffer is as you would expect:

Process    512  positionInSamples:    24055 buffer start/stop: [  1.000  ,   1.021]  playingHasStarted
Process    512  positionInSamples:    24567 buffer start/stop: [  1.021  ,   1.043]  
Process    512  positionInSamples:    25079 buffer start/stop: [  1.043  ,   1.064]  
Process    512  positionInSamples:    25591 buffer start/stop: [  1.064  ,   1.085]  

Is this a bug or a feature?

Don’t seem to be able to reproduce this - whenever Live isn’t running then timeInSamples is 0. As soon as transport starts running it’s correct - not seeing what you’re seeing.

I think I have found the error in my code. I query the sample time like this:

if (auto t = *getPlayHead()->getPosition()->getTimeInSamples())
{
    mPositionInSamples = t;
}

If getTimeInSamples() returns 0, the If statement evaluates to false and mPositionInSamples is not set.

If I replace auto with the appropriate type, the If statement evaluates to true even if t is 0

if (std::optional<int64_t> t = *getPlayHead()->getPosition()->getTimeInSamples())
{
    mPositionInSamples = t.value();
}
1 Like