generate method
override
Assíncrono porque alguns tipos leem um file: da pasta do curso. turn
é a rodada na sessão (EX05: o play-score com keys: e cycle: escolhe
o tom por ela); quem não usa, ignora.
Implementation
@override
Future<QuestionRound> generate(
ListenNoteSpec spec,
CourseFiles files,
Random rng, {
RoundTurn? turn,
}) async {
final buttons = spec.input == AnswerInput.buttons;
final notes = notesOf(spec.notes, rng, key: buttons ? null : spec.key);
final reference = spec.reference;
List<SoundCue> soundOf(Pitch pitch) => [
if (reference != null) SoundCue([reference.midi]),
SoundCue([pitch.midi]),
];
return QuestionRound([
for (final pitch in notes)
buttons
? Question(
answers: spec.choices,
correct: spec.choices.indexOf(pitch.step),
sound: soundOf(pitch),
)
: Question(
expectedPitch: pitch.midi,
anyOctave: spec.octave == OctaveRule.any,
sound: soundOf(pitch),
),
]);
}