- class neoscore.western.pitch.Pitch
A written pitch with a letter, octave, and accidental.
This class does not define an actual concert pitch, MIDI code, pitch class, etc. associated with it. Users building notation systems on it can decide whether this represents a concert pitch or a written one. Neoscore’s
westernmodule treats it mostly as a written pitch, unconditionally writing provided accidentals regardless of context and key signatures.
The class supports a helpful shorthand for standard western 12-EDO pitches inspired by Lilypond’s pitch notation; see
Extended accidentals are fully supported by passing arbitrary SMuFL glyph names to the
- letter: str
The a-g letter name of the pitch.
- accidental: Optional[AccidentalType | str]
An accidental associated with the pitch.
For conventional accidentals, this can be an
AccidentalType. Alternatively, this can be an arbitrary SMuFL glyph name string.
- octave: int
The octave number, where 4 is the octave starting with middle-C.
- classmethod from_str(shorthand: str) Pitch
Create a conventional Western
Pitchfrom a string shorthand.
The pitch shorthand is inspired by Lilypond’s. It consists of three parts: a pitch letter, an optional accidental, and an optional octave mark.
Pitch letters are the standard
The accidental may be
xfor double-sharp, and
The octave indication is given by a series of apostrophes (
') or commas (
,), where each apostrophe increases the pitch by an octave, and each comma decreases it. All octave transformations are relative to the octave starting at middle-C. The absence of an octave indicator means a pitch is within the octave starting at middle-C. (Note that this differs from Lilypond’s notation, which starts at the octave below middle-C.)
The B directly below that:
The C one octave below middle-C:
The E-flat above middle-C:
The F-sharp above middle-C:
The G-double-sharp above middle-C:
The A-double-flat above the treble staff:
- property diatonic_degree_in_c: int
The diatonic degree of the pitch as if it were in C.
>>> Pitch.from_str("c").diatonic_degree_in_c 1 >>> Pitch.from_str("c'").diatonic_degree_in_c 1 >>> Pitch.from_str("d'''").diatonic_degree_in_c 2 >>> Pitch.from_str("bf,").diatonic_degree_in_c 7
- property staff_pos_from_middle_c: float
The pitch’s staff position relative to middle C.
Values are in numeric pseudo-staff-units where positive values mean positions below middle C, and negative values mean positions above it.
>>> Pitch.from_str("c").staff_pos_from_middle_c 0 >>> Pitch.from_str("cs").staff_pos_from_middle_c 0 >>> Pitch.from_str("d").staff_pos_from_middle_c -0.5 >>> Pitch.from_str("d'").staff_pos_from_middle_c -4 >>> Pitch.from_str("cn,,").staff_pos_from_middle_c 7