music-score-1.8.1: Musical score and part representation.

Copyright(c) Hans Hoglund 2012-2014
LicenseBSD-style
Maintainerhans@hanshoglund.se
Stabilityexperimental
Portabilitynon-portable (TF,GNTD)
Safe HaskellNone
LanguageHaskell2010

Music.Time.Split

Contents

Description

 

Synopsis

Documentation

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) = t min _duration x                    iff t >= 0
_duration (ending t x)    = _duration x - (t min _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)]

Minimal complete definition

Nothing

Methods

split :: Duration -> a -> (a, a) Source

beginning :: Duration -> a -> a Source

ending :: Duration -> a -> a Source

Miscellaneous

splitAbs :: (HasPosition a, Splittable a) => Time -> a -> (a, a) Source

chunks :: (Splittable a, HasDuration a) => Duration -> a -> [a] Source