rhythmDuoScore function
Partitura do rhythm com duas mãos: a direita (right) na pauta de sol e a
esquerda (left) na de fá, ao mesmo tempo, cada uma numa linha só. Cada
lista é a de uma mão, um molde por compasso (RhythmSymbol); a altura é
fixa por pauta (si4 na direita, ré3 na esquerda), porque só o ritmo importa.
Um ataque (X ou A) com os - que vêm depois dele é uma nota, e cada
. (ou sequência de .) é uma pausa. A duração do evento é a soma das
partes dele, e tem de se escrever (ver rhythmNotatable): se não se escreve,
é erro. As colcheias e semicolcheias de um tempo levam barra, e as tercinas,
o colchete com o 3 (como o padrão do EX06). Sem left, sai uma pauta só. Com
left, as duas mãos têm o mesmo número de compassos.
Implementation
String rhythmDuoScore({
required List<List<RhythmSymbol>> right,
List<List<RhythmSymbol>> left = const [],
required String time,
int? bpm,
}) {
final units = rhythmBarUnits(time);
if (right.isEmpty) {
throw ArgumentError.value(right, 'right', 'o ritmo não tem compasso');
}
if (left.isNotEmpty && left.length != right.length) {
throw ArgumentError(
'a mão esquerda tem ${left.length} compassos, e a direita tem '
'${right.length}',
);
}
final both = left.isNotEmpty;
var notes = 0;
int nextNote() => notes++;
final rightHand = (staff: 1, pitch: Pitch.parse('B4'));
final leftHand = (staff: 2, pitch: Pitch.parse('D3'));
final measures = <List<_Event>>[
for (var m = 0; m < right.length; m++)
[
..._duoBar(right[m], units, rightHand, nextNote),
if (both) ..._duoBar(left[m], units, leftHand, nextNote),
],
];
// As barras e os colchetes de tercina agrupam pelo tempo escrito: a semínima,
// e em 6/8 a semínima pontuada (duas por compasso).
final beat = time == '6/8'
? kRhythmUnitsPerQuarter * 3 ~/ 2
: kRhythmUnitsPerQuarter;
for (final measure in measures) {
_beamPattern(measure, group: beat);
}
return _score(
measures,
(
clef: both ? Clef.grand : Clef.treble,
key: null,
time: time,
bpm: bpm,
staffLines: 1,
),
layout: (
divisions: kRhythmUnitsPerQuarter,
simultaneous: both,
repeats: const [],
shifts: const [],
timeChanges: const {},
),
);
}