Build with this node

Start with a prompt in Studio, or copy it into your own coding agent.

Ask Studio

@maruaudio/dsp/noise/xorshift32 is the canonical raw xorshift32 state transition and its mapping to a bipolar number. The transition is three shift-and-xor steps on an unsigned 32-bit word:

x ^= x << 13; x ^= x >>> 17; x ^= x << 5 (all as u32)
bipolar = x / 2^31 − 1 // [−1, 1), unrounded
let state = 2463534242
state = xorshift32NextU32(state)
const sample = rawU32ToBipolar(state)

Parameters

There are no setters or state. The caller passes the 32-bit state to xorshift32NextU32 and keeps the returned value as the next state. XORSHIFT32_ALGORITHM_REVISION (1) names the transition contract.

Lifecycle

Stateless functions; the caller owns and persists the state. Nothing allocates or does I/O.

When to use it

A deterministic, repeatable noise or random stream inside a voice or effect: excitation noise, random impulses, seeded variation that renders the same on every target.

Limits

  • No seed policy: state 0 stays 0 for ever. Callers such as @maru/noise-coloured replace a zero seed before the first step.
  • Inputs are coerced with >>> 0: −1 acts as 0xffffffff, 1.9 as 1, and NaN or infinity as 0.
  • rawU32ToBipolar is unrounded; a caller that stores f32 rounds it.

Algorithm properties and proofs

No Lean 4 proof is mapped to this node.

Explore proofs alongside performance

Dependencies

None: this node imports no other node.

Dependents

Used by