Produce multistave music using abc notation in a document

abcmusic

I have been trying to get the package '''abc''' to produce multistave music notation within a document. If possible I'd like to find a solution using this rather than, for instance, LilyPond. After consulting the documentation for the '''abc''' package, I get the impression it should be possible. It reads as follows:

A recent extension of this language, called ABC Plus, allows for
setting multiple stavesand polyphony. One of the best programs for
converting these notations into sheet music is '''abcm2ps''', which
can take an ABC or ABC Plus file and transform it intoa
PostScript-file. The purpose of this package is to allow LATEX users
to include in their doc-uments small excerpts of music written
directly in ABC (Plus).

This is what I've tried:

\documentclass{scrartcl}
\usepackage[utf8]{inputenc} 
\usepackage[generate,ps2eps]{abc} % I've tried different things within the [], but I still suspect the problem lies here... This works for single-stave stuff.
\begin{ducument}

  Here follows three identical renderings of Brother John:
  
  \begin{abc}[name=brother1]
    X:1
    T: Brother John
    L: 1/4
    K: F
    M: 4/4
    V:1
    FGAF | FGAF | ABcz | ABcz | c/d/c/B/ AF | c/d/c/B/ AF |
    V:2
    z4   | z4   | FGAF | FGAF | ABcz        | ABcz        |
  \end{abc}

  \begin{abc}[name=brother2]
    X: 1
    T: Brother John
    L: 1/4
    V: 1 clef=treble name="Soprano" sname="S"
    V: 2 clef=treble name="Contralto" sname="C"
    K: F
    %
    [V:1] FGAF | FGAF | ABcz | ABcz | c/d/c/B/ AF | c/d/c/B/ AF |
    [V:2] z4   | z4   | FGAF | FGAF | ABcz        | ABcz        |
  \end{abc}

  \begin{abc}[name=brother3]
    X: 1
    T: Brother John
    L: 1/4
    K: F 0&2
    %
    z4   & FGAF |z4    & FGAF | FGAF & ABcz | FGAF & ABcz | ABcz & c/d/c/B/ AF | ABcz & c/d/c/B/ AF |
  \end{abc}

\end{ducument}

The first two formats follows the suggestions in the documentation of ABC Plus.

The third format follows ABC2MTEX, which I attempted just in case it would work.

I tried to compile this using

latex --shell-escape testfile
dvips -o testfile.ps testfile.dvi
ps2pdf testfile.ps

This works for single-stave music.

Can one of my three examples be improved in some way, or is there some completely different way of producing multistave sheet music?

Best Answer

I'm not sure when abcm2ps started to append useless numbers to the generated PostScript files, without even any option to turn this feature off. :-(

Also, if a title is specified in the .abc file, the -O= option will use it. :-(

Here's a temporary fix.

\documentclass{scrartcl}
\usepackage[generate,ps2eps]{abc}
\usepackage{xpatch}

\makeatletter
\renewcommand{\abc@parm}{-O\[email protected]\space -c}
\define@key{abc}{name}[]{%
  \if!#1!\stepcounter{abc@count}%
    \edef\abc@tempfile{\normalabcoutputfile-\@arabic\c@abc@count}%
  \else
    \def\abc@tempfile{#1001}%
  \fi
}
\makeatother

\begin{document}
  
\begin{abc}[name=brother1]
X: 1
T: Brother John
C: Traditional
L: 1/4
K: F
M: 4/4
V:1
FGAF | FGAF | ABcz | ABcz | c/d/c/B/ AF | c/d/c/B/ AF |
V:2
z4 | z4 | FGAF | FGAF | ABcz | ABcz |
V:1
GCFz |GCFz | z4 | z4 |
V:2
c/d/c/B/ AF | c/d/c/B/ AF | GCFz | GCFz|
\end{abc}

\end{document}

enter image description here