]> git.donarmstrong.com Git - lilypond.git/blob - tex/lilyponddefs.tex
release: 0.1.16
[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 \newcount\n
55 \newdimen\balkheight
56 \newdimen\notewidth
57 \newdimen\noteheight
58 \newdimen\staffrulethickness
59 \newdimen\interstaffrule
60
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 % set fonts and primary dimensions
63 \def\musixtwentydefs{
64         \balkheight=20pt
65         \notewidth=6.7pt
66         \noteheight=5pt
67         \staffrulethickness=0.4pt
68         \musixtwentyfonts
69         \font\textmusic=cmmi12
70         \musixcalc
71 }
72
73 \def\musixsixteendefs{
74         \balkheight=16pt
75         \staffrulethickness=0.4pt
76         \notewidth=5.45pt
77         \noteheight=4pt
78         \musixsixteenfonts
79         \font\textmusic=cmmi10
80         \musixcalc
81 }
82
83 \def\textsharp{\raise.4ex\hbox{\textmusic\char"5D}}
84 \def\textnatural{\raise.4ex\hbox{\textmusic\char"5C}}
85 \def\textflat{\raise.2ex\hbox{\mus\char"5B}}
86
87
88
89
90 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
91 % do derivative calcs
92
93 \def\musixcalc{
94         \interlinedist=\fontdimen5\musicfnt
95         \smallspace=.3\interlinedist
96         \interstaffrule=\balkheight
97         \divide\interstaffrule by 4
98 }
99
100
101 \input dyndefs
102
103 \input taupindefs
104
105 \musicmathdef\cup{91} % \cup
106 \musicmathdef\wedge{94} % \wedge
107 \musicmathdef\striepke{0} % heu?
108
109 %% custom characters --- this should go: add to (meta!) font
110 % \def\myheel{\kern-.5ex\vbox{\cup}\kern-.5ex}
111 % \def\mytoe{\kern-.5ex\vbox{\wedge}\kern-.5ex}
112 \def\myheel{\vbox{\cup}}
113 \def\mytoe{\vbox{\wedge}}
114 % \def\mystriepke{\kern-1.1ex\vbox{\hbox{\kern-.05em\striepke}}\kern-1.1ex}
115 \def\mystriepke{\kern-1.8ex\vbox{\hbox{\kern-.05em\striepke}}\kern-1.8ex}
116
117 \def\heel{\vbox{\myheel}}
118 \def\toe{\vbox{\mytoe}}
119 \def\backorfront{\mystriepke}
120
121 \def\bheel{\vbox{\myheel\mystriepke}}
122 \def\btoe{\vbox{\mytoe\mystriepke}}
123 \def\fheel{\vbox{\mystriepke\myheel}}
124 \def\ftoe{\vbox{\mystriepke\mytoe}}
125 \def\heeltoe{\vbox{\myheel\mytoe}}
126 \def\toeheel{\vbox{\mytoe\myheel}}
127 %%
128
129 \def\emptybar{}
130
131 \def\defaultthinbar{\thinbar{\balkheight}}
132 \def\defaultthickbar{\thickbar{\balkheight}}
133 %? what-s wrong with rightalign?
134 \def\repeatstopbar{\hss\rightalign{\repeatcolon\hskip2\smallspace\defaultthinbar\hskip\smallspace\defaultthickbar}}
135 \def\repeatstartbar{\hbox{\defaultthickbar\kern\smallspace\defaultthinbar\kern2\smallspace\repeatcolon}}
136 \def\repeatstopstart{\hbox{\repeatcolon\kern2\smallspace\defaultthinbar\kern\smallspace\defaultthickbar\kern\smallspace\defaultthickbar\kern\smallspace\defaultthinbar\kern2\smallspace\repeatcolon}}
137
138 %compatibility
139 \def\repeatbar{\repeatstopbar}
140 \def\startrepeat{\repeatstartbar}
141 \def\repeatbarstartrepeat{\repeatstopstart}
142
143
144
145 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
146 % parametric symbols
147 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
148
149 \def\doublebar#1{\hbox{\thinbar{#1}\hskip\smallspace\thinbar{#1}}}
150 \def\thinbar#1{\vrule height #1 width 1.6\staffrulethickness} % TODO parametric.
151 \def\thickbar#1{\vrule height #1 width 2\smallspace}
152 \def\maatstreep#1{\thinbar{#1}}
153 \def\startbar#1{\leftalign{\thickbar{#1}\kern\smallspace\thinbar{#1}}}
154 \def\finishbar#1{\rightalign{\thinbar{#1}\kern\smallspace\thickbar{#1}}}
155
156 \def\pianobrace#1{{\musicdraw\char#1}}
157 \def\slurcharh#1{{\slurhfont\char#1}}
158 \def\slurcharu#1{{\slurufont\char#1}}
159 \def\slurchard#1{{\slurdfont\char#1}}
160 \def\hslurcharh#1{{\hslurhfont\char#1}}
161 \def\hslurcharu#1{{\hslurufont\char#1}}
162 \def\hslurchard#1{{\hslurdfont\char#1}}
163 % stacked numbers
164 \def\generalmeter#1#2{\botalign{\vbox to0.5\balkheight{\vss \meterfont#1}%
165         \nointerlineskip
166         \vbox to 0.5\balkheight{\vss\meterfont #2}}}
167
168 % stacked horizontal lines 
169 \def\lines#1#2#3{%
170  \vbox{\kern-\interstaffrule
171         \n=0\nointerlineskip%
172         \loop\ifnum\n<#1\advance\n by1%
173                 \kern\interstaffrule
174                 \nointerlineskip
175                 \vbox to 0pt{\hrule height #3 width#2%
176                         \vss}\nointerlineskip
177                 \repeat
178         }}
179
180 %%
181 % Ugh. Need to redo this. Wish we had PS.
182 %
183 \def\toplines#1{ % why space needed here?
184         \topalign{\hbox{\kern-\notewidth\lines{#1}{1.6\notewidth}{1.6\staffrulethickness}}}}
185
186 \def\botlines#1{ % idem ditto
187         \botalign{\hbox{\kern-\notewidth\lines{#1}{1.6\notewidth}{1.6\staffrulethickness}}}}
188
189 %
190 % a staffsymbol with #1 lines, width #2
191 % bottom at baseline
192 \def\linestafsym#1#2{\leftalign{\botalign{\lines{#1}{#2}{\staffrulethickness}}}}
193
194 \def\stem#1#2{\vrule 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\beamslope#1#2{{\count0=#2\advance\count0 by#1\musicfnt\char\count0}}
202 \def\brace#1{\count0=148\advance\count0 by #1\musicdraw\char\count0}
203 \def\crescendosym#1{\count0=84\advance\count0 by #1\musicdraw\char\count0}
204 \def\decrescendosym#1{\count0=116\advance\count0 by #1\musicdraw\char\count0}
205 \def\rulesym#1#2{\vrule height #1 width #2}
206 \def\settext#1{\normaltextfont #1}
207 \def\setitalic#1{\italicfont #1}
208 \def\setdynamic#1{\dynfont #1}
209
210 % the interline symbol. Redefine to remove it.
211 \def\defaultlineseparator{\vbox{\mussepline\vskip -5pt\mussepline}}
212 \def\lineseparator{\defaultlineseparator}
213 \def\beauty{%
214         \par\vskip 10pt plus 30pt minus 10pt\par
215         \hskip -5pt\lineseparator
216         \par\vskip 10pt plus 30pt minus 10pt\par
217 }
218
219
220 \def\interscoreline{\vskip 16pt}
221         
222 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
223 % big fat marks, if errors are detected.
224 \def\columnerrormark{\placebox{-5pt}{0pt}{\bf C!}}
225 \def\scorelineerrormark{\placebox{0pt}{-10pt}{\bf L!}}
226 \def\errormark{{\bf E!}}
227 \def\unknown{{\bf u}}
228
229 \def\postheader{}
230 \ifundefined{documentclass}
231         \footline={\ifnum\pageno=1
232         {\smalltextfont\mudelacopyright\hfil \LilyIdString
233         }\else{\hfil\the\pageno\hfil}\fi
234 }\else
235         %% FIXME
236         \def\ps@plain{
237                 \renewcommand{\@oddhead}{}%
238                 \renewcommand{\@evenfoot}{}%
239                 \renewcommand{\@evenhead}{}%
240                 \renewcommand{\@oddfoot}{\ifnum\thepage=1
241         {\hfil \LilyIdString
242         }\else{foo\hfil\the\pageno\hfil}\fi}}
243         \def\ps@empty{
244                 \renewcommand{\@oddhead}{}%
245                 \renewcommand{\@evenfoot}{}%
246                 \renewcommand{\@evenhead}{}%
247                 \renewcommand{\@oddfoot}{\ifnum\thepage=1
248         {\hfil \LilyIdString
249         }\else{foo\hfil\the\pageno\hfil}\fi}}
250 \fi
251
252