capturedMidi function
Os eventos MIDI que tocam de volta capture: cada tecla no ataque e no fim
(a nota solta sem fim toca até o ataque), e o pedal. Os ms musicais viram
segundos do motor pelo andamento speed (a rodada tocou nele), a partir de
startAt. Vêm em ordem de tempo.
Implementation
List<ScheduledMidi> capturedMidi(
PerformanceCapture capture, {
required double speed,
required double startAt,
}) {
double at(double ms) => startAt + ms / 1000 / speed;
return [
for (final note in capture.notes) ...[
ScheduledMidi(at(note.onMs), 0x90, note.pitch, note.velocity),
ScheduledMidi(at(note.offMs ?? note.onMs), 0x80, note.pitch, 0),
],
for (final pedal in capture.pedals)
ScheduledMidi(at(pedal.atMs), 0xB0, 64, pedal.down ? 127 : 0),
]..sort((a, b) => a.at.compareTo(b.at));
}