Different current samples when playing from the same position in DAWs


In my plugin I used audioPlayHead->getCurrentPosition(currentPositionInfo) to get current time in samples, then a weird thing happened…

When I played from the same position in DAW, for example, 00:00:00.000 in Pro Tools, I got a negative value from the function above, like -418
Then I did it again, it still returned a negative but different value, like -66
The value was different each time, but they were all negative.

I tried in many DAWs: Nuendo for Win, Audition for Win/Mac, Pro Tools for Win/Mac, both VST and AAX, but the results were still the same…

I think it should always return where it exactly is, namely 0.
So why did this happen? Any special mechanism about DAW or JUCE? Is there a way to fix the value?


Is it just pre-roll?


It doesn’t seem pre-roll…
I remember pre-roll and post-roll should be settable on PT panel, but in my case I didn’t set anything and the return value is not stable…


Check the tempo in AudioPlayHead::CurrentPositionInfo is valid… if it’s out of the valid range don’t use the info. Sometimes the info returned won’t be valid in my experience.