]> git.donarmstrong.com Git - lilypond.git/blob - tex/lilyponddefs.tex
02116e998cb90bc0a0d2772a4abcbe7ec328a334
[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\stemthickness
55 \newcount\n
56 \newdimen\staffheight
57 \newdimen\notewidth
58 \newdimen\noteheight
59 \newdimen\staffrulethickness
60 \newdimen\interstaffrule
61 \newdimen\dist
62
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64 % set fonts and primary dimensions
65 % ugh
66 \def\musixtwentydefs{
67         \staffheight=20pt
68         \notewidth=7.15pt
69         \noteheight=5pt
70         \twentyfonts
71         \musixcalc
72 }
73
74 \def\cmrtwenty{
75         \font\meterfont=cmbx15
76         \font\italicfont=cmti10
77         \font\musicmathfont=cmsy10
78         \font\normaltextfont=cmr10 %\textfont is a primitive
79         \font\smalltextfont=cmr8
80 }
81 \def\cmrsixteen{
82         \font\smalltextfont=cmr6
83         \font\normaltextfont=cmr8 %\textfont is a primitive
84         \font\meterfont=cmbx12
85         \font\italicfont=cmti8
86         \font\textmusic=cmmi10
87 }
88 \def\musixsixteendefs{
89         \staffheight=16pt
90         \notewidth=5.93pt
91         \noteheight=4pt
92         \sixteenfonts
93         \musixcalc
94 }
95
96 \def\textsharp{\raise.4ex\hbox{\textmusic\char"5D}}
97 \def\textnatural{\raise.4ex\hbox{\textmusic\char"5C}}
98 \def\textflat{\raise.2ex\hbox{\mus\char"5B}}
99
100
101
102
103 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
104 % do derivative calcs
105
106 % FIXME: should read from TFM/AFM/fetalog
107 %
108
109 % this has to be synced with the font definition
110 \def\musixcalc{
111         \smallspace=.3\interlinedist
112         \interstaffrule=\staffheight
113         \divide\interstaffrule by 4
114
115         %  [D.K.Roush & J.S.Gourlay] say this should be 0.072
116         % We know better
117         \staffrulethickness=0.1\interlinedist
118         \stemthickness=\staffrulethickness
119 }
120
121 % stacked numbers; may be overruled in fetdefs
122 \def\generalmeter#1#2{\vbox to 0pt{\vss\hbox{\meterfont
123          #1}\nointerlineskip
124          \hbox{\meterfont #2}\vss}}
125
126 % stacked horizontal lines 
127
128 \input dyndefs
129 \input fetdefs
130
131 %\input taupindefs
132 %\input eglerdefs
133
134
135 \def\emptybar{}
136
137 \def\defaultthinbar{\thinbar{\staffheight}}
138 \def\defaultthickbar{\thickbar{\staffheight}}
139 %? what-s wrong with rightalign?
140 \def\repeatstopbar{\hss\rightalign{\repeatcolon\hskip2\smallspace\defaultthinbar\hskip\smallspace\defaultthickbar}}
141 \def\repeatstartbar{\hbox{\defaultthickbar\kern\smallspace\defaultthinbar\kern2\smallspace\repeatcolon}}
142 \def\repeatstopstart{\hbox{\repeatcolon\kern2\smallspace\defaultthickbar\kern\smallspace\defaultthickbar\kern2\smallspace\repeatcolon}}
143
144 %compatibility
145 \def\repeatbar{\repeatstopbar}
146 \def\startrepeat{\repeatstartbar}
147 \def\repeatbarstartrepeat{\repeatstopstart}
148
149 \def\vruler#1{{%
150         \def\wid{\dimen0}%
151         \def\inc{\dimen1}%
152         \wid=#1pt
153         \inc=\wid
154         \divide\inc by #1
155         \divide\wid by 2
156         \here=-\wid
157         \loop\ifdim\here<\wid\advance\here by\inc
158                 \hbox to0pt{\vbox to0pt{\vss\hrule width2pt height 0.05pt\kern\here}\hss}%
159         \repeat%
160 }}
161 \def\hruler#1#2{\hbox{%
162         \def\wid{\dimen0}%
163         \def\here{\dimen3}%
164         \wid=#1pt
165         \divide\wid by 2
166         \here=-\wid
167         \loop\ifdim\here<\wid\advance\here by #2
168                 \hbox to0pt{\kern\here\vrule width0.05pt height 1pt depth 1pt\hss}%
169         \repeat%
170 }}
171
172
173 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
174 % parametric symbols
175 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
176
177 \def\doublebar#1{\hbox{\thinbar{#1}\hskip\smallspace\thinbar{#1}}}
178 \def\thinbar#1{\dimen0=#1%
179         \vrule height .5\dimen0 depth .5\dimen0 width 1.6\staffrulethickness} % TODO parametric.
180 \def\thickbar#1{\dimen0=#1%
181         \vrule height .5\dimen0 depth .5\dimen0 width 2\smallspace}
182 \def\maatstreep#1{\thinbar{#1}}
183 \def\startbar#1{\leftalign{\thickbar{#1}\kern\smallspace\thinbar{#1}}}
184 \def\finishbar#1{\rightalign{\thinbar{#1}\kern\smallspace\thickbar{#1}}}
185
186 \def\slurcharh#1{{\slurhfont\char#1}}
187 \def\slurcharu#1{{\slurufont\char#1}}
188 \def\slurchard#1{{\slurdfont\char#1}}
189 \def\hslurcharh#1{{\hslurhfont\char#1}}
190 \def\hslurcharu#1{{\hslurufont\char#1}}
191 \def\hslurchard#1{{\hslurdfont\char#1}}
192
193 \def\stem#1#2{\hbox{\kern -.5\stemthickness
194         \vrule width\stemthickness height#2 depth-#1}}
195
196 \def\placebox#1#2#3{%
197         \botalign{\hbox{\raise #1\leftalign{\kern #2{}#3}}}%
198 }
199
200
201 \def\brace#1{\count0=148\advance\count0 by #1\musicdraw\char\count0}
202 \def\crescendosym#1{\count0=84\advance\count0 by #1\musicdraw\char\count0}
203 \def\decrescendosym#1{\count0=116\advance\count0 by #1\musicdraw\char\count0}
204 \def\rulesym#1#2{\dimen0=#1%
205         \vrule height .5\dimen0 depth .5\dimen0 width #2}
206 \def\settext#1{\normaltextfont #1}
207 \def\setitalic#1{\italicfont #1}
208 \def\setdynamic#1{\dynfont #1}
209 \def\setfinger#1{\fingerfont #1}
210
211 % the interline symbol. Redefine to remove it.
212 \def\defaultlineseparator{\vbox{\mussepline\vskip -5pt\mussepline}}
213 \def\lineseparator{\defaultlineseparator}
214 \def\beauty{%
215         \par\vskip 10pt plus 30pt minus 10pt\par
216         \hskip -5pt\lineseparator
217         \par\vskip 10pt plus 30pt minus 10pt\par
218 }
219
220
221 \def\interscoreline{\vskip 16pt}
222         
223 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
224 % big fat marks, if errors are detected.
225 \def\columnerrormark{\placebox{-5pt}{0pt}{\bf C!}}
226 \def\scorelineerrormark{\placebox{0pt}{-10pt}{\bf L!}}
227 \def\errormark{{\bf E!}}
228 \def\unknown{{\bf u}}
229
230 \def\postheader{}
231 \ifundefined{documentclass}
232         \footline={\ifnum\pageno=1
233         {\smalltextfont\mudelacopyright\hfil \LilyIdString
234         }\else{\hfil\the\pageno\hfil}\fi
235 }\else
236         %% FIXME
237         \def\ps@plain{
238                 \renewcommand{\@oddhead}{}%
239                 \renewcommand{\@evenfoot}{}%
240                 \renewcommand{\@evenhead}{}%
241                 \renewcommand{\@oddfoot}{\ifnum\thepage=1
242         {\hfil \LilyIdString
243         }\else{foo\hfil\the\pageno\hfil}\fi}}
244         \def\ps@empty{
245                 \renewcommand{\@oddhead}{}%
246                 \renewcommand{\@evenfoot}{}%
247                 \renewcommand{\@evenhead}{}%
248                 \renewcommand{\@oddfoot}{\ifnum\thepage=1
249         {\hfil \LilyIdString
250         }\else{foo\hfil\the\pageno\hfil}\fi}}
251 \fi
252
253
254 % debugging stuff:
255 % \vbox to 0pt{\vskip .5cm \hruler{48}{3pt}\vss}