Pitch manipulation.
Bases: ly.lex._token.Token
A Token that denotes a language name.
Bases: object
A pitch with note, alter and octave attributes.
Attributes may be manipulated directly.
Bases: object
Iterate over notes or pitches in a source.
Yields all tokens, but collects Note and Octave tokens.
When a Note is encountered, also reads octave and octave check and then a Pitch is yielded instead of the tokens.
Bases: exceptions.Exception
Exception raised when there is no name for a pitch.
Can occur when translating pitch names, if the target language e.g. does not have quarter-tone names.
Bases: object
Converts string octave to an integer:
“” -> 0 ; ”,” -> -1 ; “’‘’” -> 3 ; etc.
Convert absolute music to relative music.
Converts pitches from absolute to relative.
language: language to start reading pitch names in
If first_pitch_absolute is True, the first pitch of a relative expression is written as absolute. This mimics the behaviour of LilyPond >= 2.18. (In fact, the starting pitch is then assumed to be f.)
If False, the first pitch is written as relative to c’ (LilyPond < 2.18 behaviour).
Existing relative expressions are not changed.
Convert relative music to absolute music.
Converts pitches from relative to absolute.
language: language to start reading pitch names in
is regarded as absolute, when no starting pitch was given. This mimics the behaviour of LilyPond >= 2.18. (In fact, the starting pitch is then assumed to be f.)
If False, the starting pitch, when not given, is assumed to be c’ (LilyPond < 2.18 behaviour).
Translating the language of pitch names
Inserts a language command in the document.
The command is inserted at the top or just below the version line.
If the LilyPond version specified < (2, 13, 38), the include command is used, otherwise the newer language command.
Changes the language of the pitch names.
May raise ly.pitch.PitchNameNotAvailable if the current pitch language has no quarter tones.
Returns True if there also was a language or include language command that was changed. If not and the cursor specified only a part of the document, you could warn the user that a language or include command should be added to the document. Or you could call insert_language to add a language command to the top of the document.
Transposing music.
Bases: object
Transpose pitches by number of steps within a given scale.
Instantiate with the number of steps (+/-) in the scale to transpose by, and a mode index. The mode index is the index of the major scale in the circle of fifths (C Major = 0).
Bases: ly.pitch.transpose.Transposer
Shift pitches to optional mode/scale.
The scale should be formatted in analogy to the scale in the Transposer parent class.
The key should be an instance of ly.pitch.Pitch.
Bases: ly.pitch.transpose.Transposer
Make complicated accidentals simpler by substituting naturals where possible.
Bases: object
Transpose pitches.
Instantiate with a from- and to-Pitch, and optionally a scale. The scale is a list with the pitch height of the unaltered step (0 .. 6). The default scale is the normal scale: C, D, E, F, G, A, B.
Transpose pitches using the specified transposer.
If relative_first_pitch_absolute is True, the first pitch in a relative expression is considered to be absolute, when a startpitch is not given. This is LilyPond >= 2.18 behaviour.
If relative_first_pitch_absolute is False, the first pitch in a relative expression is considered to be relative to c’, is no startpitch is given. This is LilyPond < 2.18 behaviour.
Currently, relative_first_pitch_absolute defaults to False.