@libraz/libcantus - v1.1.0
    Preparing search index...

    Function createPositionalRng

    • Create a position-addressed random source.

      at holds no cursor: it is a pure function of the seed and the path, safe to call in any order, any number of times, from anywhere in a generator. Its draws are independent of deriveSeed at the same path, so a generator may seed a sub-part and take a positional draw at one position without getting the same number twice.

      Parameters

      • seed: number

        The seed; an integer in 0..0xffffffff, typically from deriveSeed.

      Returns PositionalRng

      The positional source.

      If the seed is not a 32-bit integer.

      import { createPositionalRng, deriveSeed } from '@libraz/libcantus';
      const rng = createPositionalRng(deriveSeed(42, 'drums'));
      rng.at('ghost', 4, 2.5); // the same value however often it is asked for