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.Position

Description

This misleadingly named module provide a way to query a value for its `duration`, `onset` and `offset`.

Synopsis

# The HasPosition class

class HasDuration a => HasPosition a where Source

Class of values that have a position in time.

Many values such as notes, envelopes etc can in fact have many positions such as onset, attack point, offset, decay point time etc. Rather than having separate methods for a discrete set of cases, this class provides an interpolation from a local position to a global position. While the local position goes from 0 to 1, the global position goes from the `onset` to the `offset` of the value.

Should satisfy

```x^.duration   = x^.era.duration
x^.position n = x^.era.position n
(transform s x)^.era = transform s (x^.era)
```

Minimal complete definition

Methods

_position :: a -> Duration -> Time Source

Map a local time in value to global time.

_era :: HasPosition a => a -> Span Source

Return the conventional bounds of a value (local time 0 and 1).

Instances

 HasPosition Span (HasPosition a, Transformable a) => HasPosition [a] (HasPosition a, Transformable a) => HasPosition (Bound a) HasPosition a => HasPosition (AddMeta a) HasPosition (Event a) HasPosition (Score a) (HasDuration v, Transformable v) => HasPosition (Aligned v)

# Position and Era

position :: (HasPosition a, Transformable a) => Duration -> Lens' a Time Source

Position of the given value.

era :: (HasPosition a, Transformable a) => Lens' a Span Source

A lens to the position

## Specific positions

onset :: (HasPosition a, Transformable a) => Lens' a Time Source

Onset of the given value.

midpoint :: (HasPosition a, Transformable a) => Lens' a Time Source

Midpoint of the given value, or the value between the decay and sustain phases.

offset :: (HasPosition a, Transformable a) => Lens' a Time Source

Onset of the given value.

preOnset :: (HasPosition a, Transformable a) => Lens' a Time Source

Pre-onset of the given value, or the value right before the attack phase.

Post-offset of the given value, or the value right after the release phase.

postOnset :: (HasPosition a, Transformable a) => Lens' a Time Source

Deprecated: Use midpoint

# Moving

startAt :: (Transformable a, HasPosition a) => Time -> a -> a Source

Move a value forward in time.

stopAt :: (Transformable a, HasPosition a) => Time -> a -> a Source

Move a value forward in time.

placeAt :: (Transformable a, HasPosition a) => Duration -> Time -> a -> a Source

Align a value to a given position.

`placeAt p t` places the given thing so that its position p is at time t

````placeAt` 0 = `startAt`
`placeAt` 1 = `stopAt`
```