Karya, built on 2020-11-26T21:03:17 (patch 23b5be2d53a9e8e7d6136cda5aae2849abe5cded)
Safe HaskellNone

Solkattu.Solkattu

Description

Notation for Carnatic solkattu.

This is actually a separate library that's independent of the rest of the sequencer. The only connection is that its final output can be stroke names for some instrument and thus easily inserted into a track.

Solkattu is a general form of rhythmic notation. Since the syllables (sollus) are independent of any particular instrument, they can express general rhythmic structures, which can then be realized in a form idiomatic to different instruments.

The system is split up in a somewhat complicated way to separate rhythmic handling from sollus, and separate realizations sollus to various instruments. The structure from low to high level is:

Solkattu.Tala - General Tala.Tala type.

Solkattu.S - Generic rhythmic framework, where the "payload" note type is abstract. This can express rhythms in terms of S.Speed and S.Nadai, check them against a Tala, and realize down to S.Duration tagged notes.

Solkattu.Solkattu - Fill in a Sequence's note with a Sollu type. This supports all of the notation in Solkattu.Dsl. As Sequence leaves the note type abstract, this leaves the instrument-dependent stroke type abstract.

Solkattu.Realize - This has an instrument-specific Stroke, which is the result of resolving the sollus. The stroke type is still abstract since it's polymorphic over the specific instrument.

Solkattu.Instrument.Mridangam, Solkattu.Instrument.KendangTunggal, etc. - These describe specific instruments for Realize.

Solkattu.Korvai - A Korvai unifies the instrument-specific Patterns and StrokeMaps together with Tala and a solkattu sequence. So I can support multiple instruments from one solkattu score, it merges the stroke types into a single type, and projects out the specific strokes depending on which instrument is being realized.

Solkattu.Dsl.Solkattu - Functions for creating solkattu scores. It defines (or replaces) various operators to make scores look nicer.

Solkattu.Score.Solkattu* - Instrument-independent korvais.

Solkattu.Dsl.Mridangam, Solkattu.Score.Mridangam* - These are similar to Dsl and Score.Solkattu*, except they use concrete mridangam strokes instead of abstract sollus.

The naming convention is that "Note" is the level-specific value, itself may have a "Note" constructor with the "next level" of value. "SNote" is an alias for composing Note with Note, and "Sequence" is an alias for a list of those, but is abstractly the monoid where you can put together notation to form a score.

Synopsis

Documentation

class (Show a, Pretty a) => Notation a where Source #

Render a concrete stroke to text representing it. This is used for ASCII output, so it should produce only a single character per matra duration. There could be exceptions for strokes which are both rare and almost always occur before a rest.

The Show and Pretty superclasses are to make debugging more convenient.

Minimal complete definition

notation

Methods

notation :: a -> Text Source #

notationHtml :: a -> Doc.Html Source #

extension :: a -> Char Source #

Extend the note to fill its time with this character.

Instances

Instances details
Notation Degree # 
Instance details

Defined in Solkattu.Instrument.Sargam

Notation Pitch # 
Instance details

Defined in Solkattu.Instrument.Sargam

Notation Sollu # 
Instance details

Defined in Solkattu.Solkattu

Notation Pattern # 
Instance details

Defined in Solkattu.Solkattu

Notation Stroke # 
Instance details

Defined in Solkattu.Instrument.Sargam

Notation Stroke # 
Instance details

Defined in Solkattu.Instrument.Reyong

Notation Valantalai # 
Instance details

Defined in Solkattu.Instrument.Mridangam

Notation Thoppi # 
Instance details

Defined in Solkattu.Instrument.Mridangam

Notation Stroke # 
Instance details

Defined in Solkattu.Instrument.Mridangam

Notation Stroke # 
Instance details

Defined in Solkattu.Instrument.KendangTunggal

Notation Stroke # 
Instance details

Defined in Solkattu.Instrument.KendangPasang

Notation stroke => Notation (Stroke stroke) # 
Instance details

Defined in Solkattu.Realize

Methods

notation :: Stroke stroke -> Text Source #

notationHtml :: Stroke stroke -> Doc.Html Source #

