Skip to main content

from_volpiano

Function from_volpiano 

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

Reads a Volpiano string into a part, as music21’s toPart does.

Each note lasts a quarter, has no stem, and is liquescent with an x notehead where its token is a capital. A part opens in the treble clef until a clef token says otherwise; a flat token flats every E or B from there on, and its capital takes the flat away again. A barline closes the measure, every measure numbered nought. Two notes with nothing between them are a neume, a SpannerKind::Neume the part holds, and a neume takes in every note of its run. A break goes at the end of the measure being read. Tokens that are none of these are passed over.

use music21_rs::volpiano::from_volpiano;

let part = from_volpiano("1---c--d---fg---3")?;
let names: Vec<String> = part
    .pitches()
    .iter()
    .map(|pitch| pitch.name_with_octave())
    .collect();
assert_eq!(names, ["C4", "D4", "F4", "G4"]);
assert_eq!(part.spanners().len(), 1);

§Errors

A note further from its clef than a pitch can be spelled.