Build with this node

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

Ask Studio

@maruaudio/dsp/math/hash holds two allocation-free 32-bit integer hashes. hashStepU32(seed) is the SDK step hash used by note-level random transforms: one LCG step (seed × 1664525 + 1013904223) followed by a Murmur3-style xor-shift-multiply finalizer, returning an unsigned word. lowBias32ToUnit(index) is a separate low-bias finalizer (multipliers 0x7feb352d and 0x846ca68b, no LCG step) kept from the retired Velocity and Humanize transforms, normalized to [0, 1) by dividing by 2^32. The two are deliberately different algorithms.

Functions

NameInputOutputDomain as coded
hashStepU32seedunsigned 32-bit wordInput read as seed >>> 0, so −1 hashes like 0xffffffff and 2^32 + 1 like 1
lowBias32ToUnitindexnumber in [0, 1)Input read as index >>> 0; fractions truncate and NaN or ±Infinity read as 0

Lifecycle

None. Stateless functions with no preparation or instance state.

When to use it

Deterministic per-note or per-step randomness from a counter or seed, where the same input must give the same value on every target. Divide the word from hashStepU32 by 2^32 for a unit value, or use the word for indexing or parity.

Limits

  • Not a random-number stream: each call hashes one input with no state.
  • Changing either function would change every stored random vector that relies on it; the tests freeze both.

Algorithm properties and proofs

No Lean 4 proof is mapped to this node.

Explore proofs alongside performance

Dependencies

Dependents

Used by