Convert NoteWorthy Composer scores to MusicXML

Music::NWC2MusicXML reads a NoteWorthy Composer 2 .nwc file, still compressed in its binary container, and writes a MusicXML file that MuseScore, Finale, Sibelius and Dorico can open. NoteWorthy Composer itself does not have to be installed.

cpanm Music::NWC2MusicXML

nwc2musicxml Pilgrim.nwc
# writes Pilgrim.musicxml beside it

The work is done in three stages that each stand on their own: the binary container is decompressed back to the text format NoteWorthy Composer uses, that text is parsed into a score of staves and events, and the score is written out as MusicXML 4.0. Every stage can be called directly, and a failure is reported with the code of the stage it came from rather than as one anonymous error.

How a file is converted

  1. Decode. Music::NWC2MusicXML::NWC->read verifies the magic signature, inflates the zlib payload and returns the pipe-delimited NWCTXT text the file was built from.
  2. Parse. Music::NWC2MusicXML::Parser->parse walks the |RecordType|Field:Value records and builds a Score of Staff and Event objects, each event carrying its own duration and data.
  3. Annotate. Slurs, ties, fermatas, wedges and bar-scoped accidentals are resolved across the whole event stream before measures are grouped, because each of them spans more than one note.
  4. Generate. Music::NWC2MusicXML::MusicXML->generate writes the part list, measures, attributes, directions and notations, and hands back the document as a UTF-8 string.
  5. Report. The diagnostics object counts what went wrong; the command line turns that into an exit status, so a shell script can tell a warning from a failure.
# one file
nwc2musicxml Pilgrim.nwc

# a folder tree, keeping its shape
nwc2musicxml --recursive --output-dir musicxml scores/

# the same thing from Perl
my $converter = Music::NWC2MusicXML->new;
my $out = $converter->convert(input => 'Pilgrim.nwc', overwrite => 1);

What it does not do

Tuplet notation is not emitted yet: the durations are exact, but the <time-modification> and <tuplet> elements that make a score print them as triplets are missing. A staff's simultaneous voices are all written to voice 1, the page is fixed to A4, and the lyric and flow-control paths have not been validated against a golden score. The whole list is here.

Where to go next

Install →