Copyright | (c) Hans Hoglund 2012-2014 |
---|---|
License | BSD-style |
Maintainer | hans@hanshoglund.se |
Stability | experimental |
Portability | non-portable (TF,GNTD) |
Safe Haskell | None |
Language | Haskell2010 |
Provides time signatures and related meta-data.
- data TimeSignature
- time :: Integer -> Integer -> TimeSignature
- compoundTime :: [Integer] -> Integer -> TimeSignature
- isSimpleTime :: TimeSignature -> Bool
- isCompoundTime :: TimeSignature -> Bool
- toSimpleTime :: TimeSignature -> TimeSignature
- getTimeSignature :: TimeSignature -> ([Integer], Integer)
- timeSignature :: (HasMeta a, HasPosition a, Transformable a) => TimeSignature -> a -> a
- timeSignatureDuring :: HasMeta a => Span -> TimeSignature -> a -> a
- withTimeSignature :: TimeSignature -> (TimeSignature -> Score a -> Score a) -> Score a -> Score a
- getTimeSignatures :: TimeSignature -> Score a -> Reactive TimeSignature
- getTimeSignatureChanges :: TimeSignature -> Score a -> [(Time, TimeSignature)]
- getBarDurations :: [(TimeSignature, Duration)] -> [Duration]
- getBarTimeSignatures :: [(TimeSignature, Duration)] -> [TimeSignature]
- standardTimeSignature :: Duration -> TimeSignature
Time signature type
data TimeSignature Source
A time signature is a sequence of beat numbers and a note value (i.e. an expression on the
form (a1+a2...)/b
). For simple time signatures just one beat number is used.
TimeSignature is an instance of Fractional
and can be used as
follows:
timeSignature (4/4) timeSignature (6/8) timeSignature ((3+2)/4)
time :: Integer -> Integer -> TimeSignature Source
Create a simple time signature.
compoundTime :: [Integer] -> Integer -> TimeSignature Source
Create a compound time signature.
isSimpleTime :: TimeSignature -> Bool Source
Whether this is a simple time signature.
isCompoundTime :: TimeSignature -> Bool Source
Whether this is a compound time signature.
toSimpleTime :: TimeSignature -> TimeSignature Source
Convert to a simple time signature by adding all numerators. If given a simple time signature, returns it.
getTimeSignature :: TimeSignature -> ([Integer], Integer) Source
Extract the components of a time signature. Semantic function.
Typically used with the ViewPatterns
extension, as in
foo (getTimeSignature -> (beats, noteValue)) = ...
Adding time signature to scores
timeSignature :: (HasMeta a, HasPosition a, Transformable a) => TimeSignature -> a -> a Source
Set the time signature of the given score.
timeSignatureDuring :: HasMeta a => Span -> TimeSignature -> a -> a Source
Set the time signature of the given part of a score.
Extracting time signatures
withTimeSignature :: TimeSignature -> (TimeSignature -> Score a -> Score a) -> Score a -> Score a Source
Extract the time signature from the given score, using the given default time signature.
getTimeSignatures :: TimeSignature -> Score a -> Reactive TimeSignature Source
getTimeSignatureChanges :: TimeSignature -> Score a -> [(Time, TimeSignature)] Source
Utility
getBarDurations :: [(TimeSignature, Duration)] -> [Duration] Source
Given a list of time signatures and the duration between them (TODO use voice), return a list of appropriate bar durations.
getBarTimeSignatures :: [(TimeSignature, Duration)] -> [TimeSignature] Source
Given a list of time signatures and the duration between them (TODO use voice), return a list of appropriate time signatures for each bar.
standardTimeSignature :: Duration -> TimeSignature Source
Time signature typically used for the given duration.