Maintainer | Ertugrul Soeylemez <es@ertes.de> |
---|

Various signal analysis tools

- avg :: forall e v (>~). (Fractional v, Unbox v, WirePure >~) => Int -> Wire e >~ v v
- avgAll :: forall e v (>~). (Fractional v, WirePure >~) => Wire e >~ v v
- avgFps :: (Arrow (Wire e >~), Fractional t, Unbox t, WirePure >~, WWithDT t >~) => Int -> Wire e >~ a t
- avgFpsInt :: (Arrow (Wire e >~), Fractional t, Unbox t, WirePure >~, WSampleInt >~, WWithDT t >~) => Int -> Int -> Wire e >~ a t
- highPeak :: (Ord b, WirePure >~) => Wire e >~ b b
- lowPeak :: (Ord b, WirePure >~) => Wire e >~ b b
- peakBy :: forall b e (>~). WirePure >~ => (b -> b -> Ordering) -> Wire e >~ b b
- collect :: forall b e (>~). (Ord b, WirePure >~) => Wire e >~ b (Set b)
- diff :: forall b e (>~). (Eq b, Monoid e, WirePure >~) => Wire e >~ b b
- firstSeen :: forall a e t (>~). (Ord a, WirePure >~, WWithSysTime t >~) => Wire e >~ a t
- lastSeen :: forall a e t (>~). (Monoid e, Ord a, WirePure >~, WWithSysTime t >~) => Wire e >~ a t

# Statistics

## Average

avg :: forall e v (>~). (Fractional v, Unbox v, WirePure >~) => Int -> Wire e >~ v vSource

Calculate the average of the signal over the given number of last
samples. If you need an average over all samples ever produced,
consider using `avgAll`

instead.

- Complexity: O(n) space, O(1) time wrt number of samples.
- Depends: current instant.

avgAll :: forall e v (>~). (Fractional v, WirePure >~) => Wire e >~ v vSource

Calculate the average of the signal over all samples.

Please note that somewhat surprisingly this wire runs in constant
space and is generally faster than `avg`

, but most applications will
benefit from averages over only the last few samples.

- Depends: current instant.

avgFps :: (Arrow (Wire e >~), Fractional t, Unbox t, WirePure >~, WWithDT t >~) => Int -> Wire e >~ a tSource

Calculate the average number of frames per virtual second for the last given number of frames.

Please note that this wire uses the clock from the `WWithDT`

instance
for the underlying arrow. If this clock doesn't represent real time,
then the output of this wire won't either.

:: (Arrow (Wire e >~), Fractional t, Unbox t, WirePure >~, WSampleInt >~, WWithDT t >~) | |

=> Int | Interval size. |

-> Int | Number of Samples. |

-> Wire e >~ a t |

Same as `avgFps`

, but samples only at regular intervals. This can
improve performance, if querying the clock is an expensive operation.

## Peak

highPeak :: (Ord b, WirePure >~) => Wire e >~ b bSource

Outputs the high peak of the input signal.

- Depends: Current instant.

lowPeak :: (Ord b, WirePure >~) => Wire e >~ b bSource

Outputs the low peak of the input signal.

- Depends: Current instant.

peakBy :: forall b e (>~). WirePure >~ => (b -> b -> Ordering) -> Wire e >~ b bSource

Outputs the high peak of the input signal with respect to the given comparison function.

- Depends: Current instant.

# Monitoring

collect :: forall b e (>~). (Ord b, WirePure >~) => Wire e >~ b (Set b)Source

Collects all distinct inputs ever received.

- Complexity: O(n) space, O(log n) time wrt collected inputs so far.
- Depends: current instant.

diff :: forall b e (>~). (Eq b, Monoid e, WirePure >~) => Wire e >~ b bSource

Outputs the last input value on every change of the input signal. Acts like the identity wire at the first instant.

- Depends: current instant.
- Inhibits: on no change after the first instant.

firstSeen :: forall a e t (>~). (Ord a, WirePure >~, WWithSysTime t >~) => Wire e >~ a tSource

Reports the first global time the given input was seen.

- Complexity: O(n) space, O(log n) time wrt collected inputs so far.
- Depends: Current instant.

lastSeen :: forall a e t (>~). (Monoid e, Ord a, WirePure >~, WWithSysTime t >~) => Wire e >~ a tSource

Reports the last time the given input was seen. Inhibits when seeing a signal for the first time.

- Complexity: O(n) space, O(log n) time wrt collected inputs so far.
- Depends: Current instant.
- Inhibits: On first sight of a signal.