]> git.donarmstrong.com Git - lilypond.git/blob - tex/lilyponddefs.tex
release: 0.0.66
[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 % should use \endinput
17
18 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19 % macros to shorten other definitions
20 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21 \def\mdef#1#2{\def#1{\mchar{#2}}}
22 \def\mchar#1{\musicfnt\char#1}
23 \def\rationalmultiply#1*#2/#3{\multiply #1 by #2 \divide #1 by #3}
24 \def\maccentraise#1#2{\dimen0=\noteheight
25         \rationalmultiply\dimen0*#2%
26         \raise\dimen0\hbox{#1}}
27 \def\maccentdef#1#2#3{\def#1{\maccentraise{\mchar{#2}}{#3}}}
28 \def\vertcenter#1{\vbox to 0pt{\vss #1\vss}}
29
30 \def\mathdef#1#2{\def#1{\mathchar{#2}}}
31 \def\mathchar#1{\mathfont\char#1}
32
33 \def\topalign#1{\vbox to 0pt{#1\vss}}
34 \def\botalign#1{\vbox to 0pt{\vss #1}}
35
36 \def\centeralign#1{\hbox to 0pt{\hss#1\hss}}
37 \def\leftalign#1{\hbox to 0pt{#1\hss}}
38 \def\rightalign#1{\hbox to 0pt{\hss#1}}
39
40
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 %% set up dimensions
43 \parindent=0pt
44 \newdimen\smallspace
45 \newdimen\interlinedist
46 \newcount\n
47 \newdimen\balkhoog
48 \newdimen\notewidth
49 \newdimen\noteheight
50 \newdimen\notewidthhalf
51 \newdimen\notewidthdouble
52 \newdimen\notewidthquart
53 \newdimen\staffrulethickness
54 \newdimen\interstaffrule
55 \newdimen\balkhalf
56
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58 % set fonts and primary dimensions
59 \def\musixtwentydefs{
60         \font\textfont=cmr10
61         \font\meterfont=cmbx12
62         \font\slurufont=xslu20
63         \font\slurdfont=xsld20
64         \font\slurhfont=xslz20
65         \font\hslurufont=xslhu20
66         \font\hslurdfont=xslhd20
67         \font\hslurhfont=xslhz20
68         \font\musicfnt=musix20
69         \font\musicdraw=musixsps
70         \font\italicfont=cmti10
71         \font\dynfont=cmbxti10 scaled \magstep1
72         \font\mathfont=cmsy10
73         \balkhoog=20pt
74         \notewidth=6pt
75         \noteheight=5pt
76         \staffrulethickness=0.4pt
77         \musixcalc
78 }
79
80
81 \def\musixsixteendefs{
82         \font\textfont=cmr8
83         \font\meterfont=cmbx12
84         \font\italicfont=cmti8
85         \font\slurufont=xslu16
86         \font\slurdfont=xsld16
87         \font\slurhfont=xslz20 % sigh
88         \font\hslurufont=xslhu16
89         \font\hslurdfont=xslhd16
90         \font\hslurhfont=xslhz20
91         \font\musicfnt=musix16
92         \font\dynfont=cmbxti12
93         \font\musicdraw=musixsps
94         \font\mathfont=cmsy8
95         \balkhoog=16pt
96         \staffrulethickness=0.4pt
97         \notewidth=5pt
98         \noteheight=4pt
99         \musixcalc
100 }
101
102 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
103 % do derivative calcs
104
105 \def\musixcalc{
106         \interlinedist=\fontdimen5\musicfnt
107         \smallspace=.3\interlinedist
108         \interstaffrule=\balkhoog
109         \divide\interstaffrule by 4
110         \notewidthhalf=\notewidth
111         \notewidthquart=\notewidth
112         \notewidthdouble=\notewidth
113         \rationalmultiply \notewidthhalf*1/2
114         \rationalmultiply\notewidthquart*1/4
115         \multiply \notewidthdouble by 2
116         \balkhalf=\balkhoog
117          \rationalmultiply\balkhalf*1/2 
118 }
119
120 % dynamics take extra kerning
121 \def\dyn{\dynfont}
122 \def\kdynf{\dynfont f\kern-.1ex}
123 \def\kdynm{\dynfont m\kern-.15ex}
124 \def\kdynp{\dynfont p\kern-.15ex}
125
126
127 \def\dynp{\dynfont p}
128 \def\dynpp{\dynp\kdynp}
129 \def\dynppp{\dynpp\kdynp}
130 \def\dynmp{\dynfont m\kdynp}
131 \def\dynmf{\dynfont m\kdynf}
132 \def\dynf{\dynfont f}
133 \def\dynff{\dynf\kdynf}
134 \def\dynfff{\dynff\kdynf}
135
136
137 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
138 % provide interface to musixtex fonts 
139 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
140 \mdef\quartball{'007}
141 \mdef\halfball{'010}
142 \mdef\wholeball{'011}
143 \mdef\halfrest{'074}
144 \mdef\wholerest{'075}
145 \mdef\quartrest{62}
146 \mdef\eighthrest{63}
147 \mdef\sixteenthrest{64}
148 \mdef\thirtysecondrest{65}
149 \mdef\sixtyfourthrest{66}
150 \mdef\hundredtwentyeighthrest{67}
151 \mdef\sharp{52}
152 \mdef\flat{50}
153 \mdef\natural{54}
154 \mdef\sharpsharp{53}
155 \mdef\flatflat{51}
156
157 \mdef\singledot{'00}
158 \mdef\doubledot{'01}
159 \mdef\tripledot{'02}
160 \mdef\mussepline{155}
161
162 \mdef\violinclef{71}
163 \mdef\bassclef{73}
164 \mdef\altoclef{75}
165 \mdef\cviolinclef{72}
166 \mdef\cbassclef{74}
167 \mdef\caltoclef{76}
168
169 \mdef\deighthflag{45}
170 \mdef\dsixteenthflag{46}
171 \mdef\dthirtysecondflag{47}
172 \mdef\dsixtyfourthflag{48}
173 \mdef\dhundredtwentyeighthflag{49}
174
175 % pointing up
176 \mdef\ueighthflag{40}
177 \mdef\usixteenthflag{41}
178 \mdef\uthirtysecondflag{42}
179 \mdef\usixtyfourthflag{43}
180 \mdef\uhundredtwentyeighthflag{44}
181
182 \maccentdef\repeatcolon{55}{2/1}
183 \def\eighthflag{\topalign{\ueighthflag}}
184 \def\sixteenthflag{\topalign{\usixteenthflag}}
185 \def\thirtysecondflag{\topalign{\uthirtysecondflag}}
186 \def\sixtyfourthflag{\topalign{\usixtyfourthflag}}
187 \def\hundredtwentyeighthflag{\topalign{\uhundredtwentyeighthflag}}
188
189 \def\cquartrest{\vertcenter\quartrest}
190 \def\ceighthrest{\vertcenter\eighthrest}
191 \def\csixteenthrest{\vertcenter\sixteenthrest}
192 \def\cthirtysecondrest{\vertcenter\thirtysecondrest}
193 \def\csixtyfourthrest{\vertcenter\sixtyfourthrest}
194 \def\chundredtwentyeighthrest{\vertcenter\hundredtwentyeighthrest}
195
196 \def\lsingledot{\kern-\notewidth\singledot}
197 \def\ldoubledot{\kern-\notewidth\doubledot}
198 \def\ltripledot{\kern-\notewidth\tripledot}
199
200 \maccentdef\sforzato{30}{-3/2}
201 \maccentdef\marcato{20}{-1/1}
202 \maccentdef\imarcato{21}{1/1}
203 \maccentdef\staccato{24}{-1/3}
204 \maccentdef\istaccato{25}{1/3}
205 \maccentdef\staccatissimo{28}{-5/5}
206 \maccentdef\istaccatissimo{29}{2/5}
207 \maccentdef\portato{18}{-6/5}
208 \maccentdef\iportato{19}{3/5}
209 \maccentdef\tenuto{26}{-1/1}
210 \maccentdef\itenuto{27}{1/1}
211 \maccentdef\fermata{80}{-1/1}
212 \maccentdef\ifermata{81}{1/1}
213
214 \mdef\spicato{28}
215 \mdef\ispicato{29}
216 \mdef\upbow{23}
217 \mdef\downbow{22}
218
219 \mathdef\cup{91} % \cup
220 \mathdef\wedge{94} % \wedge
221 \mathdef\striepke{0} % heu?
222
223 %% custom characters --- this should go: add to (meta!) font
224 \def\myheel{\kern-.5ex\vbox{\cup}\kern-.5ex}
225 \def\mytoe{\kern-.5ex\vbox{\wedge}\kern-.5ex}
226 \def\mystriepke{\kern-1.1ex\vbox{\hbox{\kern-.05em\striepke}}\kern-1.1ex}
227
228 \def\heel{\vbox{\myheel}}
229 \def\toe{\vbox{\mytoe}}
230 \def\backorfront{\mystriepke}
231
232 \def\bheel{\vbox{\myheel\mystriepke}}
233 \def\btoe{\vbox{\mytoe\mystriepke}}
234 \def\fheel{\vbox{\mystriepke\myheel}}
235 \def\ftoe{\vbox{\mystriepke\mytoe}}
236 \def\heeltoe{\vbox{\myheel\mytoe}}
237 \def\toeheel{\vbox{\mytoe\myheel}}
238 %%
239
240 \def\emptybar{}
241
242 \def\thinbar{\vrule height\balkhoog width0.8pt} % TODO parametric.
243 \def\thickbar{\vrule height\balkhoog width 2\smallspace}
244 \def\maatstreep{\thinbar}
245
246 %? what-s wrong with rightalign?
247 \def\finishbar{\rightalign{\thinbar\kern\smallspace\thickbar}}
248
249 \def\repeatstopbar{\hss\rightalign{\repeatcolon\hskip2\smallspace\thinbar\hskip\smallspace\thickbar}}
250 \def\repeatstartbar{\hbox{\thickbar\kern\smallspace\thinbar\kern2\smallspace\repeatcolon}}
251 \def\repeatstopstart{\hbox{\repeatcolon\kern2\smallspace\thinbar\kern\smallspace\thickbar\kern\smallspace\thickbar\kern\smallspace\thinbar\kern2\smallspace\repeatcolon}}
252 \def\doublebar{\hbox{\thinbar\hskip\smallspace\thinbar}}
253
254 %compatibility
255 \def\repeatbar{\repeatstopbar}
256 \def\startrepeat{\repeatstartbar}
257 \def\repeatbarstartrepeat{\repeatstopstart}
258
259 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
260 % parametric symbols
261 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
262
263 \def\slurcharh#1{{\slurhfont\char#1}}
264 \def\slurcharu#1{{\slurufont\char#1}}
265 \def\slurchard#1{{\slurdfont\char#1}}
266 \def\hslurcharh#1{{\hslurhfont\char#1}}
267 \def\hslurcharu#1{{\hslurufont\char#1}}
268 \def\hslurchard#1{{\hslurdfont\char#1}}
269 % stacked numbers
270 \def\generalmeter#1#2{\botalign{\vbox to\balkhalf{\vss \meterfont#1}%
271         \nointerlineskip
272         \vbox to \balkhalf{\vss\meterfont #2}}}
273
274 % stacked horizontal lines 
275 \def\lines#1#2{%
276  \vbox{\kern-\interstaffrule
277         \n=0\nointerlineskip%
278         \loop\ifnum\n<#1\advance\n by1%
279                 \kern\interstaffrule
280                 \nointerlineskip
281                 \vbox to 0pt{\hrule height \staffrulethickness width#2%
282                         \vss}\nointerlineskip
283                 \repeat
284         }}
285
286 %%
287 % Ugh. Need to redo this. Wish we had PS.
288 %
289 \def\toplines#1{ % why space needed here?
290         \topalign{\hbox{\kern-\notewidth\lines{#1}{\notewidthdouble}}}}
291
292 \def\botlines#1{ % idem ditto
293         \botalign{\hbox{\kern-\notewidth\lines{#1}{\notewidthdouble}}}}
294
295 %
296 % a staffsymbol with #1 lines, width #2
297 % bottom at baseline
298 \def\linestafsym#1#2{\leftalign{\botalign{\lines{#1}{#2}}}}
299
300 \def\stem#1#2{\vrule height#2 depth-#1}
301
302 \def\placebox#1#2#3{%
303         \botalign{\hbox{\raise #1\leftalign{\kern #2{}#3}}}%
304 }
305
306
307 \def\beamslope#1#2{{\count0=#2\advance\count0 by#1\musicfnt\char\count0}}
308 \def\rulesym#1#2{\vrule height #1 width #2}
309 \def\crescendosym#1{\count0=84\advance\count0 by #1\musicdraw\char\count0}
310 \def\decrescendosym#1{\count0=116\advance\count0 by #1\musicdraw\char\count0}
311 \def\settext#1{\textfont #1}
312 \def\setitalic#1{\italicfont #1}
313 \def\setdynamic#1{\dynfont #1}
314
315 % the interline symbol. Redefine to remove it.
316 \def\defaultlineseparator{\vbox{\mussepline\vskip -5pt\mussepline}}
317 \def\lineseparator{\defaultlineseparator}
318 \def\beauty{%
319         \par\vskip 10pt plus 30pt minus 10pt\par
320         \hskip -5pt\lineseparator
321         \par\vskip 10pt plus 30pt minus 10pt\par
322 }
323
324
325 % redefine if not happy with interline spacing
326 %
327 \def\interstaffline{%
328         \vskip 10pt
329 }
330 \def\interscoreline{\beauty}
331         
332 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
333 % big fat marks, if errors are detected.
334 \def\columnerrormark{\placebox{-5pt}{0pt}{\bf C!}}
335 \def\scorelineerrormark{\placebox{0pt}{-10pt}{\bf L!}}