]> git.donarmstrong.com Git - lilypond.git/blob - tex/lilyponddefs.tex
release: 0.1.23
[lilypond.git] / tex / lilyponddefs.tex
1 %%
2 %% include file for LilyPond
3 %%
4 %% this file defines various macros to accomodate lilypond output
5
6 % TeXbook ex 7.7
7 \def\ifundefined#1{\expandafter\ifx\csname#1\endcsname\relax}
8
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
16
17 \ifundefined{mudelacopyright}
18         \def\mudelacopyright{\copyright\ \number\year}
19 \fi
20 \ifundefined{LilyIdString}
21         \def\LilyIdString{Lily was here}
22 \fi
23
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}
30
31
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}}
37
38 \def\musicmathdef#1#2{\def#1{\musicmathchar{#2}}}
39 \def\musicmathchar#1{\musicmathfont\char#1}
40
41 \def\topalign#1{\vbox to 0pt{#1\vss}}
42 \def\botalign#1{\vbox to 0pt{\vss #1}}
43
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}}
47
48
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
63
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
74 }
75
76 \def\musixsixteendefs{
77         \balkheight=16pt
78         \notewidth=5.93pt
79         \noteheight=4pt
80         \musixsixteenfonts
81         \font\textmusic=cmmi10
82         \musixcalc
83 }
84
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}}
88
89
90
91
92 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
93 % do derivative calcs
94
95 % FIXME: should read from TFM/AFM/fetalog
96 %
97
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
104
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
110 }
111
112
113 \input dyndefs
114
115 \input taupindefs
116 %\input eglerdefs
117
118 \musicmathdef\cup{91} % \cup
119 \musicmathdef\wedge{94} % \wedge
120 \musicmathdef\striepke{0} % heu?
121
122 %% custom characters --- this should go: add to (meta!) font
123 % \def\myheel{\kern-.5ex\vbox{\cup}\kern-.5ex}
124 % \def\mytoe{\kern-.5ex\vbox{\wedge}\kern-.5ex}
125 \def\myheel{\vbox{\cup}}
126 \def\mytoe{\vbox{\wedge}}
127 % \def\mystriepke{\kern-1.1ex\vbox{\hbox{\kern-.05em\striepke}}\kern-1.1ex}
128 \def\mystriepke{\kern-1.8ex\vbox{\hbox{\kern-.05em\striepke}}\kern-1.8ex}
129
130 \def\heel{\vbox{\myheel}}
131 \def\toe{\vbox{\mytoe}}
132 \def\backorfront{\mystriepke}
133
134 \def\bheel{\vbox{\myheel\mystriepke}}
135 \def\btoe{\vbox{\mytoe\mystriepke}}
136 \def\fheel{\vbox{\mystriepke\myheel}}
137 \def\ftoe{\vbox{\mystriepke\mytoe}}
138 \def\heeltoe{\vbox{\myheel\mytoe}}
139 \def\toeheel{\vbox{\mytoe\myheel}}
140 %%
141
142 \def\emptybar{}
143
144 \def\defaultthinbar{\thinbar{\balkheight}}
145 \def\defaultthickbar{\thickbar{\balkheight}}
146 %? what-s wrong with rightalign?
147 \def\repeatstopbar{\hss\rightalign{\repeatcolon\hskip2\smallspace\defaultthinbar\hskip\smallspace\defaultthickbar}}
148 \def\repeatstartbar{\hbox{\defaultthickbar\kern\smallspace\defaultthinbar\kern2\smallspace\repeatcolon}}
149 \def\repeatstopstart{\hbox{\repeatcolon\kern2\smallspace\defaultthinbar\kern\smallspace\defaultthickbar\kern\smallspace\defaultthickbar\kern\smallspace\defaultthinbar\kern2\smallspace\repeatcolon}}
150
151 %compatibility
152 \def\repeatbar{\repeatstopbar}
153 \def\startrepeat{\repeatstartbar}
154 \def\repeatbarstartrepeat{\repeatstopstart}
155
156 \def\vruler#1{{%
157         \def\wid{\dimen0}%
158         \def\inc{\dimen1}%
159         \wid=#1pt
160         \inc=\wid
161         \divide\inc by #1
162         \divide\wid by 2
163         \here=-\wid
164         \loop\ifdim\here<\wid\advance\here by\inc
165                 \hbox to0pt{\vbox to0pt{\vss\hrule width2pt height 0.05pt\kern\here}\hss}%
166         \repeat%
167 }}
168 \def\hruler#1#2{\hbox{%
169         \def\wid{\dimen0}%
170         \def\here{\dimen3}%
171         \wid=#1pt
172         \divide\wid by 2
173         \here=-\wid
174         \loop\ifdim\here<\wid\advance\here by #2
175                 \hbox to0pt{\kern\here\vrule width0.05pt height 1pt depth 1pt\hss}%
176         \repeat%
177 }}
178
179
180 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
181 % parametric symbols
182 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
183
184 \def\doublebar#1{\hbox{\thinbar{#1}\hskip\smallspace\thinbar{#1}}}
185 \def\thinbar#1{\vrule height #1 width 1.6\staffrulethickness} % TODO parametric.
186 \def\thickbar#1{\vrule height #1 width 2\smallspace}
187 \def\maatstreep#1{\thinbar{#1}}
188 \def\startbar#1{\leftalign{\thickbar{#1}\kern\smallspace\thinbar{#1}}}
189 \def\finishbar#1{\rightalign{\thinbar{#1}\kern\smallspace\thickbar{#1}}}
190
191 \def\pianobrace#1{{\musicdraw\char#1}}
192 \def\slurcharh#1{{\slurhfont\char#1}}
193 \def\slurcharu#1{{\slurufont\char#1}}
194 \def\slurchard#1{{\slurdfont\char#1}}
195 \def\hslurcharh#1{{\hslurhfont\char#1}}
196 \def\hslurcharu#1{{\hslurufont\char#1}}
197 \def\hslurchard#1{{\hslurdfont\char#1}}
198 % stacked numbers
199 \def\generalmeter#1#2{\vbox to 0pt{\vss\hbox{\meterfont
200         #1}\nointerlineskip
201         \hbox{\meterfont #2}\vss}}
202
203 % stacked horizontal lines 
204 \def\lines#1#2#3{%
205  \vbox{\kern-\interstaffrule
206         \n=0\nointerlineskip%
207         \loop\ifnum\n<#1\advance\n by1%
208                 \kern\interstaffrule
209                 \nointerlineskip
210                 \vbox to 0pt{\hrule height .5#3 depth .5#3 width#2%
211                         \vss}\nointerlineskip
212                 \repeat
213         }}
214
215 %%
216 % Ugh. Need to redo this. Wish we had PS.
217 %
218 \def\topledgerlines#1#2{\dist#1
219         \topalign{\hbox{\kern-.25\dist\lines{#2}{1.5\dist}{\ledgerlinethickness}}}}
220
221 \def\botledgerlines#1#2{\dist#1
222         \botalign{\hbox{\kern-.25\dist\lines{#2}{1.5\dist}{\ledgerlinethickness}}}}
223
224 %
225 % a staffsymbol with #1 lines, width #2
226 % bottom at baseline
227 \def\linestafsym#1#2{\leftalign{\botalign{\lines{#1}{#2}{\staffrulethickness}}}}
228
229 \def\stem#1#2{\hbox{\kern -.5\stemthickness
230         \vrule width\stemthickness height#2 depth-#1}}
231
232 \def\placebox#1#2#3{%
233         \botalign{\hbox{\raise #1\leftalign{\kern #2{}#3}}}%
234 }
235
236
237 \def\brace#1{\count0=148\advance\count0 by #1\musicdraw\char\count0}
238 \def\crescendosym#1{\count0=84\advance\count0 by #1\musicdraw\char\count0}
239 \def\decrescendosym#1{\count0=116\advance\count0 by #1\musicdraw\char\count0}
240 \def\rulesym#1#2{\vrule height #1 width #2}
241 \def\settext#1{\normaltextfont #1}
242 \def\setitalic#1{\italicfont #1}
243 \def\setdynamic#1{\dynfont #1}
244
245 % the interline symbol. Redefine to remove it.
246 \def\defaultlineseparator{\vbox{\mussepline\vskip -5pt\mussepline}}
247 \def\lineseparator{\defaultlineseparator}
248 \def\beauty{%
249         \par\vskip 10pt plus 30pt minus 10pt\par
250         \hskip -5pt\lineseparator
251         \par\vskip 10pt plus 30pt minus 10pt\par
252 }
253
254
255 \def\interscoreline{\vskip 16pt}
256         
257 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
258 % big fat marks, if errors are detected.
259 \def\columnerrormark{\placebox{-5pt}{0pt}{\bf C!}}
260 \def\scorelineerrormark{\placebox{0pt}{-10pt}{\bf L!}}
261 \def\errormark{{\bf E!}}
262 \def\unknown{{\bf u}}
263
264 \def\postheader{}
265 \ifundefined{documentclass}
266         \footline={\ifnum\pageno=1
267         {\smalltextfont\mudelacopyright\hfil \LilyIdString
268         }\else{\hfil\the\pageno\hfil}\fi
269 }\else
270         %% FIXME
271         \def\ps@plain{
272                 \renewcommand{\@oddhead}{}%
273                 \renewcommand{\@evenfoot}{}%
274                 \renewcommand{\@evenhead}{}%
275                 \renewcommand{\@oddfoot}{\ifnum\thepage=1
276         {\hfil \LilyIdString
277         }\else{foo\hfil\the\pageno\hfil}\fi}}
278         \def\ps@empty{
279                 \renewcommand{\@oddhead}{}%
280                 \renewcommand{\@evenfoot}{}%
281                 \renewcommand{\@evenhead}{}%
282                 \renewcommand{\@oddfoot}{\ifnum\thepage=1
283         {\hfil \LilyIdString
284         }\else{foo\hfil\the\pageno\hfil}\fi}}
285 \fi
286
287
288 % debugging stuff:
289 % \vbox to 0pt{\vskip .5cm \hruler{48}{3pt}\vss}