nCoda Lychee Docs



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.


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.

  • abjad_object ( – The abjad object to attach the ID to.
  • mei_element (lxml.etree.ElementTree.Element) – The MEI Element to attach the ID to.

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

Parameters:tuplet (Tuplet) – the Abjad tuplet to query for duration.

Convert an Abjad Chord object to an MEI chord Element.

Parameters:abjad_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.
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.


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

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

Parameters:abjad_tuplet ( – the empty Abjad Tuplet container to convert.
Returns:The corresponding MEI tupletspan Element.
Return type:lxml.etree.ElementTree.Element

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

Parameters:abjad_object ( – 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.

Convert an Abjad Measure to an MEI <measure>.

Parameters:a_measure ( – The Measure to convert.
Returns:The MEI <measure> element.
Return type:_Element

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

Parameters:abjad_note ( – the Abjad Note object to convert.
Returns:The corresponding MEI note Element.
Return type:lxml.etree.ElementTree.Element

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

Parameters:abjad_rest ( – The Abjad Rest object to convert.
Returns:The corresponding MEI rest Element.
Return type:lxml.etree.ElementTree.Element

Convert an abjad Score into an mei section Element.

Parameters:abjad_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.

  • a_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.


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.

  • mei_tupletspan (lxml.etree.ElementTree.Element) – The MEI tupletspan Element to initialize.
  • abjad_tuplet ( – the Abjad Tuplet container from which to initialize.

Abjad Duration.

Return type:


Convert an Abjad Skip object to an MEI space Element.

Parameters:abjad_skip ( – The Abjad Skip object to convert.
Returns:The corresponding MEI space Element.
Return type:lxml.etree.ElementTree.Element

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 ( – the Abjad Staff to convert.
Returns:the corresponding MEI Element or list of Elements.
Return type:lxml.etree.ElementTree.Element


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.


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 ( – 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

Convert an abjad Voice into an mei layer Element.

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