chartAudio function
Os eventos MIDI da grade a bpm (um tempo de compasso por batida), a partir
de startAt (segundos no relógio do motor). Cada acorde soa até o fim do
seu tempo, com um pouco de respiro antes do seguinte.
Implementation
List<ScheduledMidi> chartAudio(
ChordChart chart, {
required int bpm,
required double startAt,
}) {
final beat = 60 / bpm;
final events = <ScheduledMidi>[];
for (final slot in chart.slots()) {
final chord = slot.chord;
if (chord == null) continue;
final on = startAt + slot.startBeat * beat;
final off = on + slot.beats * beat * 0.9;
for (final note in buildVoicing(
chord,
bounds: VoicingBounds(lowest: 60, highest: 79),
)) {
events
..add(ScheduledMidi(on, 0x90, note, 80))
..add(ScheduledMidi(off, 0x80, note, 0));
}
}
events.addAll(_baseEvents(chart, bpm: bpm, startAt: startAt));
return events;
}