VST timeInSamples off-by-one bug on some hosts


AudioPlayHead::CurrentPositionInfo::timeInSamples is occasionally off by one on some hosts (for example reproduces on REAPER 4.31/x64 on Windows).

This happens because VstTimeInfo::samplePos is given as a “double”, and for example, is sometimes given as 1023.9999999 instead of 1024.
I’m guessing this may be due to hosts internally storing it as time in seconds and converting it to samples via a multiplication.

To fix this problem I changed in the VST wrapper, the line:

info.timeInSamples = (int64) ti->samplePos;


info.timeInSamples = (int64) (ti->samplePos + 0.5);

Happy New Years! Yair

Good one, thanks!

Thanks for solving this; however there are some hosts which are still off-by-one, for instance Cubase when playing a loop -> to handle this, one has to compute and check the result of “previous timestamp + previous number of samples” against “current timestamp”, and tweak it in case of off-by-one detection. I don’t think it’s Juce’s role to have such a tweak.

Does it reproduce easily?
We tried reproducing this over here and it didn’t happen (using Cubase 6.5.1 32-bit on OS X).
Which version of Cubase are you using? Any tips on how to reproduce this? (it’s a really important issue for us)
Thx! Yair

Does it reproduce easily?

Cubase 5.1.0 Windows 44100Hz blocksize 512, loop between t=2s and t=10s, starting after the first automatic rewind of the loop. Which company am I helping? :-p

http://www.soundradix.com :slight_smile:
thx for your help! Yair