Using the abcpp preprocessor with M-Tx

Guido Gonzato's abcpp is text preprocessing software primarily designed for use with abc music typesetting but may, as outlined by the author, also be utilized with other text based music typesetting software like MusiXTeX / PMX / M-Tx.

The abcpp software and documentation is available from the Abc Plus project web site.

An abcpp key features is macros. A macro is declared with an uppercase name optionally followed by a definition:

#define VOICEOOHS "54"

Another important feature is conditional expressions:

#ifdef MIDI
Octave: 4 4 3 3
Octave: 4 4 4 3

#ifdef MIDI

If the macro MIDI has been declared then the line(s) following the #ifdef expression are processed; else the line(s) following an optional #else clause are processed.

An abcpp source files consists of text interspersed with conditional expressions and macros which are processed by the abcpp preprocessor.An abcpp command line must include the name of the abcpp source file followed by the name of the preprocessing result file. The filename arguments may be preceded by command line options (see the abcpp manual) and macro declarations (a macro name prefixed by a dash):

abcpp -MIDI ihrl.mtp ihrlmid.mtx

The result of abcpp preprocessing a file, ihrl.mtp, containing the lines above would be:

Octave: 4 4 3 3


Among the usages of these facilities is extraction of separate parts from a score. For instrumental music the PMX part extraction utility scor2prt does that excellently, but it fails to handle lyrics of vocal music properly. In such cases abcpp can be helpful. Take as an example the typesetting source of a four part hymn setting, PDFIhr lieben Kinder freuet euch sound by Joachim a Burgk.

All M-Tx music- and lyrics paragraph lines have been prefixed with a macro expression like "S_". The value of these macros is set to an empty string if the lines should be typeset or else it is set to a comment plus a space ("% "). For example for generating the M-Tx file of the Diskant part the macro "S_" prefixing the music- and lyrics lines of the upper part is set to an empty string while all other prefix macros (e.g. "A_") are set to "% ". Notice that the value of the macro "S_" is defined to an empty string also when the macros "SCORE" and "MIDI" are declared because we need the music of the Diskant part for the full score and for the MIDI output.

#define S_ ""
#define S_ "% "

Some M-Tx preamble clauses should differ depending on the kind of score extracted from the typesetting source. For example for generating the Baß part we'll be typesetting a single staff score with a bass clef. We must also adapt the M-Tx lyrics vertical offset, which we accomplish by means of the macro BOFFS the value of which depends on which score type we're generating:

#ifdef BASS
Pages: 1
Systems: 4
Style: MyBass
Octave: 3
Name: Ba\ss.
#define BOFFS "+5"

For generating the various M-Tx source files (for typesetting a full score or a separate) out of the abcpp master source file we launch abcpp on the abcpp master source file ihrl.mtp with the appropriate macro definitions, for example for generating the full score:

abcpp -SCORE ihrl.mtp ihrlsc.mtx

and end up with ihrlsc.mtx, a source file ready for M-Tx processing a full score. We get corresponding M-Tx source files for typesetting the Diskant-, Alt-, Tenor- and Baß parts using the command line macro declarations -DISKANT, -ALT, -TENOR and -BASS. For achieving MIDI output we use the macro -MIDI for generating the M-Tx source file ihrlmid.mtx. As usual we get MIDI output from the PMX stage of the M-Tx processing of that file.

A major benefit of all that is that we need to maintain only a single abcpp master source file!