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

Portabilitynon-portable (TF,GNTD)
Stabilityexperimental
Maintainerhans@hanshoglund.se
Safe HaskellNone

Music.Time.Position

Contents

Description

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

Synopsis

Documentation

The HasPosition class

class HasDuration a => HasPosition a whereSource

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.

For instantaneous values, a suitable instance is:

 _position x = const t

For values with an onset and offset we can use alerp:

 _position x = alerp (_onset x) (_offset x)

Methods

_position :: a -> Duration -> TimeSource

Return the onset of the given value, or the value between the attack and decay phases.

_onset, _offset :: a -> TimeSource

Return the onset of the given value, or the value between the attack and decay phases.

Inspecting position

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

A lens to the position

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

Position of the given value.

Specific positions

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

Onset of the given value.

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

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

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

Onset of the given value.

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

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

postOffset :: (HasPosition a, Transformable a) => Lens' a TimeSource

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

Deprecated

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

Deprecated: Use midpoint

Moving to absolute positions

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

Move a value forward in time.

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

Move a value forward in time.

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

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

Internal

_setEra :: (HasPosition a, Transformable a) => Span -> a -> aSource

Place a value over the given span.

placeAt s t places the given thing so that x^.place = s