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