Music.Theory.Duration

Description

Common music notation duration model.

Synopsis

# Documentation

data Duration Source #

Common music notation durational model

Constructors

 Duration Fieldsdivision :: Integerdivision of whole notedots :: Integernumber of dotsmultiplier :: Rationaltuplet modifier

Instances

 Source # Methods Source # Ord instance in terms of duration_compare_meq_err. Methods(<) :: Duration -> Duration -> Bool #(>) :: Duration -> Duration -> Bool # Source # MethodsshowList :: [Duration] -> ShowS #

Are multipliers equal?

Is multiplier the identity (ie. 1)?

Compare durations with equal multipliers.

Erroring variant of duration_compare_meq.

no_dots :: (Duration, Duration) -> Bool Source #

True if neither duration is dotted.

Sum undotted divisions, input is required to be sorted.

Sum dotted divisions, input is required to be sorted.

sum_dur_dotted (4,1,4,1) == Just (Duration 2 1 1)
sum_dur_dotted (4,0,2,1) == Just (Duration 1 0 1)
sum_dur_dotted (8,1,4,0) == Just (Duration 4 2 1)
sum_dur_dotted (16,0,4,2) == Just (Duration 2 0 1)

Sum durations. Not all durations can be summed, and the present algorithm is not exhaustive.

import Music.Theory.Duration.Name
sum_dur quarter_note eighth_note == Just dotted_quarter_note
sum_dur dotted_quarter_note eighth_note == Just half_note
sum_dur quarter_note dotted_eighth_note == Just double_dotted_quarter_note

Erroring variant of sum_dur.

Standard divisions (from 0 to 256). MusicXML allows -1 as a division (for long).

Durations set derived from divisions_set with up to k dots. Multiplier of 1.

Table of number of beams at notated division.

Lookup beam_count_tbl.

whole_note_division_to_beam_count 32 == Just 3

Calculate number of beams at Duration.

map duration_beam_count [Duration 2 0 1,Duration 16 0 1] == [0,2]

# MusicXML

Table giving MusicXML types for divisions.

Lookup division_musicxml_tbl.

map whole_note_division_to_musicxml_type [2,4] == ["half","quarter"]

Variant of whole_note_division_to_musicxml_type extracting division from Duration, dots & multipler are ignored.

duration_to_musicxml_type (Duration 4 0 1) == "quarter"

# Unicode

Table giving Unicode symbols for divisions.

Lookup division_unicode_tbl.

map whole_note_division_to_unicode_symbol [1,2,4,8] == "𝅝𝅗𝅥𝅘𝅥𝅘𝅥𝅮"

Give Unicode string for Duration. The duration multiplier is not written.

map duration_to_unicode [Duration 1 2 1,Duration 4 1 1] == ["𝅝𝅭𝅭","𝅘𝅥𝅭"]

# Lilypond

Give Lilypond notation for Duration. Note that the duration multiplier is not written.

map duration_to_lilypond_type [Duration 2 0 1,Duration 4 1 1] == ["2","4."]

# Humdrum

Duration to **recip notation.

http://humdrum.org/Humdrum/representations/recip.rep.html

let d = map (\z -> Duration z 0 1) [0,1,2,4,8,16,32]
in map duration_recip_pp d == ["0","1","2","4","8","16","32"]
let d = [Duration 1 1 (1/3),Duration 4 1 1,Duration 4 1 (2/3)]
in map duration_recip_pp d == ["3.","4.","6."]