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

Copyright(c) Hans Hoglund 2012-2014
LicenseBSD-style
Maintainerhans@hanshoglund.se
Stabilityexperimental
Portabilitynon-portable (TF,GNTD)
Safe HaskellNone
LanguageHaskell2010

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

Instances

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)