Qu

process

Builtin index · Signal processing

result = process(p, x)

Input: p, x · Output: result

What it is

p: a Model (kind "processor"); x: a vector or Signal.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = process(p, x)
p Modelp: a Model (kind "processor").
x vector or Signalx: a vector or Signal.
result —
Returns the processed signal, applying p's function block by block and carrying state across the block boundaries. Also spelled p.process(x). A stateless processor calls f(block); a stateful one calls f(block, state) and requires the two-element list (y, next_state) back. A processor built with a rate refuses a signal at any other rate, naming both. Added in v0.2.4.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

lp = butter(4, "low", 80, 1000)

function lp_block(b, st)
    s   = st
    out = ()
    for v in b
        s   = filter_next(s, v)
        out = append(out, s.y)
    end for
    return (out, s)
end function

p = processor("lp_block", block = 256, state = filter_init(lp), rate = 1000)
y = process(p, x)          # or: p.process(x)


print("{p.latency} samples, {p.latency_ms} ms")   # 256 samples, 256 ms

output
256 samples, 256 ms

from signal-processing

How it works

process(p, x) / x.process(p) — run a processor over a whole signal, block by block, carrying state across the boundaries. The OFFLINE call of §5's "same object" pair; the live run(proc, input: mic, output: speakers) half is NOT built (no mic/speaker layer exists in this engine) and is deliberately not stubbed.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.