You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
LocSta provides composable, stateful stream blocks using F# computation expressions. Each block is a pure function that threads state automatically, making it easy to build complex signal processing pipelines — from simple counters to full audio DSP chains.
Core Concept
A SigStream<'v,'c,'s> is a function that takes a StateController and a context value, and returns an output value along with the updated state. The stream { } computation expression composes these blocks, automatically managing state allocation and threading.
openLocSta.Core// A simple stateful stream: counter that increments by 1letmyCounter=
stream {let!state= useState 0letcurrent= state.Value
state.Value <- current +1return current
}// Evaluate 5 samples (context is unit here)letresult= myCounter |> Eval.run 5(fun _ ->())// result = [0; 1; 2; 3; 4]
Key Primitives
Primitive
Description
stream { }
Computation expression builder for composing streams
getCtx()
Read the current input/context value
useState value
Local mutable state, initialized once
useStateWith init
Local mutable state with lazy initializer
useMemoWith init
Memoized value (lazy, computed once)
ofSeq sequence
Create a stream from a sequence
map proj stream
Transform stream output
Eval.run n getCtx stream
Evaluate n samples with a context generator
Eval.runWith inputs stream
Evaluate with an input sequence
Eval.toSeq getCtx stream
Convert to an infinite seq<'v>
Examples
Exponential Moving Average
openLocStaopenLocSta.Blocks.Statistics.Emaletinputs=[1.0;2.0;3.0;4.0;5.0]letresult= ema 0.5|> Eval.runWith inputs
// Smoothed output approaching the input signal