hmt-0.15: Haskell Music Theory

Safe Haskell | Safe
Language | Haskell98

Music.Theory.Duration.CT

Contents

- CT
- Indirect

Description

Functions to generate a click track from a metric structure.

Synopsis

- type Measure = Int
- type Pulse = Int
- mdv_to_mrq :: [[RQ]] -> [[RQ]]
- mp_lookup_err :: [[a]] -> (Measure, Pulse) -> a
- mp_compare :: (Measure, Pulse) -> (Measure, Pulse) -> Ordering
- ct_ext :: Int -> a -> [(Measure, a)] -> [(Measure, a)]
- ct_ext1 :: Int -> [(Measure, a)] -> [(Measure, a)]
- ct_dv_seq :: Int -> Tseq Measure Rational_Time_Signature -> [(Measure, [[RQ]])]
- ct_mdv_seq :: Int -> Tseq Measure Rational_Time_Signature -> [[RQ]]
- ct_rq :: Int -> Tseq Measure Rational_Time_Signature -> [[RQ]]
- ct_mp_lookup :: [[RQ]] -> (Measure, Pulse) -> RQ
- ct_m_to_rq :: [[RQ]] -> [(Measure, t)] -> [(RQ, t)]
- ct_mark_seq :: Int -> Tseq Measure Char -> Tseq Measure (Maybe Char)
- ct_pre_mark :: [(Measure, a)] -> [(Measure, Maybe ())]
- ct_pre_mark_seq :: Measure -> Tseq Measure Char -> Tseq Measure (Maybe ())
- ct_tempo_lseq_rq :: [[RQ]] -> Lseq (Measure, Pulse) RQ -> Lseq RQ RQ
- ct_tempo_at :: Lseq RQ RQ -> RQ -> Rational
- data CT_Node
  - = CT_Mark RQ
  - | CT_Start RQ
  - | CT_Normal RQ
  - | CT_Edge RQ
  - | CT_Pre RQ
  - | CT_End
- ct_leadin :: (RQ, Double, Int) -> Dseq Double CT_Node
- delay1 :: [a] -> [a]
- ct_measure :: Lseq RQ RQ -> ([RQ], Maybe Char, Maybe (), [[RQ]]) -> [(Rational, CT_Node)]
- data CT = CT {
  - ct_len :: Int
  - ct_ts :: [(Measure, Rational_Time_Signature)]
  - ct_mark :: [(Measure, Char)]
  - ct_tempo :: Lseq (Measure, Pulse) RQ
  - ct_count :: (RQ, Int)
  }
- ct_tempo0 :: CT -> Maybe RQ
- ct_tempo0_err :: CT -> RQ
- ct_measures :: CT -> [Dseq Rational CT_Node]
- ct_dseq' :: CT -> Dseq Rational CT_Node
- ct_dseq :: CT -> Dseq Double CT_Node
- ct_rq_measure :: [[RQ]] -> RQ -> Maybe Measure
- ct_rq_mp :: [[RQ]] -> RQ -> Maybe (Measure, Pulse)
- ct_rq_mp_err :: [[RQ]] -> RQ -> (Measure, Pulse)
- ct_mp_to_rq :: [[RQ]] -> [((Measure, Pulse), t)] -> [(RQ, t)]

# Documentation

type Measure = Int Source #

1-indexed.

type Pulse = Int Source #

1-indexed.

mdv_to_mrq :: [[RQ]] -> [[RQ]] Source #

Transform measures given as `RQ` divisions to absolute `RQ` locations. mdv abbreviates measure divisions.

    mdv_to_mrq [[1,2,1],[3,2,1]] == [[0,1,3],[4,7,9]]

mp_lookup_err :: [[a]] -> (Measure, Pulse) -> a Source #

Lookup function for (`Measure`,`Pulse`) indexed structure.

mp_compare :: (Measure, Pulse) -> (Measure, Pulse) -> Ordering Source #

Comparison for (`Measure`,`Pulse`) indices.

# CT

ct_ext :: Int -> a -> [(Measure, a)] -> [(Measure, a)] Source #

Latch measures (ie. make measures contiguous, hold previous value).

    unzip (ct_ext 10 'a' [(3,'b'),(8,'c')]) == ([1..10],"aabbbbbccc")

ct_ext1 :: Int -> [(Measure, a)] -> [(Measure, a)] Source #

Variant that requires a value at measure one (first measure).

ct_dv_seq :: Int -> Tseq Measure Rational_Time_Signature -> [(Measure, [[RQ]])] Source #

