Skip to main content

from_noteworthy

Function from_noteworthy 

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

Reads the text of a NoteWorthy Composer .nwctxt file into a score, as music21’s converter.parse reads one.

Each staff is a part, every one standing at the start of the score. Its notes, chords and rests are spelled from their places on the staff under the clef in force, with the key signature’s accidentals and any written earlier in the measure; slurs, ties, triplets, grace notes and the staff’s first verse of lyrics are read, as are barlines and repeats, endings, clefs, keys, meters, tempos, dynamics, words, Coda, Segno, Fine and the jumps to them, each staff’s instrument by its MIDI program, and the song’s title. A percussion clef’s notes are unpitched strokes.

music21’s own habits are kept: its first two measures are both numbered nought, a staff’s name keeps the quotation marks the file writes round it, words are placed above the staff where the file puts them below, and a chord with a rest beside it puts what the measure holds so far into a voice. What music21 passes over – fonts, page setup, crescendo and diminuendo marks, performance styles, a second verse – is passed over.

use music21_rs::noteworthy::from_noteworthy;

let score = from_noteworthy(
    "!NoteWorthyComposer(2.0)\n|AddStaff|\n|Clef|Type:Bass\n|TimeSig|Signature:4/4\n|Note|Dur:Whole|Pos:1\n",
)?;
let pitches = score.pitches();
assert_eq!(pitches[0].name_with_octave(), "E3");

§Errors

A file with no staff, a line music21 cannot read – an attribute with no value, a clef, barline style, flow mark or note length it does not know, an octave shift on an alto or tenor clef – or a number that is not one.