Hi Jon,
thank you very much for your response.
For simplicity, I have used the same example in the code provided by @LukasPsy. After more experiments and tests, I can confirm that the large offset latency occurs with the PTB sound engine and the latency mode set to 4. In some rare cases, the latency can be even up to 50ms.
I was able to fix the issue by using an external sound card (Roland Rubix22). Doing so, the latency drops significantly (2-3 ms average across 5 tones over 100 trials). However, combining the PTB and the external audio card gives rise to a weird phenomenon also described in this thread: Crackling sound with PTB and focusrite audio card - crackling sound not due to the tone volume.
This crackling sound issue can be fixed if one sets the latency mode down to 1 or 2. When the latency mode is back to 3 or 4, the crackling sound occurs again. I could see this as a trade-off and the average offset latency - in my case - is reduced down to an average of 2-3 ms for every sound.
Considering the onset of sounds, I can confirm the sub-millisecond precision (apologies).
In conclusion, at least in my case, the significantly lower offset latencies between tones are provided by the external audio card, whereas the sub-millisecond precision in tones’ onset is provided by the PTB.
kind regards
Giuseppe