The relative module
Utilities and functions to manipulate music written in relative pitches.
- class Rel2abs(processor=None, first_pitch_absolute=None)[source]
Bases:
Edit
Convert
\relative
music to absolute.Removes the
\relative
command and makes all pitches absolute.processor
: aPitchProcessor
; a default one is used if none is specified.first_pitch_absolute
: if 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 False, the first pitch in a\relative
expression is considered to be relative to c’, if no startpitch is given. This is LilyPond < 2.18 behaviour. If not specified, the function looks at the LilyPond version from the document. If the version can’t be determined, defaults to False, the old behaviour.You may change these attributes after instantiation.
- processor
The
PitchProcessor
; a default one is used if None is specified.
- first_pitch_absolute
Whether to consider the first pitch in a
\relative
expression absolute if a start pitch is not used (by default dependent on LilyPond version).
- rel2abs(music)[source]
Convenience function to convert relative music to absolute in music.
The
music
may be a parce document or cursor, a node range or an element node.
- class Abs2rel(processor=None, start_pitch=True, first_pitch_absolute=None)[source]
Bases:
Edit
Convert music in absolute notation to
\relative
notation.The topmost
MusicList
({
…}
or<<
…>>
) that has child notes gets aRelative
parent node.processor
: aPitchProcessor
; a default one is used if none is specified.start_pitch
: if True, a starting pitch is written after the\relative
command.start_pitch
: if False, thefirst_pitch_absolute
attribute determines the meaning of the first pitch in the new Relative expression. Iffirst_pitch_absolute
is True, the first pitch in the\relative
expression is considered to be absolute, when a startpitch is not given. This is LilyPond >= 2.18 behaviour. If False, the first pitch in a\relative
expression is considered to be relative to c’, if no start pitch is given. This is LilyPond < 2.18 behaviour. If not specified, the function looks at the LilyPond version from the document. If the version can’t be determined, defaults to False, the old behaviour.You may change these attributes after instantiation.
- processor
The
PitchProcessor
; a default one is used if None is specified.
- start_pitch
Whether to write a starting pitch after the
\relative
command.
- first_pitch_absolute
Whether to consider the first pitch in a
\relative
expression absolute if a start pitch is not used (by default dependent on LilyPond version).
- make_relative(node)[source]
Make al notes and pitched rests in the specified
MusicList
orSimultaneousMusicList
node relative.Returns a
Relative
node with the modified music list appended.Replace the node in its parent with the returned node if desired.