timeInSamples increments not consistent with getNumSamples() in VST3


I’m having a severe problem with VST3 implementation of a plugin.
processBlock() is been called, consistently with a buffer size of 512 samples, but the timeInSamples increments from getPlayHead()->getCurrentPosition(pos) changes from 511 to 513.

I’m logging getNumSamples(), and timeInSamples in every processBlock() call - so I’m sure the buffer size don’t change from call to call (yes, I know that host may change the buffer size - but is not this case).
Unfortunately, the increments I get in timeInSamples are not coherent with buffer sizes.

Any suggestions, besides trying to detect such incoherencies and overwrite timeInSamples values?


Which host?

Unfortunately, there’s not much can be done about something like this - the host generates that number in whatever way it sees fit…


I’m having this issue with Reaper (I haven’t tested with others)…
I believe that it could be some sort of rounding/truncating bug or similar.
VST works fine.


Yes, probably a rounding error, but we just copy the number that the host provides straight into that struct - if it’s wrong then there’s no chance for the juce wrapper to do anything about that.


beware that timeInSamples is also totally wrong in ableton live when the tempo is automated (IIRC)


I would keep own sample counter in the processor class just to be sure. Initialized when playback is started or when playback position is changed.


What is the best way to detect such events?
Start playing? (first isPlaying == true?)
Stop playing? (first isPlaying==false?)
Position changed during playing?
Position changed while stopped?