Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data Tempo = Tempo {}
- origin :: Tempo -> UTCTime
- timeToCount :: Tempo -> UTCTime -> Rational
- countToTime :: Tempo -> Rational -> UTCTime
- changeTempo :: Rational -> UTCTime -> Tempo -> Tempo
- changeTempoNow :: Rational -> Tempo -> IO Tempo
- findBeats :: Tempo -> UTCTime -> UTCTime -> Rational -> Rational -> [Rational]
- findBeats' :: Rational -> Rational -> Rational -> Rational -> [Rational]
- nextBeat :: Rational -> Rational -> Rational -> Rational
Documentation
Musical tempo is represented as a data structure with three orthogonal components. (Generic instances are derived in order to allow later generation of instances for Aeson classes.)
Instances
Eq Tempo Source # | |
Show Tempo Source # | |
Generic Tempo Source # | |
type Rep Tempo Source # | |
Defined in Data.Tempo type Rep Tempo = D1 ('MetaData "Tempo" "Data.Tempo" "tempi-1.0.2.1-73KgPsIVVp7Bl0CxYrVQxw" 'False) (C1 ('MetaCons "Tempo" 'PrefixI 'True) (S1 ('MetaSel ('Just "freq") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Rational) :*: (S1 ('MetaSel ('Just "time") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UTCTime) :*: S1 ('MetaSel ('Just "count") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Rational)))) |
origin :: Tempo -> UTCTime Source #
The origin
of a Tempo is the time at which the number of elapsed cycles/beats
would have been 0.
timeToCount :: Tempo -> UTCTime -> Rational Source #
Given a Tempo and a clock time (UTCTime), timeToCount tells us how many cycles/beats have elapsed at that time.
countToTime :: Tempo -> Rational -> UTCTime Source #
Given a Tempo and a count of elapsed cycles/beats, countToTime tells us when that "beat" will (or would have) take(n) place.
changeTempo :: Rational -> UTCTime -> Tempo -> Tempo Source #
Provided a new frequency and a pivot time, changeTempo modifies a given Tempo as if
the frequency changed at the pivot time, with the count continuing to increase monotonically
changeTempoNow :: Rational -> Tempo -> IO Tempo Source #
For convenience, changeTempoNow is an IO action that changes the frequency of the tempo
now
, ie. at the time returned by a call to getCurrentTime embedded in the action.
findBeats :: Tempo -> UTCTime -> UTCTime -> Rational -> Rational -> [Rational] Source #
Given a tempo, a window defined by two UTCTime-s, a metre (cycles of cycles), and an offset within that metre, findBeats returns all occurrences of the defined metric position within the window. The window is inclusive at the lower limit, and exclusive at the upper limit (so answers can occur exactly at the lower limit but not at the upper limit).
findBeats' :: Rational -> Rational -> Rational -> Rational -> [Rational] Source #
Given a metre and offset (eg. 2 and 0.5 to represent half-way through the first cycle of a metre lasting 2 cycles), and lower and upper limits in elapsed cycles, findBeats' returns all positions that match the given offset and metre and are greater than or equal to the lower limit, and lower than the upper limit.