pymusicxml.directions.Harmony

class pymusicxml.directions.Harmony(root_letter: str, root_alter: int, kind: str, use_symbols: bool = False, degrees: Sequence[Degree] = (), placement: str | StaffPlacement = 'above')[source]

Bases: Direction

Class representing harmonic notation.

Methods

render()

Renders this component to a tuple of ElementTree.Element.

render_direction_type()

Renders the <direction-type> element that constitutes the main substance of a <direction> element.

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.

wrap_as_score()

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

Attributes

KINDS

KINDS = ('augmented', 'augmented-seventh', 'diminished', 'diminished-seventh', 'dominant', 'dominant-11th', 'dominant-13th', 'dominant-ninth', 'French', 'German', 'half-diminished', 'Italian', 'major', 'major-11th', 'major-13th', 'major-minor', 'major-ninth', 'major-seventh', 'major-sixth', 'minor', 'minor-11th', 'minor-13th', 'minor-ninth', 'minor-seventh', 'minor-sixth', 'Neapolitan', 'none', 'other', 'pedal', 'power', 'suspended-fourth', 'suspended-second', 'Tristan')
render() Sequence[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.)

render_direction_type() Sequence[Element][source]

Renders the <direction-type> element that constitutes the main substance of a <direction> element.

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.

wrap_as_score() Score

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