Best way to cope with inconsistent timeInSamples

Hi All,

I’ve worked out that some of the hosts on iOS report some inconsistent current times. The plugin is fully synced to the host so this has caused some issues. I’ve just released an update which basically ignores the host if it is being inconsistent (see the following code). I worked out that cubasis is out by either 8 or 16 samples each buffer whilst beat maker 3 is out by anything up to about 20 samples. Because of this I have chosen a rather arbitrary value of 30 samples to be the “threshold” to ignore. Has anyone come up with a better way of doing this? Can anyone see anywhere in this which would cause me any problems? It seems a little odd to ignore the host information but it seems to be necessary to actually achieve some kind of consistency!

    if (pos.isPlaying)
    {
        lastTime = timeInSamples + lastBufferSize;
        
        timeInSamples = pos.timeInSamples;
        
        if (lastTime != timeInSamples)
        {
            if (std::abs(timeInSamples-lastTime) < 30 && playback)
            {
                timeInSamples=lastTime;
            }
        }
        playback = true;
    } else
    {
        playback = false;
    }

Thanks,
David