Install
The module and the nwc2musicxml command are one CPAN
distribution. Perl 5.36 or newer is the only thing that has to be there
beforehand.
From CPAN
cpanm Music::NWC2MusicXML
cpanm installs the dependencies below as it goes. Without
App::cpanminus, cpan Music::NWC2MusicXML does the same job,
and cpanm --installdeps . in a checkout installs exactly the
versions that checkout declares.
From a checkout
git clone https://github.com/nigelhorne/NWC2MusicXML.git
cd NWC2MusicXML
perl Makefile.PL
make
make test
make install
make test runs the full suite. The part worth knowing about
is t/40-input.t: it converts every .nwc file in
t/input/ and compares the result byte for byte with the
golden .musicxml file committed beside it. A change that
alters the output of an existing score therefore fails the suite rather
than passing quietly.
What it needs
| Requirement | Why |
|---|---|
| Perl 5.36 or newer | The minimum is declared in Makefile.PL and is not a guess: the modules are written for that version's semantics. |
Compress::Zlib |
The NWC container is a zlib stream. This is the only dependency that is not pure Perl, and it has shipped with Perl for years. |
Object::Configure |
Lets a program set converter defaults once, at class level, instead of passing them to every new. |
Params::Get, Params::Validate::Strict (0.39+) |
Argument checking for the public methods, so a misspelt parameter is rejected instead of ignored. |
Readonly |
The parser's dispatch table and the pitch, clef and tempo maps are read-only constants built once at load. |
Carp, File::*, Getopt::Long, Pod::Usage |
Core modules: errors, file handling, and the command line. |
Nothing else is required. There is no NoteWorthy Composer, no Java and no libxml2 involved: the MusicXML is written directly rather than through an XML library, so the converter runs anywhere Perl does, including on a server with no desktop software at all.
Check it works
nwc2musicxml --version
nwc2musicxml --help
The help text is the command's manual page as well:
perldoc nwc2musicxml prints the same thing, and
perldoc Music::NWC2MusicXML documents the Perl API. If
nwc2musicxml is not found, the installation put it somewhere
your PATH does not look — perl -V:installbin
says where.
What gets installed
| Path | Purpose |
|---|---|
bin/nwc2musicxml | The command-line interface. |
Music::NWC2MusicXML | The facade: convert, batch_convert, diagnostics. |
Music::NWC2MusicXML::NWC | Binary container decoder: signature check, zlib inflation, NWCTXT text. |
Music::NWC2MusicXML::Parser | NWCTXT text to a score of staves and events. |
Music::NWC2MusicXML::Score, ::Staff, ::Event | The internal score model, with durations held as exact rationals. |
Music::NWC2MusicXML::MusicXML | Score to MusicXML 4.0 document. |
Music::NWC2MusicXML::Diagnostics | The message catalogue and the carp/croak helpers behind every warning and error. |
Each of those can be used on its own. The Perl API
page shows the three-stage pipeline that convert performs.
If perl belongs to your operating system, install into a
local::lib or a perlbrew rather than over the top of it:
cpanm --local-lib=~/perl5 Music::NWC2MusicXML, then add
that library's bin to PATH. The same advice
applies to a Perl that a packaging system will overwrite at its next
upgrade.