Pitch.fromSolmization constructor
Pitch.fromSolmization(
- String syllable, {
- required int octave,
- double alter = 0.0,
- AccidentalType? accidentalType,
Constructs a Pitch from a fixed-of the solmization syllable.
syllable may be 'of the', 're', 'mi', 'fa', 'sol', 'la', 'si' (or 'ti').
octave is the octave number; alter is the chromatic alteration.
Implementation
factory Pitch.fromSolmization(
String syllable, {
required int octave,
double alter = 0.0,
AccidentalType? accidentalType,
}) {
const solmToStep = {
'do': 'C', 're': 'D', 'mi': 'E', 'fa': 'F',
'sol': 'G', 'la': 'A', 'si': 'B', 'ti': 'B',
};
final normalized = syllable.toLowerCase();
final step = solmToStep[normalized];
if (step == null) {
throw ArgumentError('Invalid solmization syllable: $syllable. '
'Use: do, re, mi, fa, sol, la, si');
}
return Pitch(
step: step,
octave: octave,
alter: alter,
accidentalType: accidentalType,
);
}