tempi-1.0.2.1: For representing musical tempi

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 Fieldsfreq :: Rational time :: UTCTime count :: Rational

#### Instances

Instances details
 Source # Instance detailsDefined in Data.Tempo Methods(==) :: Tempo -> Tempo -> Bool #(/=) :: Tempo -> Tempo -> Bool # Source # Instance detailsDefined in Data.Tempo MethodsshowsPrec :: Int -> Tempo -> ShowS #show :: Tempo -> String #showList :: [Tempo] -> ShowS # Source # Instance detailsDefined in Data.Tempo Associated Typestype Rep Tempo :: Type -> Type # Methodsfrom :: Tempo -> Rep Tempo x #to :: Rep Tempo x -> Tempo # type Rep Tempo Source # Instance detailsDefined 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))))

The origin of a Tempo is the time at which the number of elapsed cycles/beats would have been 0.

Given a Tempo and a clock time (UTCTime), timeToCount tells us how many cycles/beats have elapsed at that time.

Given a Tempo and a count of elapsed cycles/beats, countToTime tells us when that "beat" will (or would have) take(n) place.

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

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

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.

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.