1 % This file is part of Violon, a violin score engine.
2 % Copyright (C) 2009-2010 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 \expandafter\color{colVlnBowFingerCord\vlnlastcord}%
38 \fontfamily{pnc}\bfseries\sssmall}%
40 \color{colVlnBowCord}%
41 \fontfamily{pnc}\bfseries\sssmall}%
43 \expandafter\color{colVlnBowNameOctave\the\vlnlastposoctave}%
44 \fontfamily{pnc}\scshape\ssssmall}%
47 \fontfamily{pnc}\bfseries\sssmall}%
49 \fontfamily{pnc}\bfseries\ssssmall}%
51 \newcount\@calc@mod@cnt%
53 \@calc@mod@cnt=#1\relax%
54 \divide\@calc@mod@cnt by#2\relax%
55 \multiply\@calc@mod@cnt by#2\relax%
56 \advance#1 by-\@calc@mod@cnt%
59 \let\romannumeral@old\romannumeral%
61 \ifnum#1>\z@\romannumeral@old#1\else\number#1\fi%
66 %\definecolor{colVlnBowU}{rgb}{0.24,0.92,0.24}%
67 %\definecolor{colVlnBowD}{rgb}{0.80,0,0}%
68 %\definecolor{colVlnBowU}{rgb}{0.30,0.75,0.75}%
69 \definecolor{colVlnBowU}{gray}{0.50}%
70 \definecolor{colVlnBowD}{gray}{0}%
71 \definecolor{colVlnBowN}{gray}{1}%
72 \definecolor{colVlnBowCord}{rgb}{0,1,0}%
73 \definecolor{colVlnBowFinger}{rgb}{0,0,0}%
74 \definecolor{colVlnBowFingerCord0}{rgb}{0,0,0}%
75 \definecolor{colVlnBowFingerCord1}{rgb}{0,0.66,0}%
76 \definecolor{colVlnBowFingerCord2}{rgb}{0,0,1}%
77 \definecolor{colVlnBowFingerCord3}{rgb}{1,0,0}%
78 \definecolor{colVlnBowName}{rgb}{1,0,0}%
79 \definecolor{colVlnBowNameOctave0}{rgb}{0,0,0}%
80 \definecolor{colVlnBowNameOctave1}{rgb}{0,0.66,0}%
81 \definecolor{colVlnBowNameOctave2}{rgb}{0,0,1}%
82 \definecolor{colVlnBowNameOctave3}{rgb}{1,0,0}%
83 \definecolor{colVlnLineHalfTone}{gray}{0.90}%
84 \definecolor{colVlnLineHalfToneBase}{gray}{0.50}%
85 \definecolor{colVlnPart}{gray}{0}%
86 \definecolor{colVlnCrescD}{rgb}{0,0.66,0}%
87 \definecolor{colVlnCrescU}{rgb}{1,0,0}%
90 \newdimen\vlnstaffhalftonelinevdim%
91 \newskip\vlnstaffhalftonelinevskip%
92 \newskip\vlnstaffvdim%
93 \def\vlnstaffvdimpre{3.25pt}%
94 \newskip\vlnstaffintervskip%
95 \newskip\vlnstaffvskip%
97 \def\vlnstaffhsize{\hsize}%
98 \def\vlnstaffmaxvsize{\textheight}%
99 \vlnstaffhalftonelinevdim=0.5pt%
100 \vlnstaffhalftonelinevskip=4pt\relax%
101 \advance\vlnstaffhalftonelinevskip by-\vlnstaffhalftonelinevdim%
102 \vlnstaffvdim=0pt\relax%
103 \vlnstaffvskip=0pt\relax%
104 \vlnstaffintervskip=\vlnstaffhalftonelinevskip\relax%
105 \advance\vlnstaffintervskip by\vlnstaffhalftonelinevdim\relax%
106 \def\vlnstaffhalftoneline{%
107 {\color{colVlnLineHalfTone}\hrule depth 0pt height \vlnstaffhalftonelinevdim width \vlnstaffhsize }}%
108 \def\vlnbasehalftoneline{%
109 {\color{colVlnLineHalfToneBase}\hrule depth 0pt height \vlnstaffhalftonelinevdim width \vlnstaffhsize }}%
110 \def\vlnstafftoneskip{%
111 \advance\vlnstaffvdim by\vlnstaffhalftonelinevskip%
112 \advance\vlnstaffvdim by\vlnstaffhalftonelinevdim%
113 \nobreak\vskip\vlnstaffhalftonelinevskip%
115 \def\vlnstafffivehalftonelines{%
116 \vlnstafftoneskip\vlnstaffhalftoneline%
117 \vlnstafftoneskip\vlnstaffhalftoneline%
118 \vlnstafftoneskip\vlnstaffhalftoneline%
119 \vlnstafftoneskip\vlnstaffhalftoneline%
120 \vlnstafftoneskip\vlnbasehalftoneline%
122 \def\vlnstaffallhalftonelines{%
123 \vlnstafffivehalftonelines%
124 \vlnstafffivehalftonelines%
125 \vlnstafffivehalftonelines%
126 \vlnstafffivehalftonelines%
127 \vlnstafffivehalftonelines%
130 \nobreak\vskip\vlnstaffvdimpre%
131 \nobreak\vskip\vlnstaffvdim%
132 \advance\vlnstaffvskip by\vlnstaffvdim\relax%
133 \count@\vlnstaffvskip\relax%
134 \advance\count@ by\vlnstaffvdim\relax%
135 \ifnum\count@>\vlnstaffmaxvsize%
136 \vlnstaffvskip=0pt\relax%
139 \advance\vlnstaffvskip by\vlnstaffintervskip\relax%
140 \nobreak\vskip\vlnstaffintervskip%
142 \vlnnotehskip=0pt\relax%
143 \vlnstaffvdim=0pt\relax%
144 \vlnbasehalftoneline%
145 \vlnstaffallhalftonelines%
146 \advance\vlnstaffvdim by\vlnstaffhalftonelinevdim%
147 \nobreak\vskip-\vlnstaffvdim%
152 \newskip\vlnnotevskip%
153 \newskip\vlnnotehskip%
156 \newdimen\vlnnotevdim%
157 \newdimen\vlnnotevdimmore%
158 \newdimen\vlnnotehdim%
159 \newdimen\vlnnotehdimbase%
160 \newcount\vlnlastfinger%
161 \newcount\vlnlastposbase%
162 \newcount\vlnlastposunit%
163 \newcount\vlnlastposoctave%
164 \def\vlnlastletter{}%
166 \newcount\vlnnotepos%
167 \newcount\vlnlastpos%
168 \gdef\vlncrescleft{}%
169 \gdef\vlncrescright{}%
171 \vlnnotevskip=0pt\relax%
172 \vlnnotehskip=0pt\relax%
173 \vlnnotevdim=\vlnstaffhalftonelinevdim%
174 \vlnnotevdimmore=1pt\relax%
175 \vlnnotehdimbase=2cm\relax%
176 \advance\vlnnotevdim by\vlnnotevdimmore%
177 \advance\vlnnotevdim by\vlnnotevdimmore%
179 \def\vlnlastrealbow{}%
181 \def\vlnlasttimenum{}%
182 \def\vlnlasttimeden{}%
183 \def\vlnnotehdimmodetim{t}%
184 \def\vlnnotehdimmodetxt{}%
185 \parindent=0pt\relax%
187 \parfillskip=0pt\relax%
188 \def\vlnlastposfinger{%
189 \csname vlnlastposfinger\romannumeral\vlnlastfinger\endcsname%
191 \def\vlnlastfingerpos{%
192 \csname vlnlastfingerpos\romannumeral\vlnlastpos\endcsname%
194 \def\vlnlastposname{%
195 \csname vlnlastposname\romannumeral\vlnlastpos\endcsname%
197 \def\vlntimefrac#1/#2{%
200 \kern-.4ex\lower.3ex\hbox{\bfseries\tiny /}%
201 \kern-.3ex\lower.6ex\hbox{#2}%
203 \def\vlndoatnote#1#2#3#4{%
205 \vlnnotevskip\vlnstaffhalftonelinevskip%
206 \advance\vlnnotevskip by\vlnstaffhalftonelinevdim\relax%
207 \multiply\vlnnotevskip by#1\relax%
208 \advance\vlnnotevskip by-\vlnnotevdimmore\relax%
209 \nobreak\vskip\vlnnotevskip\relax%
210 \vrule depth 0pt height 0pt width \vlnnotehskip\relax%
212 \advance\vlnnotevskip by \ht0\relax%
216 \nobreak\vskip-\vlnnotevskip\relax%
220 \advance\vlnnotehskip by\vlnnotehdim\relax%
222 \def\vlnnotedraw crd#1pos#2fgr#3bow#4nam#5tim#6#7{%
224 \ifthenelse{\equal{#2}{.}}%
226 {\vlnlastpos#2\relax}%
228 \ifthenelse{\equal{#6}{.}}%
230 {\def\vlnlasttimenum{#6}}%
231 \ifthenelse{\equal{#7}{.}}%
233 {\def\vlnlasttimeden{#7}}%
234 \vlnnotehdim\vlnnotehdimbase%
235 \ifthenelse{\equal{}{\vlnnotehdimmodetim}}%
237 {\multiply\vlnnotehdim by\vlnlasttimenum\relax%
238 \divide\vlnnotehdim by\vlnlasttimeden\relax%
240 % Automatic staff break
241 \count@\vlnnotehskip\relax%
242 \advance\count@ by\vlnnotehdim\relax%
243 \ifnum\count@>\vlnstaffhsize\vlnstaff\fi%
244 \def\vlnnotehdimmodetxtdo{%
246 \ifthenelse{\equal{}{\vlnnotehdimmodetxt}}%
250 \ifthenelse{\equal{\vlnlasttimeden}{1}}%
251 {{\vlntimefont{\vlnlasttimenum}}}%
252 {\vlntimefrac{\vlntimefont{\vlnlasttimenum}}/{\vlntimefont{\vlnlasttimeden}}}%
254 \nobreak\vskip\vlnnotevdim\relax%
255 \nobreak\vskip0.2mm\relax%
256 \nobreak\hskip\vlnnotehdim\relax%
257 \nobreak\hskip-\wd0\relax%
262 \ifthenelse{\equal{#6/#7}{\vlnlasttimenum/\vlnlasttimeden}}%
264 {\vlndoatnote{\vlnlastpos}%
266 {\vlnnotehdimmodetxtdo}%
270 \ifthenelse{\equal{#4}{C}}%
271 {\ifthenelse{\equal{U}{\vlnlastrealbow}}%
272 {\def\vlnlastbow{D}}%
273 {\def\vlnlastbow{U}}}%
274 {\ifthenelse{\equal{#4}{.}}%
276 {\def\vlnlastbow{#4}}}%
277 \ifthenelse{\equal{\vlnlastbow}{N}}%
279 {\edef\vlnlastrealbow{\vlnlastbow}}%
280 \vlndoatnote{\vlnlastpos}%
281 {\begingroup\expandafter\color{colVlnBow\vlnlastbow}}%
284 \vrule depth 0pt height \vlnnotevdim width \vlnnotehdim\relax%
285 \nobreak\hskip-\vlnnotehdim\relax%
286 \ifthenelse{\equal{\vlnlastbow}{N}}
290 \divide\dimen@ by3\relax%
291 \dimen@@\vlnnotehdim%
292 \divide\dimen@@ by2\relax%
293 \ifthenelse{\equal{\vlncrescleft}{}}%
295 \ifthenelse{\equal{\vlncrescright}{}}%
299 \vrule depth 0pt height 0pt width \dimen@@\relax%
300 \color{colVlnCresc\vlncrescright}%
301 \vrule depth 0pt height \dimen@ width \dimen@@\relax%
305 \ifthenelse{\equal{\vlncrescright}{}}%
307 \color{colVlnCresc\vlncrescleft}%
308 \vrule depth 0pt height \dimen@ width \dimen@@\relax%
311 \color{colVlnCresc\vlncrescleft}%
312 \vrule depth 0pt height \dimen@ width \dimen@@\relax%
313 \color{colVlnCresc\vlncrescright}%
314 \vrule depth 0pt height \dimen@ width \dimen@@\relax%
317 \global\let\vlncrescleft\vlncrescright%
323 \ifthenelse{\equal{#1}{\vlnlastcord}}%
325 {\ifthenelse{\equal{#1}{.}}%
327 {\def\vlnlastcord{#1}%
328 %\vlndoatnote{\vlnlastpos}%
331 % \setbox0=\hbox{{\vlncordfont{%
333 % \advance\count@ by1\relax%
335 % \or 0\or 1\or 2\or 3%
337 % %\nobreak\vskip\vlnnotevdim\relax%
338 % %\nobreak\vskip0.2mm\relax%
339 % \nobreak\vskip-0.2mm\relax%
340 % \nobreak\vskip-\ht0\relax%
341 % \nobreak\hskip\vlnnotehdim\relax%
342 % \nobreak\hskip-\wd0\relax%
348 \ifthenelse{\equal{#3}{.}}%
350 {\vlnlastfinger#3\relax}%
351 \ifthenelse{\equal{\vlnlastbow}{N}%
352 % \OR\equal{\the\vlnlastfinger}{\vlnlastfingerpos}%
353 % \AND\equal{\the\vlnlastpos}{\vlnlastposfinger}%
354 % \AND\equal{\the\vlnlastcord}{\thevlnlastlastcord}%
358 \expandafter\edef\csname vlnlastfingerpos\romannumeral\vlnlastpos\endcsname{\the\vlnlastfinger}%
359 \expandafter\edef\csname vlnlastposfinger\romannumeral\vlnlastfinger\endcsname{\the\vlnlastpos}%
360 \vlndoatnote{\vlnlastpos}%
363 \setbox0=\hbox{{\vlnfingerfont{\the\vlnlastfinger}}}%
364 \nobreak\vskip\vlnnotevdim\relax%
365 \nobreak\vskip0.2mm\relax%
366 \dp0=0pt\relax% NOTE: to prevent fonts like pnc to mess up the vertical alignment
371 \ifthenelse{\equal{#5}{\vlnlastname}\AND\equal{#2}{\vlnlastpos}}%
374 \def\vlnlastname{#5}%
375 \expandafter\edef\csname vlnlastposname\romannumeral\vlnlastpos\endcsname{#5}%
376 \ifthenelse{\equal{\vlnlastbow}{N}}%
378 {%\edef\vlnlastname{#5}%
379 \vlndoatnote{\vlnlastpos}%
382 \setbox0=\hbox{{\vlnnamefont{#5}}}%
383 \nobreak\vskip-0.275mm\relax%
384 \nobreak\vskip-\ht0\relax%
386 \dp0=0pt\relax% NOTE: to prevent fonts like pnc to mess up the vertical alignment
402 \def\vlncordposi{0}% G
403 \def\vlncordposii{7}% D
404 \def\vlncordposiii{14}% A
405 \def\vlncordposiv{21}% E
408 % Demi-tons alphabétiques sans modification
409 \expandafter\def\csname vlnnotetoneofnameG=\endcsname{0}%
410 \expandafter\def\csname vlnnotetoneofnameG+\endcsname{1}%
411 \expandafter\def\csname vlnnotetoneofnameA-\endcsname{1}%
412 \expandafter\def\csname vlnnotetoneofnameA=\endcsname{2}%
413 \expandafter\def\csname vlnnotetoneofnameA+\endcsname{3}%
414 \expandafter\def\csname vlnnotetoneofnameB-\endcsname{3}%
415 \expandafter\def\csname vlnnotetoneofnameB=\endcsname{4}%
416 \expandafter\def\csname vlnnotetoneofnameB+\endcsname{5}%
417 \expandafter\def\csname vlnnotetoneofnameC-\endcsname{4}%
418 \expandafter\def\csname vlnnotetoneofnameC=\endcsname{5}%
419 \expandafter\def\csname vlnnotetoneofnameC+\endcsname{6}%
420 \expandafter\def\csname vlnnotetoneofnameD-\endcsname{6}%
421 \expandafter\def\csname vlnnotetoneofnameD=\endcsname{7}%
422 \expandafter\def\csname vlnnotetoneofnameD+\endcsname{8}%
423 \expandafter\def\csname vlnnotetoneofnameE-\endcsname{8}%
424 \expandafter\def\csname vlnnotetoneofnameE=\endcsname{9}%
425 \expandafter\def\csname vlnnotetoneofnameE+\endcsname{10}%
426 \expandafter\def\csname vlnnotetoneofnameF-\endcsname{9}%
427 \expandafter\def\csname vlnnotetoneofnameF=\endcsname{10}%
428 \expandafter\def\csname vlnnotetoneofnameF+\endcsname{11}%
429 \expandafter\def\csname vlnnotetoneofnameG-\endcsname{11}%
431 \expandafter\def\csname vlnshiftsymbol-\endcsname{\kern-0.7pt$\flat$}%
432 \expandafter\def\csname vlnshiftsymbol=\endcsname{}%
433 \expandafter\def\csname vlnshiftsymbol+\endcsname{$\sharp$}%
434 \def\vlnnotedrawtonebyname#1#2#3#4#5#6{%
435 \ifthenelse{\equal{#1}{.}}%
437 {\vlnlastposoctave#1\relax}%
438 \ifthenelse{\equal{#2}{.}}%
440 {\def\vlnlastletter{#2}}%
441 \ifthenelse{\equal{#3}{.}}%
443 {\def\vlnlastshift{#3}}%
444 \edef\tmp{\csname vlnnotetoneofname\vlnlastletter\vlnlastshift\endcsname}%
446 \count@\vlnlastposoctave\relax%
447 \multiply\count@ by12\relax%
448 \advance\vlnnotepos by\count@%
449 \ifthenelse{\equal{#4}{.}}%
450 {\count@\vlnlastcord}%
452 \advance\count@ by1\relax%
453 \advance\vlnnotepos by-\csname vlncordpos\romannumeral\count@\endcsname%
454 \edef\nam{\vlnlastletter\csname vlnshiftsymbol\vlnlastshift\endcsname}%
455 \vlnnotedraw crd{#4}pos{\the\vlnnotepos}fgr{#5}bow{#6}nam{\nam}tim%
461 \setbox0=\hbox{{\vlnpartfont{#1}}}%
462 \nobreak\vskip-0.2mm\relax%
463 \nobreak\vskip-\ht0\relax%
464 \dp0=0pt\relax% NOTE: to prevent fonts like pnc to mess up the vertical alignment
472 \setbox0=\hbox{\color{colVlnLineHalfToneBase}\vrule depth 0pt height \vlnstaffvdim width 0.1pt\relax}%
473 \nobreak\vskip\vlnnotevdimmore\relax%
479 \global\let\vlncrescleft\vlncrescright%
480 \xdef\vlncrescright{#1}%