lilypond-0.1.27
[lilypond.git] / tex / lilyponddefs.tex
blob4bd3ab3d5d666085b163c4f59547b99427f45aaa
1 %%
2 %% include file for LilyPond
3 %%
4 %% this file defines various macros to accomodate lilypond output
6 % TeXbook ex 7.7
7 \def\ifundefined#1{\expandafter\ifx\csname#1\endcsname\relax}
9 % skip if included already
10 \def\SkipLilydefs{\endinput}
11 \ifundefined{EndLilyPondOutput}
12 \def\EndLilyPondOutput{\csname bye\endcsname}
13 \def\SkipLilydefs{}
14 \fi
15 \SkipLilydefs
17 \ifundefined{mudelacopyright}
18 \def\mudelacopyright{\copyright\ \number\year}
19 \fi
20 \ifundefined{LilyIdString}
21 \def\LilyIdString{Lily was here}
22 \fi
24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25 % macros to shorten other definitions
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27 \def\musicdef#1#2{\def#1{\musicchar{#2}}}
28 \def\musicchar#1{\musicfnt\char#1}
29 \def\rationalmultiply#1*#2/#3{\multiply #1 by #2 \divide #1 by #3}
32 \def\maccentraise#1#2{\dimen0=\noteheight
33 \rationalmultiply\dimen0*#2%
34 \raise\dimen0\hbox{#1}}
35 \def\maccentdef#1#2#3{\def#1{\maccentraise{\musicchar{#2}}{#3}}}
36 \def\vertcenter#1{\vbox to 0pt{\vss #1\vss}}
38 \def\musicmathdef#1#2{\def#1{\musicmathchar{#2}}}
39 \def\musicmathchar#1{\musicmathfont\char#1}
41 \def\topalign#1{\vbox to 0pt{#1\vss}}
42 \def\botalign#1{\vbox to 0pt{\vss #1}}
44 \def\centeralign#1{\hbox to 0pt{\hss#1\hss}}
45 \def\leftalign#1{\hbox to 0pt{#1\hss}}
46 \def\rightalign#1{\hbox to 0pt{\hss#1}}
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50 %% set up dimensions
51 \parindent=0pt
52 \newdimen\smallspace
53 \newdimen\interlinedist
54 \newdimen\ledgerlinethickness
55 \newdimen\stemthickness
56 \newcount\n
57 \newdimen\balkheight
58 \newdimen\notewidth
59 \newdimen\noteheight
60 \newdimen\staffrulethickness
61 \newdimen\interstaffrule
62 \newdimen\dist
64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 % set fonts and primary dimensions
66 % ugh
67 \def\musixtwentydefs{
68 \balkheight=20pt
69 \notewidth=7.15pt
70 \noteheight=5pt
71 \musixtwentyfonts
72 \font\textmusic=cmmi12
73 \musixcalc
76 \def\musixsixteendefs{
77 \balkheight=16pt
78 \notewidth=5.93pt
79 \noteheight=4pt
80 \musixsixteenfonts
81 \font\textmusic=cmmi10
82 \musixcalc
85 \def\textsharp{\raise.4ex\hbox{\textmusic\char"5D}}
86 \def\textnatural{\raise.4ex\hbox{\textmusic\char"5C}}
87 \def\textflat{\raise.2ex\hbox{\mus\char"5B}}
92 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
93 % do derivative calcs
95 % FIXME: should read from TFM/AFM/fetalog
98 % this has to be synced with the font definition
99 \def\musixcalc{
100 \interlinedist=\fontdimen5\musicfnt
101 \smallspace=.3\interlinedist
102 \interstaffrule=\balkheight
103 \divide\interstaffrule by 4
105 % [D.K.Roush & J.S.Gourlay] say this should be 0.072
106 % We know better
107 \staffrulethickness=0.1\interlinedist
108 \stemthickness=\staffrulethickness
109 \ledgerlinethickness=2\staffrulethickness
112 % stacked numbers; may be overruled in fetdefs
113 \def\generalmeter#1#2{\vbox to 0pt{\vss\hbox{\meterfont
114 #1}\nointerlineskip
115 \hbox{\meterfont #2}\vss}}
117 % stacked horizontal lines
119 \input dyndefs
121 \input taupindefs
122 %\input eglerdefs
124 \musicmathdef\cup{91} % \cup
125 \musicmathdef\wedge{94} % \wedge
126 \musicmathdef\striepke{0} % heu?
128 %% custom characters --- this should go: add to (meta!) font
129 % \def\myheel{\kern-.5ex\vbox{\cup}\kern-.5ex}
130 % \def\mytoe{\kern-.5ex\vbox{\wedge}\kern-.5ex}
131 \def\myheel{\vbox{\cup}}
132 \def\mytoe{\vbox{\wedge}}
133 % \def\mystriepke{\kern-1.1ex\vbox{\hbox{\kern-.05em\striepke}}\kern-1.1ex}
134 \def\mystriepke{\kern-1.8ex\vbox{\hbox{\kern-.05em\striepke}}\kern-1.8ex}
136 \def\heel{\vbox{\myheel}}
137 \def\toe{\vbox{\mytoe}}
138 \def\backorfront{\mystriepke}
140 \def\bheel{\vbox{\myheel\mystriepke}}
141 \def\btoe{\vbox{\mytoe\mystriepke}}
142 \def\fheel{\vbox{\mystriepke\myheel}}
143 \def\ftoe{\vbox{\mystriepke\mytoe}}
144 \def\heeltoe{\vbox{\myheel\mytoe}}
145 \def\toeheel{\vbox{\mytoe\myheel}}
148 \def\emptybar{}
150 \def\defaultthinbar{\thinbar{\balkheight}}
151 \def\defaultthickbar{\thickbar{\balkheight}}
152 %? what-s wrong with rightalign?
153 \def\repeatstopbar{\hss\rightalign{\repeatcolon\hskip2\smallspace\defaultthinbar\hskip\smallspace\defaultthickbar}}
154 \def\repeatstartbar{\hbox{\defaultthickbar\kern\smallspace\defaultthinbar\kern2\smallspace\repeatcolon}}
155 \def\repeatstopstart{\hbox{\repeatcolon\kern2\smallspace\defaultthinbar\kern\smallspace\defaultthickbar\kern\smallspace\defaultthickbar\kern\smallspace\defaultthinbar\kern2\smallspace\repeatcolon}}
157 %compatibility
158 \def\repeatbar{\repeatstopbar}
159 \def\startrepeat{\repeatstartbar}
160 \def\repeatbarstartrepeat{\repeatstopstart}
162 \def\vruler#1{{%
163 \def\wid{\dimen0}%
164 \def\inc{\dimen1}%
165 \wid=#1pt
166 \inc=\wid
167 \divide\inc by #1
168 \divide\wid by 2
169 \here=-\wid
170 \loop\ifdim\here<\wid\advance\here by\inc
171 \hbox to0pt{\vbox to0pt{\vss\hrule width2pt height 0.05pt\kern\here}\hss}%
172 \repeat%
174 \def\hruler#1#2{\hbox{%
175 \def\wid{\dimen0}%
176 \def\here{\dimen3}%
177 \wid=#1pt
178 \divide\wid by 2
179 \here=-\wid
180 \loop\ifdim\here<\wid\advance\here by #2
181 \hbox to0pt{\kern\here\vrule width0.05pt height 1pt depth 1pt\hss}%
182 \repeat%
186 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
187 % parametric symbols
188 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
190 \def\doublebar#1{\hbox{\thinbar{#1}\hskip\smallspace\thinbar{#1}}}
191 \def\thinbar#1{\vrule height #1 width 1.6\staffrulethickness} % TODO parametric.
192 \def\thickbar#1{\vrule height #1 width 2\smallspace}
193 \def\maatstreep#1{\thinbar{#1}}
194 \def\startbar#1{\leftalign{\thickbar{#1}\kern\smallspace\thinbar{#1}}}
195 \def\finishbar#1{\rightalign{\thinbar{#1}\kern\smallspace\thickbar{#1}}}
197 \def\pianobrace#1{{\musicdraw\char#1}}
198 \def\slurcharh#1{{\slurhfont\char#1}}
199 \def\slurcharu#1{{\slurufont\char#1}}
200 \def\slurchard#1{{\slurdfont\char#1}}
201 \def\hslurcharh#1{{\hslurhfont\char#1}}
202 \def\hslurcharu#1{{\hslurufont\char#1}}
203 \def\hslurchard#1{{\hslurdfont\char#1}}
205 \def\lines#1#2#3{%
206 \vbox{\kern-\interstaffrule
207 \n=0\nointerlineskip%
208 \loop\ifnum\n<#1\advance\n by1%
209 \kern\interstaffrule
210 \nointerlineskip
211 \vbox to 0pt{\hrule height .5#3 depth .5#3 width#2%
212 \vss}\nointerlineskip
213 \repeat
217 % Ugh. Need to redo this. Wish we had PS.
219 \def\topledgerlines#1#2{\dist#1
220 \topalign{\hbox{\kern-.25\dist\lines{#2}{1.5\dist}{\ledgerlinethickness}}}}
222 \def\botledgerlines#1#2{\dist#1
223 \botalign{\hbox{\kern-.25\dist\lines{#2}{1.5\dist}{\ledgerlinethickness}}}}
226 % a staffsymbol with #1 lines, width #2
227 % bottom at baseline
228 \def\linestafsym#1#2{\leftalign{\botalign{\lines{#1}{#2}{\staffrulethickness}}}}
230 \def\stem#1#2{\hbox{\kern -.5\stemthickness
231 \vrule width\stemthickness height#2 depth-#1}}
233 \def\placebox#1#2#3{%
234 \botalign{\hbox{\raise #1\leftalign{\kern #2{}#3}}}%
238 \def\brace#1{\count0=148\advance\count0 by #1\musicdraw\char\count0}
239 \def\crescendosym#1{\count0=84\advance\count0 by #1\musicdraw\char\count0}
240 \def\decrescendosym#1{\count0=116\advance\count0 by #1\musicdraw\char\count0}
241 \def\rulesym#1#2{\vrule height #1 width #2}
242 \def\settext#1{\normaltextfont #1}
243 \def\setitalic#1{\italicfont #1}
244 \def\setdynamic#1{\dynfont #1}
246 % the interline symbol. Redefine to remove it.
247 \def\defaultlineseparator{\vbox{\mussepline\vskip -5pt\mussepline}}
248 \def\lineseparator{\defaultlineseparator}
249 \def\beauty{%
250 \par\vskip 10pt plus 30pt minus 10pt\par
251 \hskip -5pt\lineseparator
252 \par\vskip 10pt plus 30pt minus 10pt\par
256 \def\interscoreline{\vskip 16pt}
258 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
259 % big fat marks, if errors are detected.
260 \def\columnerrormark{\placebox{-5pt}{0pt}{\bf C!}}
261 \def\scorelineerrormark{\placebox{0pt}{-10pt}{\bf L!}}
262 \def\errormark{{\bf E!}}
263 \def\unknown{{\bf u}}
265 \def\postheader{}
266 \ifundefined{documentclass}
267 \footline={\ifnum\pageno=1
268 {\smalltextfont\mudelacopyright\hfil \LilyIdString
269 }\else{\hfil\the\pageno\hfil}\fi
270 }\else
271 %% FIXME
272 \def\ps@plain{
273 \renewcommand{\@oddhead}{}%
274 \renewcommand{\@evenfoot}{}%
275 \renewcommand{\@evenhead}{}%
276 \renewcommand{\@oddfoot}{\ifnum\thepage=1
277 {\hfil \LilyIdString
278 }\else{foo\hfil\the\pageno\hfil}\fi}}
279 \def\ps@empty{
280 \renewcommand{\@oddhead}{}%
281 \renewcommand{\@evenfoot}{}%
282 \renewcommand{\@evenhead}{}%
283 \renewcommand{\@oddfoot}{\ifnum\thepage=1
284 {\hfil \LilyIdString
285 }\else{foo\hfil\the\pageno\hfil}\fi}}
289 % debugging stuff:
290 % \vbox to 0pt{\vskip .5cm \hruler{48}{3pt}\vss}