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 tempo meta-data.
- type Bpm = Duration
- type NoteValue = Duration
- data Tempo
- metronome :: Duration -> Bpm -> Tempo
- tempoNoteValue :: Tempo -> Maybe NoteValue
- tempoBeatsPerMinute :: Tempo -> Bpm
- getTempo :: Tempo -> (NoteValue, Bpm)
- tempoToDuration :: Tempo -> Duration
- tempo :: (HasMeta a, HasPosition a) => Tempo -> a -> a
- tempoDuring :: HasMeta a => Span -> Tempo -> a -> a
- presto :: Tempo
- allegro :: Tempo
- allegretto :: Tempo
- moderato :: Tempo
- andante :: Tempo
- adagio :: Tempo
- largo :: Tempo
- lento :: Tempo
- renderTempo :: Score a -> Score a
Tempo type
Represents musical tempo as a scaling factor with an optional name and/or beat duration.
tempoToDuration
provides a scaling factor such that
stretch (tempoToDuration t) notation = sounding compress (tempoToDuration t) sounding = notation
You can construct a tempo in various ways
tempoToDuration (metronome (1/4) 120) == tempoToDuration (metronome (1/2) 60) metronome (1/4) 120 /= metronome (1/2) 60
metronome :: Duration -> Bpm -> Tempo Source
Create a tempo from a duration and a number of beats per minute.
For example metronome (1/2) 48
means 48 half notes per minute.
tempoNoteValue :: Tempo -> Maybe NoteValue Source
Get the note value indicated by a tempo.
tempoBeatsPerMinute :: Tempo -> Bpm Source
Get the number of beats per minute indicated by a tempo.
getTempo :: Tempo -> (NoteValue, Bpm) Source
Get the note value and number of beats per minute indicated by a tempo.
Typically used with the ViewPatterns
extension, as in
foo (getTempo -> (nv, bpm)) = ...
tempoToDuration :: Tempo -> Duration Source
Convert a tempo to a duration suitable for converting written to sounding durations.
stretch (tempoToDuration t) notation = sounding compress (tempoToDuration t) sounding = notation
Adding tempo to scores
tempo :: (HasMeta a, HasPosition a) => Tempo -> a -> a Source
Set the tempo of the given score.
tempoDuring :: HasMeta a => Span -> Tempo -> a -> a Source
Set the tempo of the given part of a score.
Common tempi
Extracting tempo
renderTempo :: Score a -> Score a Source
Extract all tempi from the given score, using the given default tempo. withTempo :: (Tempo -> Score a -> Score a) -> Score a -> Score a withTempo f = withMeta (f . fromMaybe def . fmap getFirst . getOption)