lcgNoise static method

Float32List lcgNoise(
  1. int n, {
  2. double amplitude = 1.0,
  3. int seed = 123456789,
})

Implementation

static Float32List lcgNoise(
  int n, {
  double amplitude = 1.0,
  int seed = 123456789,
}) {
  int x = seed & 0x7fffffff;
  const int a = 1103515245;
  const int c = 12345;
  const int m = 0x7fffffff;

  double next() {
    x = (a * x + c) & m;
    return x / m;
  }

  final out = Float32List(n);
  for (int i = 0; i < n; i++) {
    out[i] = (amplitude * (2.0 * next() - 1.0));
  }
  return out;
}