`rts_divisions` of `ct_ext1`.

ct_mdv_seq :: Int -> Tseq Measure Rational_Time_Signature -> [[RQ]] Source #

`ct_dv_seq` without measures numbers.

ct_rq :: Int -> Tseq Measure Rational_Time_Signature -> [[RQ]] Source #

`mdv_to_mrq` of `ct_mdv_seq`.

ct_mp_lookup :: [[RQ]] -> (Measure, Pulse) -> RQ Source #

ct_m_to_rq :: [[RQ]] -> [(Measure, t)] -> [(RQ, t)] Source #

ct_mark_seq :: Int -> Tseq Measure Char -> Tseq Measure (Maybe Char) Source #

Latch rehearsal mark sequence, only indicating marks. Initial mark is `.`.

    ct_mark_seq 2 [] == [(1,Just '.'),(2,Nothing)]

    let r = [(1,Just '.'),(3,Just 'A'),(8,Just 'B')]
    in filter (isJust . snd) (ct_mark_seq 10 [(3,'A'),(8,'B')]) == r

ct_pre_mark :: [(Measure, a)] -> [(Measure, Maybe ())] Source #

Indicate measures prior to marks.

    ct_pre_mark [] == []
    ct_pre_mark [(1,'A')] == []
    ct_pre_mark [(3,'A'),(8,'B')] == [(2,Just ()),(7,Just ())]

ct_pre_mark_seq :: Measure -> Tseq Measure Char -> Tseq Measure (Maybe ()) Source #

Contiguous pre-mark sequence.

    ct_pre_mark_seq 1 [(1,'A')] == [(1,Nothing)]
    ct_pre_mark_seq 10 [(3,'A'),(8,'B')]

ct_tempo_lseq_rq :: [[RQ]] -> Lseq (Measure, Pulse) RQ -> Lseq RQ RQ Source #

ct_tempo_at :: Lseq RQ RQ -> RQ -> Rational Source #

Interpolating lookup of tempo sequence (`lseq_lookup_err`).

data CT_Node Source #

Types of nodes.

Constructors

CT_Mark RQ | The start of a measure with a rehearsal mark.
CT_Start RQ | The start of a regular measure.
CT_Normal RQ | A regular pulse.
CT_Edge RQ | The start of a pulse group within a measure.
CT_Pre RQ | A regular pulse in a measure prior to a rehearsal mark.
CT_End | The end of the track.

Instances

Eq CT_Node Source # |
Methods (==) :: CT_Node -> CT_Node -> Bool # (/=) :: CT_Node -> CT_Node -> Bool #
Show CT_Node Source # |
Methods showsPrec :: Int -> CT_Node -> ShowS # show :: CT_Node -> String # showList :: [CT_Node] -> ShowS #

ct_leadin :: (RQ, Double, Int) -> Dseq Double CT_Node Source #

Lead-in of `(pulse,tempo,count)`.

delay1 :: [a] -> [a] Source #

Prepend initial element to start of list.

    delay1 "abc" == "aabc"

ct_measure :: Lseq RQ RQ -> ([RQ], Maybe Char, Maybe (), [[RQ]]) -> [(Rational, CT_Node)] Source #

data CT Source #

Click track definition.

Constructors

CT |

Fields

- ct_len :: Int
- ct_ts :: [(Measure, Rational_Time_Signature)]
- ct_mark :: [(Measure, Char)]
- ct_tempo :: Lseq (Measure, Pulse) RQ
- ct_count :: (RQ, Int)

Instances

Show CT Source # |
Methods showsPrec :: Int -> CT -> ShowS # show :: CT -> String # showList :: [CT] -> ShowS #

ct_tempo0 :: CT -> Maybe RQ Source #

Initial tempo, if given.

ct_tempo0_err :: CT -> RQ Source #

Erroring variant.

ct_measures :: CT -> [Dseq Rational CT_Node] Source #

ct_dseq' :: CT -> Dseq Rational CT_Node Source #

ct_dseq :: CT -> Dseq Double CT_Node Source #

# Indirect

ct_rq_measure :: [[RQ]] -> RQ -> Maybe Measure Source #

ct_rq_mp :: [[RQ]] -> RQ -> Maybe (Measure, Pulse) Source #

ct_rq_mp_err :: [[RQ]] -> RQ -> (Measure, Pulse) Source #

ct_mp_to_rq :: [[RQ]] -> [((Measure, Pulse), t)] -> [(RQ, t)] Source #