Skip to main content

from_abc

Function from_abc 

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

Reads ABC text into a score: music21’s converter.parse for the format.

A file holding one tune comes back as a score, with a part for each of its voices. A file holding several tunes, each under its own X: reference number, comes back as an opus of scores in the order of their numbers.

use music21_rs::abc::from_abc;

let score = from_abc("X:1\nT:Scale\nM:4/4\nL:1/4\nK:G\nG A B c | d e f g |\n")?;
let part = score.parts()[0];
assert_eq!(part.measures().len(), 2);
// The key's F sharp is read into the note.
assert_eq!(part.measures()[1].pitches()[2].name_with_octave(), "F#5");