Euterpea-1.1.1: Library for computer music research and education

Safe HaskellNone
LanguageHaskell98

Euterpea

Synopsis

Documentation

type SEvent = Maybe

SEvent is short for "Stream Event" and is a type synonym for Maybe.

edge :: ArrowCircuit a => a Bool (SEvent ())

edge generates an event whenever the Boolean input signal changes from False to True -- in signal processing this is called an ``edge detector,'' and thus the name chosen here.

accum :: ArrowCircuit a => b -> a (SEvent (b -> b)) b

The signal function (accum v) starts with the value v, but then applies the function attached to the first event to that value to get the next value, and so on.

constA :: Arrow a => c -> a b c

constA is an arrowized version of const.

constSF :: Arrow a => b -> a b d -> a c d

constSF is a convenience composing constA with the given SF.

foldA :: ArrowChoice a => (c -> d -> d) -> d -> a b c -> a [b] d

This essentially allows an arrow that processes b to c to take [b] and recursively generate cs, combining them all into a final output d.

foldSF :: Arrow a => (b -> c -> c) -> c -> [a () b] -> a () c

For folding results of a list of signal functions.

unique :: (Eq e, ArrowCircuit a) => a e (SEvent e)

The signal function unique will produce an event each time its input signal changes.

hold :: ArrowCircuit a => b -> a (SEvent b) b

hold is a signal function whose output starts as the value of the static argument. This value is held until the first input event happens, at which point it changes to the value attached to that event, which it then holds until the next event, and so on.

now :: ArrowCircuit a => a () (SEvent ())

Now is a signal function that produces one event and then forever after produces nothing. It is essentially an impulse function.

mergeE :: (a -> a -> a) -> SEvent a -> SEvent a -> SEvent a

mergeE merges two events with the given resolution function.

delay

Arguments

:: forall (a :: * -> * -> *). ArrowCircuit a 
=> b

the value to return initially.

-> a b b

an arrow that propagates its input with a one-tick delay.

A delay component.

vdelay :: (ArrowReader DeltaT a, ArrowCircuit a) => a (DeltaT, SEvent b) (SEvent b)

vdelay is a delay function that delays for a variable amount of time. It takes the current time, an amount of time to delay, and an event stream and delays the event stream by the delay amount. vdelay, like fdelay, guarantees that the order of events in is the same as the order of events out and that no event will be skipped. If the events are too dense or the delay argument drops too quickly, some events may be over delayed.

fdelay :: (ArrowReader DeltaT a, ArrowCircuit a) => DeltaT -> a (SEvent b) (SEvent b)

fdelay is a delay function that delays for a fixed amount of time, given as the static argument. It returns a signal function that takes the current time and an event stream and delays the event stream by the delay amount. fdelay guarantees that the order of events in is the same as the order of events out and that no event will be skipped. However, if events are too densely packed in the signal (compared to the clock rate of the underlying arrow), then some events may be over delayed.

timer :: (ArrowReader DeltaT a, ArrowCircuit a) => a DeltaT (SEvent ())

timer is a variable duration timer. This timer takes the current time as well as the (variable) time between events and returns an SEvent steam. When the second argument is non-positive, the output will be a steady stream of events. As long as the clock speed is fast enough compared to the timer frequency, this should give accurate and predictable output and stay synchronized with any other timer and with time itself.

genEvents :: (ArrowReader DeltaT a, ArrowCircuit a) => [b] -> a DeltaT (SEvent b)

genEvents is a timer that instead of returning unit events returns the next element of the input list. When the input list is empty, the output stream becomes all Nothing.

type Time = Double

Time is simply represented as a Double.

type DeltaT = Double

DeltaT is a type synonym referring to a change in Time.