Karya, built on Sun Nov 26 01:04:37 PST 2017 (patch 0a920b2bde70c0cbac8ee09d158064798b61bbe5)

Safe HaskellNone

Derive.Solkattu.Sequence

Contents

Description

Low level support for rhythmic sequences in a Tala. The actual Note type is polymorphic, so this is purely rhythmic.

Synopsis

Documentation

data Note g a Source #

Constructors

Note !a 
TempoChange !TempoChange ![Note g a] 
Group !g ![Note g a] 

Instances

Functor (Note g) # 

Methods

fmap :: (a -> b) -> Note g a -> Note g b #

(<$) :: a -> Note g b -> Note g a #

Rest (SNote sollu) # 

Methods

__ :: SNote sollu Source #

Rest (SequenceT sollu) # 

Methods

__ :: SequenceT sollu Source #

(Eq g, Eq a) => Eq (Note g a) # 

Methods

(==) :: Note g a -> Note g a -> Bool #

(/=) :: Note g a -> Note g a -> Bool #

(Ord g, Ord a) => Ord (Note g a) # 

Methods

compare :: Note g a -> Note g a -> Ordering #

(<) :: Note g a -> Note g a -> Bool #

(<=) :: Note g a -> Note g a -> Bool #

(>) :: Note g a -> Note g a -> Bool #

(>=) :: Note g a -> Note g a -> Bool #

max :: Note g a -> Note g a -> Note g a #

min :: Note g a -> Note g a -> Note g a #

(Show g, Show a) => Show (Note g a) # 

Methods

showsPrec :: Int -> Note g a -> ShowS #

show :: Note g a -> String #

showList :: [Note g a] -> ShowS #

(Pretty.Pretty a, Pretty.Pretty g) => Pretty.Pretty (Note g a) # 

Methods

pretty :: Note g a -> Text Source #

format :: Note g a -> Doc Source #

formatList :: [Note g a] -> Doc Source #

newtype Duration Source #

A single Duration unit is equivalent to 1 Akshara.

Constructors

Duration Rational 

type Matra = Int Source #

A matra is an akshara divided by the nadai. It corresponds to a single sollu in first speed, which means the actual duration is dependent on Nadai and Speed.

type Speed = Int Source #

0 means nadai matras per akshara. Positive numbers double that and negative ones halve it.

type Nadai = Int Source #

type Stride = Int Source #

This could be Duration, but it would make normalize_speed tricky.

change_speed :: Speed -> [Note g a] -> Note g a Source #

class HasMatras a where Source #

Minimal complete definition

matras_of, has_duration

Methods

matras_of :: a -> Matra Source #

has_duration :: a -> Bool Source #

True if this note has a duration in time. Otherwise, it's a single stroke, which logically has zero duration. So far, this only affects how the note is drawn.

Instances

HasMatras Pattern # 
HasMatras (Note sollu) # 

Methods

matras_of :: Note sollu -> Matra Source #

has_duration :: Note sollu -> Bool Source #

HasMatras (Note stroke) # 

Methods

matras_of :: Note stroke -> Matra Source #

has_duration :: Note stroke -> Bool Source #

transform

map_group :: (g -> h) -> Note g a -> Note h a Source #

flatten_groups :: [Note g a] -> [Note h a] Source #

simplify :: [Note g a] -> [Note g a] Source #

Drop empty TempoChanges, combine nested ones. Drop empty groups.

map1 :: (a -> a) -> Note g a -> Note g a Source #

Transform only the first Note.

tempo

data Tempo Source #

Constructors

Tempo 

Fields

Instances

flatten

data Meta g Source #

Constructors

Meta 

Fields

  • _mark :: !(Maybe (GroupMark g))

    If Just, this marks the start of a group, with count of elements and polymorphic payload. The count is >=1.

  • _tempo :: !Tempo
     

Instances

Functor Meta # 

Methods

fmap :: (a -> b) -> Meta a -> Meta b #

(<$) :: a -> Meta b -> Meta a #

Eq g => Eq (Meta g) # 

Methods

(==) :: Meta g -> Meta g -> Bool #

(/=) :: Meta g -> Meta g -> Bool #

Show g => Show (Meta g) # 

Methods

showsPrec :: Int -> Meta g -> ShowS #

show :: Meta g -> String #

showList :: [Meta g] -> ShowS #

Pretty.Pretty g => Pretty.Pretty (Meta g) # 

Methods

pretty :: Meta g -> Text Source #

