chordReferenceAttacksOf function
- List<
ChordAttackPoint> points, { - ChordMelody? melody,
A realização de points, na ordem: as notas de cada ataque (_voicingOf), e o
ataque anterior de cada um, que a condução usa. No estilo de hino, a melodia de
melody que soa no ataque põe as notas da direita (_underMelodyOf).
Implementation
List<ChordReferenceAttack> chordReferenceAttacksOf(
List<ChordAttackPoint> points, {
ChordMelody? melody,
}) {
final attacks = <ChordReferenceAttack>[];
List<int>? previous;
for (final point in points) {
final voicing = _voicingOf(point.span, point.rule, previous);
final hymn = point.rule == ChordRule.hymn;
final sounding = hymn ? melody?.pitchAt(point.onMs) : null;
final right = hymn
? _underMelodyOf(point.span, sounding)
: const <MusicSpelledPitch>[];
final index = attacks.length;
attacks.add(
ChordReferenceAttack(
span: point.span,
rule: point.rule,
onMs: point.onMs,
offMs: point.offMs,
beat: point.beat,
previous: previous,
melody: sounding,
left: [
for (final (k, note) in voicing.indexed)
ChordReferenceNote(
id: 'ref-$index-$k',
pitch: note.midi,
onMs: point.onMs,
offMs: point.offMs,
step: note.step,
alter: note.alter,
),
],
right: [
for (final (k, note) in right.indexed)
ChordReferenceNote(
id: 'ref-$index-r$k',
pitch: note.midi,
onMs: point.onMs,
offMs: point.offMs,
step: note.step,
alter: note.alter,
),
],
),
);
previous = voicing.isEmpty ? null : [for (final note in voicing) note.midi];
}
return attacks;
}