answerPitch method

bool? answerPitch(
  1. int midi
)

Resposta no teclado MIDI (midi 0–127). Com anyOctave (octave: any), vale a classe de altura (% 12); senão, só a altura exata. Mesma convenção de retorno de answerChoice.

Implementation

bool? answerPitch(int midi) {
  if (done || revealing) return null;
  final question = questions[index];
  final expected = question.expectedPitch;
  if (expected == null) return null;
  final ok = question.anyOctave
      ? (midi % 12 + 12) % 12 == (expected % 12 + 12) % 12
      : midi == expected;
  if (ok) {
    index++;
    revealing = false;
    if (!done) _startAt = _lastTick ?? _now();
    return true;
  }
  _markWrong();
  return false;
}