Skip to main content

from_roman_text

Function from_roman_text 

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

Reads a RomanText analysis into a score: music21’s converter.parse of one.

The score holds one part of measures, and in each the chords the numerals stand for, in the key they were written in, each carrying its figure as its lyric – the key too where it has just changed, as G: V7. A chord lasts until the next, or to the end of its bar; one held into a measure that opens after its first beat is tied there. NC is a rest under a no-chord symbol. A measure written m5 = m1 is a copy of another, its chords read in the key now in force.

A file of several Movement: lines comes back as an opus of scores, the lines before the first heading each of them.

use music21_rs::romantext::from_roman_text;

let score = from_roman_text("Time Signature: 3/4\nm1 G: I b3 V6\nm2 I\n")?;
let part = score.parts()[0];
assert_eq!(part.measures().len(), 2);
let names: Vec<String> = part.measures()[0]
    .pitches()
    .iter()
    .map(|pitch| pitch.name())
    .collect();
assert_eq!(names, ["G", "B", "D", "F#", "A", "D"]);