nCoda Lychee Docs

Abjad

Warning

This module is intended for internal Lychee use only, so the API may change without notice. If you wish to use this module outside Lychee, please contact us to discuss the best way.

Tip

We recommend that you use the converters indirectly. Refer to How to Use the Converters for more information.

lychee.converters.inbound.__abjad.add_xml_ids(abjad_object, mei_element)[source]

Attach the same SHA256 hash digest as xml ID to both an abjad object and an mei element.

Parameters:
  • abjad_object (abjad.tools.abctools.AbjadObject.AbjadObject) – The abjad object to attach the ID to.
  • mei_element (lxml.etree.ElementTree.Element) – The MEI Element to attach the ID to.
lychee.converters.inbound.__abjad.calculate_tuplet_duration(tuplet)[source]

Calculate the duration of a tuplet that potentially contains nested tuplets.

Parameters:tuplet (Tuplet) – the Abjad tuplet to query for duration.
lychee.converters.inbound.__abjad.chord_to_chord(abjad_chord)[source]

Convert an Abjad Chord object to an MEI chord Element.

Parameters:abjad_chord (abjad.tools.scoretools.Chord.Chord) – the Abjad Chord object to convert.
Returns:the corresponding MEI chord Element.
Return type:lxml.etree.ElementTree.Element
lychee.converters.inbound.__abjad.convert(document, **kwargs)[source]

Convert an Abjad document into an MEI document.

Parameters:document (object) – the Abjad document.
Returns:None
Raises:lychee.exceptions.InboundConversionError for a forseeable error during conversion.

This function emits the lychee.inbound.CONVERSION_STARTED signal immediately, and the lychee.inbound.CONVERSION_FINISHED signal with the converted document.

lychee.converters.inbound.__abjad.convert_accidental(abjad_accidental_string)[source]

Convert an abjad accidental string to an mei accidental string.

Parameters:abjad_accidental_string (string) – the Abjad accidental string.
Returns:the MEI accidental string.
Return type:string
lychee.converters.inbound.__abjad.empty_tuplet_to_tupletspan_element(abjad_tuplet)[source]

Convert an empty Abjad Tuplet container to an MEI tupletspan Element.

Parameters:abjad_tuplet (abjad.tools.scoretools.Tuplet.Tuplet) – the empty Abjad Tuplet container to convert.
Returns:The corresponding MEI tupletspan Element.
Return type:lxml.etree.ElementTree.Element
lychee.converters.inbound.__abjad.leaf_to_element(abjad_object)[source]

Convert an Abjad leaf (Rest, Note, Chord) container to the corresponding MEI element.

Parameters:abjad_object (abjad.tools.scoretools.Leaf.Leaf) – the Abjad leaf to convert.
Returns:the corresponding MEI Element.
Return type:List or lxml.etree.ElementTree.Element
Raises:lychee.exceptions.InboundConversionError when abjad_object is not a leaf.
lychee.converters.inbound.__abjad.measure_to_measure(a_measure)[source]

Convert an Abjad Measure to an MEI <measure>.

Parameters:a_measure (abjad.tools.scoretools.Measure) – The Measure to convert.
Returns:The MEI <measure> element.
Return type:_Element
lychee.converters.inbound.__abjad.note_to_note(abjad_note)[source]

Convert an Abjad Note or NoteHead object to an MEI note Element.

Parameters:abjad_note (abjad.tools.scoretools.Note.Note) – the Abjad Note object to convert.
Returns:The corresponding MEI note Element.
Return type:lxml.etree.ElementTree.Element
lychee.converters.inbound.__abjad.rest_to_rest(abjad_rest)[source]

Convert an Abjad Rest object to an MEI rest Element. Collects info from the abjad object, then generates mei Element.

Parameters:abjad_rest (abjad.tools.scoretools.Rest.Rest) – The Abjad Rest object to convert.
Returns:The corresponding MEI rest Element.
Return type:lxml.etree.ElementTree.Element
lychee.converters.inbound.__abjad.score_to_section(abjad_score)[source]

Convert an abjad Score into an mei section Element.

Parameters:abjad_score (abjad.tools.scoretools.Score.Score) – the Abjad Score object to convert.
Returns:the corresponding MEI section Element.
Return type:lxml.etree.ElementTree.Element
lychee.converters.inbound.__abjad.set_initial_clef(a_staff, m_staffdef)[source]

Set the initial clef for a <staffDef> according to the Abjad Staff.

Parameters:
  • a_staff (abjad.tools.scoretools.Staff) – The Abjad Staff in which to find the initial clef.
  • m_staffdef (lxml.etree.ElementTree.Element) – The MEI <staffDef> element in which to set the initial clef.
Returns:

None

If the clef is unset, or a currently-unsupported type, nothing happens.

lychee.converters.inbound.__abjad.setup_outermost_tupletspan(mei_tupletspan, abjad_tuplet)[source]

Set an mei tupletspan’s ‘dur’, ‘dots’, ‘n’, ‘num’, and ‘numBase’ attributes according to info from an abjad Tuplet.

Parameters:
  • mei_tupletspan (lxml.etree.ElementTree.Element) – The MEI tupletspan Element to initialize.
  • abjad_tuplet (abjad.tools.scoretools.Tuplet.Tuplet) – the Abjad Tuplet container from which to initialize.
Returns:

Abjad Duration.

Return type:

class:abjad.tools.durationtools.Duration.Duration

lychee.converters.inbound.__abjad.skip_to_space(abjad_skip)[source]

Convert an Abjad Skip object to an MEI space Element.

Parameters:abjad_skip (abjad.tools.scoretools.Skip.Skip) – The Abjad Skip object to convert.
Returns:The corresponding MEI space Element.
Return type:lxml.etree.ElementTree.Element
lychee.converters.inbound.__abjad.staff_to_staff(abjad_staff)[source]

Convert an abjad Staff to an mei staff Element. Handles sibling Voice and Leaf components by flattening all into a single Voice.

Parameters:abjad_staff (abjad.tools.scoretools.Staff.Staff) – the Abjad Staff to convert.
Returns:the corresponding MEI Element or list of Elements.
Return type:lxml.etree.ElementTree.Element

Note

Because this function cannot determine the correct @n attribute of the abjad_staff, both the @n and @xml:id attributes are unset for the returned <staff> element. It is the caller’s responsibilty to provide the @n attribute, then @xml:id, which depends on the former.

lychee.converters.inbound.__abjad.tuplet_to_tupletspan(abjad_tuplet)[source]

Convert an empty abjad Tuplet container into an mei tupletspan Element and converts a full abjad Tuplet container into a list beginning with a tupletspan element and followed by appropriate conversions of the container’s leaves.

Parameters:abjad_tuplet (abjad.tools.scoretools.Tuplet.Tuplet) – The Abjad Tuplet container to convert.
Returns:the corresponding MEI tupletspan Element or list of MEI Elements.
Return type:lxml.etree.ElementTree.Element or list
lychee.converters.inbound.__abjad.voice_to_layer(abjad_voice)[source]

Convert an abjad Voice into an mei layer Element.

Parameters:abjad_voice (abjad.tools.scoretools.Voice.Voice) – the Abjad Voice to convert.
Returns:the corresponding MEI layer Element.
Return type:lxml.etree.ElementTree.Element