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

Copyright (c) Hans Hoglund 2012-2014 BSD-style hans@hanshoglund.se experimental non-portable (TF,GNTD) None Haskell2010

Music.Time.Split

Description

Synopsis

# 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` = t `min` x^.`duration`                    iff t >= 0

(`ending` t x)^.`duration`    = x^.`duration` - (t `min` 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)]
```

Minimal complete definition

Nothing

Methods

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

beginning :: Duration -> a -> a Source

ending :: Duration -> a -> a Source

Instances

 Splittable () Splittable Duration (Splittable a, Transformable a) => Splittable (Note a) (Transformable a, Splittable a) => Splittable (Voice a) Splittable a => Splittable (AddMeta a)