»Home
»User Guide
»Installation
»FAQ
»asciidoc(1)
»a2x(1)
»API
»Plugins
»Cheatsheet
»Tests
»ChangeLog
»Support
AsciiDoc
Text based document generation

The AsciiDoc distribution includes a Music Block filter that translates music in LilyPond or ABC notation to standard classical notation in the form of a trimmed PNG image which is automatically inserted into the AsciiDoc output document (see the examples below).

Actually the filter (./filters/music/music2png.py) can be used outside AsciiDoc to convert LilyPond or ABC music files to PNG images. Execute the following command to see how to use it:

$ ./filters/music/music2png.py --help
Example 1. Music Block containing ABC notation

This Music Block:

["music","music1.png",scaledwidth="100%"]
---------------------------------------------------------------------
T:The Butterfly
R:slip jig
C:Tommy Potts
H:Fiddle player Tommy Potts made this tune from two older slip jigs,
H:one of which is called "Skin the Peelers" in Roche's collection.
H:This version by Peter Cooper.
D:Bothy Band: 1975.
M:9/8
K:Em
vB2(E G2)(E F3)|B2(E G2)(E F)ED|vB2(E G2)(E F3)|(B2d) d2(uB A)FD:|
|:(vB2c) (e2f) g3|(uB2d) (g2e) (dBA)|(B2c) (e2f) g2(ua|b2a) (g2e) (dBA):|
|:~B3 (B2A) G2A|~B3 BA(uB d)BA|~B3 (B2A) G2(A|B2d) (g2e) (dBA):|
---------------------------------------------------------------------

Renders:

music1.png
Example 2. Music Block containing LilyPond notation

This example contains LilyPond musical markup.

[music]
---------------------------------------------------------------------
\version "2.14.2"
\paper {
 ragged-right = ##t
}
{
 \time 3/4
 \clef bass
 c2 e4 g2. f4 e d c2 r4
}
---------------------------------------------------------------------

Renders:

music-filter__1.png
Note If you get an error processing the above example it may be that it is not compatible with your version of LilyPond. Use the LilyPond convert-ly(1) utility to update the source to the version that you are using.

Using the Filter

  • The Music filter is invoked by setting the Listing block or Paragraph style (the first positional block attribute) to music.

  • The second positional attribute (named target is optional, it sets the name of the generated PNG image file. If this is not supplied a file name like {docname}__{target-number}.png is synthesised (where {docname} is the document file name and {target-number} is an integer number.

  • The third positional attribute (format) specifies the music input format: either abc for ABC or ly for LilyPond. If the format is omitted ABC notation is assumed unless the text starts with a backslash character, in which case the format is set to ly.

Because the LaTeX images are rendered using the image block templates you can also use the optional named image block attributes (see Image macro attributes in the AsciiDoc User Guide).

Limitations

  • The asciidoc(1) input and output files cannot both be - (stdin and stdout), either the input or output files (or both) must be a named file.

Installation

In addition to AsciiDoc you will need to have installed:

  • LilyPond (most Linux distributions include this package).

  • ImageMagick (most Linux distributions include this package).

Test the music filter it by converting the test file to HTML with AsciiDoc:

$ asciidoc -v ./filters/music/music-filter-test.txt
$ firefox ./filters/music/music-filter-test.html &

The filter was developed and tested on Xubuntu Linux using LilyPond 2.10.5 and ImageMagick 6.2.4.

Note The filter does not work with LilyPond 2.2.6 because it did not generate the requested output file name correctly (2.6.3 does not have a problem).