[Interest] Ultra precise timing in Qt
Nuno Santos
nunosantos at imaginando.pt
Sat Apr 23 19:46:14 CEST 2016
Alright! Even that I feel completely dumb right now, I’m happy that I don’t need to reinvent the wheel!!! :)
In the mean time, with all of this refactoring I have changes that could probably lead to better timing mechanism.
With this in mind I will do further refactor.
Thanks for your prompt reply.
Regards
Nuno
> On 23 Apr 2016, at 18:20, Thiago Macieira <thiago.macieira at intel.com> wrote:
>
> On sábado, 23 de abril de 2016 18:06:38 PDT Nuno Santos wrote:
>> So far I was using QElapsedTimer to measure this. One particular behaviour I
>> observed was, once I started moving the virtual knobs and faders of the
>> synth, it would start to get out of sync with the machine. My conclusion is
>> that somehow, QElapsedTimer is tied to the event loop thus making it slower
>> when other interactions are happening. Does this make sense? I haven’t
>> looked to QElapsedTimer source code, i’m just guessing. Maybe I’m saying
>> silly things.
>
> Yeah, kinda... Your description above summarises to "the more code I add, the
> more work needs to be done".
>
> The use of QElapsedTimer does not have any further impact on the event loop
> besides executing more code and is not any different from any other further
> addition of code that causes a system call. On some OSes, getting the system
> time is a very fast operation (Linux); on others, it might be slow.
>
>> I search for options and started using mach_absolute_time. The problem seems
>> to be solved now. I have the soft synth running with the arpeggiator
>> enabled sending midi clock to the machine, and they keep their tempo
>> constant, even when the controls are being used or the device is under
>> stress.
>>
>> Does Qt provide any kind of cpu absolute clock for every platform? I
>> couldn’t find it so far.
>
> Yes, it's called QElapsedTimer.
>
>> Does anyone know the equivalent to mach_absolute_time in Windows and Android
>> (probably the same as linux).
>
> On Windows, you use GetTickCount64 or QueryPerformanceCounter. On Android and
> Linux, use clock_gettime for the CLOCK_MONOTONIC or CLOCK_MONOTONIC_COARSE.
>
> Do you know how I know this? I looked into qelapsedtimer_win.cpp and
> qelapsedtimer_unix.cpp.
>
>
> --
> Thiago Macieira - thiago.macieira (AT) intel.com
> Software Architect - Intel Open Source Technology Center
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
More information about the Interest
mailing list