hanonTrillPosition function

int hanonTrillPosition(
  1. int bar, {
  2. bool second = false,
})

A posição da mão (o grau do polegar da direita) no começo do compasso bar ou, com second, depois da troca do meio dele. Sobe de 0 a 24 nos compassos 1 a 31 (3 a cada troca), recomeça em 21 no 32 e desce até 0 no 53.

Implementation

int hanonTrillPosition(int bar, {bool second = false}) {
  final inside = second && hanonTrillShifts(bar) ? 1 : 0;
  if (bar <= 31) {
    var passed = 0;
    for (var b = 10; b < bar; b++) {
      if (hanonTrillShifts(b)) passed++;
    }
    return 3 * (passed + inside);
  }
  var passed = 0;
  for (var b = 34; b < bar; b++) {
    if (hanonTrillShifts(b)) passed++;
  }
  return 21 - 3 * (passed + inside);
}