swung static method

double swung(
  1. double beat,
  2. int swing
)

Leva um tempo da grade (reto) ao tempo do swing. Só mexe na parte fracionária: o tempo inteiro fica, a metade cai em swing/100, e o resto de cada metade é esticado para caber.

Implementation

static double swung(double beat, int swing) {
  final base = beat.floorToDouble();
  final s = swing / 100;
  final f = beat - base;
  if (f <= 0.5) return base + f * 2 * s;
  return base + s + (f - 0.5) * 2 * (1 - s);
}