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 Splittable a where
- splitAbs :: (HasPosition a, Splittable a) => Time -> a -> (a, a)
- chunks :: (Splittable a, HasDuration a) => Duration -> a -> [a]
Documentation
module Music.Time.Position
The Splittable class
class 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
_duration
(beginning
t x) +_duration
(ending
t x) =_duration
x_duration
(beginning
t x) = tmin
_duration
x iff t >= 0_duration
(ending
t x) =_duration
x - (tmin
_duration
x) 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 Span | |
Splittable Duration | |
Splittable Meta | |
Splittable Attribute | |
(HasPosition a, Splittable a) => Splittable (Bound a) | |
Splittable a => Splittable (AddMeta a) | |
(Ord k, Splittable a) => Splittable (Map k a) | |
Splittable (Nominal f a) |
Miscellaneous
splitAbs :: (HasPosition a, Splittable a) => Time -> a -> (a, a) Source
chunks :: (Splittable a, HasDuration a) => Duration -> a -> [a] Source