Karya, built on 2018-02-23T20:23:55 (patch cf8565b7ac832266878af99a942555d139065f12)

Perform.Lilypond.Meter

Contents

Description

Support for rhythmic spelling in different meters.

Synopsis

# Documentation

data Meter Source #

Constructors

 Meter Fieldsmeter_nums :: ![Int]NonEmpty list of numerators. E.g. [2, 3] indicates 2+3.meter_denom :: !Types.Duration meter_ranks :: !Ranks

Instances

 # Methods(==) :: Meter -> Meter -> Bool #(/=) :: Meter -> Meter -> Bool # # MethodsshowsPrec :: Int -> Meter -> ShowS #show :: Meter -> String #showList :: [Meter] -> ShowS # # MethodsformatList :: [Meter] -> Doc Source # # Methods

Duration of a measure, in Time.

# tie breaking

Figure out how much time a note at the given position should be allowed before it must tie.

The heuristic is:

• A binary meter is one whose numerator is a power of 2.
• First, restrict the maximum allowed_time. For binary meters, this is up to the rank of the start point - 2, which means that if you start on an 8th note, you can span until the next half note. Compound meters are different because the rank divisions don't correspond to binary note divisions (e.g. 34 goes dotted half, quarter, 8th, etc., instead of 44's whole, half, quarter, etc.). So they only go up to the rank-1. This is winds up being too restrictive though, because it means that e.g. you could never span a quarter note if you start on an eighth, but 8 4 8 4 is a perfectly readable 3/4 bar. So the allowed duration is extended to twice the duration to the next rank-1 crossing, which allows 8 8~8 to become 8 4.
• Next, if the allowed duration corresponds exactly to possible note duration, take that. This expresses that it's preferable to spell without a tie if you can. If it doesn't correspond to a note duration, then it has to be tied, and break on the place where it crosses the lowest rank.
• Complex meters like 2+3/4 are treated as binary if you are in the binary part. TODO not yet

See NOTE [tie-breaking heuristic]

data Meter Source #

Constructors

 Meter Fieldsmeter_nums :: ![Int]NonEmpty list of numerators. E.g. [2, 3] indicates 2+3.meter_denom :: !Types.Duration meter_ranks :: !Ranks

Instances

 # Methods(==) :: Meter -> Meter -> Bool #(/=) :: Meter -> Meter -> Bool # # MethodsshowsPrec :: Int -> Meter -> ShowS #show :: Meter -> String #showList :: [Meter] -> ShowS # # MethodsformatList :: [Meter] -> Doc Source # # Methods

Meter rank, indexed by 128th note.

type Rank = Int Source #

Duration of a measure, in Time.

# allowed time

Figure out how much time a note at the given position should be allowed before it must tie.

The heuristic is:

• A binary meter is one whose numerator is a power of 2.
• First, restrict the maximum allowed_time. For binary meters, this is up to the rank of the start point - 2, which means that if you start on an 8th note, you can span until the next half note. Compound meters are different because the rank divisions don't correspond to binary note divisions (e.g. 34 goes dotted half, quarter, 8th, etc., instead of 44's whole, half, quarter, etc.). So they only go up to the rank-1. This is winds up being too restrictive though, because it means that e.g. you could never span a quarter note if you start on an eighth, but 8 4 8 4 is a perfectly readable 3/4 bar. So the allowed duration is extended to twice the duration to the next rank-1 crossing, which allows 8 8~8 to become 8 4.
• Next, if the allowed duration corresponds exactly to possible note duration, take that. This expresses that it's preferable to spell without a tie if you can. If it doesn't correspond to a note duration, then it has to be tied, and break on the place where it crosses the lowest rank.
• Complex meters like 2+3/4 are treated as binary if you are in the binary part. TODO not yet

See NOTE [tie-breaking heuristic]

See allowed_duration.

Find the time of the rank <= the given one. Rank 0 can never be spanned, so always stop at a rank 0.