Skip to main content

to_volpiano

Function to_volpiano 

Source
pub fn to_volpiano(stream: &Stream) -> Result<String>
Expand description

Writes a stream as Volpiano, as music21’s fromStream does.

Every element is taken in turn, however deep: treble and bass clefs (and the treble and bass clefs an octave off) as 1 and 2, any other clef changing only where the notes sit, barlines, breaks, and notes, a liquescent one being one with an x notehead. A note is followed by a hyphen, or by two where it has a lyric and three where that lyric says it ends a word, and by nothing where a neume carries on past it. A flat is written before the first flatted B or E, and a natural before the first one after that is not.

What Volpiano cannot write is left out, as music21 leaves it out: chords, rests, a note off the edge of what the tokens reach, and an accidental other than a flat on a B or an E (the note is written, with no hyphen after it).

use music21_rs::volpiano::{from_volpiano, to_volpiano};

let part = from_volpiano("1--c--d---f--d---ed--c")?;
assert_eq!(to_volpiano(&part)?, "1---c-d-f-d-ed-c-");

§Errors

A note under a clef that places no pitches.