Tracktion / tracktion_engine

Tracktion Engine module
Other
1.16k stars 148 forks source link

Add TimePosition double constuctor in seconds #130

Closed jamierpond closed 1 year ago

jamierpond commented 1 year ago

Basically allows constructions of TimeRanges with branced loops, and implicit casting of doubles to TimePositions.

drowaudio commented 1 year ago

I know it seems annoying but I deliberately didn't want to be able to construct a TimePosition from a double. The whole point is that a TimePosition isn't in "seconds" so constructing one from a double is ambiguous. Is the double minutes, hours, frames etc. That's the whole point of the explicit fromSeconds function.

If you're using compile-time constants, you can use the chrono literals to construct them e.g. 1s, 2ms etc.

drowaudio commented 1 year ago

And can't you construct a BarsAndBeats using aggregate initialisation like this: BarsAndBeats ({ numBars })?

jamierpond commented 1 year ago

Hmmm... that's fair. I thought this was probably the case.

BarsAndBeats needed a more explicit constructor since now it's ambiguous whether it's constructing that or a TimeRange.