xml2abc
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
abc2xml
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.
Usage:
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.
See tutorial
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.
- Option --nbr disables translation to broken rhythms.
Normally xml2abc tries to write broken rythms whenever possible. This option disables that behaviour
- Option --rbm re-beams all measures.
Only meant for files that completely lack any beaming.
- Option --fin=N selects the rule set for microtonal accidentals.
Some well known score editors behave differently when microtonal accidentals
are present in the score.
xml2abc uses different translation rules, depending on which score editor was
used to make the xml file
When microtonal accidentals are present in the score, xml2abc
searches for the identification of the encoding software.
The following encoders are recognized: abc2xml, burak uyar, musescore and finale.
When no match is found musescore is assumed.
With option --fin one can override the automatic detection:
abc2xml: --fin=0
burak uyar: --fin=1
musescore: --fin=2 (default)
finale: --fin=3
- Option --temp=N selects the temperament for microtonal accidentals.
When microtonal accidentals are present in the score a corresponfing tuning
is aufomatically selected. Only EDO-53 and EDO-36 are implemented.
EDO-36 is used for the up/down accidentals in MusicXML and EDO-53
for the makam accidentals.
When a mixture of these accidentals is detected, EDO-53 is selected
and the up/down accidentals are mapped to the closest makam variant.
--temp=0 => only map up/down accidentals when they occur mixed with makam accidentals (default)
--temp=1 => always map up/down accidentals, even when not mixed with makam accidentals (i.e. a pure
EDO-36 file)
--temp=2 => up/down accidentals are translated to fractional ABC accidentals, and can be
mixed with (whole number) makam accidentals in ABC.
For instance, <natural-up> is translated to ^1/3 and <sharp-down> to ^2/3,
but <quarter-sharp> is translated to ^1, and <sharp> to ^4.
Download
The python script: xml2abc.py-167.zip
(the change log)
Stand alone win32 executable:
xml2abc.exe-167.zip
Blechtrottel.net has developed
abc2xmlGUI,
a graphical user interface for both abc2xml and xml2abc.