format :: Meta g -> Doc Source #

formatList :: [Meta g] -> Doc Source #

data GroupMark g Source #

Constructors

GroupMark 

Fields

Instances

Functor GroupMark # 

Methods

fmap :: (a -> b) -> GroupMark a -> GroupMark b #

(<$) :: a -> GroupMark b -> GroupMark a #

Eq g => Eq (GroupMark g) # 

Methods

(==) :: GroupMark g -> GroupMark g -> Bool #

(/=) :: GroupMark g -> GroupMark g -> Bool #

Show g => Show (GroupMark g) # 
Pretty.Pretty g => Pretty.Pretty (GroupMark g) # 

notes :: [Note g a] -> [a] Source #

flatten :: [Note g a] -> [(Meta g, a)] Source #

flatten_with :: Tempo -> [Note g a] -> [(Meta g, a)] Source #

tempo_to_state :: HasMatras a => Tala.Tala -> [(Tempo, a)] -> (State, [(State, a)]) Source #

Calculate Tala position for each note.

data Stroke a Source #

Constructors

Attack a 
Sustain a 
Rest 

Instances

Eq a => Eq (Stroke a) # 

Methods

(==) :: Stroke a -> Stroke a -> Bool #

(/=) :: Stroke a -> Stroke a -> Bool #

Show a => Show (Stroke a) # 

Methods

showsPrec :: Int -> Stroke a -> ShowS #

show :: Stroke a -> String #

showList :: [Stroke a] -> ShowS #

Pretty.Pretty a => Pretty.Pretty (Stroke a) # 

normalize_speed :: HasMatras a => Tala.Tala -> [(Meta g, a)] -> [(Maybe (GroupMark g), (State, Stroke a))] Source #

Normalize to the fastest speed, then mark position in the Tala. This normalizes speed, not nadai, because Realize.format lays out notation by nadai, not in absolute time.

State

data State Source #

Keep track of timing and tala position.

Constructors

State 

Fields

functions

note_duration :: HasMatras a => Tempo -> Note g a -> Duration Source #

Flatten the note and return its Duration.

matra_duration :: Tempo -> Duration Source #

Duration of one matra in the given tempo.

data Note g a Source #

Constructors

Note !a 
TempoChange !TempoChange ![Note g a] 
Group !g ![Note g a] 

Instances

Functor (Note g) # 

Methods

fmap :: (a -> b) -> Note g a -> Note g b #

(<$) :: a -> Note g b -> Note g a #

Rest (SNote sollu) # 

Methods

__ :: SNote sollu Source #

Rest (SequenceT sollu) # 

Methods

__ :: SequenceT sollu Source #

(Eq g, Eq a) => Eq (Note g a) # 

Methods

(==) :: Note g a -> Note g a -> Bool #

(/=) :: Note g a -> Note g a -> Bool #

(Ord g, Ord a) => Ord (Note g a) # 

Methods

compare :: Note g a -> Note g a -> Ordering #

(<) :: Note g a -> Note g a -> Bool #

(<=) :: Note g a -> Note g a -> Bool #

(>) :: Note g a -> Note g a -> Bool #

(>=) :: Note g a -> Note g a -> Bool #

max :: Note g a -> Note g a -> Note g a #

min :: Note g a -> Note g a -> Note g a #

(Show g, Show a) => Show (Note g a) # 

Methods

showsPrec :: Int -> Note g a -> ShowS #

show :: Note g a -> String #

showList :: [Note g a] -> ShowS #

(Pretty.Pretty a, Pretty.Pretty g) => Pretty.Pretty (Note g a) # 

Methods

pretty :: Note g a -> Text Source #

format :: Note g a -> Doc Source #

formatList :: [Note g a] -> Doc Source #

newtype Duration Source #

A single Duration unit is equivalent to 1 Akshara.

Constructors

Duration Rational 

type Matra = Int Source #

A matra is an akshara divided by the nadai. It corresponds to a single sollu in first speed, which means the actual duration is dependent on Nadai and Speed.

type Speed = Int Source #

0 means nadai matras per akshara. Positive numbers double that and negative ones halve it.

type Nadai = Int Source #

type Stride = Int Source #

This could be Duration, but it would make normalize_speed tricky.

change_speed :: Speed -> [Note g a] -> Note g a Source #

class HasMatras a where Source #

Minimal complete definition

matras_of, has_duration

Methods

matras_of :: a -> Matra Source #

has_duration :: a -> Bool Source #

