MusicXML Interface

muspy.read_musicxml(path: Union[str, pathlib.Path], resolution: int = None, compressed: bool = None) → muspy.music.Music[source]

Read a MusicXML file into a Music object.

Parameters:
  • path (str or Path) – Path to the MusicXML file to read.
  • resolution (int, optional) – Time steps per quarter note. Defaults to the least common multiple of all divisions.
  • compressed (bool, optional) – Whether it is a compressed MusicXML file. Defaults to infer from the filename.
Returns:

Converted Music object.

Return type:

muspy.Music

Notes

Grace notes and unpitched notes are not supported.

muspy.write_musicxml(path: Union[str, pathlib.Path], music: Music, compressed: bool = None)[source]

Write a Music object to a MusicXML file.

Parameters:
  • path (str or Path) – Path to write the MusicXML file.
  • music (muspy.Music) – Music object to write.
  • compressed (bool, optional) – Whether to write to a compressed MusicXML file. If None, infer from the extension of the filename (‘.xml’ and ‘.musicxml’ for an uncompressed file, ‘.mxl’ for a compressed file).