The dom.lily module¶
Elements needed for LilyPond expressions.
-
class
Music(*children, **attrs)[source]¶ Bases:
quickly.dom.element.ElementBase class for all elements that contain music.
-
is_sequential()[source]¶ Return True if child music nodes should be played sequentially.
This is used to compute the time position of a child: if this returns False, every child starts at the same position; if True, preceding nodes must be traversed in order to get the time position.
-
transform()[source]¶ Can return a
Transformthat adjusts the duration of child nodes.By default, None is returned.
-
properties()[source]¶ Can return a
Propertiesobject with values to keep in the context of this node.By default, None is returned.
Inside the
Music.time_length()method you can access and modify the accumulated properties of the current Music node via thepropertiesattribute of aTimeContextobject
-
time_length(context, end=None)[source]¶ Return the length of this expression, using a
TimeContexthandler.If
endis given it is the index to stop just before.
-
-
class
HandleDuration(*children, **attrs)[source]¶ Bases:
quickly.dom.element.ElementMixin class to manipulate a Duration child via attributes.
The
duration,scalingandduration_scalingproperties make it easy to manipulate the respective child and grandchild nodes. Floating point values are automatically converted to Fractions, with a limit on the denominator, so a lazynote.scaling = 1/3works properly.-
duration_required= False¶ Whether the Duration child is required (e.g. skip)
-
duration_sets_previous= False¶ Whether this Duration is stored as the previous duration for Durables without Duration
-
duration¶ Read or set the duration.
The duration is the head value of the Duration child. The value is None if there is no Duration child. Delete or set to None to remove the child. (In that case the scaling also disappears.)
-
scaling¶ Read or set the scaling.
The scaling is the value of the DurationScaling child of the Duration child. The value is None if there is no Duration child and 1 if there is no DurationScaling grand child. Delete or set to None to remove the DurationScaling grand child.
Setting the property while there is no duration child raises a ValueError. Setting it to None or 1 removes the DurationScaling grand child.
-
duration_scaling¶ Access duration and scaling in one go.
This value is either a two-tuple (duration, scaling) or None.
-
-
class
Durable(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.HandleDuration,quickly.dom.lily.MusicBase class for a single musical object that takes time and can have a Duration child.
Inherited by:
Note,Rest,Chord,Space,Skip,LyricTextetc.-
duration_required= False¶ Whether the Duration child is required (e.g. skip)
-
duration_sets_previous= True¶ Whether this Duration is stored as the previous duration for Durables without Duration
-
time_length(context, end=None)[source]¶ Return the length of this Durable, using a
TimeContexthandler.For Durable,
endis ignored.
-
-
class
Pitchable(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.TextElement,quickly.dom.lily.MusicBase class for a note or pitched rest.
The head value is the pitch name. To read, write and understand the pitch name, use a
PitchProcessor.This class provides convenient properties to manipulate the
Octave,Accidentaland/orOctCheckchild nodes.Inherited by:
Note,Pitch(a pitch that is no durable music),PitchedRest.-
octave¶ Read or set the octave.
The octave is an integer value, indicating how many
'-s or,-s are displayed after the pitch name. Automatically creates anOctavechild if needed. Delete this attribute or set it to 0 to remove the octave.
-
accidental¶ Read or set the accidental.
The accidental is
None,"cautionary"or"forced". Automatically creates anAccidentalchild if needed. Delete this attribute or set it to None to remove the accidental.
-
-
class
Reference(*children, **attrs)[source]¶ Bases:
quickly.dom.element.ElementBase class for an Element that (potentially) refers to another node, possibly in another DOM tree.
This is used te get the value of a variable, e.g. for the IdentifierRef and the MarkupCommand element types. The
get_value()method returns the value. Here is an example of how it works:>>> from quickly.dom import read >>> m = read.lily_document(r''' ... titled = "blurk" ... ... \header { ... title = "Wilbert" ... composer = \title ... } ... ''', True) >>> m.dump() <lily.Document (2 children)> ├╴<lily.Assignment titled (3 children)> │ ├╴<lily.Identifier (1 child)> │ │ ╰╴<lily.Symbol 'titled' [1:7]> │ ├╴<lily.EqualSign [8:9]> │ ╰╴<lily.String 'blurk' [10:17]> ╰╴<lily.Header (2 children) [19:70]> ├╴<lily.Assignment title (3 children)> │ ├╴<lily.Identifier (1 child)> │ │ ╰╴<lily.Symbol 'title' [31:36]> │ ├╴<lily.EqualSign [37:38]> │ ╰╴<lily.String 'Wilbert' [39:48]> ╰╴<lily.Assignment composer (3 children)> ├╴<lily.Identifier (1 child)> │ ╰╴<lily.Symbol 'composer' [51:59]> ├╴<lily.EqualSign [60:61]> ╰╴<lily.IdentifierRef 'title' [62:68]> >>> n = m[1].composer >>> n <lily.IdentifierRef 'title' [62:68]> >>> n.get_value() <lily.String 'Wilbert' [39:48]> >>> n.head = "titled" >>> n.get_value() <lily.String 'blurk' [10:17]>
The
composerfield in the header is set to the value of the title field. When requesting the value, the value of the title assignment is returned. When we change the name of the variable reference totitled, it finds the “blurk” value in the toplevel document.A reference can also point to another file. A
Scopeis used to define the context of a file and the desired path to look for\includefiles. Here is an example. First we create two LilyPond files:>>> with open('file_a.ly', 'w') as f: ... f.write("music = { c d e f g }\n") ... 22 >>> with open('file_b.ly', 'w') as f: ... f.write('\\include "file_a.ly"\n\n{ \\music }\n') ... 33
Then we load
file_b.lyinto a parce document, and we try to find the value of the\musicvariable:>>> import quickly >>> d = quickly.load('file_b.ly') >>> print(d.text()) \include "file_a.ly" { \music } >>> m = d.get_transform(True) >>> m.dump() <lily.Document (2 children)> ├╴<lily.Include 'file_a.ly' (1 child) [0:8]> │ ╰╴<lily.String 'file_a.ly' [9:20]> ╰╴<lily.MusicList (1 child) [22:32]> ╰╴<lily.IdentifierRef 'music' [24:30]> >>> m[1][0] <lily.IdentifierRef 'music' [24:30]> >>> print(m[1][0].get_value()) None
We see that the returned value is None, meaning that the definition of
musicwas not found infile_b.ly. Now, we create aScopeto find included files, and try it again:>>> from quickly.dom.scope import Scope >>> s = Scope(d) >>> m[1][0].get_value(s) <lily.MusicList (5 children) [8:21]> >>> m[1][0].get_value(s).dump() <lily.MusicList (5 children) [8:21]> ├╴<lily.Note 'c' [10:11]> ├╴<lily.Note 'd' [12:13]> ├╴<lily.Note 'e' [14:15]> ├╴<lily.Note 'f' [16:17]> ╰╴<lily.Note 'g' [18:19]> >>> m[1][0].get_value_with_scope(s) (<lily.MusicList (5 children) [8:21]>, <Scope 'file_a.ly'>)
The
musicinfile_a.lyis found. Theget_value_with_scope()method also returns the scope the definition was found in, which can be used to recursively resolve Reference nodes in the returned node.-
get_value(scope=None, wait=True)[source]¶ Find the value this variable refers to.
Returns the value if found, and None otherwise. For the arguments, see
get_value_with_scope().
-
get_value_with_scope(scope=None, wait=True)[source]¶ Find the value this variable refers to.
Searches for Assignments. If found, returns a two-tuple (value, scope). Otherwise None. The scope is the scope the value was found in.
The
scope, if given, is used to resolve include files. If no scope is given, only searches the current DOM document; the returned scope is then always None.If a scope is given, include commands are followed and
waitdetermines whether to wait for ongoing transformations of external DOM documents. If wait is False, and a transformation is not yet finished, a value found in an included document will not be returned.
-
-
class
HandleAssignments(*children, **attrs)[source]¶ Bases:
quickly.dom.element.ElementMixin class to handle Assignment children in a convenient way.
-
get_variable(name)[source]¶ Convenience method to find the value of the named variable.
Finds an Assignment child that assigns a value to a Identifier with the specified
name. Returns the Element node representing the value, or None if no assignment with that name exists.When the node is a String or an Int, its head value is returned. If no assignment with the name can be found, None is returned.
For the
name, seeIdentifier.set_name().
-
set_variable(name, value)[source]¶ Convenience method to add or replace a variable assignment.
If an Assignment exists with the named variable, replaces its node value; otherwise appends a new Assignment.
If the value is an Element node, it is used directly. If it is an integer, an Int element is created; if it is a string, a String element is created. (If such element was already in use, only the head value is changed.)
-
-
class
Document(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.HandleAssignments,quickly.dom.base.DocumentA full LilyPond source document.
-
version¶ The LilyPond version number, as a tuple of ints (may be empty).
-
-
class
Number(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.TextElementBase class for numeric values.
-
class
Int(head, *children, **attrs)[source]¶ Bases:
quickly.dom.lily.NumberAn integer number.
-
class
Fraction(head, *children, **attrs)[source]¶ Bases:
quickly.dom.lily.NumberA fraction, like
1/2.The head value is a two-tuple of ints (numerator, denominator).
-
fraction()[source]¶ Return the head value as a
fractions.Fraction.
-
-
class
Float(head, *children, **attrs)[source]¶ Bases:
quickly.dom.lily.NumberA floating point number.
-
class
Symbol(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.TextElementA symbol (unquoted text piece).
-
class
String(head, *children, **attrs)[source]¶ Bases:
quickly.dom.base.StringA quoted string.
-
class
Scheme(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.TextElementA Scheme expression in LilyPond.
A Scheme expression can start with
$,#,$@or#@. The latter two are rarely used; they unroll a list in the surrounding expression.A Scheme expression starting with a dollar sign is directly executed by LilyPond when encountered in a source file, it is then ignored when it is no valid expression; an expression starting with a hash sign is evaluated later, when evalating the music expression.
-
space_before= ' '¶
-
space_after= ' '¶
-
-
class
Spanner(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.MappingElementBase class for spanner elements, that start or stop.
Specify
"start"or"stop"to the constructor, and put the texts that are displayed for either in thespanner_startandspanner_stopattribute.-
spanner_start= '<start>'¶
-
spanner_stop= '<stop>'¶
-
find_parallel(limit=0)[source]¶ Try to find the other end of this spanner. May return None.
Does not look outside of the current New or Assignment node. The
limitcan be used to further restrict the number of nodes searched, e.g. to prevent slowness in text editors that do not need to highlight items far offscreen.For example:
>>> from quickly.dom import lily, read >>> n = read.lily(r"{ c\=1( d e f g\=2) a\=1) }", True) >>> n.dump() <lily.MusicList (6 children) [0:27]> ├╴<lily.Note 'c' (1 child) [2:3]> │ ╰╴<lily.Articulations (1 child)> │ ╰╴<lily.SpannerId (2 children) [3:5]> │ ├╴<lily.Int 1 [5:6]> │ ╰╴<lily.Slur 'start' [6:7]> ├╴<lily.Note 'd' [8:9]> ├╴<lily.Note 'e' [10:11]> ├╴<lily.Note 'f' [12:13]> ├╴<lily.Note 'g' (1 child) [14:15]> │ ╰╴<lily.Articulations (1 child)> │ ╰╴<lily.SpannerId (2 children) [15:17]> │ ├╴<lily.Int 2 [17:18]> │ ╰╴<lily.Slur 'stop' [18:19]> ╰╴<lily.Note 'a' (1 child) [20:21]> ╰╴<lily.Articulations (1 child)> ╰╴<lily.SpannerId (2 children) [21:23]> ├╴<lily.Int 1 [23:24]> ╰╴<lily.Slur 'stop' [24:25]> >>> slur = n.find_descendant(6) >>> slur <lily.Slur 'start' [6:7]> >>> slur.find_parallel() <lily.Slur 'stop' [24:25]>
-
-
class
Block(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.HandleAssignments,quickly.dom.element.BlockElementBase class for a block, e.g. score, paper, etc.
Newlines are placed by default between all child nodes. There are convenience methods to access variables inside a block.
-
space_before= '\n'¶
-
space_after= '\n'¶
-
space_after_head= '\n'¶
-
space_before_tail= '\n'¶
-
space_between= '\n'¶
-
head= '<fill in> {'¶
-
tail= '}'¶
-
-
class
Book(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.BlockA book { } block.
-
head= '\\book {'¶
-
-
class
BookPart(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.BlockA bookpart { } block.
-
head= '\\bookpart {'¶
-
-
class
Score(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.BlockA score { } block.
-
head= '\\score {'¶
-
-
class
Header(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.BlockA header { } block.
The standard LilyPond header variables are accessible as attributes. When setting a value to a simple string, a String element is created automatically. When reading a value that is a single String element, the string contents is returned.
For example:
>>> from quickly.dom import lily >>> h = lily.Header() >>> h.title = "My title" >>> h.composer = "Wilbert Berendsen" >>> h.tagline = False >>> print(h.write_indented()) \header { title = "My title" composer = "Wilbert Berendsen" tagline = ##f } >>> h.dump() <lily.Header (2 children)> ├╴<lily.Assignment title (3 children)> │ ├╴<lily.Identifier (1 child)> │ │ ╰╴<lily.Symbol 'title'> │ ├╴<lily.EqualSign> │ ╰╴<lily.String 'My title'> ╰╴<lily.Assignment composer (3 children)> ├╴<lily.Identifier (1 child)> │ ╰╴<lily.Symbol 'composer'> ├╴<lily.EqualSign> ╰╴<lily.String 'Wilbert Berendsen'>
Header variables can also be specified as keyword arguments on construction (just like any attribute):
>>> h = lily.Header(composer="Johann Sebastian Bach")
When a variable is not present, None is returned. Other variable names can be set using
set_variable()and read usingget_variable(). The methodvariables()returns a list with the names of all assignments.Deleting a variable can be done in two ways:
>>> h.title = None >>> del h.title # same as setting to None
-
head= '\\header {'¶
-
dedication¶ The dedication.
-
title¶ The title.
-
subtitle¶ The subtitle.
-
subsubtitle¶ The subsubtitle.
-
instrument¶ The instrument (shown on all pages).
-
poet¶ The poet.
-
composer¶ The composer.
-
meter¶ The meter (shown left).
-
arranger¶ The arranger (shown right).
-
tagline¶ The tagline (at the bottom of the last page).
-
copyright¶ The copyright (at the bottom of the first page).
-
-
class
Paper(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.BlockA paper { } block.
The most used paper variables can be set using properties, which auto-convert string, int and boolean values. Where LilyPond uses hyphens in paper variables, these properties use underscores.
-
head= '\\paper {'¶
-
paper_height¶ Paper height.
-
top_margin¶ Top margin.
-
bottom_margin¶ Bottom margin.
-
ragged_bottom¶ Whether to have a ragged bottom (bool).
-
ragged_last_bottom¶ Whether to have a ragged bottom on the last page (bool).
-
markup_system_spacing¶ Spacing between markup and first system.
-
score_markup_spacing¶ Spacing between score and markup.
-
score_system_spacing¶ Spacing between two adjacent scores.
-
system_system_spacing¶ Spacing between systems of one score.
-
markup_markup_spacing¶ Spacing between two markups.
-
last_bottom_spacing¶ Spacing between the last system or markup and the page bottom.
-
top_system_spacing¶ Spacing between page top and first system.
-
top_markup_spacing¶ Spacing between page top and first markup.
-
paper_width¶ Paper width.
-
line_width¶ Line witdh.
-
left_margin¶ Left margin.
-
right_margin¶ Right margin.
-
check_consistency¶ Check whether all width settings fit.
-
ragged_right¶ Whether to fill out the systems to the right (bool).
-
ragged_last¶ Whether to fill out the last system to the right (bool).
-
two_sided¶ Whether to have mirrored margins for left and right pages.
-
inner_margin¶ Margin at binding side.
-
outer_margin¶ Margin at outer side.
-
binding_offset¶ Extra offset for inner-margin.
-
horizontal_shift¶ Amount al systems and markups are shifted to the right.
-
indent¶ Indent distance for the first system.
-
short_indent¶ Indent distance for all other systems.
-
max_systems_per_page¶ The maximum number of systems on a page.
-
min_systems_per_page¶ The minimum number of systems on a page.
-
systems_per_page¶ How many systems to put on a page.
-
system_count¶ The number of systems to create.
-
page_breaking¶ Page-breaking algorithm to use.
-
page_breaking_system_system_spacing¶ Specially adjust spacing for page breaker.
-
page_count¶ The number of pages to be used.
-
blank_page_penalty¶ Penalty for having a blank page.
-
blank_last_page_penalty¶ Penalty for ending on a left page.
-
blank_after_score_page_penalty¶ Penalty for having a blank page before a score.
-
auto_first_page_number¶ Automatically choose whether to start with even or odd page number.
-
first_page_number¶ The page number for the first page.
-
print_first_page_number¶ Print the page number on the first page (bool).
-
print_page_number¶ Print page numbers anyway (bool).
-
page_spacing_weight¶ Relative importance of page and line spacing.
-
print_all_headers¶ Whether to print all headers in each score (bool).
-
system_separator_markup¶ Markup to use between systems.
-
-
class
Layout(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.BlockA layout { } block.
The most used layout variables can be set using properties, which auto-convert string, int and boolean values. Where LilyPond uses hyphens in paper variables, these properties use underscores.
-
head= '\\layout {'¶
-
line_width¶ Line witdh.
-
ragged_right¶ Whether to fill out the systems to the right (bool).
-
ragged_last¶ Whether to fill out the last system to the right (bool).
-
indent¶ Indent distance for the first system.
-
short_indent¶ Indent distance for all other systems.
-
system_count¶ The number of systems to create.
-
-
class
Midi(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.BlockA midi { } block.
-
head= '\\midi {'¶
-
-
class
With(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.BlockA with { } block.
-
head= '\\with {'¶
-
space_before= ' '¶
-
space_after= ' '¶
-
-
class
LayoutContext(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.BlockA context { } block within layout or midi.
-
head= '\\context {'¶
-
-
class
EqualSign(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementAn equal sign (
=).-
head= '='¶
-
space_before= ' '¶
-
space_after= ' '¶
-
-
class
Separator(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.TextElementA separator.
-
class
List(*children, **attrs)[source]¶ Bases:
quickly.dom.element.ElementA list consisting of String, Scheme, Int or Symbol elements.
Separated by Separator elements; may also contain Comment nodes.
-
class
Assignment(*children, **attrs)[source]¶ Bases:
quickly.dom.element.ElementA variable = value construct.
The first node is a Identifier element, then an EqualSign, and then the value.
-
space_before= '\n'¶
-
space_after= '\n'¶
-
classmethod
with_name(name, node)[source]¶ Convenience constructor to create a complete Assignment.
Automatically creates a Identifier child node for the
name, an EqualSign node, and appends the specifiednodeas the value of the assignment. For thename, seeIdentifier.set_name().
-
-
class
Identifier(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.ListA variable name, the first node is always a Symbol or String.
Further contains Symbol, String, Separator, Int or Scheme. This element is created when a List is encountered in an assignment by the transformer (see
handle_assignments()).-
get_name()[source]¶ Convenience method to get the name of this variable.
This can be a plain string or a tuple. It is a tuple when the variable name consists of multiple parts, separated by dots. The first item in the tuple is always a string, but the other items might also be numbers.
-
set_name(name)[source]¶ Convenience method to set the name of this variable.
In most cases the name is an alphanumeric identifier, but it can be any string (in that case it is automatically quoted) or a tuple of names, strings and even numbers. The first item in the tuple always must be a name or string. An alphanumeric string is turned into a
Symbolelement, a string containing “illegal” characters into aStringelement, and an integer value into aIntelement.
-
-
class
IdentifierRef(head, *children, **attrs)[source]¶ Bases:
quickly.dom.base.BackslashCommand,quickly.dom.lily.ReferenceA
\variablename.The first symbol part is in the head of this element. Additional nodes can be Symbol, String, Separator, Int or Scheme.
For the
\"name", construct, head is the empty string, and the first child is a String. Otherwise, if there are child nodes, the first child is a Separator.For the constructor, the backslash is not needed:
>>> from quickly.dom.lily import * >>> var = IdentifierRef('music') >>> var.write() '\\music' >>> var = IdentifierRef.with_name(('music', 1)) >>> var.write() '\\music.1'
-
classmethod
with_name(name)[source]¶ Convenience method to create a IdentifierRef with specified name.
This is especially useful with complicated names that are not a simple symbol.
-
get_name()[source]¶ Convenience method to get the name of this variable.
The backslash is not returned. The name can be a plain string or a tuple. It is a tuple when the variable name consists of multiple parts, separated by dots. The first item in the tuple is always a string, but the other items might also be numbers.
-
set_name(name)[source]¶ Convenience method to set the name of this variable.
In most cases the name is an alphanumeric identifier, but it can be any string (in that case it is automatically quoted) or a tuple of names, strings and even numbers. The first item in the tuple always must be a name or string. An alphanumeric string is turned into a
Symbolelement, a string containing “illegal” characters into aStringelement, and an integer value into aIntelement.A backslash need not to be prepended.
-
classmethod
-
class
MusicFunction(head, *children, **attrs)[source]¶ Bases:
quickly.dom.base.BackslashCommand,quickly.dom.lily.MusicA generic music function with a backslash, like
\stemUpTo be used if there is no special Element type for the music function. When manually constructing this element, the initial backslash need not to be given. Example:
>>> from quickly.dom.lily import MusicFunction >>> MusicFunction('stemUp').write() '\\stemUp'
-
space_between= ' '¶
-
space_after_head= ' '¶
-
-
class
Context(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.Music\context ....-
space_between= ' '¶
-
space_after_head= ' '¶
-
head= '\\context'¶
-
-
class
New(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.Context\new ....-
head= '\\new'¶
-
-
class
Change(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.Music\change ....-
space_between= ' '¶
-
space_after_head= ' '¶
-
head= '\\change'¶
-
-
class
AddQuote(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementAn
\addQuotecommand, at toplevel.-
space_between= ' '¶
-
space_after_head= ' '¶
-
head= '\\addQuote'¶
-
-
class
QuoteDuring(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicA
\quoteDuringcommand.-
space_between= ' '¶
-
space_after_head= ' '¶
-
head= '\\quoteDuring'¶
-
-
class
ApplyContext(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementThe
\applyContextcommand.-
space_between= ' '¶
-
space_after_head= ' '¶
-
head= '\\applyContext'¶
-
-
class
ApplyMusic(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementThe
\applyMusicfunction.-
space_between= ' '¶
-
space_after_head= ' '¶
-
head= '\\applyMusic'¶
-
-
class
ApplyOutput(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementThe
\applyOutputcommand.-
space_between= ' '¶
-
space_after_head= ' '¶
-
head= '\\applyOutput'¶
-
-
class
Relative(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicRelative music.
-
head= '\\relative'¶
-
space_between= ' '¶
-
space_after_head= ' '¶
-
-
class
Absolute(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicAbsolute music.
-
head= '\\absolute'¶
-
space_between= ' '¶
-
space_after_head= ' '¶
-
-
class
Fixed(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicFixed music.
-
head= '\\fixed'¶
-
space_between= ' '¶
-
space_after_head= ' '¶
-
-
class
Transpose(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicTransposed music.
-
head= '\\transpose'¶
-
space_between= ' '¶
-
space_after_head= ' '¶
-
-
class
Repeat(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicRepeated music.
-
head= '\\repeat'¶
-
space_between= ' '¶
-
space_after_head= ' '¶
-
-
class
Alternative(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicAlternative music for repeats.
-
head= '\\alternative'¶
-
space_between= ' '¶
-
space_after_head= ' '¶
-
-
class
UnfoldRepeats(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicThe
\unfoldRepeatscommand.-
space_between= ' '¶
-
space_after_head= ' '¶
-
head= '\\unfoldRepeats'¶
-
-
class
Unfolded(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicThe
\unfoldedcommand.-
head= '\\unfolded'¶
-
space_between= ' '¶
-
space_after_head= ' '¶
-
-
class
Volta(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicThe
\voltacommand.-
head= '\\volta'¶
-
space_between= ' '¶
-
space_after_head= ' '¶
-
-
class
Transposition(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicA
\tranpositioncommand.-
head= '\\transposition'¶
-
space_between= ' '¶
-
space_after_head= ' '¶
-
-
class
Ottava(*children, **attrs)[source]¶ Bases:
quickly.dom.lily._ConvertUnpitchedToInt,quickly.dom.element.HeadElement,quickly.dom.lily.MusicAn
\ottavacommand.-
space_between= ' '¶
-
space_after_head= ' '¶
-
head= '\\ottava'¶
-
-
class
MusicList(*children, **attrs)[source]¶ Bases:
quickly.dom.element.BlockElement,quickly.dom.lily.MusicA list of music items between
{…}.-
space_after_head= ' '¶
-
space_before_tail= ' '¶
-
space_between= ' '¶
-
head= '{'¶
-
tail= '}'¶
-
-
class
SimultaneousMusicList(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.MusicListA list of music items between
<<…>>.-
head= '<<'¶
-
tail= '>>'¶
-
-
class
Sequential(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicThe
\sequentialcommand, has one MusicList child.-
head= '\\sequential'¶
-
space_between= ' '¶
-
space_after_head= ' '¶
-
-
class
Simultaneous(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicThe
\simultaneouscommand, has one MusicList child.-
head= '\\simultaneous'¶
-
space_between= ' '¶
-
space_after_head= ' '¶
-
-
class
InputMode(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.MusicBase class for any input mode, such as
\figuresor\lyricmode.The head value is the command without backslash prepended.
-
space_between= ' '¶
-
space_after_head= ' '¶
-
-
class
LyricMode(head, *children, **attrs)[source]¶ Bases:
quickly.dom.base.BackslashCommand,quickly.dom.lily.InputMode\lyricmode,\lyricsor\lyricsto.
-
class
ChordMode(head, *children, **attrs)[source]¶ Bases:
quickly.dom.base.BackslashCommand,quickly.dom.lily.InputMode\chordmodeor\chords.
-
class
DrumMode(head, *children, **attrs)[source]¶ Bases:
quickly.dom.base.BackslashCommand,quickly.dom.lily.InputMode\drummodeor\drums.
-
class
NoteMode(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.InputMode\notemode.-
head= '\\notemode'¶
-
-
class
FigureMode(head, *children, **attrs)[source]¶ Bases:
quickly.dom.base.BackslashCommand,quickly.dom.lily.InputMode\figuremodeor\figures.
-
class
Chord(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.DurableA chord. Must have a ChordBody element.
-
time_length(context, end=None)[source]¶ Return the length of this Durable, using a
TimeContexthandler.For Chord,
endis ignored; returns 0 if the chord is empty, in accordance with LilyPond’s behaviour.
-
-
class
ChordBody(*children, **attrs)[source]¶ Bases:
quickly.dom.element.BlockElementThe body of a chord
<…>.Always the child of a Chord, which can have a duration and articulations. Contains Note elements.
-
space_between= ' '¶
-
head= '<'¶
-
tail= '>'¶
-
-
class
Note(head, *children, **attrs)[source]¶ Bases:
quickly.dom.lily.Pitchable,quickly.dom.lily.DurableA musical note.
-
class
Pitch(head, *children, **attrs)[source]¶ Bases:
quickly.dom.lily.PitchableA pitch name.
This is used as pitch argument for
\transpose,\tranposition,\fixed,\relative,\keyetc. The difference withNoteis that a Pitch is not a Durable and can’t have a duration or articulations.
-
class
Unpitched(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.DurableAn unpitched note, always has a Duration child.
-
duration_required= True¶ always needs a duration
-
-
class
RestType(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.DurableBase class for Rest, PitchedRest and MultiMeasureRest.
-
class
Rest(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.RestType-
head= 'r'¶ A normal rest (
r).
-
-
class
MultiMeasureRest(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.Rest-
head= 'R'¶ A multi-measure rest (
R).
-
-
class
PitchedRest(head, *children, **attrs)[source]¶ Bases:
quickly.dom.lily.Pitchable,quickly.dom.lily.RestTypeA pitched rest.
This rest has a pitchname but also a RestModifier child, e.g.
c\rest. It is a normal rest, but vertically positioned using a pitch name, which is the head value. This element can also have an Octave or OctCheck.
-
class
Space(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.DurableA space (
s).-
head= 's'¶
-
-
class
Skip(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.DurableA
\skip.For LilyPond version upto and including 2.22, must have a Duration child. For LilyPond version from 2.23.6, may have a Music argument instead, which then defines the length of the skip.
With a duration, LilyPond creates a SkipMusic event; with a music argument, LilyPond creates a SkippedMusic construct with music that’s just not printed and does not create outputs, but whose length is computed precisely.
We handle both; the
duration_requiredmeans here that it may not be removed if it’s there. If there is no direct Duration child, the Skip is not to be regarded as a regular Durable, but rather as a music function.-
head= '\\skip'¶
-
space_after_head= ' '¶
-
duration_required= True¶ always needs a duration
-
duration_sets_previous= False¶ the “previous” duration is not changed by skip
-
time_length(context, end=None)[source]¶ Return the length of this Durable, using a
TimeContexthandler.Reimplemented to handle the case where
\skiphas a music argument instead of a Duration argument.
-
signatures()[source]¶ Return an iterable of signature tuples.
A signature is a tuple. Every item in the tuple is an Element type, or a tuple of Element types; and is used with
build_tree()to see whether an element can be a child of this element.By default an empty iterable is returned.
-
child_order()[source]¶ Return an iterable of tuples with element types.
This is almost the same as
signatures()but used when a child node is inserted usingadd().By default an empty iterable is returned.
-
-
class
After(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.HandleDuration,quickly.dom.lily.MusicAn
\after. Must have a Duration child and an event.-
head= '\\after'¶
-
-
class
Q(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.DurableA
q, repeating the previous chord.The repeated chord always has the same absolute pitch, Octave childs are not possible. LilyPond signals a warning if there is no previous chord in the current music expression, and the q becomes a skip.
Articulations attached to the repeated chord or to its individual notes are not copied, but internal tweaks to the noteheads are.
-
head= 'q'¶
-
-
class
Drum(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.TextElement,quickly.dom.lily.DurableA drum note.
-
class
Accidental(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.MappingElementThe accidental after a note.
Can be
cautionaryorforced.-
mapping= {'!': 'forced', '?': 'cautionary'}¶
-
-
class
Octave(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.TextElementThe octave after a note.
The head value is the number of
'(if positive) or the number of,, if negative.
-
class
OctCheck(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.TextElementThe octavecheck after a note, e.g. like
=,.The head value is the number of
'(if positive) or the number of,, if negative.
-
class
OctaveCheck(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementThe
\octaveCheckcommand.-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\octaveCheck'¶
-
-
class
Duration(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.TextElementA duration after a note.
To the constructor the duration is specified using a numerical value, which can be a
Fraction. A whole note is 1, a breve 2, etc; a quarter note or crotchet 1/4, etc.The value must be expressable (is that English?:-) in a length value and zero or more dots. Examples:
>>> from quickly.dom.lily import Duration >>> Duration(2).write() '\breve' >>> Duration(3/2).write() '1.' >>> Duration(7/4).write() '1..' >>> Duration(7/16).write() '4..'
-
classmethod
from_string(text)[source]¶ Convenience constructor to make a Duration from a string.
Examples:
>>> lily.Duration.from_string('4') <lily.Duration Fraction(1, 4)> >>> lily.Duration.from_string('2.') <lily.Duration Fraction(3, 4)> >>> d = lily.Duration.from_string('1*1/3') >>> d.dump() <lily.Duration Fraction(1, 1) (1 child)> ╰╴<lily.DurationScaling Fraction(1, 3)> >>> d.duration() Fraction(1, 3)
-
classmethod
from_duration(duration, scaling=1)[source]¶ Convenience constructor to make a Duration from a duration and scaling value.
An example:
>>> from quickly.dom.lily import Duration >>> d = Duration.from_duration(1/4) >>> d.write() '4' >>> d = Duration.from_duration(1/4, 1/3) >>> d.write() '4*1/3'
-
duration()[source]¶ Return the two-tuple(duration, scaling).
The duration is simply our head value, the scaling is computed from a
DurationScalingchild if present, or 1.
-
classmethod
-
class
DurationScaling(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.TextElementAn optional scaling after a
Duration.E.g.
*1/2. May be read from multiple*n/mparts, but always outputs a single*n/dvalue, or*nwhen the denominator is 1. To the constructor any numerical value may be given, but the value is always represented as a fraction (omitting the denominator if 1).
-
class
LyricItem(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.DurableWrap a Scheme, String, Symbol or Markup in lyricmode.
If it has no Scherm, String, Symbol or Markup child, a duration is required.
-
child_order()[source]¶ Return an iterable of tuples with element types.
This is almost the same as
signatures()but used when a child node is inserted usingadd().By default an empty iterable is returned.
-
duration_required¶ Duration is required if no visible child.
-
-
class
LyricText(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.TextElement,quickly.dom.lily.DurableA word in lyric mode.
-
class
LyricExtender(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementA lyric extender
__.-
head= '__'¶
-
-
class
LyricHyphen(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementA lyric hyphen
--.-
head= '--'¶
-
-
class
LyricSkip(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.DurableA lyric skip
_.-
head= '_'¶
-
-
class
ChordModifiers(*children, **attrs)[source]¶ Bases:
quickly.dom.element.ElementA list of elements attachted to a note in chord mode.
-
class
AddSteps(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementContains the steps to be added in chordmode.
-
head= ':'¶
-
-
class
RemoveSteps(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementContains the steps to be added in chordmode.
-
head= '^'¶
-
-
class
Qualifier(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.TextElementA qualifier like
majin chord mode.
-
class
Inversion(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementInversion (
/) in chordmode.-
head= '/'¶
-
-
class
AddInversion(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementInversion adding the bass note (
/+) in chordmode.-
head= '/+'¶
-
-
class
Step(head, *children, **attrs)[source]¶ Bases:
quickly.dom.lily.IntContains the steps to be added in chordmode.
-
class
Alteration(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.TextElementThe alteration of a step (
+or-).
-
class
Articulations(*children, **attrs)[source]¶ Bases:
quickly.dom.element.ElementA list of elements that are attached to a note or chord.
-
class
Direction(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.MappingElementA
-,_or^.The value is -1 for
_, 0 for-or 1 for^-
mapping= {'-': 0, '^': 1, '_': -1}¶
-
-
class
Articulation(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.TextElementAn ArticulationEvent.
-
class
Modifier(head, *children, **attrs)[source]¶ Bases:
quickly.dom.base.BackslashCommandA generic modifier that is not an articulation but added to the Articulations after a note.
For example
\noBeam.The backslash is not in the head value.
-
class
RestModifier(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementA
\restcommand after a note.Is a child of a Rest element that has a pitch name and possibly octave information instead of plain “r”.
-
head= '\\rest'¶
-
-
class
Fingering(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.TextElementA FingeringEvent.
-
class
Dynamic(head, *children, **attrs)[source]¶ Bases:
quickly.dom.base.BackslashCommandA dynamic symbol, like
pp.
-
class
Slur(head, *children, **attrs)[source]¶ Bases:
quickly.dom.lily.SpannerA slur
(or).-
spanner_start= '('¶
-
spanner_stop= ')'¶
-
mapping= {'(': 'start', ')': 'stop'}¶
-
-
class
PhrasingSlur(head, *children, **attrs)[source]¶ Bases:
quickly.dom.lily.SpannerA phrasing slur
\(or\).-
spanner_start= '\\('¶
-
spanner_stop= '\\)'¶
-
mapping= {'\\(': 'start', '\\)': 'stop'}¶
-
-
class
Tie(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementA tie.
-
head= '~'¶
-
-
class
LaissezVibrer(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.TieA
\laissezVibrertie.-
head= '\\laissezVibrer'¶
-
-
class
RepeatTie(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.TieA
\repeatTietie.-
head= '\\repeatTie'¶
-
-
class
Beam(head, *children, **attrs)[source]¶ Bases:
quickly.dom.lily.SpannerA beam
[or].-
spanner_start= '['¶
-
spanner_stop= ']'¶
-
mapping= {'[': 'start', ']': 'stop'}¶
-
-
class
Ligature(head, *children, **attrs)[source]¶ Bases:
quickly.dom.lily.SpannerA ligature
\[or\].-
spanner_start= '\\['¶
-
spanner_stop= '\\]'¶
-
mapping= {'\\[': 'start', '\\]': 'stop'}¶
-
-
class
TextSpanner(head, *children, **attrs)[source]¶ Bases:
quickly.dom.lily.SpannerA text spanner.
-
spanner_start= '\\startTextSpan'¶
-
spanner_stop= '\\stopTextSpan'¶
-
mapping= {'\\startTextSpan': 'start', '\\stopTextSpan': 'stop'}¶
-
-
class
TrillSpanner(head, *children, **attrs)[source]¶ Bases:
quickly.dom.lily.SpannerA trill spanner.
-
spanner_start= '\\startTrillSpan'¶
-
spanner_stop= '\\stopTrillSpan'¶
-
mapping= {'\\startTrillSpan': 'start', '\\stopTrillSpan': 'stop'}¶
-
-
class
Melisma(head, *children, **attrs)[source]¶ Bases:
quickly.dom.lily.SpannerA melisma spanner.
-
spanner_start= '\\melisma'¶
-
spanner_stop= '\\melismaEnd'¶
-
mapping= {'\\melisma': 'start', '\\melismaEnd': 'stop'}¶
-
-
class
Arpeggio(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicAn
\arpeggio.-
head= '\\arpeggio'¶
-
-
class
Glissando(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicA
\glissando.-
head= '\\glissando'¶
-
-
class
Bar(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicA
\bar. Has a String child.-
space_after_head= ' '¶
-
head= '\\bar'¶
-
-
class
Breathe(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicA
\breathe.-
head= '\\breathe'¶
-
-
class
Break(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.ToggleElementA
\breakor\noBreak.-
toggle_on= '\\break'¶
-
toggle_off= '\\noBreak'¶
-
mapping= {'\\break': True, '\\noBreak': False}¶
-
-
class
PageBreak(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.ToggleElementA
\pageBreakor\noPageBreak.-
toggle_on= '\\pageBreak'¶
-
toggle_off= '\\noPageBreak'¶
-
mapping= {'\\noPageBreak': False, '\\pageBreak': True}¶
-
-
class
PageTurn(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.MappingElementA
\pageTurn,\allowPageTurnor\noPageTurn.-
mapping= {'\\allowPageTurn': 'allow', '\\noPageTurn': 'no', '\\pageTurn': 'yes'}¶
-
-
class
InStaffSegno(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicAn
\inStaffSegnocommand.-
head= '\\inStaffSegno'¶
-
-
class
PipeSymbol(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementA PipeSymbol, most times used as bar check.
-
head= '|'¶
-
-
class
VoiceSeparator(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementA voice separator.
-
head= '\\\\'¶
-
-
class
Label(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicA
\labelcommand. Has one scheme expression child.-
head= '\\label'¶
-
-
class
Mark(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicA
\markcommand. Has one child.-
head= '\\mark'¶
-
-
class
Default(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementThe
\defaultmark argument.-
head= '\\default'¶
-
-
class
Tempo(*children, **attrs)[source]¶ Bases:
quickly.dom.lily._ConvertUnpitchedToDuration,quickly.dom.lily.HandleDuration,quickly.dom.element.HeadElement,quickly.dom.lily.MusicA
\tempocommand.Can have text (symbol, string, markup) child and/or duration, EqualSign and numeric value childs.
-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\tempo'¶
-
child_order()[source]¶ Return an iterable of tuples with element types.
This is almost the same as
signatures()but used when a child node is inserted usingadd().By default an empty iterable is returned.
-
-
class
SpannerId(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementA spanner id (
\=).The first child is the id (Int, Symbol, String or Scheme). The second child the attached slur, phrasing slur or other object. (LilyPond only supports slurs).
-
head= '\\='¶
-
-
class
PesOrFlexa(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementA pes-or-flexa event (
\~).-
head= '\\~'¶
-
-
class
Tweak(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementA
\tweakcommand.On the music level, this node has two children, a Symbol and an argument. As an event after a note, this node has three children, the symbol, the argument and the object to tweak.
-
space_after_head= ' '¶
-
space_between= ' '¶
-
space_after= ' '¶
-
head= '\\tweak'¶
-
-
class
Tremolo(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementA Tremolo (
:) with an optional Duration child.-
head= ':'¶
-
-
class
Mode(head, *children, **attrs)[source]¶ Bases:
quickly.dom.base.BackslashCommandThe mode subcommand of the
\keystatement.
-
class
Key(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicA key statement.
Must have a Pitch and a (Mode, IdentifierRef or Scheme) child.
-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\key'¶
-
key_signature(processor, scope=None, wait=True)[source]¶ Return a
KeySignatureobject for this key signature.The processor is a
PitchProcessor, which interprets the pitch language.scopeandwaithelp (when the mode argument is a variable) finding its value in another file.
-
-
class
Clef(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicA
\clefstatement.Must have a Symbol or String child indicating the clef type.
-
space_after_head= ' '¶
-
head= '\\clef'¶
-
-
class
Time(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicA
\timestatement.Has an optional List child and a Fraction child.
-
space_after_head= ' '¶
-
head= '\\time'¶
-
-
class
Partial(*children, **attrs)[source]¶ Bases:
quickly.dom.lily._ConvertUnpitchedToDuration,quickly.dom.lily.HandleDuration,quickly.dom.element.HeadElement,quickly.dom.lily.MusicA
\partialstatement.Has a Duration child.
-
space_after_head= ' '¶
-
head= '\\partial'¶
-
-
class
Times(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicA
\timesstatement.Has a Fraction child and a Music child. The
\timescommand is not documented anymore in LilyPond, but also not deprecated. Using\tupletis recommended.-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\times'¶
-
-
class
Tuplet(*children, **attrs)[source]¶ Bases:
quickly.dom.lily._ConvertUnpitchedToDuration,quickly.dom.lily.HandleDuration,quickly.dom.element.HeadElement,quickly.dom.lily.MusicA
\tupletstatement.Has a Fraction child, an optional Duration child and a Music child.
-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\tuplet'¶
-
child_order()[source]¶ Return an iterable of tuples with element types.
This is almost the same as
signatures()but used when a child node is inserted usingadd().By default an empty iterable is returned.
-
-
class
ScaleDurations(*children, **attrs)[source]¶ Bases:
quickly.dom.lily._ConvertUnpitchedToInt,quickly.dom.element.HeadElement,quickly.dom.lily.MusicA
\scaleDurationscommand.Has a Fraction child and a Music child.
-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\scaleDurations'¶
-
-
class
ShiftDurations(*children, **attrs)[source]¶ Bases:
quickly.dom.lily._ConvertUnpitchedToInt,quickly.dom.element.HeadElement,quickly.dom.lily.MusicA
\shiftDurationscommand.Has two Scheme children and a Music child.
-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\shiftDurations'¶
-
-
class
Grace(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicA
\gracecommand.Has a Music child.
-
space_after_head= ' '¶
-
head= '\\grace'¶
-
-
class
Acciaccatura(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.GraceAn
\acciaccaturacommand.Has a Music child.
-
head= '\\acciaccatura'¶
-
-
class
Appoggiatura(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.GraceAn
\appoggiaturacommand.Has a Music child.
-
head= '\\appoggiatura'¶
-
-
class
SlashedGrace(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.GraceA
\slashedGracecommand.Has a Music child.
-
head= '\\slashedGrace'¶
-
-
class
AfterGrace(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicAn
\afterGracecommand.Has an optional Fraction and two Music children. The second music expression is the grace music and has length 0, the fraction is multiplied with the duration of the first music expression and determines the moment the grace music is displayed.
The default fraction (if not specified) is in the toplevel
afterGraceFractionvariable or 3/4.-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\afterGrace'¶
-
time_length(context, end=None)[source]¶ Return the length of this expression, using a
TimeContexthandler.Reimplemented to skip the second child music expression.
-
-
class
PartCombine(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicThe
\partcombinecommand, with two Music arguments.-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\partcombine'¶
-
-
class
MultilineComment(head, *children, **attrs)[source]¶ Bases:
quickly.dom.base.MultilineCommentA multiline comment between
%{and%}.
-
class
SinglelineComment(head, *children, **attrs)[source]¶ Bases:
quickly.dom.base.SinglelineCommentA singleline comment after
%.-
space_after= '\n'¶
-
-
class
Markup(head, *children, **attrs)[source]¶ Bases:
quickly.dom.base.BackslashCommandA
\markup,\markuplinesor\markuplistexpression.When manually constructing a Markup, the backslash is not needed.
-
space_before= ''¶
-
space_after= ' '¶
-
space_between= ' '¶
-
space_after_head= ' '¶
-
-
class
MarkupWord(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.TextElementA word in markup mode.
-
space_before= ' '¶
-
space_after= ' '¶
-
-
class
MarkupList(*children, **attrs)[source]¶ Bases:
quickly.dom.element.BlockElementA bracketed markup expression, like
{…}.-
space_after_head= ' '¶
-
space_before_tail= ' '¶
-
space_between= ' '¶
-
head= '{'¶
-
tail= '}'¶
-
-
class
MarkupCommand(head, *children, **attrs)[source]¶ Bases:
quickly.dom.base.BackslashCommand,quickly.dom.lily.ReferenceA markup command, like
\bold <arg>.When manually constructing a MarkupCommand, the backslash is not needed.
-
space_after_head= ' '¶
-
space_before_tail= ' '¶
-
space_between= ' '¶
-
-
class
MarkupScore(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.ScoreA
\scorein Markup.-
space_after_head= ' '¶
-
space_before_tail= ' '¶
-
space_between= ' '¶
-
-
class
MarkupScoreLines(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.MarkupScoreA
\score-linesin Markup.-
head= '\\score-lines {'¶
-
-
class
Figure(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.MusicA bass figure in figure mode.
Always has one FigureBody child, which contains the numbers etc. Can also have a duration child.
-
class
FigureBody(*children, **attrs)[source]¶ Bases:
quickly.dom.element.BlockElementOne
<…>figure “chord” in figuremode.Always the child of a Figure element, which can have a duration.
-
space_between= ' '¶
-
head= '<'¶
-
tail= '>'¶
-
-
class
FigureBracket(*children, **attrs)[source]¶ Bases:
quickly.dom.element.BlockElementOne
[…]bracketed set of figures in figuremode.-
space_between= ' '¶
-
head= '['¶
-
tail= ']'¶
-
-
class
FigureStep(head, *children, **attrs)[source]¶ Bases:
quickly.dom.lily.IntA step number in figure mode.
-
class
FigureSkip(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementThe invisible figure step
_.-
head= '_'¶
-
-
class
FigureAccidental(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.MappingElementAn accidental in figure mode.
- One of: -1, -0.5, 0, 0.5, 1, corresponding to:
'--','-','','+'or'++'.
-
mapping= {'': 0, '+': 0.5, '++': 1, '-': -0.5, '--': -1}¶
-
class
FigureAlteration(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.MappingElementAn alteration in figure mode.
One of: “augmented”, “diminished”, “raised” or “end-of-line”, corresponding to: +, /, \ or !.
-
mapping= {'/': 'diminished', '\\!': 'end-of-line', '\\+': 'augmented', '\\\\': 'raised'}¶
-
-
class
Tag(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementA
\tagcommand.-
head= '\\tag'¶
-
-
class
KeepWithTag(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementA
\keepWithTagcommand.-
head= '\\keepWithTag'¶
-
-
class
RemoveWithTag(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementA
\removeWithTagcommand.-
head= '\\removeWithTag'¶
-
-
class
TagGroup(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementA
\tagGroupcommand.-
head= '\\tagGroup'¶
-
-
class
PushToTag(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementA
\pushToTagcommand.-
head= '\\pushToTag'¶
-
-
class
AppendToTag(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementA
\appendToTagcommand.-
head= '\\appendToTag'¶
-
-
class
Etc(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementThe
\etcplaceholder.-
head= '\\etc'¶
-
-
class
Accepts(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementThe
\acceptscommand.-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\accepts'¶
-
-
class
Denies(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementThe
\deniescommand.-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\denies'¶
-
-
class
Name(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementThe
\namecommand.-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\name'¶
-
-
class
Alias(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementThe
\aliascommand.-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\alias'¶
-
-
class
Consists(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementThe
\consistscommand.-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\consists'¶
-
-
class
Remove(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementThe
\removecommand.-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\remove'¶
-
-
class
DefaultChild(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementThe
\defaultchildcommand.-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\defaultchild'¶
-
-
class
Omit(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicThe
\omitcommand.-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\omit'¶
-
-
class
Hide(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicThe
\hidecommand.-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\hide'¶
-
-
class
Undo(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicThe
\undocommand.-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\undo'¶
-
-
class
Once(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicThe
\oncecommand.-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\once'¶
-
-
class
Temporary(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicThe
\temporarycommand.-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\temporary'¶
-
-
class
Override(*children, **attrs)[source]¶ Bases:
quickly.dom.lily._ConvertUnpitchedToInt,quickly.dom.element.HeadElement,quickly.dom.lily.MusicThe
\overridecommand.-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\override'¶
-
-
class
Revert(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicThe
\revertcommand.-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\revert'¶
-
-
class
Set(*children, **attrs)[source]¶ Bases:
quickly.dom.lily._ConvertUnpitchedToInt,quickly.dom.element.HeadElement,quickly.dom.lily.MusicThe
\setcommand.-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\set'¶
-
-
class
Unset(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicThe
\unsetcommand.-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\unset'¶
-
-
class
Version(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElement,quickly.dom.lily.MusicThe
\versioncommand.-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\version'¶
-
version¶ The version number, as a tuple of ints (may be empty).
-
-
class
Language(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementThe
\languagecommand.Has a
Stringchild with the language name, which can be conveniently edited via thelanguageattribute.-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\language'¶
-
signatures()[source]¶ Return an iterable of signature tuples.
A signature is a tuple. Every item in the tuple is an Element type, or a tuple of Element types; and is used with
build_tree()to see whether an element can be a child of this element.By default an empty iterable is returned.
-
language¶ The language.
-
-
class
Include(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementThe
\includecommand.You can use the :attr:
languageattribute, assuming that the included file is a language definition file. If thefilenameis not recognized as a language definition file, the property will return None.-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\include'¶
-
signatures()[source]¶ Return an iterable of signature tuples.
A signature is a tuple. Every item in the tuple is an Element type, or a tuple of Element types; and is used with
build_tree()to see whether an element can be a child of this element.By default an empty iterable is returned.
-
filename¶ The filename.
-
language¶ The language, if the filename refers to a known language definition.
Setting the attribute appends the
".ly"automatically.
-
-
class
VoiceN(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.MappingElementCommands like
\voiceOne,\voiceTwo, etc.-
mapping= {'\\voiceFive': 5, '\\voiceFour': 4, '\\voiceOne': 1, '\\voiceSix': 6, '\\voiceThree': 3, '\\voiceTwo': 2}¶
-
-
class
GrobDirection(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.MappingElementA collection of commands concerning direction, like
\slurUp.To create a
\slurUpcommand, use:>>> node = lily.GrobDirection(("Slur", 1)) >>> node.write() '\\slurUp'
Or:
>>> node = lily.GrobDirection.from_mapping(r'\slurUp')
When reading this node programmatically, the
grobanddirectionattributes can be read and modified:>>> node.grob 'Slur' >>> node.direction 1 >>> node.write() '\\slurUp' >>> node.direction = -1 >>> node.write() '\\slurDown'
The
grobsclass attribute is a dictionary mapping each available grob to a tuple of the directions it supports. (Technically not all named objects are grobs (graphical objects).) Most “grobs” support all three directions: Up (1), Neutral (0), Down (-1).-
mapping= {'\\arpeggioArrowDown': ('ArpeggioArrow', -1), '\\arpeggioArrowUp': ('ArpeggioArrow', 1), '\\bassFigureStaffAlignmentDown': ('BassFigureStaffAlignment', -1), '\\bassFigureStaffAlignmentNeutral': ('BassFigureStaffAlignment', 0), '\\bassFigureStaffAlignmentUp': ('BassFigureStaffAlignment', 1), '\\dotsDown': ('Dots', -1), '\\dotsNeutral': ('Dots', 0), '\\dotsUp': ('Dots', 1), '\\dynamicDown': ('Dynamic', -1), '\\dynamicNeutral': ('Dynamic', 0), '\\dynamicUp': ('Dynamic', 1), '\\phrasingSlurDown': ('PhrasingSlur', -1), '\\phrasingSlurNeutral': ('PhrasingSlur', 0), '\\phrasingSlurUp': ('PhrasingSlur', 1), '\\slurDown': ('Slur', -1), '\\slurNeutral': ('Slur', 0), '\\slurUp': ('Slur', 1), '\\stemDown': ('Stem', -1), '\\stemNeutral': ('Stem', 0), '\\stemUp': ('Stem', 1), '\\textSpannerDown': ('TextSpanner', -1), '\\textSpannerNeutral': ('TextSpanner', 0), '\\textSpannerUp': ('TextSpanner', 1), '\\tieDown': ('Tie', -1), '\\tieNeutral': ('Tie', 0), '\\tieUp': ('Tie', 1), '\\tupletDown': ('Tuplet', -1), '\\tupletNeutral': ('Tuplet', 0), '\\tupletUp': ('Tuplet', 1)}¶
-
grobs= {'ArpeggioArrow': (-1, 1), 'BassFigureStaffAlignment': (-1, 0, 1), 'Dots': (-1, 0, 1), 'Dynamic': (-1, 0, 1), 'PhrasingSlur': (-1, 0, 1), 'Slur': (-1, 0, 1), 'Stem': (-1, 0, 1), 'TextSpanner': (-1, 0, 1), 'Tie': (-1, 0, 1), 'Tuplet': (-1, 0, 1)}¶
-
grob¶ The grob (graphical object), starting with a Capital.
-
direction¶ The direction, 1 for up, 0 for neutral, -1 for down.
-
-
class
GrobStyle(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.MappingElementA collection of commands concerning direction, like
\slurDashed.To create a
\slurDashedcommand, use:>>> node = lily.GrobStyle(("Slur", "dashed")) >>> node.write() '\\slurDashed'
Or:
>>> node = lily.GrobStyle.from_mapping(r'\slurDashed')
When reading this node programmatically, the
grobandstyleattributes can be read and modified:>>> node.grob 'Slur' >>> node.style 'dashed' >>> node.write() '\\slurDashed' >>> node.style = "dotted" >>> node.write() '\\slurDotted'
The
grobsclass attribute is a dictionary mapping each available grob to a tuple of the styles it supports. All grobs support the styles"solid","dashed","half_solid","half_dashed", and"dotted".-
mapping= {'\\phrasingSlurDashed': ('PhrasingSlur', 'dashed'), '\\phrasingSlurDotted': ('PhrasingSlur', 'dotted'), '\\phrasingSlurHalfDashed': ('PhrasingSlur', 'half_dashed'), '\\phrasingSlurHalfSolid': ('PhrasingSlur', 'half_solid'), '\\phrasingSlurSolid': ('PhrasingSlur', 'solid'), '\\slurDashed': ('Slur', 'dashed'), '\\slurDotted': ('Slur', 'dotted'), '\\slurHalfDashed': ('Slur', 'half_dashed'), '\\slurHalfSolid': ('Slur', 'half_solid'), '\\slurSolid': ('Slur', 'solid'), '\\tieDashed': ('Tie', 'dashed'), '\\tieDotted': ('Tie', 'dotted'), '\\tieHalfDashed': ('Tie', 'half_dashed'), '\\tieHalfSolid': ('Tie', 'half_solid'), '\\tieSolid': ('Tie', 'solid')}¶
-
grobs= {'PhrasingSlur': ('dashed', 'dotted', 'half_dashed', 'half_solid', 'solid'), 'Slur': ('dashed', 'dotted', 'half_dashed', 'half_solid', 'solid'), 'Tie': ('dashed', 'dotted', 'half_dashed', 'half_solid', 'solid')}¶
-
grob¶ The grob (graphical object), starting with a Capital.
-
style¶ The style:
"solid","dashed", or"dotted".
-
-
class
GrobDashPattern(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.MappingElement,quickly.dom.lily._ConvertUnpitchedToIntThe commands
\slur-\tie- and\phrasingSlurDashPattern.-
mapping= {'\\phrasingSlurDashPattern': 'PhrasingSlur', '\\slurDashPattern': 'Slur', '\\tieDashPattern': 'Tie'}¶
-
-
class
Toggle(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.MappingElementA collection of commands that can be on/off, like
\textLengthOn.To create a
\textLengthOncommand, use:>>> node = lily.Toggle(("textLength", True)) >>> node.write() '\\textLengthOn'
Or:
>>> node = lily.Toggle.from_mapping(r'\textLengthOn')
When reading this node programmatically, the
propandvalueattributes can be read and modified:>>> node.prop 'textLength' >>> node.value True >>> node.write() '\\textLengthOn' >>> node.value = False >>> node.write() '\\textLengthOff'
The
propsclass attribute is a tuple with all available prop names. All props support the values True and False.-
props= ('autoBeam', 'autoBreaks', 'autoLineBreaks', 'autoPageBreaks', 'balloonLength', 'bassFigureExtenders', 'cadenza', 'deadNotes', 'easyHeads', 'improvisation', 'harmonics', 'kievan', 'markLength', 'mergeDifferentlyDotted', 'mergeDifferentlyHeaded', 'palmMute', 'pointAndClick', 'predefinedFretboards', 'sostenuto', 'sustain', 'textLength', 'xNotes')¶
-
mapping= {'\\autoBeamOff': ('autoBeam', False), '\\autoBeamOn': ('autoBeam', True), '\\autoBreaksOff': ('autoBreaks', False), '\\autoBreaksOn': ('autoBreaks', True), '\\autoLineBreaksOff': ('autoLineBreaks', False), '\\autoLineBreaksOn': ('autoLineBreaks', True), '\\autoPageBreaksOff': ('autoPageBreaks', False), '\\autoPageBreaksOn': ('autoPageBreaks', True), '\\balloonLengthOff': ('balloonLength', False), '\\balloonLengthOn': ('balloonLength', True), '\\bassFigureExtendersOff': ('bassFigureExtenders', False), '\\bassFigureExtendersOn': ('bassFigureExtenders', True), '\\cadenzaOff': ('cadenza', False), '\\cadenzaOn': ('cadenza', True), '\\deadNotesOff': ('deadNotes', False), '\\deadNotesOn': ('deadNotes', True), '\\easyHeadsOff': ('easyHeads', False), '\\easyHeadsOn': ('easyHeads', True), '\\harmonicsOff': ('harmonics', False), '\\harmonicsOn': ('harmonics', True), '\\improvisationOff': ('improvisation', False), '\\improvisationOn': ('improvisation', True), '\\kievanOff': ('kievan', False), '\\kievanOn': ('kievan', True), '\\markLengthOff': ('markLength', False), '\\markLengthOn': ('markLength', True), '\\mergeDifferentlyDottedOff': ('mergeDifferentlyDotted', False), '\\mergeDifferentlyDottedOn': ('mergeDifferentlyDotted', True), '\\mergeDifferentlyHeadedOff': ('mergeDifferentlyHeaded', False), '\\mergeDifferentlyHeadedOn': ('mergeDifferentlyHeaded', True), '\\palmMuteOff': ('palmMute', False), '\\palmMuteOn': ('palmMute', True), '\\pointAndClickOff': ('pointAndClick', False), '\\pointAndClickOn': ('pointAndClick', True), '\\predefinedFretboardsOff': ('predefinedFretboards', False), '\\predefinedFretboardsOn': ('predefinedFretboards', True), '\\sostenutoOff': ('sostenuto', False), '\\sostenutoOn': ('sostenuto', True), '\\sustainOff': ('sustain', False), '\\sustainOn': ('sustain', True), '\\textLengthOff': ('textLength', False), '\\textLengthOn': ('textLength', True), '\\xNotesOff': ('xNotes', False), '\\xNotesOn': ('xNotes', True)}¶
-
prop¶ The property that can be on or off.
-
value¶ The value (True for
"On", False for"Off").
-
-
class
Shape(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementThe
\shapecommand.Has a Scheme and a SYMBOL child. (As articulation, has only a Scheme child.)
-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\shape'¶
-
-
class
VShape(*children, **attrs)[source]¶ Bases:
quickly.dom.lily.ShapeThe
\vshapecommand.Like
\shapebut draws the control points.-
head= '\\vshape'¶
-
-
class
StringTuning(*children, **attrs)[source]¶ Bases:
quickly.dom.element.HeadElementThe
\stringTuningcommand, with one Chord argument.-
space_after_head= ' '¶
-
space_between= ' '¶
-
head= '\\stringTuning'¶
-
-
class
Unit(head, *children, **attrs)[source]¶ Bases:
quickly.dom.element.MappingElementA unit:
\mm,\cm,\ptor\in.A Unit node can be attached to an Int or Float:
>>> from quickly.dom import lily >>> lily.Int(10, lily.Unit("cm")).write() '10\\cm'
-
mapping= {'\\cm': 'cm', '\\in': 'in', '\\mm': 'mm', '\\pt': 'pt'}¶
-
-
class
Lookup(node, scope=None, wait=True)[source]¶ Bases:
objectHelper class to find definitions and other stuff in a lily.Document from the viewpoint of a
node.A
Scope, if given using thescopeparameter, is used to resolve include files. If no scope is given, only searches the current DOM document; the yielded scope is then always None.If a scope is given, include commands are followed and
waitdetermines whether to wait for ongoing transformations of external DOM documents. If wait is False, and a transformation is not yet finished the included document’s toplevel nodes will not be yielded.-
ancestors()[source]¶ Yield the ancestors with index of node that should be searched for possible definitions.
The default implementation yields ancestors that inherit HandleAssignments and stops at the Document node.
-
preceding_nodes()[source]¶ Yield preceding nodes in ancestors and toplevel, in backward direction, as two-tuples (node, scope).
If a scope was given on instantiation, included files are followed.
When the beginning of the current scope (document) is reached, continues the search in parent scopes (if a scope was given), and if that parent scope has a node pointer, continues the search from there. This is useful when an included file refers to a variable that was set in the parent document before the
\includecommand.So when
file_a.lyreads:music = { c } \include "file_b.ly"
And
file_b.lyonly contains:\new Score { \music }
When traversing the musical contents of file a, the value of the
\musicReference in file b is correctly found in file a.
-
-
make_list_node(value)[source]¶ Return an element node corresponding to the value.
If value is a string, a Symbol is returned if it’s valid LilyPond identifier. otherwise String. If value is an integer, a Int is returned.
If no suitable node type could be returned, None is returned.
-
duration_getter()[source]¶ Return a callable that returns the (duration, scaling) tuple of a
Durable.If the durable does not have a Duration child, the callable searches backwards until a Durable is found that has a duration that LilyPond would use for the current durable. All found durables without duration are cached, so the next request only needs at most to search back one durable. If no durable with a value is found,
(Fraction(1, 4), 1)is returned.Use this getter if you are not sure you really iterate over all the durables in a node and cannot keep track of the previous durable yourself.
Get a new getter if you also modify durations.
-
previous_duration(node)[source]¶ Return a two-tuple(duration, scaling) of the closest preceding Durable that has a duration that LilyPond would use if the current node had no duration.
If no such node was found, returns
(Fraction(1, 4), 1).This function is potentially slow, as it searches backwards for a Durable node. Don’t use it if you have the opportunity to keep track of the previous duration yourself (from a
Durablethat has theduration_sets_previousattribute set to True).You can also use a
duration_getter(), which optimizes for adjacent notes without duration.
-
convert_duration_to_int(node)[source]¶ Return an Int element, created from the specified Duration element.
This can be used if a music function wants an integer number, while the origin token was seen as a duration by parce and the music builder.
-
create_element_from_value(value)[source]¶ Convert a regular Python value to a lilypond Element node.
This can be used to ease manually building a node structure. Converts:
- bool to Scheme(‘#’, scm.Bool(value))
- int to Int(value)
- float to Float(value)
- str to String(value)
- tuple(int, “unit”) to Int(value, Unit(“unit”)) where unit in “mm”, “cm”, “in”, “pt”
- tuple(float, “unit”) to Float(value, Unit(“unit”)) where unit in “mm”, “cm”, “in”, “pt”
- an Element node is returned unchanged.
Raises ValueError when a value can’t be converted to an element.
-
create_value_from_element(node)[source]¶ Get the Python value from an Element node.
Returns:
- bool, int, float etc for a Scheme(‘#’, scm.Bool(value) or scm.Number(value)) node
- int for an Int node
- float for a Float node
- Fraction for a Fraction node
- str for a String, Symbol or scm.String node
- tuple(int, “unit”) for a Int(Unit()) node
- tuple(float, “unit”) for a Float(Unit()) node
Returns None when this function cannot get a simple value from the node.