[Interest] Ultra precise timing in Qt

Nuno Santos nunosantos at imaginando.pt
Sat Apr 23 19:06:38 CEST 2016


Hi,

I have an audio app can sends midi to machines. Midi clock will set the machine tempo. When I have an arpeggiator running in the synth I want the machine to have exactly the same tempo. If the tempo is not the same, both will start to get out of sync. In music that is simply not acceptable.

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.

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. 

Does anyone know the equivalent to mach_absolute_time in Windows and Android (probably the same as linux). 

Regards,

Nuno






More information about the Interest mailing list