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 |
- module Music.Time.Position
- class HasDuration a => Splittable a where
- chunks :: (Splittable a, HasDuration a, Transformable a) => Duration -> a -> [a]
Documentation
module Music.Time.Position
The Splittable class
class HasDuration a => Splittable a where Source
Class of values that can be split.
For non-positioned values such as Stretched
, split cuts a value into pieces
of the given duration and the rest.
For positioned values succh as Note
, split cuts a value relative to its onset.
To split at an absolute position, see splitAbs
.
Law
(beginning
t x)^.duration
+ (ending
t x)^.duration
= x^.duration
(beginning
t x)^.duration
= tmin
x^.duration
iff t >= 0 (ending
t x)^.duration
= x^.duration
- (tmin
x^.duration
) iff t >= 0
(Note that any of these three laws can be derived from the other two, so it is sufficient to prove two!).
>>>
(\x -> fmap (flip split x) [-2,-1,0,0.5,1,2]) $ (1::Duration)
[(0,1),(0,1),(0,1),((1/2),(1/2)),(1,0),(1,0)]
>>>
(\x -> fmap (flip split x) [-2,-1,0,0.5,1,2]) $ (0<->1)
[(0 <-> 0,0 <-> 1),(0 <-> 0,0 <-> 1),(0 <-> 0,0 <-> 1),(0 <-> (1/2),(1/2) <-> 1),(0 <-> 1,1 <-> 1),(0 <-> 1,1 <-> 1)]
Nothing
Splittable () | |
Splittable Duration | |
(Splittable a, Transformable a) => Splittable (Note a) | |
(Transformable a, Splittable a) => Splittable (Voice a) | |
Splittable a => Splittable (AddMeta a) |
Miscellaneous
chunks :: (Splittable a, HasDuration a, Transformable a) => Duration -> a -> [a] Source