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

Portability non-portable (TF,GNTD) experimental hans@hanshoglund.se None

Music.Time.Reactive

Description

Reactive values, or piecewise functions of time.

Similar to Conal's definition in http://conal.net/blog/posts/reactive-normal-form, but defined in negative time as well. Its semantics function is either `occs` `&&&` `?` or `initial` `&&&` `updates`, where `intial` is the value from negative infinity to the first update.

TODO integrate better in the library

Synopsis

# Documentation

data Reactive a Source

Instances

 Functor Reactive Applicative Reactive HasBehavior Reactive Enum a => Enum (Reactive a) Eq (Reactive b) Floating b => Floating (Reactive b) Fractional b => Fractional (Reactive b) Integral a => Integral (Reactive a) Num a => Num (Reactive a) Ord b => Ord (Reactive b) (Num a, Ord a) => Real (Reactive a) IsString a => IsString (Reactive a) Monoid a => Monoid (Reactive a) Semigroup a => Semigroup (Reactive a) Wrapped (Reactive a) VectorSpace v => VectorSpace (Reactive v) AdditiveGroup v => AdditiveGroup (Reactive v) Delayable (Reactive a) Stretchable (Reactive a)

# Create, isos etc (TODO)

initial :: Reactive a -> aSource

Get the initial value.

final :: Reactive a -> aSource

Get the final value.

type Future a = (Time, a)Source

type Past a = (Time, a)Source

updates :: Reactive a -> [Future a]Source

Get the time of all updates and the value switched to at this point.

occs :: Reactive a -> [Time]Source

Get the time of all updatese.

# Combinators

step :: (AdditiveGroup a, Fractional a) => Reactive aSource

The unit step function, which goes from 0 to 1 at `start`.

switch :: Time -> Reactive a -> Reactive a -> Reactive aSource

`switch t a b` behaves as `a` before time `t`, then as `b`.

trim :: Monoid a => Span -> Reactive a -> Reactive aSource

Replace everthing outside the given span by `mempty`.

trimBefore :: Monoid a => Time -> Reactive a -> Reactive aSource

Replace everthing before the given time by `mempty`.

trimAfter :: Monoid a => Time -> Reactive a -> Reactive aSource

Replace everthing after the given time by `mempty`.