]> git.donarmstrong.com Git - lilypond.git/blob - tex/lilyponddefs.tex
release: 0.1.47
[lilypond.git] / tex / lilyponddefs.tex
1 %%
2 %% include file for LilyPond
3 %%
4 %% this file defines various macros to accomodate lilypond output
5 %% 
6 %% let's not make par before endinput
7 %
8 % TeXbook ex 7.7
9 \def\ifundefined#1{\expandafter\ifx\csname#1\endcsname\relax}
10 %
11 % skip if included already
12 \def\SkipLilydefs{\endinput}
13 \ifundefined{EndLilyPondOutput}
14         \def\EndLilyPondOutput{\csname bye\endcsname}
15         \def\SkipLilydefs{}
16 \fi
17 \SkipLilydefs
18 %
19 \ifundefined{mudelacopyright}
20         \def\mudelacopyright{\copyright\ \number\year}
21 \fi
22 \ifundefined{LilyIdString}
23         \def\LilyIdString{Lily was here}
24 \fi
25
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27 % macros to shorten other definitions
28 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
29 \def\musicdef#1#2{\def#1{\musicchar{#2}}}
30 \def\musicchar#1{\musicfnt\char#1}
31 \def\rationalmultiply#1*#2/#3{\multiply #1 by #2 \divide #1 by #3}
32
33
34 \def\maccentraise#1#2{\dimen0=\noteheight
35         \rationalmultiply\dimen0*#2%
36         \raise\dimen0\hbox{#1}}
37 \def\maccentdef#1#2#3{\def#1{\maccentraise{\musicchar{#2}}{#3}}}
38 \def\vertcenter#1{\vbox to 0pt{\vss #1\vss}}
39
40 \def\musicmathdef#1#2{\def#1{\musicmathchar{#2}}}
41 \def\musicmathchar#1{\musicmathfont\char#1}
42
43 \def\topalign#1{\vbox to 0pt{#1\vss}}
44 \def\botalign#1{\vbox to 0pt{\vss #1}}
45
46 \def\centeralign#1{\hbox to 0pt{\hss#1\hss}}
47 \def\leftalign#1{\hbox to 0pt{#1\hss}}
48 \def\rightalign#1{\hbox to 0pt{\hss#1}}
49
50
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52 %% set up dimensions
53 \parindent=0pt
54 \newdimen\smallspace
55 \newdimen\interlinedist
56 \newdimen\stemthickness
57 \newcount\n
58 \newdimen\staffheight
59 \newdimen\notewidth
60 \newdimen\noteheight
61 \newdimen\staffrulethickness
62 \newdimen\interstaffrule
63 \newdimen\dist
64
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 % set fonts and primary dimensions
67 % ugh
68 \def\musixtwentydefs{
69         \twentyfonts
70         \musixcalc
71 }
72
73 \def\cmrtwenty{
74         \font\meterfont=cmbx15
75         \font\italicfont=cmti10
76         \font\musicmathfont=cmsy10
77         \font\normaltextfont=cmr10 %\textfont is a primitive
78         \font\smalltextfont=cmr8
79         \font\boldfont=cmbx10
80         \font\textmusic=cmmi12
81 }
82 \def\cmrsixteen{
83         \font\smalltextfont=cmr6
84         \font\normaltextfont=cmr8 %\textfont is a primitive
85         \font\meterfont=cmbx12
86         \font\italicfont=cmti8
87         \font\textmusic=cmmi10
88         \font\boldfont=cmbx8
89 }
90 \def\cmreleven{
91         \font\smalltextfont=cmr5
92         \font\normaltextfont=cmr6
93         \font\meterfont=cmbx8
94         \font\italicfont=cmti6
95         \font\textmusic=cmmi8
96         \font\boldfont=cmbx6
97 }
98
99 \def\cmrthirteen{
100         \font\smalltextfont=cmr6
101         \font\normaltextfont=cmr7
102         \font\meterfont=cmbx9
103         \font\italicfont=cmti7
104         \font\textmusic=cmmi9
105         \font\boldfont=cmbx7
106 }
107 \def\musixsixteendefs{
108         \sixteenfonts
109         \musixcalc
110 }
111 \def\musixtwentysixdefs{
112         \twentysixfonts
113         \musixcalc
114 }
115 \def\musixthirteendefs{
116         \thirteenfonts
117         \musixcalc
118 }
119 \def\musixelevendefs{
120         \elevendefs
121         \musixcalc
122 }
123
124 \def\textsharp{\raise.4ex\hbox{\textmusic\char"5D}}
125 \def\textnatural{\raise.4ex\hbox{\textmusic\char"5C}}
126 \def\textflat{\raise.2ex\hbox{\textmusic\char"5B}}
127
128
129
130
131 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
132 % do derivative calcs
133
134 % this has to be synced with the font definition
135 \def\musixcalc{
136         \staffheight=\mudelapaperbarsize pt
137         \interlinedist=\staffheight
138         \divide\interlinedist by 4
139         \notewidth=\mudelapapernotewidth pt
140
141         \smallspace=.3\interlinedist
142         \interstaffrule=\staffheight
143         \divide\interstaffrule by 4
144         \staffrulethickness=\mudelapaperrulethickness pt
145         \stemthickness=\staffrulethickness
146 }
147
148 % stacked numbers; may be overruled in fetdefs
149 \def\generalmeter#1#2{\vbox to 0pt{\vss\hbox{\meterfont
150          #1}\nointerlineskip
151          \hbox{\meterfont #2}\vss}}
152
153 % stacked horizontal lines 
154
155 \input dyndefs
156 \input fetdefs
157
158 %\input taupindefs
159 %\input eglerdefs
160
161
162 \def\emptybar{}
163
164 \def\defaultthinbar{\thinbar{\staffheight}}
165 \def\defaultthickbar{\thickbar{\staffheight}}
166 %? what-s wrong with rightalign?
167 \def\repeatstopbar{\hss\rightalign{\repeatcolon\hskip2\smallspace\defaultthinbar\hskip\smallspace\defaultthickbar}}
168 \def\repeatstartbar{\hbox{\defaultthickbar\kern\smallspace\defaultthinbar\kern2\smallspace\repeatcolon}}
169 \def\repeatstopstart{\hbox{\repeatcolon\kern2\smallspace\defaultthickbar\kern\smallspace\defaultthickbar\kern2\smallspace\repeatcolon}}
170
171 %compatibility
172 \def\repeatbar{\repeatstopbar}
173 \def\startrepeat{\repeatstartbar}
174 \def\repeatbarstartrepeat{\repeatstopstart}
175
176 \def\vruler#1{{%
177         \def\wid{\dimen0}%
178         \def\inc{\dimen1}%
179         \wid=#1pt
180         \inc=\wid
181         \divide\inc by #1
182         \divide\wid by 2
183         \here=-\wid
184         \loop\ifdim\here<\wid\advance\here by\inc
185                 \hbox to0pt{\vbox to0pt{\vss\hrule width2pt height 0.05pt\kern\here}\hss}%
186         \repeat%
187 }}
188 \def\hruler#1#2{\hbox{%
189         \def\wid{\dimen0}%
190         \def\here{\dimen3}%
191         \wid=#1pt
192         \divide\wid by 2
193         \here=-\wid
194         \loop\ifdim\here<\wid\advance\here by #2
195                 \hbox to0pt{\kern\here\vrule width0.05pt height 1pt depth 1pt\hss}%
196         \repeat%
197 }}
198
199
200 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
201 % parametric symbols
202 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
203
204 \def\doublebar#1{\hbox{\thinbar{#1}\hskip\smallspace\thinbar{#1}}}
205 \def\thinbar#1{\dimen0=#1%
206         \vrule height .5\dimen0 depth .5\dimen0 width 1.6\staffrulethickness} % TODO parametric.
207 \def\thickbar#1{\dimen0=#1%
208         \vrule height .5\dimen0 depth .5\dimen0 width 2\smallspace}
209 \def\maatstreep#1{\thinbar{#1}}
210 \def\startbar#1{\leftalign{\thickbar{#1}\kern\smallspace\thinbar{#1}}}
211 \def\finishbar#1{\rightalign{\thinbar{#1}\kern\smallspace\thickbar{#1}}}
212
213
214 \def\stem#1#2{\hbox{\kern -.5\stemthickness
215         \vrule width\stemthickness height#2 depth-#1}}
216
217 \def\placebox#1#2#3{%
218         \botalign{\hbox{\raise #1\leftalign{\kern #2{}#3}}}%
219 }
220
221
222 \def\rulesym#1#2{\dimen0=#1%
223         \vrule height .5\dimen0 depth .5\dimen0 width #2}
224 \def\settext#1{\normaltextfont #1}
225 \def\setitalic#1{\italicfont #1}
226 \def\setbold#1{\boldfont #1}
227 \def\setdynamic#1{\dynfont #1}
228 \def\setfinger#1{\fingerfont #1}
229
230 % the interline symbol. Redefine to remove it.
231 \def\defaultlineseparator{\vbox{\mussepline\vskip -5pt\mussepline}}
232 \def\lineseparator{\defaultlineseparator}
233 \def\beauty{%
234         \par\vskip 10pt plus 30pt minus 10pt\par
235         \hskip -5pt\lineseparator
236         \par\vskip 10pt plus 30pt minus 10pt\par
237 }
238
239
240 \def\interscoreline{\vskip 16pt}
241         
242 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
243 % big fat marks, if errors are detected.
244 \def\columnerrormark{\placebox{-5pt}{0pt}{\bf C!}}
245 \def\scorelineerrormark{\placebox{0pt}{-10pt}{\bf L!}}
246 \def\errormark{{\bf E!}}
247 \def\unknown{{\bf u}}
248
249 \def\postheader{}
250 \ifundefined{documentclass}
251         \footline={\ifnum\pageno=1
252         {\smalltextfont\mudelacopyright\hfil \LilyIdString
253         }\else{\hfil\the\pageno\hfil}\fi
254 }\else
255         %% FIXME
256         \def\ps@plain{
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         \def\ps@empty{
264                 \renewcommand{\@oddhead}{}%
265                 \renewcommand{\@evenfoot}{}%
266                 \renewcommand{\@evenhead}{}%
267                 \renewcommand{\@oddfoot}{\ifnum\thepage=1
268         {\hfil \LilyIdString
269         }\else{foo\hfil\the\pageno\hfil}\fi}}
270 \fi
271
272
273 % debugging stuff:
274 % \vbox to 0pt{\vskip .5cm \hruler{48}{3pt}\vss}