pub fn from_musicxml(document: &str) -> Result<Stream>Available on crate feature
musicxml only.Expand description
Reads a MusicXML document – the text of a .musicxml file, or of the
score inside a compressed .mxl – into a score: music21’s
converter.parse for the format.
use music21_rs::musicxml::from_musicxml;
let score = from_musicxml(
"<score-partwise><part-list><score-part id=\"P1\"><part-name>Flute</part-name>\
</score-part></part-list><part id=\"P1\"><measure number=\"1\">\
<attributes><divisions>1</divisions></attributes>\
<note><pitch><step>C</step><octave>4</octave></pitch><duration>4</duration>\
<type>whole</type></note></measure></part></score-partwise>",
)?;
let part = score.parts()[0];
assert_eq!(part.name(), Some("Flute"));
assert_eq!(part.measures()[0].pitches()[0].name_with_octave(), "C4");