leadSheetCourseUse function

CourseUse? leadSheetCourseUse({
  1. required LeadSheetSource source,
  2. required LeadSheetHand hand,
  3. required LeadSheetTiming timing,
  4. List<String> extraNotes = const [],
})

play-lead-sheet (EX17) com o .musicxml de source: a mão esquerda (hand), o andamento e o pass (timing). O curso só lê .musicxml: outro arquivo devolve null, e quem chama usa o bloco de partitura. extraNotes são as linhas ao lado do bloco.

Implementation

CourseUse? leadSheetCourseUse({
  required LeadSheetSource source,
  required LeadSheetHand hand,
  required LeadSheetTiming timing,
  List<String> extraNotes = const [],
}) {
  const ext = '.musicxml';
  final fileName = source.fileName;
  if (!fileName.toLowerCase().endsWith(ext)) return null;
  final stem = _slug(fileName.substring(0, fileName.length - ext.length));
  final path = 'media/$stem-${_fingerprint(source.bytes)}$ext';
  final block = _block([
    'id: $stem',
    'type: play-lead-sheet',
    'title: ${source.title}',
    'file: $path',
    ?(hand.style == null ? null : 'style: ${hand.style}'),
    ?(hand.pattern == null ? null : 'pattern: ${hand.pattern}'),
    'melody: ${hand.melody}',
    ?(timing.bpm == null ? null : 'bpm: ${timing.bpm}'),
    'pass: {accuracy: ${timing.pass.accuracy}, rounds: ${timing.pass.rounds}}',
  ]);
  return CourseUse(
    text: block,
    files: [CourseUseFile(path, source.bytes)],
    notes: [
      'Copie o arquivo $path para a pasta media/ da lição. Compartilhar '
          'manda o arquivo junto com o texto.',
      ...extraNotes,
    ],
  );
}