xml2abc is a command line utility that translates MusicXML into ABC+ notation.
Parts of MusicXML that lie beyond the scope of the ABC standard 2.1 are not translated.
For example: specific positioning information, slurs spanning staves.
The program translates all examples in the set from MakeMusic.
The translated examples produce reasonable score when typeset with abcm2ps.
In Mandoline, one of the samples,
you can compare the output of xml2abc (via abcm2ps) with that of MuseScore 1.2.
Another example from the set produces this score: Ave_Maria (Schubert).
(see also the generated ABC of Mandoline_abc and Ave_Maria_abc)
All non standard extensions of ABC supported by
are also supported by xml2abc. For instance, tablature
and percussion scores can be translated from MusicXML into ABC and back to MusicXML,
without significant loss of information.
When you have Python installed:
> python xml2abc.py [-h] [-u] [-m] [-c C] [-d D] [-v V] [-n CPL] [-b BPL] [-o DIR] [-x] [-p FMT] [-t] [-s] file1 [file2 ...]
When you use the Win32 executable:
> xml2abc.exe [-h] [-u] [-m] [-c C] [-d D] [-v V] [-n CPL] [-b BPL] [-o DIR] [-x] [-p FMT] [-t] [-s] file1 [file2 ...]
Translates all .xml files (MusicXML) or compressed .mxl files in the file list
to ABC-notation. Output goes to stdout unless the -o option is given. Wildcards in
file names are expanded.
- Option -h prints help message with explanation of the options.
- Option -u turns off repeat translation and unfolds simple repeats instead.
- Option -m M When M=1 only %%MIDI program commands are output. For a percussion voice
also %%MIDI channel and %%MIDI drummap statements are added.
When M=2 all supported midi commands are output:
%%MIDI channel, %%MIDI program, %%MIDI contol 7, %%MIDI control 10 and
%%MIDI drummap for a percussion voice. The default is M=0, which outputs no midi commands.
- Option -c C sets the filter level of the credit filter. This filter tries to eliminate
redundant T: fields. The level C goes from 0 (default) to 6 (no filtering). A higher level
does less filtering. The default filters as much as possible and only includes the xml
credit elements if no title of movement-title is found. Level 6 does no filtering and includes
all xml credit elements as T: fields.
- Option -d D sets the unit length for the ABC output to L:1/D. This overrides the computation
of the optimal unit length per voice.
- Option -v V. The default (V=0) translates volta backets in all voices. V=1 prevents abcm2ps to
write volta brackets on all but the first voice. (A %%repbra 0 command is added to each voice that
hides its volta's.) When V=2 abcm2ps only typesets volta brackets on the first voice of each
xml-part. When V=3 the volta brackets are only translated for the first abc voice, which has the
same effect on the output of abcm2ps as V=1, but the abc code is not suited for abc2midi.
- Option -n CPL sets the maximum line length for ABC output to CPL characters. The default is
100 chars per line. An integer number of bars, at least one, is always output. How many bars fit into the
maximum line length is calculated from the note line, not from the lyric lines.
Line- and page breaks in MusicXML are translated to '$' after the previous barline [or volta number]
- Option -b BPL sets the number of bars per line. Every line of ABC will have BPL
bars (measures). When both -n and -b options are given -b is ignored.
- Option -o DIR translates every .xml file to a separate .abc file with the same name
into directory DIR. For example, -o. puts all abc files into the same directory where
the input files reside.
- Option -t translates percussion (perc) and tablature (tab) staves to ABC code using
%%map and %%voicemap. It also prepends a %%beginsvg ... %%endsvg section
with definitions for noteheads.
For percussion only the following MusicXML noteheads are supported:
x, circle-x, square, triangle and diamond.
The tablature translation can map one note (one ABC pitch) to at most 4 different strings (per voice).
If you use more strings for one note (in one voice), it will reject those mappings. Mapping of
one note to three different strings is abc2midi compatible.
for more explanation and examples.
- Option -s Shift note heads in a tab staff 3 units to the left. This will draw the note heads
straight above the stems. However, ties and dots with seem shifted too much to the right. This option
only takes effect when also -t is present.
- Option -x disables translation of xml line breaks. No abc score line breaks ($) will be output.
- Option --v1 allocates all XML staff directions to the first voice of the staff. Normally a staff
direction is allocated to the voice of the next note after the direction (if any).
- Option --noped disables translation of xml pedal elements.
- Option -p FMT, FMT=scale,pageheight,pagewidth,leftmargin,rightmargin,topmargin,botmargin. The
specified pageformat parameters are included in the generated abc code as pseudo instructions (%%scale,
%%pageheight etc.) For example: -p 0.7,25,15,1.2,1.2,1.2,1.2 sets the scale to 0.7, the page height
to 25 cm, the page width to 15 cm and all margins to 1.2 cm. After -p should follow 7 (floating point)
numbers separated by comma's and without any spaces! Alle measures are in centimeter (cm). The scale
value is the same as used by abcm2ps, i.e. a floating point number somewhere around 1.0
- Option -pf (this is option -p without number list) Enables the translation of xml page format
specifications into abc page format instructions (%%pageheight etc).
- Option -i tells xml2abc to read XML data from standard input. When writing
the an output file with option -o the name of the output file is stdin.xml.
The python script: xml2abc.py-135.zip
(the change log)
Stand alone win32 executable: