pymusicxml.score_components.Notehead

class pymusicxml.score_components.Notehead(notehead_name: str, filled: bool = None)[source]

Bases: pymusicxml.score_components.MusicXMLComponent

Class representing a notehead type.

Parameters
  • notehead_name – accepts any of the MusicXML notehead types, possibly preceded by “filled” or “open”. So “filled triangle” will create the triangle notehead type with the filled flag set to true.

  • filled – whether or not the notehead is filled

Methods

render()

Renders this component to a tuple of ElementTree.Element.

wrap_as_score()

Wraps this component in a Score so that it can be exported and viewed

Inherited Methods

export_to_file(file_path[, pretty_print])

Exports this musical object (wrapped as a score) to the given file path.

to_xml([pretty_print])

Renders this component to MusicXML, adding a version tag, but not wrapping it up as a full score.

view_in_software(command)

Uses the given terminal command to create a score out of this musical object, and open it in music notation software.

Attributes

valid_xml_types

List of valid MusicXML notehead types

valid_xml_types = ['normal', 'diamond', 'triangle', 'slash', 'cross', 'x', 'circle-x', 'inverted triangle', 'square', 'arrow down', 'arrow up', 'circled', 'slashed', 'back slashed', 'cluster', 'circle dot', 'left triangle', 'rectangle', 'do', 're', 'mi', 'fa', 'fa up', 'so', 'la', 'ti', 'none']

List of valid MusicXML notehead types

render() → Sequence[xml.etree.ElementTree.Element][source]

Renders this component to a tuple of ElementTree.Element. (The reason for making it a tuple is that musical objects like chords are represented by several notes side by side, with all but the first containing a </chord> tag.)

wrap_as_score()pymusicxml.score_components.Score[source]

Wraps this component in a Score so that it can be exported and viewed

export_to_file(file_path: str, pretty_print: bool = True) → None

Exports this musical object (wrapped as a score) to the given file path.

Parameters
  • file_path – The path of the file we want to write to.

  • pretty_print – If True, breaks the MusicXML onto multiple lines, with indentation

to_xml(pretty_print: bool = False) → str

Renders this component to MusicXML, adding a version tag, but not wrapping it up as a full score.

Parameters

pretty_print – If True, breaks the MusicXML onto multiple lines, with indentation

view_in_software(command: str) → None

Uses the given terminal command to create a score out of this musical object, and open it in music notation software.

Parameters

command – The terminal command corresponding to the software with which we want to open the score.