Karya, built on 2023-08-29T07:47:28 (patch 7a412d5d6ba4968ca4155ef276a062ccdeb9109a)
Safe HaskellSafe-Inferred

Ui.ScoreTime

Synopsis

Documentation

data ScoreTime Source #

Score time is the abstract unit of time, and its mapping to real time is dependent on the score context. ScoreTime units can be negative, but blocks only display events at >=0 ScoreTime.

Instances

Instances details
Num ScoreTime Source # 
Instance details

Defined in Ui.ScoreTime

Read.Read ScoreTime Source # 
Instance details

Defined in Ui.ScoreTime

Fractional ScoreTime Source # 
Instance details

Defined in Ui.ScoreTime

Real ScoreTime Source # 
Instance details

Defined in Ui.ScoreTime

RealFrac ScoreTime Source # 
Instance details

Defined in Ui.ScoreTime

Show ScoreTime Source # 
Instance details

Defined in Ui.ScoreTime

C.CStorable ScoreTime Source # 
Instance details

Defined in Ui.ScoreTime

DeepSeq.NFData ScoreTime Source # 
Instance details

Defined in Ui.ScoreTime

Methods

rnf :: ScoreTime -> () #

Eq ScoreTime Source # 
Instance details

Defined in Ui.ScoreTime

Ord ScoreTime Source # 
Instance details

Defined in Ui.ScoreTime

Time ScoreTime Source # 
Instance details

Defined in Derive.Deriver.Internal

ToVal ScoreTime Source # 
Instance details

Defined in Derive.REnv

Methods

to_val :: ScoreTime -> Val Source #

ShowVal.ShowVal ScoreTime Source # 
Instance details

Defined in Ui.ScoreTime

ToVal ScoreTime Source # 
Instance details

Defined in Derive.Typecheck

Methods

to_val :: ScoreTime -> Val Source #

Typecheck ScoreTime Source # 
Instance details

Defined in Derive.Typecheck

TypecheckNum ScoreTime Source # 
Instance details

Defined in Derive.Typecheck

Pretty ScoreTime Source # 
Instance details

Defined in Ui.ScoreTime

Seed.Seed ScoreTime Source # 
Instance details

Defined in Ui.ScoreTime

Methods

to_seed :: Int -> ScoreTime -> Int Source #

Serialize.Serialize ScoreTime Source # 
Instance details

Defined in Ui.ScoreTime

ApproxEq.ApproxEq ScoreTime Source # 
Instance details

Defined in Ui.ScoreTime

Methods

eq :: Double -> ScoreTime -> ScoreTime -> Bool Source #

type TrackTime = ScoreTime Source #

This is also ScoreTime, but it's relative to the beginning of the track. I.e., UI events are all in track time, but when they get shifted and stretched as by note slicing they're no longer in TrackTime, but not yet in RealTime.

I'd like to make a type-level distinction because it's easy to get confused about whether a time has or hasn't been transformed, but when I tried it seemed like a big hassle since I'd really like for TrackTime to be a subtype of ScoreTime. I could do it with a phantom type, but it would change about a million type declarations. And since Events start in TrackTime but are then ScoreTime if transformed, they would also need a type parameter, along with probably a few other basic data types.

Unless I work up the courage to do that someday, the least I can do is document the difference with a type synonym.

round :: ScoreTime -> ScoreTime Source #

Traditionally, time would be an integral type with a highly composite number as the unit. This is so that common musical durations such as 1/3, 16, or 164 can be represented exactly. However, while this is good enough for the score, it's insufficiently accurate for derivation, which uses ScoreTime to shift and stretch events.

A principled solution would probably be to use an integral type for UI events in Events.Events and convert to floating point on derivation. However, that seems like a hassle and simply rounding the event's start and durations when they go into the track should achieve the same effect.

suffix :: Char Source #

t is for time, since RealTime uses s for seconds

eta :: ScoreTime Source #

Eta for comparison. ScoreTimes are all relative, but there's no reason to use such tiny ones.

(==) :: ScoreTime -> ScoreTime -> Bool Source #

ScoreTimes are imprecise, so compare them with this instead of (==).

(>) :: ScoreTime -> ScoreTime -> Bool Source #

True if the second is greater than the first - eta. This can be used to determine if the start of an event has passed, while giving a little bit of extra allowance if its close enough.

(<=) :: ScoreTime -> ScoreTime -> Bool Source #

True if the second is greater than the first - eta. This can be used to determine if the start of an event has passed, while giving a little bit of extra allowance if its close enough.

is_negative :: ScoreTime -> Bool Source #

Unlike <0, this counts -0 as negative.