True if this note has a duration in time. Otherwise, it's a single stroke, which logically has zero duration. So far, this only affects how the note is drawn.

Instances

HasMatras Pattern # 
HasMatras (Note sollu) # 

Methods

matras_of :: Note sollu -> Matra Source #

has_duration :: Note sollu -> Bool Source #

HasMatras (Note stroke) # 

Methods

matras_of :: Note stroke -> Matra Source #

has_duration :: Note stroke -> Bool Source #

transform

map_group :: (g -> h) -> Note g a -> Note h a Source #

flatten_groups :: [Note g a] -> [Note h a] Source #

simplify :: [Note g a] -> [Note g a] Source #

Drop empty TempoChanges, combine nested ones. Drop empty groups.

map1 :: (a -> a) -> Note g a -> Note g a Source #

Transform only the first Note.

flatten

notes :: [Note g a] -> [a] Source #

flatten :: [Note g a] -> [(Meta g, a)] Source #

data Meta g Source #

Constructors

Meta 

Fields

  • _mark :: !(Maybe (GroupMark g))

    If Just, this marks the start of a group, with count of elements and polymorphic payload. The count is >=1.

  • _tempo :: !Tempo
     

Instances

Functor Meta # 

Methods

fmap :: (a -> b) -> Meta a -> Meta b #

(<$) :: a -> Meta b -> Meta a #

Eq g => Eq (Meta g) # 

Methods

(==) :: Meta g -> Meta g -> Bool #

(/=) :: Meta g -> Meta g -> Bool #

Show g => Show (Meta g) # 

Methods

showsPrec :: Int -> Meta g -> ShowS #

show :: Meta g -> String #

showList :: [Meta g] -> ShowS #

Pretty.Pretty g => Pretty.Pretty (Meta g) # 

Methods

pretty :: Meta g -> Text Source #

format :: Meta g -> Doc Source #

formatList :: [Meta g] -> Doc Source #

data GroupMark g Source #

Constructors

GroupMark 

Fields

Instances

Functor GroupMark # 

Methods

fmap :: (a -> b) -> GroupMark a -> GroupMark b #

(<$) :: a -> GroupMark b -> GroupMark a #

Eq g => Eq (GroupMark g) # 

Methods

(==) :: GroupMark g -> GroupMark g -> Bool #

(/=) :: GroupMark g -> GroupMark g -> Bool #

Show g => Show (GroupMark g) # 
Pretty.Pretty g => Pretty.Pretty (GroupMark g) # 

flatten_with :: Tempo -> [Note g a] -> [(Meta g, a)] Source #

tempo_to_state :: HasMatras a => Tala.Tala -> [(Tempo, a)] -> (State, [(State, a)]) Source #

Calculate Tala position for each note.

data Stroke a Source #

Constructors

Attack a 
Sustain a 
Rest 

Instances

Eq a => Eq (Stroke a) # 

Methods

(==) :: Stroke a -> Stroke a -> Bool #

(/=) :: Stroke a -> Stroke a -> Bool #

Show a => Show (Stroke a) # 

Methods

showsPrec :: Int -> Stroke a -> ShowS #

show :: Stroke a -> String #

showList :: [Stroke a] -> ShowS #

Pretty.Pretty a => Pretty.Pretty (Stroke a) # 

expand_groups :: [Maybe (GroupMark g)] -> [Stroke a] -> [(Int, GroupMark g)] Source #

Re-associate groups with the output of flatten_speed by expanding their _counts. Each group entry corresponds to an Attack Stroke.

normalize_speed :: HasMatras a => Tala.Tala -> [(Meta g, a)] -> [(Maybe (GroupMark g), (State, Stroke a))] Source #

Normalize to the fastest speed, then mark position in the Tala. This normalizes speed, not nadai, because Realize.format lays out notation by nadai, not in absolute time.

flatten_speed :: HasMatras a => [(Tempo, a)] -> ([(Nadai, Stroke a)], Duration) Source #

Normalize to the fastest speed. Fill slower strokes in with rests. Speed 0 always gets at least one Stroke, even if it's not the slowest.

data Tempo Source #

Constructors

Tempo 

Fields

Instances

State

data State Source #

Keep track of timing and tala position.

Constructors

State 

Fields

functions

note_duration :: HasMatras a => Tempo -> Note g a -> Duration Source #

Flatten the note and return its Duration.

matra_duration :: Tempo -> Duration Source #

Duration of one matra in the given tempo.