]> git.donarmstrong.com Git - lilypond.git/blob - tex/lilyponddefs.tex
release: 0.1.20
[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=1.5\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
157
158 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
159 % parametric symbols
160 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
161
162 \def\doublebar#1{\hbox{\thinbar{#1}\hskip\smallspace\thinbar{#1}}}
163 \def\thinbar#1{\vrule height #1 width 1.6\staffrulethickness} % TODO parametric.
164 \def\thickbar#1{\vrule height #1 width 2\smallspace}
165 \def\maatstreep#1{\thinbar{#1}}
166 \def\startbar#1{\leftalign{\thickbar{#1}\kern\smallspace\thinbar{#1}}}
167 \def\finishbar#1{\rightalign{\thinbar{#1}\kern\smallspace\thickbar{#1}}}
168
169 \def\pianobrace#1{{\musicdraw\char#1}}
170 \def\slurcharh#1{{\slurhfont\char#1}}
171 \def\slurcharu#1{{\slurufont\char#1}}
172 \def\slurchard#1{{\slurdfont\char#1}}
173 \def\hslurcharh#1{{\hslurhfont\char#1}}
174 \def\hslurcharu#1{{\hslurufont\char#1}}
175 \def\hslurchard#1{{\hslurdfont\char#1}}
176 % stacked numbers
177 \def\generalmeter#1#2{\botalign{\vbox to0.5\balkheight{\vss \meterfont#1}%
178         \nointerlineskip
179         \vbox to 0.5\balkheight{\vss\meterfont #2}}}
180
181 % stacked horizontal lines 
182 \def\lines#1#2#3{%
183  \vbox{\kern-\interstaffrule
184         \n=0\nointerlineskip%
185         \loop\ifnum\n<#1\advance\n by1%
186                 \kern\interstaffrule
187                 \nointerlineskip
188                 \vbox to 0pt{\hrule height .5#3 depth .5#3 width#2%
189                         \vss}\nointerlineskip
190                 \repeat
191         }}
192
193 %%
194 % Ugh. Need to redo this. Wish we had PS.
195 %
196 \def\topledgerlines#1#2{\dist#1
197         \topalign{\hbox{\kern-.25\dist\lines{#2}{1.5\dist}{\ledgerlinethickness}}}}
198
199 \def\botledgerlines#1#2{\dist#1
200         \botalign{\hbox{\kern-.25\dist\lines{#2}{1.5\dist}{\ledgerlinethickness}}}}
201
202 %
203 % a staffsymbol with #1 lines, width #2
204 % bottom at baseline
205 \def\linestafsym#1#2{\leftalign{\botalign{\lines{#1}{#2}{\staffrulethickness}}}}
206
207 \def\stem#1#2{\hbox{\kern -.5\stemthickness
208         \vrule width\stemthickness height#2 depth-#1}}
209
210 \def\placebox#1#2#3{%
211         \botalign{\hbox{\raise #1\leftalign{\kern #2{}#3}}}%
212 }
213
214
215 \def\brace#1{\count0=148\advance\count0 by #1\musicdraw\char\count0}
216 \def\crescendosym#1{\count0=84\advance\count0 by #1\musicdraw\char\count0}
217 \def\decrescendosym#1{\count0=116\advance\count0 by #1\musicdraw\char\count0}
218 \def\rulesym#1#2{\vrule height #1 width #2}
219 \def\settext#1{\normaltextfont #1}
220 \def\setitalic#1{\italicfont #1}
221 \def\setdynamic#1{\dynfont #1}
222
223 % the interline symbol. Redefine to remove it.
224 \def\defaultlineseparator{\vbox{\mussepline\vskip -5pt\mussepline}}
225 \def\lineseparator{\defaultlineseparator}
226 \def\beauty{%
227         \par\vskip 10pt plus 30pt minus 10pt\par
228         \hskip -5pt\lineseparator
229         \par\vskip 10pt plus 30pt minus 10pt\par
230 }
231
232
233 \def\interscoreline{\vskip 16pt}
234         
235 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
236 % big fat marks, if errors are detected.
237 \def\columnerrormark{\placebox{-5pt}{0pt}{\bf C!}}
238 \def\scorelineerrormark{\placebox{0pt}{-10pt}{\bf L!}}
239 \def\errormark{{\bf E!}}
240 \def\unknown{{\bf u}}
241
242 \def\postheader{}
243 \ifundefined{documentclass}
244         \footline={\ifnum\pageno=1
245         {\smalltextfont\mudelacopyright\hfil \LilyIdString
246         }\else{\hfil\the\pageno\hfil}\fi
247 }\else
248         %% FIXME
249         \def\ps@plain{
250                 \renewcommand{\@oddhead}{}%
251                 \renewcommand{\@evenfoot}{}%
252                 \renewcommand{\@evenhead}{}%
253                 \renewcommand{\@oddfoot}{\ifnum\thepage=1
254         {\hfil \LilyIdString
255         }\else{foo\hfil\the\pageno\hfil}\fi}}
256         \def\ps@empty{
257                 \renewcommand{\@oddhead}{}%
258                 \renewcommand{\@evenfoot}{}%
259                 \renewcommand{\@evenhead}{}%
260                 \renewcommand{\@oddfoot}{\ifnum\thepage=1
261         {\hfil \LilyIdString
262         }\else{foo\hfil\the\pageno\hfil}\fi}}
263 \fi
264
265