parse static method

PitchClass parse(
  1. String pitchClassName
)

Implementation

static PitchClass parse(String pitchClassName) {
  final match = _pitchClassPattern.matchAsPrefix(pitchClassName);
  if (match == null)
    throw new FormatException("$pitchClassName is not a pitch class name");
  final String naturalName = match[1]!;
  final String accidentals = match[2]!;
  int integer = noteNames.indexOf(naturalName.toUpperCase());
  integer += parseAccidentals(accidentals);
  return new PitchClass(integer: integer);
}