Copyright | (c) Hans Hoglund 2012-2014 |
---|---|
License | BSD-style |
Maintainer | hans@hanshoglund.se |
Stability | experimental |
Portability | non-portable (TF,GNTD) |
Safe Haskell | None |
Language | Haskell2010 |
- data Score a
- score :: Getter [Event a] (Score a)
- events :: Lens (Score a) (Score b) [Event a] [Event b]
- eras :: Traversal' (Score a) Span
- triples :: Lens (Score a) (Score b) [(Time, Duration, a)] [(Time, Duration, b)]
- mapWithSpan :: (Span -> a -> b) -> Score a -> Score b
- filterWithSpan :: (Span -> a -> Bool) -> Score a -> Score a
- mapFilterWithSpan :: (Span -> a -> Maybe b) -> Score a -> Score b
- mapTriples :: (Time -> Duration -> a -> b) -> Score a -> Score b
- filterTriples :: (Time -> Duration -> a -> Bool) -> Score a -> Score a
- mapFilterTriples :: (Time -> Duration -> a -> Maybe b) -> Score a -> Score b
- hasOverlappingEvents :: Score a -> Bool
- simultaneous :: (Transformable a, Semigroup a) => Score a -> Score a
- normalizeScore :: Score a -> Score a
- removeRests :: Score (Maybe a) -> Score a
- printEras :: Score a -> IO ()
- unsafeEvents :: Iso (Score a) (Score b) [Event a] [Event b]
- unsafeTriples :: Iso (Score a) (Score b) [(Time, Duration, a)] [(Time, Duration, b)]
Score type
A Score
is a sequential or parallel composition of values, and allows overlapping events
Query
Construction
eras :: Traversal' (Score a) Span Source
Print all eras of the given score.
>>>
toListOf eras $ scat [c,d,e :: Score Integer]
[0 <-> 1,1 <-> 2,2 <-> 3]
triples :: Lens (Score a) (Score b) [(Time, Duration, a)] [(Time, Duration, b)] Source
View a score as a list of time-duration-value triplets.
Traversal
mapWithSpan :: (Span -> a -> b) -> Score a -> Score b Source
Map over the values in a score.
mapFilterWithSpan :: (Span -> a -> Maybe b) -> Score a -> Score b Source
Combination of mapTriples
and filterTriples
.
mapTriples :: (Time -> Duration -> a -> b) -> Score a -> Score b Source
Map over the values in a score.
filterTriples :: (Time -> Duration -> a -> Bool) -> Score a -> Score a Source
Filter the values in a score.
mapFilterTriples :: (Time -> Duration -> a -> Maybe b) -> Score a -> Score b Source
Efficient combination of mapTriples
and filterTriples
.
Simultaneous
hasOverlappingEvents :: Score a -> Bool Source
simultaneous :: (Transformable a, Semigroup a) => Score a -> Score a Source
Merge all simultaneous events using their Semigroup
instance.
Normalize
normalizeScore :: Score a -> Score a Source
Normalize a score, assuring its events spans are all forward (as by isForwardSpan
),
and that its onset is at least zero. Consequently, the onset and offset of each event
in the score is at least zero.
removeRests :: Score (Maybe a) -> Score a Source