netwire-4.0.5: Flexible wire arrows for FRP

MaintainerErtugrul Soeylemez <es@ertes.de>
Safe HaskellNone

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

avgIntSource

Arguments

:: forall a m e v . (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 vSource

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 DoubleSource

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.

avgFpsIntSource

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 bSource

High peak.

  • Depends: current instant.

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

Low peak.

  • Depends: current instant.

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

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 TimeSource

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 TimeSource

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.