parseHelmholtzNotation static method
Implementation
static Pitch parseHelmholtzNotation(String pitchName) {
final match = _helmholtzPitchNamePattern.matchAsPrefix(pitchName);
if (match == null)
throw new FormatException("not in Helmholtz notation: $pitchName");
final String naturalName = match[1]!;
final String accidentals = match[2]!;
final String commas = match[3]!;
final String apostrophes = match[4]!;
final int pitch = noteNames.indexOf(naturalName.toUpperCase());
final int accidentalSemitones = parseAccidentals(accidentals);
int octave = 3 + apostrophes.length - commas.length;
if (naturalName == naturalName.toUpperCase()) {
octave -= 1;
}
return new Pitch(
chromaticIndex: pitch,
accidentalSemitones: accidentalSemitones,
octave: octave);
}