1 % This file is part of Violon, a violin score engine.
2 % Copyright (C) 2009 Julien Moutinho
4 % This program is free software: you can redistribute it and/or modify
5 % it under the terms of the GNU General Public License as published
6 % by the Free Software Foundation, either version 3 of the License,
7 % or any later version.
9 % This program is distributed in the hope that it will be useful,
10 % but WITHOUT ANY WARRANTY; without even the implied warranty
11 % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 % See the GNU General Public License for more details.
14 % You should have received a copy of the GNU General Public License
15 % along with this program. If not, see <http://www.gnu.org/licenses/>.
17 % Any comment or contribution is welcome
18 % at julm arobase julm dot meeee dot eu.
21 \def\fileversion{1.0}%
22 \def\filedate{2009/10/11}%
23 \NeedsTeXFormat{LaTeX2e}%
24 \ProvidesPackage{violon}[\filedate\space\fileversion\space%
25 Violin score library (Julien Moutinho)]%
31 \@setfontsize\sssmall{5pt}{5pt}}%
33 \@setfontsize\sssmall{6pt}{6pt}}%
35 \@setfontsize\ssmall\@viiipt\@ixpt}%
37 \fontfamily{pnc}\bfseries\sssmall}%
39 \fontfamily{pnc}\scshape\ssssmall}%
41 \fontfamily{pnc}\bfseries\ssssmall}%
43 \newcount\@calc@mod@cnt%
45 \@calc@mod@cnt=#1\relax%
46 \divide\@calc@mod@cnt by#2\relax%
47 \multiply\@calc@mod@cnt by#2\relax%
48 \advance#1 by-\@calc@mod@cnt%
51 \let\romannumeral@old\romannumeral%
53 \ifnum#1>\z@\romannumeral@old#1\else\number#1\fi%
58 \definecolor{colVlnBowUp}{rgb}{0.24,0.92,0.24}%
59 \definecolor{colVlnBowDn}{rgb}{1,0,0}%
60 \definecolor{colVlnBowU}{rgb}{0.24,0.92,0.24}%
61 \definecolor{colVlnBowD}{rgb}{1,0,0}%
62 \definecolor{colVlnLineHalfTone}{gray}{0.90}%
63 \definecolor{colVlnLineHalfToneBase}{gray}{0.50}%
66 \newdimen\vlnstaffhalftonelinevdim%
67 \newskip\vlnstaffhalftonelinevskip%
68 \newskip\vlnstaffvdim%
69 \newskip\vlnstaffintervskip%
70 \newskip\vlnstaffvskip%
72 \def\vlnstaffhsize{\hsize}%
73 \def\vlnstaffmaxvsize{\textheight}%
74 \vlnstaffhalftonelinevdim=0.5pt%
75 \vlnstaffhalftonelinevskip=4pt\relax%
76 \advance\vlnstaffhalftonelinevskip by-\vlnstaffhalftonelinevdim%
77 \vlnstaffvdim=0pt\relax%
78 \vlnstaffvskip=0pt\relax%
79 \vlnstaffintervskip=\vlnstaffhalftonelinevskip\relax%
80 \advance\vlnstaffintervskip by\vlnstaffhalftonelinevdim\relax%
81 \def\vlnstaffhalftoneline{%
82 {\color{colVlnLineHalfTone}\hrule depth 0pt height \vlnstaffhalftonelinevdim width \vlnstaffhsize }}%
83 \def\vlnbasehalftoneline{%
84 {\color{colVlnLineHalfToneBase}\hrule depth 0pt height \vlnstaffhalftonelinevdim width \vlnstaffhsize }}%
85 \def\vlnstafftoneskip{%
86 \advance\vlnstaffvdim by\vlnstaffhalftonelinevskip%
87 \advance\vlnstaffvdim by\vlnstaffhalftonelinevdim%
88 \nobreak\vskip\vlnstaffhalftonelinevskip%
90 \def\vlnstafffivehalftonelines{%
91 \vlnstafftoneskip\vlnstaffhalftoneline%
92 \vlnstafftoneskip\vlnstaffhalftoneline%
93 \vlnstafftoneskip\vlnstaffhalftoneline%
94 \vlnstafftoneskip\vlnstaffhalftoneline%
95 \vlnstafftoneskip\vlnbasehalftoneline%
97 \def\vlnstaffallhalftonelines{%
98 \vlnstafffivehalftonelines%
99 \vlnstafffivehalftonelines%
100 \vlnstafffivehalftonelines%
101 \vlnstafffivehalftonelines%
104 \nobreak\vskip\vlnstaffvdim%
105 \advance\vlnstaffvskip by\vlnstaffvdim\relax%
106 \count@\vlnstaffvskip\relax%
107 \advance\count@ by\vlnstaffvdim\relax%
108 \ifnum\count@>\vlnstaffmaxvsize%
109 \vlnstaffvskip=0pt\relax%
112 \advance\vlnstaffvskip by\vlnstaffintervskip\relax%
113 \nobreak\vskip\vlnstaffintervskip%
115 \vlnnotehskip=0pt\relax%
116 \vlnstaffvdim=0pt\relax%
117 \vlnbasehalftoneline%
118 \vlnstaffallhalftonelines%
119 \advance\vlnstaffvdim by\vlnstaffhalftonelinevdim%
120 \nobreak\vskip-\vlnstaffvdim%
125 \newskip\vlnnotevskip%
126 \newskip\vlnnotehskip%
127 \newdimen\vlnnotevdim%
128 \newdimen\vlnnotevdimmore%
129 \newdimen\vlnnotehdim%
130 \newdimen\vlnnotehdimbase%
131 \newcount\vlnlastfinger%
132 \newcount\vlnlastposbase%
133 \newcount\vlnlastposunit%
134 \newcount\vlnnotepos%
135 \newcount\vlnlastpos%
137 \vlnnotevskip=0pt\relax%
138 \vlnnotehskip=0pt\relax%
139 \vlnnotevdim=\vlnstaffhalftonelinevdim%
140 \vlnnotevdimmore=1pt\relax%
141 \vlnnotehdimbase=2cm\relax%
142 \advance\vlnnotevdim by\vlnnotevdimmore%
143 \advance\vlnnotevdim by\vlnnotevdimmore%
146 \def\vlnlasttimenum{}%
147 \def\vlnlasttimeden{}%
148 \def\vlnnotehdimmodetim{1}%
149 \def\vlnnotehdimmodetxt{}%
150 \parindent=0pt\relax%
152 \parfillskip=0pt\relax%
153 \def\vlnlastposfinger{%
154 \csname vlnlastposfinger\romannumeral\vlnlastfinger\endcsname%
156 \def\vlnlastfingerpos{%
157 \csname vlnlastfingerpos\romannumeral\vlnlastpos\endcsname%
159 \def\vlntimefrac#1/#2{%
162 \kern-.4ex\lower.3ex\hbox{\bfseries\tiny /}%
163 \kern-.3ex\lower.6ex\hbox{#2}%
165 \def\vlndoatnote#1#2#3#4{%
167 \vlnnotevskip\vlnstaffhalftonelinevskip%
168 \advance\vlnnotevskip by\vlnstaffhalftonelinevdim\relax%
169 \multiply\vlnnotevskip by#1\relax%
170 \advance\vlnnotevskip by-\vlnnotevdimmore\relax%
171 \nobreak\vskip\vlnnotevskip\relax%
172 \nobreak\vskip-\vlnnotevskip\relax%
173 \nobreak\vskip\vlnnotevskip\relax%
174 \vrule depth 0pt height 0pt width \vlnnotehskip\relax%
176 \advance\vlnnotevskip by \ht0\relax%
180 \nobreak\vskip-\vlnnotevskip\relax%
184 \advance\vlnnotehskip by\vlnnotehdim\relax%
186 \def\vlnnotedraw crd#1pos#2fgr#3bow#4tim#5#6{%
188 \ifthenelse{\equal{#2}{.}}%
190 {\vlnlastpos#2\relax}%
192 \ifthenelse{\equal{#5}{.}}%
194 {\def\vlnlasttimenum{#5}}%
195 \ifthenelse{\equal{#6}{.}}%
197 {\def\vlnlasttimeden{#6}}%
198 \vlnnotehdim\vlnnotehdimbase%
199 \ifthenelse{\equal{}{\vlnnotehdimmodetim}}%
201 {\multiply\vlnnotehdim by\vlnlasttimenum\relax%
202 \divide\vlnnotehdim by\vlnlasttimeden\relax%
204 % Automatic staff break
205 \count@\vlnnotehskip\relax%
206 \advance\count@ by\vlnnotehdim\relax%
207 \ifnum\count@>\vlnstaffhsize\vlnstaff\fi%
208 \ifthenelse{\equal{#5/#6}{\vlnlasttimenum/\vlnlasttimeden}}%
210 {\vlndoatnote{\vlnlastpos}%
213 \ifthenelse{\equal{}{\vlnnotehdimmodetxt}}%
217 \ifthenelse{\equal{\vlnlasttimeden}{1}}%
218 {{\vlntimefont{\vlnlasttimenum}}}%
219 {\vlntimefrac{\vlntimefont{\vlnlasttimenum}}/{\vlntimefont{\vlnlasttimeden}}}%
221 \nobreak\vskip\vlnnotevdim\relax%
222 \nobreak\vskip0.2mm\relax%
223 \nobreak\hskip\vlnnotehdim\relax%
224 \nobreak\hskip-\wd0\relax%
232 \ifthenelse{\equal{#4}{C}}%
233 {\ifthenelse{\equal{U}{\vlnlastbow}}%
234 {\def\vlnlastbow{D}}%
235 {\def\vlnlastbow{U}}}%
236 {\ifthenelse{\equal{#4}{.}}%
238 {\def\vlnlastbow{#4}}}%
239 \vlndoatnote{\vlnlastpos}%
240 {\begingroup\expandafter\color{colVlnBow\vlnlastbow}}%
243 \vrule depth 0pt height \vlnnotevdim width \vlnnotehdim\relax%
248 \ifthenelse{\equal{#3}{.}}%
250 {\vlnlastfinger#3\relax}%
251 \ifthenelse{\equal{\the\vlnlastfinger}{\vlnlastfingerpos}\AND\equal{\the\vlnlastpos}{\vlnlastposfinger}}%
254 \expandafter\edef\csname vlnlastfingerpos\romannumeral\vlnlastpos\endcsname{\the\vlnlastfinger}\relax%
255 \expandafter\edef\csname vlnlastposfinger\romannumeral\vlnlastfinger\endcsname{\the\vlnlastpos}\relax%
256 \vlndoatnote{\vlnlastpos}%
259 \setbox0=\hbox{{\vlnfingerfont{\the\vlnlastfinger}}}%
260 \nobreak\vskip-0.2mm\relax%
263 \dp0=0pt\relax% NOTE: to prevent fonts like pnc to mess up the vertical alignment
268 \ifthenelse{\equal{#1}{\vlnlastcord}}%
270 {\ifthenelse{\equal{#1}{.}}%
272 {\def\vlnlastcord{#1}%
273 \vlndoatnote{\vlnlastpos}%
276 \setbox0=\hbox{{\vlncordfont{%
278 \advance\count@ by1\relax%
280 \or 0\or I\or II\or III%
282 \nobreak\vskip\vlnnotevdim\relax%
283 \nobreak\vskip0.2mm\relax%
292 \def\vlncordposi{0}% G
293 \def\vlncordposii{7}% D
294 \def\vlncordposiii{14}% A
295 \def\vlncordposiv{21}% E
298 \def\vlnnotedrawtone#1#2#3#4#5{%
299 \ifthenelse{\equal{#1}{.}}%
301 {\vlnlastposbase#1\relax}%
302 \ifthenelse{\equal{#2}{.}}%
304 {\vlnlastposunit#2\relax}%
305 \ifthenelse{\equal{#3}{.}}%
306 {\vlnnotepos\vlnlastcord\relax}%
307 {\vlnnotepos#3\relax}%
308 \advance\vlnnotepos by1\relax%
309 \expandafter\vlnnotepos-\csname vlncordpos\romannumeral\vlnnotepos\endcsname\relax%
310 \ifthenelse{\equal{\the\vlnlastposbase}{0}}%
311 {\advance\vlnnotepos by\vlnlastposunit\relax}%
312 {\edef\tmp{\the\vlnlastposbase\the\vlnlastposunit}%
313 \advance\vlnnotepos by\tmp\relax}%
315 \vlnnotedraw crd{#3}pos{\the\vlnnotepos}fgr{#4}bow{#5}tim%
317 \def\vlnnoteshift#1{%
319 \modulo{\count@}{#1}%
320 \advance\count@ by1\relax%
321 \edef\tmp{\csname vlnnoteshift\romannumeral\count@\endcsname}%
322 \ifthenelse{\equal{\tmp}{}}%
324 {\advance\vlnnotepos by\tmp\relax}%