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.
- Perl 5.36+
- GPL-2
- NWC 2.x
- MusicXML 4.0
- No NWC licence needed
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.
-
The container, not an export
The NWC 2.x file is checked against its magic signature and inflated with zlib, so nothing has to be exported by hand and the converting machine needs no NoteWorthy Composer copy.
-
Exact durations
Rhythm is held as a rational in quarter-note units, and
<divisions>is the least common multiple across every staff, so triplets, double dots and dotted triplets do not drift. -
Notation, not appearance
Clefs, key and time signatures, tempo, dynamics, hairpins, fermatas, slurs, ties, grace notes, articulations, lyrics and barline styles come out as MusicXML elements.
-
Dynamics that still sound
A staff's NWC
DynVelvelocities become<sound dynamics="…"/>, so a playback engine can still tell mp from mf. -
Folders, not just files
A directory argument collects the
.nwcfiles in it;--recursivewalks the tree and keeps its shape under--output-dir. One unreadable file does not abandon the rest. -
Diagnostics with codes
error_no_input,error_decode,error_parse,error_generateand the rest are catalogue entries, so a script can act on them and--warningscan collect them in a file.
How a file is converted
- Decode.
Music::NWC2MusicXML::NWC->readverifies the magic signature, inflates the zlib payload and returns the pipe-delimited NWCTXT text the file was built from. - Parse.
Music::NWC2MusicXML::Parser->parsewalks the|RecordType|Field:Valuerecords and builds aScoreofStaffandEventobjects, each event carrying its own duration and data. - 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.
- Generate.
Music::NWC2MusicXML::MusicXML->generatewrites the part list, measures, attributes, directions and notations, and hands back the document as a UTF-8 string. - 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 — from CPAN or from a checkout, and what has to be present first.
- Quick start — one file to MuseScore, then a whole folder.
- Commands — the options, the exit codes and what counts as input.
- Perl API —
convert,batch_convertand the three stages underneath. - What converts — every NWC construct that has a MusicXML destination.