-\input dyndefs
-\input fetdefs
-
-
-
-\def\emptybar{}
-
-\def\defaultthinbar{\thinbar{\staffheight}}
-\def\defaultthickbar{\thickbar{\staffheight}}
-%? what-s wrong with rightalign?
-\def\repeatstopbar{\rightalign{\repeatcolon\kern2\smallspace\defaultthinbar\kern\smallspace\defaultthickbar}}
-\def\repeatstartbar{\hbox{\defaultthickbar\kern\smallspace\defaultthinbar\kern2\smallspace\repeatcolon}}
-\def\repeatstopstart{\hbox{\repeatcolon\kern2\smallspace\defaultthickbar\kern\smallspace\defaultthickbar\kern2\smallspace\repeatcolon}}
-
-%compatibility
-%urg
-\fetdef\repeatcolon{20}
-\def\repeatbar#1{\repeatstopbar}
-\def\startrepeat#1{\repeatstartbar}
-\def\repeatbarstartrepeat#1{\repeatstopstart}
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% parametric symbols
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-\def\doublebar#1{\hbox{\thinbar{#1}\hskip\smallspace\thinbar{#1}}}
-\def\thinbar#1{\dimen0=#1%
- \vrule height .5\dimen0 depth .5\dimen0 width 1.6\stafflinethickness} % TODO parametric.
-\def\thickbar#1{\dimen0=#1%
- \vrule height .5\dimen0 depth .5\dimen0 width 2\smallspace}
-\def\maatstreep#1{\thinbar{#1}}
-\def\startbar#1{\leftalign{\thickbar{#1}\kern\smallspace\thinbar{#1}}}
-\def\finishbar#1{\rightalign{\thinbar{#1}\kern\smallspace\thickbar{#1}}}
-\def\fatdoublebar#1{\hbox{\phantom{\repeatcolon\kern2\smallspace}\thickbar{#1}\kern\smallspace\thickbar{#1}}}
+%% This macro provides the necessary setup to make the lilypond data
+%% work with plain TeX, LaTeX, and texinfo.
+%%
+%% The reason of using \begingroup and \endgroup is to make the macro \x
+%% immediately disappear after it has been executed. Since we have \def
+%% within \def within \gdef, four hash signs (`#') are needed for
+%% parameters.
+%%
+%% \lilypondfontencoding is emitted by LilyPond to set the encoding of
+%% text strings.
+%%
+\gdef\lilypondstart{
+ \frenchspacing
+ \outputscale \lilypondpaperoutputscale\lilypondpaperunit
+
+ \begingroup
+ \catcode `\@=11\relax
+
+ %% \@nodocument is defined as \relax after `\begin{document}'
+ \lilypondifundefined{@nodocument}
+ {%% Either plain TeX or texinfo or not at the beginning of LaTeX input.
+ \def\x{
+ \endgroup
+
+ \def\lilypondfontencoding####1{
+ \lilypondECencoding}
+ \def\lilypondpagebreak{
+ \eject}
+ \def\lilypondnopagebreak{
+ \ifvmode
+ \penalty 10000\relax
+ \fi}}}
+
+ {%% LaTeX mode: Provide a complete preamble.
+ \def\x{
+ \endgroup
+
+ %% Indicate that we shall emit `\end{document}' while executing
+ %% \lilypondend.
+ \def\lilyponddocument{}
+
+ \def\lilypondfontencoding####1{
+ \fontencoding{####1}
+ \selectfont}
+ \def\lilypondpagebreak{
+ \newpage}
+ \def\lilypondnopagebreak{
+ \nopagebreak}
+
+ \documentclass[\lilyponddocumentclassoptions]{article}
+
+ %% As a safety guard, don't produce auxiliary files.
+ \nofiles
+
+ %% FIXME: workaround non-existent TeX.def.
+ \def\TeXdef{TeX}\ifx\TeXdef\lilypondpaperinputencoding
+ \usepackage[latin1]{inputenc}
+ \else
+ \usepackage[\lilypondpaperinputencoding]{inputenc}
+ \fi
+ \pagestyle{empty}
+
+ \usepackage{color}
+
+ \lilypondifundefined{lilypondclassic}
+ {%% If not in `classic' mode, undo LaTeX's page layout settings
+ %% since LilyPond does the layout by itself.
+ \topmargin-1in
+ \headheight0pt\headsep0pt
+ \oddsidemargin-1in
+ \evensidemargin\oddsidemargin}
+
+ {%% Otherwise center output horizontally, without changing the
+ %% vertical positioning.
+ \hsize\lilypondpaperlinewidth\lilypondpaperunit
+ \lytempdim \paperwidth
+ \advance\lytempdim -\the\hsize
+ \lytempdim 0.5\lytempdim
+ \advance\lytempdim -1in
+ \oddsidemargin \lytempdim
+ \evensidemargin \lytempdim}
+
+ \parindent 0pt
+
+ %% We can't directly say `\begin{document}' in this macro since
+ %% older versions of texinfo.tex define \begin as \outer; this
+ %% means that it causes an error if \begin is found within another
+ %% macro (even if the corresponding code will never be executed).
+ %% As a workaround we use \csname to call \begin.
+ \csname begin\endcsname{document}}}
+ \x}
+
+%% The opposite of \lilypondstart.
+%%
+\gdef\lilypondend{
+ %% Handle the `lastpagefill' parameter from the \layout block.
+ %% Ignore it if \lilypondbook is defined.
+ \lilypondifundefined{lilypondbook}
+ {\lilypondifundefined{lilypondpaperlastpagefill}
+ {\vskip 0pt plus\lilypondpaperinterscorelinefill00 fill}
+ {}}
+ {}
+
+ \begingroup
+ \lilypondifundefined{lilyponddocument}
+ {\def\x{
+ \endgroup}}
+ {\def\x{
+ \endgroup
+ \csname end\endcsname{document}}}
+ \x}
+
+%% Load the PostScript drawing routines. This is done using \special.
+%% To avoid multiple inclusions, redefine \lilypondspecial to a no-op
+%% afterwards.
+%%
+\gdef\lilypondspecial{
+ \special{header=music-drawing-routines.ps}
+ \gdef\lilypondspecial{}}