Skip to main content

from_tiny_notation

Function from_tiny_notation 

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

Reads a line of TinyNotation into a part of measures: music21’s converter.parse('tinyNotation: ...').

The text may start with tinyNotation:. A token that is not a meter, a note or a rest is passed over, as music21 passes over it. The part is cut into measures by make_measures: a line with no meter is in 4/4, and a note running past a barline is left whole in the measure it starts in.

use music21_rs::tinynotation::from_tiny_notation;

let part = from_tiny_notation("tinyNotation: 3/4 E4 r f# g=lastG trip{b-8 a g} c'2.")?;
let measures = part.measures();
assert_eq!(measures.len(), 3);
let names: Vec<String> = measures[1]
    .pitches()
    .iter()
    .map(|pitch| pitch.name_with_octave())
    .collect();
// The last note starts in this measure and runs on past its barline.
assert_eq!(names, ["G4", "Bb4", "A4", "G4", "C5"]);