Lilypond scores with cover page and performance notes

In this post I will describe the method for creating musical scores in Lilypond which incorporate a cover page and performance/technical notes at the start of a score. Let’s assume that the performance notes are pretty complicated and include a few musical examples from the score, some stage layout diagrams and a few examples of Pure Data patches from the live electronics part. To make things a little more interesting, we’ll insist that all graphics and score end up as scalable PDF for professional-quality print.

The approach we are going to take is to create the score and front pages as two separate PDF documents and join them together at the end. Let’s assume that the PDF for the actual Lilypond score is complete, and give that no further thought.

Latex template

The first thing we need to do is make the Latex document that will contain our performance notes, score excerpts diagrams etc. Let’s call this document preliminaries-book.lytex.

Firstly to get the book with a nice front cover, we need to use the document class ‘book’:

\documentclass[a4paper, landscape, twocolumn, 12pt]{book}

I use a two-column, a4 landscape layout with 12pt font size, but this can be customised.

Select the ‘graphicx’ package for including our PDFs:

\usepackage{graphicx}

Next we can optionally change the default typeface:

%% Use lmodern font
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\renewcommand*\familydefault{\sfdefault}

We also want to suppress the automatic page numbering, because we want our numbering to start on the first page of the score proper:

%% Suppress page numbering
\usepackage{nopageno}

Now begin the document and make the title:

\begin{document}

\author{My Name}
\title{My Piece \\
    {\large {for \\ \textbf {Piano and Live Electronics}}}}
\date{2008}

\maketitle

\section* {Live electronics setup}

Notice that we use section* to suppress section numbering.

The rest of the document is standard LaTeX except for the Lilypond snippet (see below), and won’t be described any further.

Making the diagrams

Now let’s assume that we have some introductory text interspersed with four diagrams:

  • A logical connection diagram for the live electronics made in dia
  • A ‘screenshot’ of the Pd patch
  • A physical layout diagram showing the Piano, microphone and stage positions made in Inkscape
  • A short excerpt from the score

We are going to be using pdflatex to render our ‘.tex’ file, so we want all of our diagrams in PDF format. We also want them all to be scalable - not PNG, JPEG etc. We will be including each diagram as follows:

\begin{figure}
    \centering
    \includegraphics[scale=0.4]{pd_patch.pdf}
    \caption{PD patch}
    \label{fig:pd_patch}
\end{figure}

We will then reference the figures in the text as follows:

blah blah is in figure~\ref{fig:pd_patch}

Dia diagram

We can save our working Dia diagram in ‘.dia’ format, and do the necessary conversion to PDF in the build script. This way any changes to the diagram will automatically be incorporated into the score book when the script is run.

We convert from ‘.dia’ to PDF in two steps:

dia -t eps-pango -e diagram1.eps diagram1.dia

Then:

epstopdf diagram1.eps --outfile=diagram1.pdf

This requires the `epstopdf’ tool to be installed. There are other ways to convert epstopdf, but this method was found to give the best results.

Converting the PD patch to PDF

Any Pure Data patch can be ‘printed’ to Postscript, simply by selecting the ‘print’ option from Pd’s ‘file’ menu. However, it is often more convenient to script the process so that changes to the Pd patch are automatically incorporated into the final score when the build script is run.

Assuming that we have a Pd patch called ‘MAIN_PATCH.pd’ in a subdirectory called ‘pd-patches’, we can use this script along with this helper patch to print the patch to Postscript (note: this script was originally devised by Andy Farnell and Frank Barknecht - see this thread):

pdprint3.sh pd-patches/

This should give us a file called MAIN_Patch.pd.ps in the pd-patches subdirectory. This can now be converted to PDF using the command `ps2pdf’, however better results were achieved by using an intermediate SVG stage as follows:

pstoedit -f plot-svg pd-patches/MAIN_PATCH.pd.svg --export-pdf=MAIN_PATCH.pdf
inkscape MAIN_PATCH.pd.svg --export-pdf=MAIN_PATCH.pdf

Converting the Inkscape diagram to PDF

This is the easiest step since Inkscape natively exports PDF, and conveniently makes this functionality available via the command line:

inkscape diagram2.svg --export-pdf=diagram.pdf

Incorporating score fragments

If we preprocess the document with `lilypond-book’, score fragments can be incorporated into the LaTeX code e.g.:

Acciaccaturas are to be played quickly and on the beat.
\begin [quote,fragment,staffsize=16]{lilypond}
    \acciaccatura f'16 b'2
\end {lilypond}
Should be played:
\begin [fragment,staffsize=16]{lilypond}
    \stemUp f'32 b'8.. ~ b'4
\end {lilypond}

Putting it all together

First we convert our ‘.lytex’ file to standard LaTeX:

lilypond-book --pdf -o preliminaries-book preliminaries-book.lytex

Now render with pdflatex. Note: we can’t use latex, dvips etc because our diagrams are in PDF format.

cd preliminaries-book
pdflatex preliminaries-book.tex

Finally we join the rendered PDF to the actual score using ghostscript:

cd .. gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=finished.pdf preliminaries-book/preliminaries-book.pdf ../score.pdf

Replacing `score.pdf’ with the name of the lilypond score as appropriate.

…and finally:

evince finished.pdf

:-)

Related Entries

About

I work at Birmingham Conservatoire as senior researcher and software development manager for the Integra Project. I live with my wife and three beautiful children in Birmingham, UK.» More...

Tag Cloud

Projects

-->
Close