#music-notation #music #format #deserializer #read-write #parser

no-std musicxml

MusicXML parsing, manipulation, and export library

8 stable releases

1.1.2 Nov 5, 2024
1.1.0 Nov 4, 2024
1.0.6 Jul 11, 2024
1.0.5 Jun 18, 2024

#560 in Parser implementations

Download history 39/week @ 2024-09-14 8/week @ 2024-09-21 386/week @ 2024-11-02 53/week @ 2024-11-09 14/week @ 2024-11-16 3/week @ 2024-11-23 61/week @ 2024-11-30

155 downloads per month
Used in 2 crates (via amm_sdk)

MIT license

7MB
20K SLoC

Contains (WOFF font, 4MB) assets/fonts/BravuraText.woff, (WOFF font, 335KB) assets/fonts/BravuraText.woff2, (Zip file, 49KB) tests/Grande Valse Brillante.mxl

MusicXML

MusicXML is a library for reading and writing MusicXML files in Rust. MusicXML is a standard format for representing Western musical notation and is widely used in music notation software such as Finale, Sibelius, and MuseScore. This library provides a simple interface for parsing MusicXML files and converting them into a structured data format that can be easily manipulated and analyzed programmatically.

The library is designed to be easy to use and flexible, allowing you to read and write MusicXML files with minimal effort. It provides functions for reading MusicXML files and converting them into a structured data format, as well as functions for writing structured data back to MusicXML files. It is also designed to be robust and reliable, handling a wide variety of MusicXML files and formats with ease.

Features

  • Implements the full official MusicXML Standard
  • Supports both raw .musicxml and compressed .mxl file formats
  • Supports both "partwise" and "timewise" data representations
  • Allows for transparent conversion between the partwise and timewise representations
  • Is provided as a Rust-format library so that it can be link-time optimized with your own code
  • Is no_std compatible with default features turned off

Getting Started

To use this library in your Rust project, simply add the following line to your Cargo.toml file:

[dependencies]
musicxml = "1.1"

You can then parse any regular MusicXML file or compressed MXL file into a structured data format using:

use musicxml::*;

match read_score_partwise("path/to/file.musicxml") {
  Ok(score) => {}, // Do something with the score
  Err(e) => println!("Error reading MusicXML file: {}", e),
}

or

use musicxml::*;

match read_score_timewise("path/to/file.musicxml") {
  Ok(score) => {}, // Do something with the score
  Err(e) => println!("Error reading MusicXML file: {}", e),
}

If you are using this library in a no_std environment, you can parse MusicXML data directly by instead calling the read_score_data_partwise() and read_score_data_timewise() functions.

Please refer to the library documentation for full usage instructions. You may also want to consult the official MusicXML Standard for additional details.

License

This library is licensed under the MIT license.

TODO

  • Remove dependency on regex
  • Create WASM build

Dependencies

~2.5–4MB
~75K SLoC