Tracktion Engine TimePosition errors

Hi all,

I have been experimenting with some projects that uses tracktion engine. I get some errors when converting beats to X coordinates and time to beats etc. For example, I get “No matching member function for call to ‘timeToBeats’” on this function

double timeToBeat (double t) const
{
return m_edit.tempoSequence.timeToBeats (t);
}

It seems these return TimePosition and needs conversion from a double and I am not sure what is the right way to do that. I have been getting this type of error a lot, another example is the screenshot below where i used int instead of timeDuration. Can someone help me with these i have been trying to figure them out with no success.

Time is strongly typed in Tracktion Engine to avoid seconds/beat ambiguities.
Take a look at the Time/Beat Position/Duration classes here:

Notably:

  • You can compare them to literals with the _tp, _td, _bp, _bd suffixes
  • Get the num beats/seconds from a position/duration with .inSeconds()/.inBeats() functions
  • Create them from a raw number of beats/seconds with TimePosition::fromSeconds (), BeatPosition::fromBeats ()

Hope that helps.

1 Like

@dave96 thank you Dave i fixed some of the errors but i cant figure out how to use the .inSeconds in this code below

viewX1.referTo (state, IDs::viewX1, um, 0);
viewX2.referTo (state, IDs::viewX2, um, 60);
viewY.referTo (state, IDs::viewY, um, 0);

This is the code from EditViewState class from the Tracktion engine demos. The values 0, 60 and 0 have to be in TimePosition rather than in double. Can you provide an example on this code please?

Use 0_tp & 60_tp.