pymusicxml.music_xml_objects.Note¶
-
class
pymusicxml.music_xml_objects.
Note
(pitch: Union[pymusicxml.music_xml_objects.Pitch, str], duration: Union[pymusicxml.music_xml_objects.Duration, str, float], ties: str = None, notations=(), articulations=(), notehead: Union[Notehead, str] = None, directions: Sequence[Direction] = (), stemless: bool = False)[source]¶ Bases:
pymusicxml.music_xml_objects._XMLNote
Class representing a single, pitched note.
- Parameters
pitch – either a Pitch object or a string to parse as a pitch (see
Pitch.from_string()
)duration – either a
Duration
object, a string to parse as a duration (seeDuration.from_string()
), or a number of quarter notes.ties – one of “start”, “continue”, “stop”, None
notations – Either a single notation, or a list of notations that will populate the musicXML “notations” tag. Each is either a
Notation
object, anElementTree.Element
object, or a string that will be converted into an Element object.articulations – Either a single articulations or a list of articulations that will populate the musicXML “articulations” tag (itself in the “notations” tag). Each is either an
ElementTree.Element
object, or a string that will be converted into an Element object.notehead – a
Notehead
or a string representing XML notehead type. Note that the default of None represents an ordinary notehead.directions – either a single direction, or a list of directions (e.g.
TextAnnotation
,MetronomeMark
) to populate the musicXML “directions” tag.stemless – boolean for whether to render the note with no stem.
Inherited Methods
export_to_file
(file_path[, pretty_print])Exports this musical object (wrapped as a score) to the given file path.
Minimum divisor of a quarter note that would be needed to represent the duration of this note accurately.
Returns the number of beams needed to represent this note’s duration.
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.
Whether or not this note starts a tie.
Whether or not this note ends a tie.
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.
-
property
starts_tie
¶ Whether or not this note starts a tie.
-
property
stops_tie
¶ Whether or not this note ends a tie.
-
property
divisions
¶ Subdivision used when representing this duration.
-
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
-
property
length_in_divisions
¶ Length in terms of subdivisions. (See description of “divisions” attribute in
Duration
)
-
min_denominator
() → int¶ 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.
-
num_beams
() → int¶ Returns the number of beams needed to represent this note’s duration.
-
render
() → Sequence[xml.etree.ElementTree.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
-
property
true_length
¶ True length in terms of the number of quarter notes, taking into tuplet time modification. Returns 0 in the case of grace notes.
-
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
() → pymusicxml.music_xml_objects.Score¶ Wraps this component in a
Score
so that it can be exported and viewed
-
property
written_length
¶ Written length in terms of the number of quarter notes.