Skip to main content

from_humdrum

Function from_humdrum 

Source
pub fn from_humdrum(text: &str) -> Result<Stream>
Expand description

Reads a Humdrum file into a score: music21’s converter.parse of one.

Every **kern spine is a part, the last in the file first; its barlines are the measures, its instructions the clefs, keys, meters, tempos and instruments, and a spine split in two is two voices in the measures where it is split. **dynam and **text spines put their dynamics and words on the notes of the staff they name. A cell that cannot be read is passed over, as music21 passes over it.

A file holding several tables, each closed before the next opens, comes back as an opus of scores. **harm spines, and a voice that splits again, are not read.

use music21_rs::humdrum::from_humdrum;

let score = from_humdrum("**kern\n*clefG2\n*M2/4\n=1\n4c\n4d\n=2\n2e\n==\n*-\n")?;
let part = score.parts()[0];
assert_eq!(part.measures().len(), 2);
assert_eq!(part.measures()[1].pitches()[0].name_with_octave(), "E4");