extension :: Stroke stroke -> Char Source #

Notation stroke => Notation (Note stroke) # 
Instance details

Defined in Solkattu.Realize

Methods

notation :: Note stroke -> Text Source #

notationHtml :: Note stroke -> Doc.Html Source #

extension :: Note stroke -> Char Source #

data Note sollu Source #

Instances

Instances details
Functor Note # 
Instance details

Defined in Solkattu.Solkattu

Methods

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

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

Foldable Note # 
Instance details

Defined in Solkattu.Solkattu

Methods

fold :: Monoid m => Note m -> m #

foldMap :: Monoid m => (a -> m) -> Note a -> m #

foldMap' :: Monoid m => (a -> m) -> Note a -> m #

foldr :: (a -> b -> b) -> b -> Note a -> b #

foldr' :: (a -> b -> b) -> b -> Note a -> b #

foldl :: (b -> a -> b) -> b -> Note a -> b #

foldl' :: (b -> a -> b) -> b -> Note a -> b #

foldr1 :: (a -> a -> a) -> Note a -> a #

foldl1 :: (a -> a -> a) -> Note a -> a #

toList :: Note a -> [a] #

null :: Note a -> Bool #

length :: Note a -> Int #

elem :: Eq a => a -> Note a -> Bool #

maximum :: Ord a => Note a -> a #

minimum :: Ord a => Note a -> a #

sum :: Num a => Note a -> a #

product :: Num a => Note a -> a #

Traversable Note # 
Instance details

Defined in Solkattu.Solkattu

Methods

traverse :: Applicative f => (a -> f b) -> Note a -> f (Note b) #

sequenceA :: Applicative f => Note (f a) -> f (Note a) #

mapM :: Monad m => (a -> m b) -> Note a -> m (Note b) #

sequence :: Monad m => Note (m a) -> m (Note a) #

Eq sollu => Eq (Note sollu) # 
Instance details

Defined in Solkattu.Solkattu

Methods

(==) :: Note sollu -> Note sollu -> Bool #

(/=) :: Note sollu -> Note sollu -> Bool #

Ord sollu => Ord (Note sollu) # 
Instance details

Defined in Solkattu.Solkattu

Methods

compare :: Note sollu -> Note sollu -> Ordering #

(<) :: Note sollu -> Note sollu -> Bool #

(<=) :: Note sollu -> Note sollu -> Bool #

(>) :: Note sollu -> Note sollu -> Bool #

(>=) :: Note sollu -> Note sollu -> Bool #

max :: Note sollu -> Note sollu -> Note sollu #

min :: Note sollu -> Note sollu -> Note sollu #

Show sollu => Show (Note sollu) # 
Instance details

Defined in Solkattu.Solkattu

Methods

showsPrec :: Int -> Note sollu -> ShowS #

show :: Note sollu -> String #

showList :: [Note sollu] -> ShowS #

Pretty sollu => Pretty (Note sollu) # 
Instance details

Defined in Solkattu.Solkattu

Methods

pretty :: Note sollu -> Text Source #

format :: Note sollu -> Doc Source #

formatList :: [Note sollu] -> Doc Source #

S.HasMatras (Note sollu) # 
Instance details

Defined in Solkattu.Solkattu

Methods

matrasOf :: Note sollu -> S.Matra Source #

hasSustain :: Note sollu -> Bool Source #

Rest (Note sollu) # 
Instance details

Defined in Solkattu.Dsl.Notation

Methods

__ :: Note sollu Source #

Rest (SequenceT sollu) # 
Instance details

Defined in Solkattu.Dsl.Notation

Methods

__ :: SequenceT sollu Source #

data Group Source #

A Group is metadata stored alongside the nested sollus, but the actual nesting happens in S.Group. See NOTE [nested-groups] for how I arrived at the design.

Constructors

GReduction !Reduction 
GMeta !Meta 

Instances

Instances details
Eq Group # 
Instance details

Defined in Solkattu.Solkattu

Methods

(==) :: Group -> Group -> Bool #

(/=) :: Group -> Group -> Bool #

Ord Group # 
Instance details

Defined in Solkattu.Solkattu

