Playback Position Resolution and Beats

I would like to display the current playback position in bars,beats,ticks and hours:minutes:seconds:ms, like in Waveform.

The only API’s I could find to get the current position are
edit->getTransport().getCurrentPlayhead()->getPosition()
edit->getTransport().getPosition()

When I use either of these APIs, the returned value resolution is lower than I expected. It is only to the hundredths of a second (0.01). In Waveform the transport control is showing values to the millisecond (0.001) , and the tracktionedit files shows clips and notes being stored with sub-ms precision.

Is there a way to get the playback position with sub-ms timing? Or at the very least, how do I get the position with millisecond timing like in waveform?

Also is there an API to get (or convert) the current playback position into bars, beats, ticks?

I’m not sure where you’re getting that it’s only accurate to 0.01s? Both methods are the same value except one is a cached version (TransportControl::getPosition) so may be a little out of date but is better for UI updates etc.

If you look in the PlayHead class you’ll see that the getPosition() is based on the stream time (indirectly) from the DeviceManager which in turn is calculated by the block size and the current sample rate which are all doubles.

Are you perhaps converting it to a string that’s only giving you 0.01s resolution?


For the conversions look at TempoSequence (which Edit has an instance of) and then the timeToBarsBeats method.

Are you perhaps converting it to a string that’s only giving you 0.01s resolution?

Yes that was it. The string class was rounding the double value down to a hundredths of second. The actual double value is not rounded and has super high resolution.

For the conversions look at TempoSequence (which Edit has an instance of) and then the timeToBarsBeats method.

Thanks for pointing me to the API.