sample method

double sample(
  1. double time
)

Returns a value in [-1, 1] for the given time in seconds.

Implementation

double sample(double time) {
  final t = time * frequency * math.pi * 2;
  final a = math.sin(t + seed * 0.7);
  final b = math.sin(t * 1.73 + seed * 1.3 + 1.7);
  final c = math.sin(t * 2.61 + seed * 0.3 + 3.1);
  return (a * 0.5 + b * 0.3 + c * 0.2).clamp(-1.0, 1.0);
}