Safe Haskell | Safe-Inferred |
---|
Types to describe meters.
A meter ruler divides up a block analogous to a staff notation meter. It's actually more general, since the meter just says how to divide up a single measure, and only at one level, while the ruler has arbitrary divisions. However, in practice, it's convenient to use a similar organization to staff notation's meter. So by convention the ranks are for section, measure, half note, etc., and Cmd.TimeStep uses abbreviated mnemonics of these durations for the various ruler ranks it can snap to.
However, rank r_2
, which corresponds to TimeStep's
, doesn't
necessarily correspond to a half note. It actually corresponds to the
division below the measure, which in 3+3/8 is a dotted quarter. In the
case of 2/4 it would be a quarter note, but to keep the mnemonic names from
getting too far from their staff notation counterparts, the 2/4 meter
should skip a rank so that h
r_1
and r_2
both correspond to the same
amount of time.
Synopsis
- data Meter = Meter {
- meter_config :: !Config
- meter_sections :: ![MSection]
- data MSection = MSection {}
- type Measures = Int
- meter :: Config -> [MSection] -> Meter
- meter_end :: Meter -> TrackTime
- empty_meter :: Meter
- modify_config :: (Config -> Config) -> Meter -> Meter
- set_sections :: [MSection] -> Meter -> Meter
- modify_sections :: ([MSection] -> [MSection]) -> Meter -> Meter
- sections_split :: TrackTime -> [MSection] -> ([MSection], [MSection])
- sections_drop :: TrackTime -> [MSection] -> [MSection]
- sections_take :: TrackTime -> [MSection] -> [MSection]
- section_starts :: [MSection] -> [(Duration, MSection)]
- type Duration = TrackTime
- time_to_duration :: TrackTime -> Duration
- data Config = Config {}
- default_config :: Config
- data Rank
- all_ranks :: [Rank]
- rank_names :: [(Rank, Text)]
- rank_name :: Rank -> Text
- data LabelConfig
- type Label = Text
- data AbstractMeter
- = T
- | D [AbstractMeter]
- subdivide :: Int -> AbstractMeter -> AbstractMeter
- subdivides :: [Int] -> AbstractMeter -> AbstractMeter
- repeat :: Int -> AbstractMeter -> AbstractMeter
- repeats :: [Int] -> AbstractMeter -> AbstractMeter
- regular_subdivision :: [Int] -> AbstractMeter
- meter_length :: AbstractMeter -> Int
Documentation
Duration is of one AbstractMeter, so total duration will be count*dur.
Meter | |
|
MSection | |
|
empty_meter :: Meter Source #
sections_drop :: TrackTime -> [MSection] -> [MSection] Source #
Trimming the AbstractMeter from the start will change the labels, but that's probably desired everywhere except a pickup.
type Duration = TrackTime Source #
Duration between ruler marks. Since these are added together, there is
a risk of accumulating innaccuracy. I could use rationals if I changed
PosMark
to rational, but for the moment it's more convenient to
stay as TrackTime, and convert to rationals before adding, assuming that
TrackTime has enough resolution to figure out what the rational should be.
TODO If I get more inaccuracy problems I should probably just switch to rational, but it's a bit of a pain because Ruler.Marklist and its callers have to change. Also, I'm not even sure if it's a good idea, because TrackTime is still floating point, so there will still be rounding in there somewhere, and this would just put it in more places.
time_to_duration :: TrackTime -> Duration Source #
TODO it's id for now, but maybe I'll want to make it Rational at some point?
Config | |
|
Instances
rank_names :: [(Rank, Text)] Source #
These are mnemonics for staff notation durations, though they may not correspond exactly, as documented in Cmd.Meter.
data LabelConfig Source #
Instances
Show LabelConfig Source # | |
Defined in Ui.Meter.Meter showsPrec :: Int -> LabelConfig -> ShowS # show :: LabelConfig -> String # showList :: [LabelConfig] -> ShowS # | |
Eq LabelConfig Source # | |
Defined in Ui.Meter.Meter (==) :: LabelConfig -> LabelConfig -> Bool # (/=) :: LabelConfig -> LabelConfig -> Bool # | |
Pretty.Pretty LabelConfig Source # | |
Defined in Ui.Meter.Meter pretty :: LabelConfig -> Text Source # format :: LabelConfig -> Doc Source # formatList :: [LabelConfig] -> Doc Source # | |
Serialize LabelConfig Source # | |
Defined in Cmd.Serialize put :: Putter LabelConfig Source # get :: Get LabelConfig Source # |
AbstractMeter
data AbstractMeter Source #
An AbstractMeter is a structured description of how a unit of time is
broken up into hiererchical sections. A T
represents a mark with the
unit duration, and a D
is a group of Meters. The rank of each mark is
determined by its nesting depth.
Previously a T
could take a duration, but I didn't wind up using that
feature, so I removed it. So meters have to be built of multiples of a
unit duration multiplied by some stretch factor.
An AbstractMeter can be created either by declaring it outright, or by declaring a simpler AbstractMeter and subdividing or repeating it.
T | |
D [AbstractMeter] |
Instances
Show AbstractMeter Source # | |
Defined in Ui.Meter.Meter showsPrec :: Int -> AbstractMeter -> ShowS # show :: AbstractMeter -> String # showList :: [AbstractMeter] -> ShowS # | |
Eq AbstractMeter Source # | |
Defined in Ui.Meter.Meter (==) :: AbstractMeter -> AbstractMeter -> Bool # (/=) :: AbstractMeter -> AbstractMeter -> Bool # | |
Pretty.Pretty AbstractMeter Source # | |
Defined in Ui.Meter.Meter pretty :: AbstractMeter -> Text Source # format :: AbstractMeter -> Doc Source # formatList :: [AbstractMeter] -> Doc Source # | |
Serialize AbstractMeter Source # | |
Defined in Cmd.Serialize put :: Putter AbstractMeter Source # get :: Get AbstractMeter Source # |
subdivide :: Int -> AbstractMeter -> AbstractMeter Source #
Subdivide each mark into the given number D
s. This has the effect of
putting one layer of subdivision under the current structure.
subdivides :: [Int] -> AbstractMeter -> AbstractMeter Source #
repeat :: Int -> AbstractMeter -> AbstractMeter Source #
Create a layer that repeats the given meter a certain number of times.
repeats :: [Int] -> AbstractMeter -> AbstractMeter Source #
regular_subdivision :: [Int] -> AbstractMeter Source #
Form a meter based on regular subdivision. E.g. [4, 4] is 4 groups of 4, [3, 3] is like 9/8, and [4, 3] is 4 groups of 3 (12/8).
meter_length :: AbstractMeter -> Int Source #