targetPitchClasses function

Set<int> targetPitchClasses(
  1. TargetNote target,
  2. ChordSymbol chord
)

As classes de altura (0 a 11) que contam como o alvo target no chord. Vazio quando o acorde não tem essa nota (a 7ª de um acorde maior, por exemplo): o exercício não cobra o tempo ali. A guide-tone aceita a 3ª e a 7ª; quem escolhe a mais perto é nearestGuideTone.

Implementation

Set<int> targetPitchClasses(TargetNote target, ChordSymbol chord) {
  final root = chord.root % 12;
  final third = chord.third;
  final seventh = chord.seventh;
  return switch (target) {
    TargetNote.one => {root},
    TargetNote.three => {if (third != null) (root + third) % 12},
    TargetNote.five => {(root + chord.fifth) % 12},
    TargetNote.seven => {if (seventh != null) (root + seventh) % 12},
    TargetNote.nine => {(root + 2) % 12},
    TargetNote.chordTone => chord.pitchClasses,
    TargetNote.guideTone => guideCandidates(chord).toSet(),
  };
}