Methods

compare :: Group -> Group -> Ordering #

(<) :: Group -> Group -> Bool #

(<=) :: Group -> Group -> Bool #

(>) :: Group -> Group -> Bool #

(>=) :: Group -> Group -> Bool #

max :: Group -> Group -> Group #

min :: Group -> Group -> Group #

Show Group # 
Instance details

Defined in Solkattu.Solkattu

Methods

showsPrec :: Int -> Group -> ShowS #

show :: Group -> String #

showList :: [Group] -> ShowS #

Pretty Group # 
Instance details

Defined in Solkattu.Solkattu

Rest (SequenceT sollu) # 
Instance details

Defined in Solkattu.Dsl.Notation

Methods

__ :: SequenceT sollu Source #

data Reduction Source #

Constructors

Reduction 

Fields

Instances

Instances details
Eq Reduction # 
Instance details

Defined in Solkattu.Solkattu

Ord Reduction # 
Instance details

Defined in Solkattu.Solkattu

Show Reduction # 
Instance details

Defined in Solkattu.Solkattu

Pretty Reduction # 
Instance details

Defined in Solkattu.Solkattu

data Meta Source #

Constructors

Meta 

Fields

  • _matras :: !(Maybe S.Matra)

    This is the logical number of Matras the group has. It has to be stored because the number of matras is only accurate relative to the tempo context. For GSarva, this actually defines the duration, which is pretty unfortunate. See flatDuration.

  • _name :: !(Maybe Text)

    Normally name is derived from _matras and _type, but some groups want to override that.

  • _type :: !GroupType

    This determines abstraction level and color highlight in the score.

Instances

Instances details
Eq Meta # 
Instance details

Defined in Solkattu.Solkattu

Methods

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

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

Ord Meta # 
Instance details

Defined in Solkattu.Solkattu

Methods

compare :: Meta -> Meta -> Ordering #

(<) :: Meta -> Meta -> Bool #

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

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

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

max :: Meta -> Meta -> Meta #

min :: Meta -> Meta -> Meta #

Show Meta # 
Instance details

Defined in Solkattu.Solkattu

Methods

showsPrec :: Int -> Meta -> ShowS #

show :: Meta -> String #

showList :: [Meta] -> ShowS #

Pretty Meta # 
Instance details

Defined in Solkattu.Solkattu

data GroupType Source #

Constructors

GTheme

Part of a main theme, should be highlighted prominently.

GFiller

A bit of decorative filler, should be highlighted subtly if at all.

GPattern 
GExplicitPattern

A pattern with sollus already given.

GSarva 
GCheckDuration !S.Duration

Check that this group has the duration in _matras. This group type should be stripped out after the check.

Instances

Instances details
Eq GroupType # 
Instance details

Defined in Solkattu.Solkattu

Ord GroupType # 
Instance details

Defined in Solkattu.Solkattu

Show GroupType # 
Instance details

Defined in Solkattu.Solkattu

Pretty GroupType # 
Instance details

Defined in Solkattu.Solkattu

groupTypes :: [GroupType] Source #

All GroupTypes that should be seen by render. GCheckDuration should have been removed by checkDuration. I could express that in the type, but it seems too noisy for now.

data Side Source #

Before means drop the strokes before the _split split, After means drop the ones after.

Constructors

Before 
After 

Instances

Instances details
Eq Side # 
Instance details

Defined in Solkattu.Solkattu

Methods

(==) :: Side -> Side -> Bool #

(/=) :: Side -> Side -> Bool #

Ord Side # 
Instance details

Defined in Solkattu.Solkattu

Methods

compare :: Side -> Side -> Ordering #

(<) :: Side -> Side -> Bool #

(<=) :: Side -> Side -> Bool #

(>) :: Side -> Side -> Bool #

(>=) :: Side -> Side -> Bool #

max :: Side -> Side -> Side #

min :: Side -> Side -> Side #

Show Side # 
Instance details

Defined in Solkattu.Solkattu

Methods

showsPrec :: Int -> Side -> ShowS #

show :: Side -> String #

showList :: [Side] -> ShowS #

