netwire-4.0.1: Flexible wire arrows for FRP

Copyright(c) 2012 Ertugrul Soeylemez
LicenseBSD3
MaintainerErtugrul Soeylemez <es@ertes.de>
Safe HaskellNone
LanguageHaskell2010

Control.Wire.Prefab.Analyze

Contents

Description

Signal analysis wires.

Synopsis

Statistics

Average

avg :: forall a m e v. (Fractional a, VectorSpace v, Scalar v ~ a) => Int -> Wire e m v v Source

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 wrt number of samples.
  • Depends: current instant.

avgInt Source

Arguments

:: (Fractional a, VectorSpace v, Scalar v ~ a) 
=> Int

Sampling interval.

-> Int

Number of samples.

-> Wire e m v v 

Same as avg, but with a sampling interval. This can be used to increase the performance, if the input is complicated.

  • Complexity: O(n) space wrt number of samples.
  • Depends: current instant.

avgAll :: forall a m e v. (Fractional a, VectorSpace v, Scalar v ~ a) => Wire e m v v Source

Calculate the average of the input signal over all samples. This is usually not what you want. In most cases the avg wire is preferable.

  • Depends: current instant.

avgFps :: Monad m => Int -> Wire e m a Double Source

Calculate the average number of instants per second for the last given number of instants. In a continuous game or simulation this corresponds to the average number of frames per second, hence the name.

  • Complexity: O(n) space wrt number of samples.
  • Depends: time.

avgFpsInt Source

Arguments

:: Monad m 
=> Int

Sampling interval.

-> Int

Number of samples.

-> Wire e m a Double 

Like avgFps, but sample in discrete intervals only. This can greatly enhance the performance, when you have an inefficient clock source.

  • Complexity: O(n) space wrt number of samples.
  • Depends: time.

Peak

highPeak :: Ord b => Wire e m b b Source

High peak.

  • Depends: current instant.

lowPeak :: Ord b => Wire e m b b Source

Low peak.

  • Depends: current instant.

peakBy :: forall b m e. (b -> b -> Ordering) -> Wire e m b b Source

Output the peak with respect to the given comparison function.

  • Depends: current instant.

Monitoring

collect :: forall b m e. Ord b => Wire e m b (Map b Int) Source

Collect all distinct inputs ever received together with a count. Elements not appearing in the map have not been observed yet.

  • Complexity: O(n) space.
  • Depends: current instant.

firstSeen :: forall a m e. Ord a => Wire e m a Time Source

Outputs the first local time the input was seen.

  • Complexity: O(n) space, O(log n) time wrt number of samples so far.
  • Depends: current instant, time.

lastSeen :: forall a m e. (Monoid e, Ord a) => Wire e m a Time Source

Outputs the local time the input was previously seen.

  • Complexity: O(n) space, O(log n) time wrt number of samples so far.
  • Depends: current instant, time.
  • Inhibits: if this is the first time the input is seen.