echoPhraseAbc function
- EchoPhrase phrase
O ABC de uma frase, para a revelação (EX14): um ou mais compassos 4/4, com o
que soa escrito. As figuras saem em semicolcheias (L:1/16).
Implementation
String echoPhraseAbc(EchoPhrase phrase) {
final flat = phrase.keyName.contains('b') || phrase.keyName == 'F';
final out = StringBuffer();
var at = 0.0;
void barIfAny() {
if (at % kEchoBeatsPerBar == 0 && at < phrase.beats) out.write('| ');
}
for (final note in phrase.notes) {
final rest = note.start - at;
if (rest > 0) {
out.write('z${_units(rest)} ');
at = note.start;
barIfAny();
}
out.write('${_abcPitch(note.pitch, flat)}${_units(note.beats)} ');
at = note.start + note.beats;
barIfAny();
}
final tail = phrase.beats - at;
if (tail > 0) out.write('z${_units(tail)} ');
out.write('|]');
return out.toString();
}