Pretty Side # 
Instance details

Defined in Solkattu.Solkattu

data Space Source #

A note that can take up a variable amount of space. Since it doesn't have set strokes (or any, in the case of Rest), it can be arbitrarily divided.

Constructors

Rest 
Offset

This is not actual rest time in the performance, but inserted in the score for a start offset.

Instances

Instances details
Eq Space # 
Instance details

Defined in Solkattu.Solkattu

Methods

(==) :: Space -> Space -> Bool #

(/=) :: Space -> Space -> Bool #

Ord Space # 
Instance details

Defined in Solkattu.Solkattu

Methods

compare :: Space -> Space -> Ordering #

(<) :: Space -> Space -> Bool #

(<=) :: Space -> Space -> Bool #

(>) :: Space -> Space -> Bool #

(>=) :: Space -> Space -> Bool #

max :: Space -> Space -> Space #

min :: Space -> Space -> Space #

Show Space # 
Instance details

Defined in Solkattu.Solkattu

Methods

showsPrec :: Int -> Space -> ShowS #

show :: Space -> String #

showList :: [Space] -> ShowS #

Pretty Space # 
Instance details

Defined in Solkattu.Solkattu

data NoteT sollu Source #

Constructors

NoteT 

Fields

  • _sollu :: !sollu
     
  • _karvai :: !Bool

    If it's a karvai sollu, and it's followed by a rest, it will replace the rest. Otherwise, it will be replaced by a note.

  • _tag :: !(Maybe Tag)

    Tag a sequence for alternate realization.

Instances

Instances details
Functor NoteT # 
Instance details

Defined in Solkattu.Solkattu

Methods

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

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

Foldable NoteT # 
Instance details

Defined in Solkattu.Solkattu

Methods

fold :: Monoid m => NoteT m -> m #

foldMap :: Monoid m => (a -> m) -> NoteT a -> m #

foldMap' :: Monoid m => (a -> m) -> NoteT a -> m #

foldr :: (a -> b -> b) -> b -> NoteT a -> b #

foldr' :: (a -> b -> b) -> b -> NoteT a -> b #

foldl :: (b -> a -> b) -> b -> NoteT a -> b #

foldl' :: (b -> a -> b) -> b -> NoteT a -> b #

foldr1 :: (a -> a -> a) -> NoteT a -> a #

foldl1 :: (a -> a -> a) -> NoteT a -> a #

toList :: NoteT a -> [a] #

null :: NoteT a -> Bool #

length :: NoteT a -> Int #

elem :: Eq a => a -> NoteT a -> Bool #

maximum :: Ord a => NoteT a -> a #

minimum :: Ord a => NoteT a -> a #

sum :: Num a => NoteT a -> a #

product :: Num a => NoteT a -> a #

Traversable NoteT # 
Instance details

Defined in Solkattu.Solkattu

Methods

traverse :: Applicative f => (a -> f b) -> NoteT a -> f (NoteT b) #

sequenceA :: Applicative f => NoteT (f a) -> f (NoteT a) #

mapM :: Monad m => (a -> m b) -> NoteT a -> m (NoteT b) #

sequence :: Monad m => NoteT (m a) -> m (NoteT a) #

Eq sollu => Eq (NoteT sollu) # 
Instance details

Defined in Solkattu.Solkattu

Methods

(==) :: NoteT sollu -> NoteT sollu -> Bool #

(/=) :: NoteT sollu -> NoteT sollu -> Bool #

Ord sollu => Ord (NoteT sollu) # 
Instance details

Defined in Solkattu.Solkattu

Methods

compare :: NoteT sollu -> NoteT sollu -> Ordering #

(<) :: NoteT sollu -> NoteT sollu -> Bool #

(<=) :: NoteT sollu -> NoteT sollu -> Bool #

(>) :: NoteT sollu -> NoteT sollu -> Bool #

(>=) :: NoteT sollu -> NoteT sollu -> Bool #

max :: NoteT sollu -> NoteT sollu -> NoteT sollu #

min :: NoteT sollu -> NoteT sollu -> NoteT sollu #

Show sollu => Show (NoteT sollu) # 
Instance details

