Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Common music notation duration model.
Synopsis
- type Division = Integer
- type Dots = Int
- data Duration = Duration {}
- duration_meq :: Duration -> Duration -> Bool
- duration_m1 :: Duration -> Bool
- duration_compare_meq :: Duration -> Duration -> Maybe Ordering
- duration_compare_meq_err :: Duration -> Duration -> Ordering
- no_dots :: (Duration, Duration) -> Bool
- sum_dur_undotted :: Rational -> (Division, Division) -> Maybe Duration
- sum_dur_dotted :: Rational -> (Division, Dots, Division, Dots) -> Maybe Duration
- sum_dur :: Duration -> Duration -> Maybe Duration
- sum_dur_err :: Duration -> Duration -> Duration
- divisions_std_set :: [Division]
- divisions_musicxml_set :: [Division]
- duration_set :: Dots -> [Duration]
- beam_count_tbl :: [(Division, Int)]
- whole_note_division_to_beam_count :: Division -> Maybe Int
- duration_beam_count :: Duration -> Int
- division_musicxml_tbl :: [(Division, String)]
- whole_note_division_to_musicxml_type :: Division -> String
- duration_to_musicxml_type :: Duration -> String
- division_unicode_tbl :: [(Integer, Char)]
- whole_note_division_to_unicode_symbol :: Division -> Char
- duration_to_unicode :: Duration -> String
- duration_to_lilypond_type :: Duration -> String
- duration_recip_pp :: Duration -> String
- whole_note_division_name_tbl :: [(Division, String)]
- whole_note_division_name :: Division -> Maybe String
- whole_note_division_letter_tbl :: [(Division, Char)]
- whole_note_division_letter_pp :: Division -> Maybe Char
- duration_letter_pp :: Duration -> Maybe String
Documentation
Common music notation durational model
duration_m1 :: Duration -> Bool Source #
Is multiplier the identity (ie. 1
)?
duration_compare_meq :: Duration -> Duration -> Maybe Ordering Source #
Compare durations with equal multipliers.
duration_compare_meq_err :: Duration -> Duration -> Ordering Source #
Erroring variant of duration_compare_meq
.
sum_dur_undotted :: Rational -> (Division, Division) -> Maybe Duration Source #
Sum undotted divisions, input is required to be sorted.
sum_dur_dotted :: Rational -> (Division, Dots, Division, Dots) -> Maybe Duration Source #
Sum dotted divisions, input is required to be sorted.
sum_dur_dotted 1 (4,1,4,1) == Just (Duration 2 1 1) sum_dur_dotted 1 (4,0,2,1) == Just (Duration 1 0 1) sum_dur_dotted 1 (8,1,4,0) == Just (Duration 4 2 1) sum_dur_dotted 1 (16,0,4,2) == Just (Duration 2 0 1)
sum_dur :: Duration -> Duration -> Maybe Duration Source #
Sum durations. Not all durations can be summed, and the present algorithm is not exhaustive.
import Music.Theory.Duration 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
divisions_std_set :: [Division] Source #
Standard divisions (from 1 to 256). MusicXml allows 0 for breve and -1 for long. Negative divisors can represent any number of longer durations, -2 be a breve, -4 a long, -8 a maximus, &etc.
duration_set :: Dots -> [Duration] Source #
Durations set derived from divisions_std_set
with up to k dots. Multiplier of 1
.
beam_count_tbl :: [(Division, Int)] Source #
Table of number of beams at notated division.
whole_note_division_to_beam_count :: Division -> Maybe Int Source #
Lookup beam_count_tbl
.
whole_note_division_to_beam_count 32 == Just 3
duration_beam_count :: Duration -> Int Source #
Calculate number of beams at Duration
.
map duration_beam_count [Duration 2 0 1,Duration 16 0 1] == [0,2]
MusicXml
division_musicxml_tbl :: [(Division, String)] Source #
Table giving MusicXml types for divisions.
whole_note_division_to_musicxml_type :: Division -> String Source #
Lookup division_musicxml_tbl
.
map whole_note_division_to_musicxml_type [2,4] == ["half","quarter"]
duration_to_musicxml_type :: Duration -> String Source #
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
division_unicode_tbl :: [(Integer, Char)] Source #
Table giving Unicode
symbols for divisions.
whole_note_division_to_unicode_symbol :: Division -> Char Source #
Lookup division_unicode_tbl
.
map whole_note_division_to_unicode_symbol [1,2,4,8] == "𝅝𝅗𝅥𝅘𝅥𝅘𝅥𝅮"
duration_to_unicode :: Duration -> String Source #
Give Unicode string for Duration
. The duration multiplier is not written.
map duration_to_unicode [Duration 1 2 1,Duration 4 1 1] == ["𝅝𝅭𝅭","𝅘𝅥𝅭"]
Lilypond
duration_to_lilypond_type :: Duration -> String Source #
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_recip_pp :: Duration -> String Source #
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] 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)] map duration_recip_pp d == ["3.","4.","6."]
Letter
whole_note_division_name_tbl :: [(Division, String)] Source #
Names for note divisions. Starting from 1/32 these names haev uniqe initial letters that can be used for concise notation.