/ simulated_instruments / cymbal
Sign in
simulated_instruments / cymbal
cymbal / matlab / cymbal_rngv.m
15 lines · 826 BCodeBlameHistory
2% CYMBAL_RNGV Vectorized seeded uniform generator: one 32-bit LCG stream per
3% element of `state`, all advanced by one step. Returns the uniforms in (0, 1)
4% and the advanced state, both the same shape as the input.
5%
6% The scalar cymbal_rng draws a sequence from one stream, which is what the
7% stroke process wants. The cascade wants one fresh number per mode per
8% control frame, hundreds of thousands of them, so it runs hundreds of
9% independent streams side by side instead of looping. Every product below
10% stays under 2^53 (2^32 * 1664525 < 2^53), so the arithmetic is exact in the
11% CLI, in Node and in the browser alike, and a given seed reproduces the
12% identical render everywhere.
13state = mod(state * 1664525 + 1013904223, 4294967296);
14r = (state + 0.5) / 4294967296;
15end
↑↓ move↵openescclose