Defined in Solkattu.Solkattu

Methods

showsPrec :: Int -> NoteT sollu -> ShowS #

show :: NoteT sollu -> String #

showList :: [NoteT sollu] -> ShowS #

Pretty sollu => Pretty (NoteT sollu) # 
Instance details

Defined in Solkattu.Solkattu

Methods

pretty :: NoteT sollu -> Text Source #

format :: NoteT sollu -> Doc Source #

formatList :: [NoteT sollu] -> Doc Source #

data Tag Source #

A sollu can have a tag attached. This is used to map certain sets of sollus to a different realization. The idea is that even though the sollus are the same, they may be realized different ways in different contexts.

Constructors

Tag !Int 
Middle

Marks the middle karvai in a tirmanam. This is applied automatically, so it can have an alternate realization.

Standard

Marks a standard pattern. This isolates the "standard pattern" use of common sollus like taka.

Instances

Instances details
Eq Tag # 
Instance details

Defined in Solkattu.Solkattu

Methods

(==) :: Tag -> Tag -> Bool #

(/=) :: Tag -> Tag -> Bool #

Num Tag # 
Instance details

Defined in Solkattu.Solkattu

Methods

(+) :: Tag -> Tag -> Tag #

(-) :: Tag -> Tag -> Tag #

(*) :: Tag -> Tag -> Tag #

negate :: Tag -> Tag #

abs :: Tag -> Tag #

signum :: Tag -> Tag #

fromInteger :: Integer -> Tag #

Ord Tag # 
Instance details

Defined in Solkattu.Solkattu

Methods

compare :: Tag -> Tag -> Ordering #

(<) :: Tag -> Tag -> Bool #

(<=) :: Tag -> Tag -> Bool #

(>) :: Tag -> Tag -> Bool #

(>=) :: Tag -> Tag -> Bool #

max :: Tag -> Tag -> Tag #

min :: Tag -> Tag -> Tag #

Show Tag # 
Instance details

Defined in Solkattu.Solkattu

Methods

showsPrec :: Int -> Tag -> ShowS #

show :: Tag -> String #

showList :: [Tag] -> ShowS #

Pretty Tag # 
Instance details

Defined in Solkattu.Solkattu

note :: sollu -> NoteT sollu Source #

noteOf :: Note sollu -> Maybe (NoteT sollu) Source #

solluOf :: Note sollu -> Maybe sollu Source #

modifyNote :: (NoteT a -> NoteT b) -> Note a -> Note b Source #

newtype Pattern Source #

Constructors

PatternM S.Matra 

Instances

Instances details
Eq Pattern # 
Instance details

Defined in Solkattu.Solkattu

Methods

(==) :: Pattern -> Pattern -> Bool #

(/=) :: Pattern -> Pattern -> Bool #

Ord Pattern # 
Instance details

Defined in Solkattu.Solkattu

Show Pattern # 
Instance details

Defined in Solkattu.Solkattu

Pretty Pattern # 
Instance details

Defined in Solkattu.Solkattu

S.HasMatras Pattern # 
Instance details

Defined in Solkattu.Solkattu

Expr.ToExpr Pattern # 
Instance details

Defined in Solkattu.Solkattu

Notation Pattern # 
Instance details

Defined in Solkattu.Solkattu

data Karvai Source #

Constructors

Karvai 
NotKarvai 

Instances

Instances details
Eq Karvai # 
Instance details

Defined in Solkattu.Solkattu

Methods

(==) :: Karvai -> Karvai -> Bool #

(/=) :: Karvai -> Karvai -> Bool #

Ord Karvai # 
Instance details

Defined in Solkattu.Solkattu

Show Karvai # 
Instance details

Defined in Solkattu.Solkattu

data Sollu Source #

Constructors

NoSollu

a dummy sollu for rests in Konnakol

Dheem 
Dhom 
Di 
Dim 
Din 
Dit 
Du 
Ga 
Gin 
Gu 
Jo 
Ka 
Ki 
Ku 
Kum 
Lang 
Mi 
Na 
Nam 
Nang 
Nu 
Ri 
Ta 
Tam 
Tang 
Tong 
Tat 
Tha 
Thom 
Ti 

