notesScore function

String notesScore(
  1. List<Pitch> notes, {
  2. Clef clef = Clef.treble,
  3. String? key,
  4. String time = '4/4',
})

Partitura de notes, uma nota por tempo (semínimas; em 6/8, semínimas pontuadas — dois tempos por compasso), com barras de compasso. Em Clef.grand, a nota abaixo do dó central vai para a pauta de fá e as demais para a de sol; na outra pauta fica um espaço.

Implementation

String notesScore(
  List<Pitch> notes, {
  Clef clef = Clef.treble,
  String? key,
  String time = '4/4',
}) {
  final compound = time == '6/8';
  final unit = compound ? 3 : 2;
  final perMeasure = compound ? 2 : _timeParts(time).beats;
  final events = [
    for (var i = 0; i < notes.length; i++)
      _Event(
        duration: unit,
        type: 'quarter',
        dots: compound ? 1 : 0,
        pitch: notes[i],
        staff: clef == Clef.grand ? (notes[i].diatonic < 28 ? 2 : 1) : 1,
        noteIndex: i,
      ),
  ];
  final measures = [
    for (var i = 0; i < events.length; i += perMeasure)
      events.sublist(i, min(i + perMeasure, events.length)),
  ];
  return _score(measures, _plainHeading(clef, key, time));
}