pymusicxml.score_components.DurationalObject
- class pymusicxml.score_components.DurationalObject[source]
Bases:
MusicXMLComponent
,ABC
Abstract base class for all objects that have duration within a measure.
Methods
Minimum divisor of a quarter note that would be needed to represent the duration of this note accurately.
Inherited Methods
export_to_file
(file_path[, pretty_print])Exports this musical object (wrapped as a score) to the given file path.
render
()Renders this component to a tuple of ElementTree.Element.
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.
Wraps this component in a
Score
so that it can be exported and viewedAttributes
Subdivision used when representing this duration.
Length in terms of subdivisions.
True length in terms of the number of quarter notes, taking into tuplet time modification.
Written length in terms of the number of quarter notes.
- abstract property true_length: float
True length in terms of the number of quarter notes, taking into tuplet time modification. Returns 0 in the case of grace notes.
- abstract property written_length: float
Written length in terms of the number of quarter notes.
- abstract property length_in_divisions: int
Length in terms of subdivisions. (See description of “divisions” attribute in
Duration
)
- abstract property divisions: int
Subdivision used when representing this duration.
- abstract min_denominator() int [source]
Minimum divisor of a quarter note that would be needed to represent the duration of this note accurately. For instance, a triplet quarter note would have min_denominator 3, since it is 2/3 of a quarter.
- 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
- abstract render() Sequence[Element]
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.)
- 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.