]> git.donarmstrong.com Git - lilypond.git/blob - tex/lilyponddefs.tex
299ff2edd8550a40fede8932c938e75cd5d4e246
[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
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
25
26 \def\maccentraise#1#2{\dimen0=\noteheight
27         \rationalmultiply\dimen0*#2%
28         \raise\dimen0\hbox{#1}}
29 \def\maccentdef#1#2#3{\def#1{\maccentraise{\mchar{#2}}{#3}}}
30 \def\vertcenter#1{\vbox to 0pt{\vss #1\vss}}
31
32 \def\mathdef#1#2{\def#1{\mathchar{#2}}}
33 \def\mathchar#1{\mathfont\char#1}
34
35 \def\topalign#1{\vbox to 0pt{#1\vss}}
36 \def\botalign#1{\vbox to 0pt{\vss #1}}
37
38 \def\centeralign#1{\hbox to 0pt{\hss#1\hss}}
39 \def\leftalign#1{\hbox to 0pt{#1\hss}}
40 \def\rightalign#1{\hbox to 0pt{\hss#1}}
41
42
43 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44 %% set up dimensions
45 \parindent=0pt
46 \newdimen\smallspace
47 \newdimen\interlinedist
48 \newcount\n
49 \newdimen\balkheight
50 \newdimen\notewidth
51 \newdimen\noteheight
52 \newdimen\staffrulethickness
53 \newdimen\interstaffrule
54
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 % set fonts and primary dimensions
57 \def\musixtwentydefs{
58         \balkheight=20pt
59         \notewidth=6pt
60         \noteheight=5pt
61         \staffrulethickness=0.4pt
62         \musixtwentyfonts
63         \musixcalc
64 }
65
66 \def\musixsixteendefs{
67         \balkheight=16pt
68         \staffrulethickness=0.4pt
69         \notewidth=5pt
70         \noteheight=4pt
71         \musixsixteenfonts
72         \musixcalc
73 }
74
75 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76 % do derivative calcs
77
78 \def\musixcalc{
79         \interlinedist=\fontdimen5\musicfnt
80         \smallspace=.3\interlinedist
81         \interstaffrule=\balkheight
82         \divide\interstaffrule by 4
83 }
84
85 % dynamics take extra kerning
86 \def\dyn{\dynfont}
87 \def\kdynf{\dynfont f\kern-.1ex}
88 \def\kdynm{\dynfont m\kern-.15ex}
89 \def\kdynp{\dynfont p\kern-.15ex}
90
91
92 \def\dynp{\dynfont p}
93 \def\dynpp{\dynp\kdynp}
94 \def\dynppp{\dynpp\kdynp}
95 \def\dynmp{\dynfont m\kdynp}
96 \def\dynmf{\dynfont m\kdynf}
97 \def\dynf{\dynfont f}
98 \def\dynff{\dynf\kdynf}
99 \def\dynfff{\dynff\kdynf}
100
101
102 \input taupindefs
103
104 \mathdef\cup{91} % \cup
105 \mathdef\wedge{94} % \wedge
106 \mathdef\striepke{0} % heu?
107
108 %% custom characters --- this should go: add to (meta!) font
109 % \def\myheel{\kern-.5ex\vbox{\cup}\kern-.5ex}
110 % \def\mytoe{\kern-.5ex\vbox{\wedge}\kern-.5ex}
111 \def\myheel{\vbox{\cup}}
112 \def\mytoe{\vbox{\wedge}}
113 % \def\mystriepke{\kern-1.1ex\vbox{\hbox{\kern-.05em\striepke}}\kern-1.1ex}
114 \def\mystriepke{\kern-1.8ex\vbox{\hbox{\kern-.05em\striepke}}\kern-1.8ex}
115
116 \def\heel{\vbox{\myheel}}
117 \def\toe{\vbox{\mytoe}}
118 \def\backorfront{\mystriepke}
119
120 \def\bheel{\vbox{\myheel\mystriepke}}
121 \def\btoe{\vbox{\mytoe\mystriepke}}
122 \def\fheel{\vbox{\mystriepke\myheel}}
123 \def\ftoe{\vbox{\mystriepke\mytoe}}
124 \def\heeltoe{\vbox{\myheel\mytoe}}
125 \def\toeheel{\vbox{\mytoe\myheel}}
126 %%
127
128 \def\emptybar{}
129
130 \def\thinbar{\vrule height\balkheight width 1.6\staffrulethickness} % TODO parametric.
131 \def\thickbar{\vrule height\balkheight width 2\smallspace}
132 \def\maatstreep{\thinbar}
133
134 %? what-s wrong with rightalign?
135 \def\finishbar{\rightalign{\thinbar\kern\smallspace\thickbar}}
136
137 \def\repeatstopbar{\hss\rightalign{\repeatcolon\hskip2\smallspace\thinbar\hskip\smallspace\thickbar}}
138 \def\repeatstartbar{\hbox{\thickbar\kern\smallspace\thinbar\kern2\smallspace\repeatcolon}}
139 \def\repeatstopstart{\hbox{\repeatcolon\kern2\smallspace\thinbar\kern\smallspace\thickbar\kern\smallspace\thickbar\kern\smallspace\thinbar\kern2\smallspace\repeatcolon}}
140 \def\doublebar{\hbox{\thinbar\hskip\smallspace\thinbar}}
141
142 %compatibility
143 \def\repeatbar{\repeatstopbar}
144 \def\startrepeat{\repeatstartbar}
145 \def\repeatbarstartrepeat{\repeatstopstart}
146
147 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
148 % parametric symbols
149 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
150
151 \def\slurcharh#1{{\slurhfont\char#1}}
152 \def\slurcharu#1{{\slurufont\char#1}}
153 \def\slurchard#1{{\slurdfont\char#1}}
154 \def\hslurcharh#1{{\hslurhfont\char#1}}
155 \def\hslurcharu#1{{\hslurufont\char#1}}
156 \def\hslurchard#1{{\hslurdfont\char#1}}
157 % stacked numbers
158 \def\generalmeter#1#2{\botalign{\vbox to0.5\balkheight{\vss \meterfont#1}%
159         \nointerlineskip
160         \vbox to 0.5\balkheight{\vss\meterfont #2}}}
161
162 % stacked horizontal lines 
163 \def\lines#1#2#3{%
164  \vbox{\kern-\interstaffrule
165         \n=0\nointerlineskip%
166         \loop\ifnum\n<#1\advance\n by1%
167                 \kern\interstaffrule
168                 \nointerlineskip
169                 \vbox to 0pt{\hrule height #3 width#2%
170                         \vss}\nointerlineskip
171                 \repeat
172         }}
173
174 %%
175 % Ugh. Need to redo this. Wish we had PS.
176 %
177 \def\toplines#1{ % why space needed here?
178         \topalign{\hbox{\kern-\notewidth\lines{#1}{1.6\notewidth}{1.6\staffrulethickness}}}}
179
180 \def\botlines#1{ % idem ditto
181         \botalign{\hbox{\kern-\notewidth\lines{#1}{1.6\notewidth}{1.6\staffrulethickness}}}}
182
183 %
184 % a staffsymbol with #1 lines, width #2
185 % bottom at baseline
186 \def\linestafsym#1#2{\leftalign{\botalign{\lines{#1}{#2}{\staffrulethickness}}}}
187
188 \def\stem#1#2{\vrule height#2 depth-#1}
189
190 \def\placebox#1#2#3{%
191         \botalign{\hbox{\raise #1\leftalign{\kern #2{}#3}}}%
192 }
193
194
195 \def\beamslope#1#2{{\count0=#2\advance\count0 by#1\musicfnt\char\count0}}
196 \def\rulesym#1#2{\vrule height #1 width #2}
197 \def\crescendosym#1{\count0=84\advance\count0 by #1\musicdraw\char\count0}
198 \def\decrescendosym#1{\count0=116\advance\count0 by #1\musicdraw\char\count0}
199 \def\settext#1{\textfont #1}
200 \def\setitalic#1{\italicfont #1}
201 \def\setdynamic#1{\dynfont #1}
202
203 % the interline symbol. Redefine to remove it.
204 \def\defaultlineseparator{\vbox{\mussepline\vskip -5pt\mussepline}}
205 \def\lineseparator{\defaultlineseparator}
206 \def\beauty{%
207         \par\vskip 10pt plus 30pt minus 10pt\par
208         \hskip -5pt\lineseparator
209         \par\vskip 10pt plus 30pt minus 10pt\par
210 }
211
212
213 % redefine if not happy with interline spacing
214 %
215 \def\interstaffline{%
216         \vskip 10pt
217 }
218 \def\interscoreline{\beauty}
219         
220 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
221 % big fat marks, if errors are detected.
222 \def\columnerrormark{\placebox{-5pt}{0pt}{\bf C!}}
223 \def\scorelineerrormark{\placebox{0pt}{-10pt}{\bf L!}}
224 \def\unknown{{\bf u}}