Pitch class

Represents the musical pitch of a note.

A pitch is fully described by its diatonic step ("C""B"), octave number, and optional chromatic alter value. Microtonal alterations are supported through fractional alter values and the accidentalType field.

Example:

const Pitch(step: 'F', octave: 4, alter: 1.0) // F-sharp 4
Pitch.withAccidental(step: 'B', octave: 3, accidentalType: AccidentalType.flat) // B-flat 3
Pitch.fromString('C#5') // C-sharp 5
Available extensions

Constructors

Pitch({required String step, required int octave, double alter = 0.0, AccidentalType? accidentalType, String? customAccidentalGlyph})
Creates a pitch from a diatonic step, an octave and an optional chromatic alter.
const
Pitch.fromSolmization(String syllable, {required int octave, double alter = 0.0, AccidentalType? accidentalType})
Constructs a Pitch from a fixed-do solmization syllable. syllable may be 'do', 're', 'mi', 'fa', 'sol', 'la', 'si' (or 'ti'). octave is the octave number; alter is the chromatic alteration.
factory
Pitch.fromString(String notation)
Constructs a Pitch from a string (e.g. "C4", "F#5", "Bb3", "C-1").
factory
Pitch.validated({required String step, required int octave, double alter = 0.0, AccidentalType? accidentalType})
Creates a pitch after validating and normalizing its step.
factory
Pitch.withAccidental({required String step, required int octave, required AccidentalType accidentalType})
Constructor with a specific accidental type.
factory

Properties

accidentalGlyph String?
Returns the SMuFL glyph name for the accidental.
no setter
accidentalType AccidentalType?
Specific accidental type (optional, for special notations).
final
alter double
Chromatic alteration: -2.0 = double flat, -1.0 = flat, 0.0 = natural, +1.0 = sharp, +2.0 = double sharp. Decimal values are supported for microtones.
final
centsDeviation double
Returns the deviation in cents from the nearest tempered pitch.
no setter
customAccidentalGlyph String?
For custom accidentals.
final
effectiveAlter double
Effective alteration value used for calculations.
no setter
frequency double
Calculates the frequency in Hz (A4 = 440 Hz).
no setter
hashCode int
The hash code for this object.
no setteroverride
hasMicrotone bool
Returns true if the pitch has a microtonal alteration.
no setter
midiNumber int
Calculates the MIDI note number (C4 = 60). For microtones, returns the nearest integer value.
no setter
octave int
The octave number (4 is the standard middle octave).
final
pitchClass int
Returns the pitch class as an integer 0–11, as per the MEI v5 pclass attribute. C=0, C#=1, D=2, ..., B=11.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
solmizationName String
Returns the fixed-do solmization name of this pitch (do, re, mi, fa, sol, la, si). Equivalent to the MEI v5 solmization system.
no setter
step String
The note letter name (C, D, E, F, G, A, B).
final

Methods

getLedgerLinePositions(Clef clef, {int extraOctaveShift = 0}) List<int>

Available on Pitch, provided by the PitchStaffPosition extension

Gets ledger lines required
needsLedgerLines(Clef clef, {int extraOctaveShift = 0}) bool

Available on Pitch, provided by the PitchStaffPosition extension

Checks if needs de ledger lines
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
staffPosition(Clef clef, {int extraOctaveShift = 0}) int

Available on Pitch, provided by the PitchStaffPosition extension

Calculates staff position for a clef
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
Two pitches are equal when they share the same step, octave and effectiveAlter.
override

Static Methods

isValidStep(String s) bool
Returns true if s is one of the seven diatonic step letters.

Constants

validSteps → const List<String>
The seven valid diatonic step letters, in ascending diatonic order.