sightFastLeaps function
Todos os pares de começos seguidos da mesma mão separados por menos de sightFastLeapMs. O salto é o maior entre as notas mais graves e as mais agudas dos dois grupos.
Implementation
List<SightLeap> sightFastLeaps(SightExercise ex) {
final events = sightSoundingEvents(ex);
final bpm = _dBpm(ex.step);
final msPerTick = 60000 / bpm / sightTicksPerQuarter;
final out = <SightLeap>[];
for (final staff in [1, 2]) {
final onsets = sightOnsetsOf(events, staff);
for (var i = 1; i < onsets.length; i++) {
final ms = (onsets[i] - onsets[i - 1]) * msPerTick;
if (ms >= sightFastLeapMs) continue;
final a = _groupAt(events, staff, onsets[i - 1]);
final b = _groupAt(events, staff, onsets[i]);
final leap = _max((a.$1 - b.$1).abs(), (a.$2 - b.$2).abs());
out.add((
staff: staff,
measure: onsets[i] ~/ ex.ticksPerMeasure,
semitones: leap,
ms: ms,
));
}
}
return out;
}