tempi-1.0.2.1: For representing musical tempi
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Tempo

Synopsis

Documentation

data Tempo Source #

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.)

Constructors

Tempo 

Fields

Instances

Instances details
Eq Tempo Source # 
Instance details

Defined in Data.Tempo

Methods

(==) :: Tempo -> Tempo -> Bool #

(/=) :: Tempo -> Tempo -> Bool #

Show Tempo Source # 
Instance details

Defined in Data.Tempo

Methods

showsPrec :: Int -> Tempo -> ShowS #

show :: Tempo -> String #

showList :: [Tempo] -> ShowS #

Generic Tempo Source # 
Instance details

Defined in Data.Tempo

Associated Types

type Rep Tempo :: Type -> Type #

Methods

from :: Tempo -> Rep Tempo x #

to :: Rep Tempo x -> Tempo #

type Rep Tempo Source # 
Instance details

Defined in Data.Tempo

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.

nextBeat :: Rational -> Rational -> Rational -> Rational Source #

Given a metre, offset, and a lower limit in elapsed cycles, nextBeat returns the next position in cycles that matches the given offset and metre, and is greater than or equal to the lower limit.