Copyright | (c) Antony Courtney and Henrik Nilsson Yale University 2003 |
---|---|

License | BSD-style (see the LICENSE file in the distribution) |

Maintainer | ivan.perez@keera.co.uk |

Stability | provisional |

Portability | non-portable (GHC extensions) |

Safe Haskell | None |

Language | Haskell98 |

Discrete to continuous-time signal functions.

## Synopsis

- hold :: a -> SF (Event a) a
- dHold :: a -> SF (Event a) a
- trackAndHold :: a -> SF (Maybe a) a
- dTrackAndHold :: a -> SF (Maybe a) a
- accum :: a -> SF (Event (a -> a)) (Event a)
- accumHold :: a -> SF (Event (a -> a)) a
- dAccumHold :: a -> SF (Event (a -> a)) a
- accumBy :: (b -> a -> b) -> b -> SF (Event a) (Event b)
- accumHoldBy :: (b -> a -> b) -> b -> SF (Event a) b
- dAccumHoldBy :: (b -> a -> b) -> b -> SF (Event a) b
- accumFilter :: (c -> a -> (c, Maybe b)) -> c -> SF (Event a) (Event b)

# Wave-form generation

Zero-order hold.

Converts a discrete-time signal into a continuous-time signal, by holding the last value until it changes in the input signal. The given parameter may be used for time zero, and until the first event occurs in the input signal, so hold is always well-initialized.

`>>>`

[1,1,2,2,3,3]`embed (hold 1) (deltaEncode 0.1 [NoEvent, NoEvent, Event 2, NoEvent, Event 3, NoEvent])`

dHold :: a -> SF (Event a) a #

Zero-order hold with a delay.

Converts a discrete-time signal into a continuous-time signal, by holding
the last value until it changes in the input signal. The given parameter is
used for time zero (until the first event occurs in the input signal), so
`dHold`

shifts the discrete input by an infinitesimal delay.

`>>>`

[1,1,1,2,2,3]`embed (dHold 1) (deltaEncode 0.1 [NoEvent, NoEvent, Event 2, NoEvent, Event 3, NoEvent])`

trackAndHold :: a -> SF (Maybe a) a #

Tracks input signal when available, holding the last value when the input
is `Nothing`

.

This behaves similarly to `hold`

, but there is a conceptual difference, as
it takes a signal of input `Maybe a`

(for some `a`

) and not `Event`

.

`>>>`

[1,1,2,2,3,3]`embed (trackAndHold 1) (deltaEncode 0.1 [Nothing, Nothing, Just 2, Nothing, Just 3, Nothing])`

dTrackAndHold :: a -> SF (Maybe a) a #

Tracks input signal when available, holding the last value when the input is `Nothing`

,
with a delay.

This behaves similarly to `hold`

, but there is a conceptual difference, as
it takes a signal of input `Maybe a`

(for some `a`

) and not `Event`

.

`>>>`

[1,1,1,2,2,3]`embed (dTrackAndHold 1) (deltaEncode 0.1 [Nothing, Nothing, Just 2, Nothing, Just 3, Nothing])`

# Accumulators

accumHold :: a -> SF (Event (a -> a)) a #

Zero-order hold accumulator (always produces the last outputted value until an event arrives).

dAccumHold :: a -> SF (Event (a -> a)) a #

Zero-order hold accumulator with delayed initialization (always produces the last outputted value until an event arrives, but the very initial output is always the given accumulator).

accumBy :: (b -> a -> b) -> b -> SF (Event a) (Event b) #

Accumulator parameterized by the accumulation function.

accumHoldBy :: (b -> a -> b) -> b -> SF (Event a) b #

Zero-order hold accumulator parameterized by the accumulation function.

dAccumHoldBy :: (b -> a -> b) -> b -> SF (Event a) b #

Zero-order hold accumulator parameterized by the accumulation function with delayed initialization (initial output sample is always the given accumulator).