Instances

Instances details
Eq Sollu # 
Instance details

Defined in Solkattu.Solkattu

Methods

(==) :: Sollu -> Sollu -> Bool #

(/=) :: Sollu -> Sollu -> Bool #

Ord Sollu # 
Instance details

Defined in Solkattu.Solkattu

Methods

compare :: Sollu -> Sollu -> Ordering #

(<) :: Sollu -> Sollu -> Bool #

(<=) :: Sollu -> Sollu -> Bool #

(>) :: Sollu -> Sollu -> Bool #

(>=) :: Sollu -> Sollu -> Bool #

max :: Sollu -> Sollu -> Sollu #

min :: Sollu -> Sollu -> Sollu #

Show Sollu # 
Instance details

Defined in Solkattu.Solkattu

Methods

showsPrec :: Int -> Sollu -> ShowS #

show :: Sollu -> String #

showList :: [Sollu] -> ShowS #

Pretty Sollu # 
Instance details

Defined in Solkattu.Solkattu

Expr.ToExpr Sollu # 
Instance details

Defined in Solkattu.Instrument.Konnakol

Notation Sollu # 
Instance details

Defined in Solkattu.Solkattu

Expr.ToExpr (Stroke Sollu) # 
Instance details

Defined in Solkattu.Instrument.Konnakol

durations

_durationOf :: (S.HasMatras a, Num dur, Ord dur) => (S.Tempo -> S.Duration -> dur) -> S.Tempo -> [S.Note Group a] -> dur Source #

flatDuration :: S.HasMatras a => S.Flat Group a -> S.Duration Source #

Unfortunately, with Reduction and GSarva groups, the notes don't reflect the actual durations, so for Group-bearing S.Flat, I need a special function. I tried really hard to prevent this but failed. The sollus have to go in the note field, and with reductions and sarva, they no longer correspond exactly to realized strokes. I would have to two note slots, one for a space-filling Group FMatras, and another for the sollus, but since groups can be nested, it gets really head-hurting for my tiny brain.

See NOTE [nested-groups] for chaotic details.

functions

cancelKarvai :: [S.Flat g (Note sollu)] -> [S.Flat g (Note sollu)] Source #

A Karvai Note followed by a Space will replace the rest, if followed by a Note or Pattern, the Karvai will be dropped. Since a Karvai note logically has no duration, if it's the last note it will be dropped

vary

vary Source #

Arguments

:: (S.Matra -> Variations)

variations allowed for this duration

-> [S.Note g (Note sollu)] 
-> [[S.Note g (Note sollu)]] 

Variation means replacing a triad of patterns of the same duration with a an increasing or decreasing sequence. For instance, 666 can become 567, 765, or 777 can become 678 or 579 or their inverses.

TODO Variation on a higher order is also possible, so for instance 777, 777, 777 may become 666, 777, 888

TODO Also we have 5, 55, 555 -> 55, 55, 55 -> 555, 55, 5. This actually applies to more than just Patterns, e.g. 3 as tadin_. I think this is orthogonal and could get a different function.

findTriads :: [S.Note g (Note sollu)] -> [(S.Matra, (Int, Int, Int))] Source #

Find triples of Patterns with the same length and return their indices. The indices are in ascending order.

exceptions

newtype Exception Source #

Yes, I use impure exceptions, because otherwise the DSL has to become monadic or at least applicative. But it seems less egregious because there isn't such a strong distinction between compiling and running anyway.

But it does mean I have to be careful to force and catch at the boundaries.

Constructors

Exception Text 

Instances

Instances details
Eq Exception # 
Instance details

Defined in Solkattu.Solkattu

Show Exception # 
Instance details

Defined in Solkattu.Solkattu

Exception Exception # 
Instance details

Defined in Solkattu.Solkattu

util

applyModifications Source #

Arguments

:: (a -> mod -> a) 
-> [(Int, mod)]

modifications along with their indices, in ascending order

-> [a] 
-> [a] 

permuteFst :: (a -> [b]) -> [(a, x)] -> [[(b, x)]] Source #