music-score-1.7.1: Musical score and part representation.

Portabilitynon-portable (TF,GNTD)
Stabilityexperimental
Maintainerhans@hanshoglund.se
Safe HaskellNone

Music.Score.Meta.Tempo

Contents

Description

Provides tempo meta-data.

Synopsis

Tempo type

data Tempo Source

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 -> TempoSource

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 NoteValueSource

Get the note value indicated by a tempo.

tempoBeatsPerMinute :: Tempo -> BpmSource

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 -> DurationSource

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 -> aSource

Set the tempo of the given score.

tempoDuring :: HasMeta a => Span -> Tempo -> a -> aSource

Set the tempo of the given part of a score.

Extracting tempo

renderTempo :: Score a -> Score aSource

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)