1 % This file is part of Violon, a violin score engine.
2 % Copyright (C) 2009-2012 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&autogeree.net.
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{colVlnLineHalfToneEven}{gray}{0.98}%
84 \definecolor{colVlnLineHalfToneOdd}{gray}{1}%
85 \definecolor{colVlnLineHalfToneFifth}{gray}{0.92}%
86 \definecolor{colVlnPart}{gray}{0}%
87 \definecolor{colVlnBar}{gray}{.85}%
88 \definecolor{colVlnCrescD}{rgb}{0,0.66,0}%
89 \definecolor{colVlnCrescU}{rgb}{1,0,0}%
92 \newdimen\vlnstaffhalftonelinevdim%
93 \newskip\vlnstaffvdim%
94 \def\vlnstaffvdimpre{3.25pt}%
95 \newskip\vlnstaffintervskip%
96 \newskip\vlnstaffvskip%
98 \def\vlnstaffhsize{\hsize}%
99 \def\vlnstaffmaxvsize{\textheight}%
100 \vlnstaffhalftonelinevdim=3pt%
101 \vlnstaffvdim=0pt\relax%
102 \vlnstaffvskip=0pt\relax%
103 \vlnstaffintervskip=\vlnstaffhalftonelinevdim\relax%
104 \multiply\vlnstaffintervskip by 2\relax%
105 \def\vlnstaffhalftoneline#1{%
106 {\color{colVlnLineHalfTone#1}\hrule depth 0pt height \vlnstaffhalftonelinevdim width \vlnstaffhsize }}%
107 \def\vlnstafftoneskip{%
108 \advance\vlnstaffvdim by\vlnstaffhalftonelinevdim%
111 \def\vlnstafffivehalftonelines{%
112 \vlnstaffhalftoneline{Odd}\vlnstafftoneskip%
113 \vlnstaffhalftoneline{Even}\vlnstafftoneskip%
114 \vlnstaffhalftoneline{Odd}\vlnstafftoneskip%
115 \vlnstaffhalftoneline{Even}\vlnstafftoneskip%
116 \vlnstaffhalftoneline{Fifth}\vlnstafftoneskip%
118 \def\vlnstaffallhalftonelines{%
119 \vlnstaffhalftoneline{Fifth}\vlnstafftoneskip%
120 \vlnstafffivehalftonelines%
121 \vlnstafffivehalftonelines%
122 \vlnstafffivehalftonelines%
123 \vlnstafffivehalftonelines%
124 \vlnstafffivehalftonelines%
127 \nobreak\vskip\vlnstaffvdimpre%
128 \nobreak\vskip\vlnstaffvdim%
129 \advance\vlnstaffvskip by\vlnstaffvdim\relax%
130 \count@\vlnstaffvskip\relax%
131 \advance\count@ by\vlnstaffvdim\relax%
132 \ifnum\count@>\vlnstaffmaxvsize%
133 \vlnstaffvskip=0pt\relax%
136 \advance\vlnstaffvskip by\vlnstaffintervskip\relax%
137 \nobreak\vskip\vlnstaffintervskip%
139 \vlnnotehskip=0pt\relax%
140 \vlnstaffvdim=0pt\relax%
141 \vlnstaffallhalftonelines%
142 \advance\vlnstaffvdim by\vlnstaffhalftonelinevdim%
143 \nobreak\vskip-\vlnstaffvdim%
148 \newskip\vlnnotevskip%
149 \newskip\vlnnotehskip%
152 \newdimen\vlnnotevdim%
153 \newdimen\vlnnotevdimmore%
154 \newdimen\vlnnotehdim%
155 \newdimen\vlnnotehdimbase%
156 \newcount\vlnlastfinger%
157 \newcount\vlnlastposbase%
158 \newcount\vlnlastposunit%
159 \newcount\vlnlastposoctave%
161 \def\vlnlastletter{}%
163 \newcount\vlnnotepos%
164 \newcount\vlnlastpos%
165 \gdef\vlncrescleft{}%
166 \gdef\vlncrescright{}%
168 \vlnnotevskip=0pt\relax%
169 \vlnnotehskip=0pt\relax%
170 \vlnnotevdim=\vlnstaffhalftonelinevdim%
171 \vlnnotevdimmore=1pt\relax%
172 \vlnnotehdimbase=2cm\relax%
173 %\advance\vlnnotevdim by\vlnnotevdimmore%
174 %\advance\vlnnotevdim by\vlnnotevdimmore%
176 \def\vlnlastrealbow{}%
178 \def\vlnlasttimenum{}%
179 \def\vlnlasttimeden{}%
180 \def\vlnnotehdimmodetim{t}%
181 \def\vlnnotehdimmodetxt{}%
182 \parindent=0pt\relax%
184 \parfillskip=0pt\relax%
185 \def\vlnlastposfinger{%
186 \csname vlnlastposfinger\romannumeral\vlnlastfinger\endcsname%
188 \def\vlnlastfingerpos{%
189 \csname vlnlastfingerpos\romannumeral\vlnlastpos\endcsname%
191 \def\vlnlastposname{%
192 \csname vlnlastposname\romannumeral\vlnlastpos\endcsname%
194 \def\vlntimefrac#1/#2{%
197 \kern-.4ex\lower.3ex\hbox{\bfseries\tiny /}%
198 \kern-.3ex\lower.6ex\hbox{#2}%
200 \def\vlndoatnote#1#2#3#4{%
202 \vlnnotevskip=0pt\relax%
203 \advance\vlnnotevskip by\vlnstaffhalftonelinevdim\relax%
204 \multiply\vlnnotevskip by#1\relax%
205 \advance\vlnnotevskip by\vlnstaffhalftonelinevdim\relax%
206 %\advance\vlnnotevskip by-\vlnnotevdimmore\relax%
207 \nobreak\vskip\vlnnotevskip\relax%
208 \vrule depth 0pt height 0pt width \vlnnotehskip\relax%
210 \advance\vlnnotevskip by \ht0\relax%
214 \nobreak\vskip-\vlnnotevskip\relax%
218 \advance\vlnnotehskip by\vlnnotehdim\relax%
220 \def\vlnnotedraw crd#1pos#2fgr#3bow#4nam#5tim#6#7{%
222 \ifthenelse{\equal{#2}{.}}%
224 {\vlnlastpos#2\relax}%
226 \ifthenelse{\equal{#6}{.}}%
228 {\def\vlnlasttimenum{#6}}%
229 \ifthenelse{\equal{#7}{.}}%
231 {\def\vlnlasttimeden{#7}}%
232 \vlnnotehdim\vlnnotehdimbase%
233 \ifthenelse{\equal{}{\vlnnotehdimmodetim}}%
235 {\multiply\vlnnotehdim by\vlnlasttimenum\relax%
236 \divide\vlnnotehdim by\vlnlasttimeden\relax%
238 % Automatic staff break
239 \count@\vlnnotehskip\relax%
240 \advance\count@ by\vlnnotehdim\relax%
241 \ifnum\count@>\vlnstaffhsize\vlnstaff\fi%
242 \def\vlnnotehdimmodetxtdo{%
244 \ifthenelse{\equal{}{\vlnnotehdimmodetxt}}%
248 \ifthenelse{\equal{\vlnlasttimeden}{1}}%
249 {{\vlntimefont{\vlnlasttimenum}}}%
250 {\vlntimefrac{\vlntimefont{\vlnlasttimenum}}/{\vlntimefont{\vlnlasttimeden}}}%
252 \nobreak\vskip\vlnnotevdim\relax%
253 \nobreak\vskip0.2mm\relax%
254 \nobreak\hskip\vlnnotehdim\relax%
255 \nobreak\hskip-\wd0\relax%
260 \ifthenelse{\equal{#6/#7}{\vlnlasttimenum/\vlnlasttimeden}}%
262 {\vlndoatnote{\vlnlastpos}%
264 {\vlnnotehdimmodetxtdo}%
268 \ifthenelse{\equal{#4}{C}}%
269 {\ifthenelse{\equal{U}{\vlnlastrealbow}}%
270 {\def\vlnlastbow{D}}%
271 {\def\vlnlastbow{U}}}%
272 {\ifthenelse{\equal{#4}{.}}%
274 {\def\vlnlastbow{#4}}}%
275 \ifthenelse{\equal{\vlnlastbow}{N}}%
277 {\edef\vlnlastrealbow{\vlnlastbow}}%
278 \vlndoatnote{\vlnlastpos}%
279 {\begingroup\expandafter\color{colVlnBow\vlnlastbow}}%
282 \ifthenelse{\equal{\vlnlastbow}{N}}
285 \vrule depth 0pt height \vlnnotevdim width \vlnnotehdim\relax%
286 \nobreak\hskip-\vlnnotehdim\relax%
288 \divide\dimen@ by3\relax%
289 \dimen@@\vlnnotehdim%
290 \divide\dimen@@ by2\relax%
291 \ifthenelse{\equal{\vlncrescleft}{}}%
293 \ifthenelse{\equal{\vlncrescright}{}}%
297 \vrule depth 0pt height 0pt width \dimen@@\relax%
298 \color{colVlnCresc\vlncrescright}%
299 \vrule depth 0pt height \dimen@ width \dimen@@\relax%
303 \ifthenelse{\equal{\vlncrescright}{}}%
305 \color{colVlnCresc\vlncrescleft}%
306 \vrule depth 0pt height \dimen@ width \dimen@@\relax%
309 \color{colVlnCresc\vlncrescleft}%
310 \vrule depth 0pt height \dimen@ width \dimen@@\relax%
311 \color{colVlnCresc\vlncrescright}%
312 \vrule depth 0pt height \dimen@ width \dimen@@\relax%
315 \global\let\vlncrescleft\vlncrescright%
321 \ifthenelse{\equal{#1}{\vlnlastcord}}%
323 {\ifthenelse{\equal{#1}{.}}%
325 {\def\vlnlastcord{#1}%
326 %\vlndoatnote{\vlnlastpos}%
329 % \setbox0=\hbox{{\vlncordfont{%
331 % \advance\count@ by1\relax%
333 % \or 0\or 1\or 2\or 3%
335 % %\nobreak\vskip\vlnnotevdim\relax%
336 % %\nobreak\vskip0.2mm\relax%
337 % \nobreak\vskip-0.2mm\relax%
338 % \nobreak\vskip-\ht0\relax%
339 % \nobreak\hskip\vlnnotehdim\relax%
340 % \nobreak\hskip-\wd0\relax%
346 \ifthenelse{\equal{#3}{.}}%
348 {\vlnlastfinger#3\relax}%
349 \ifthenelse{\equal{\vlnlastbow}{N}%
350 % \OR\equal{\the\vlnlastfinger}{\vlnlastfingerpos}%
351 % \AND\equal{\the\vlnlastpos}{\vlnlastposfinger}%
352 % \AND\equal{\the\vlnlastcord}{\thevlnlastlastcord}%
356 \expandafter\edef\csname vlnlastfingerpos\romannumeral\vlnlastpos\endcsname{\the\vlnlastfinger}%
357 \expandafter\edef\csname vlnlastposfinger\romannumeral\vlnlastfinger\endcsname{\the\vlnlastpos}%
358 \vlndoatnote{\vlnlastpos}%
361 \setbox0=\hbox{{\vlnfingerfont{\the\vlnlastfinger}}}%
362 \nobreak\vskip\vlnnotevdim\relax%
363 \nobreak\vskip0.2mm\relax%
364 \dp0=0pt\relax% NOTE: to prevent fonts like pnc to mess up the vertical alignment
369 \ifthenelse{\equal{#5}{\vlnlastname}\AND\equal{#2}{\vlnlastpos}}%
372 \def\vlnlastname{#5}%
373 \expandafter\edef\csname vlnlastposname\romannumeral\vlnlastpos\endcsname{#5}%
374 \ifthenelse{\equal{\vlnlastbow}{N}}%
376 {%\edef\vlnlastname{#5}%
377 \vlndoatnote{\vlnlastpos}%
380 \setbox0=\hbox{{\vlnnamefont{#5}}}%
381 \nobreak\vskip-0.275mm\relax%
382 \nobreak\vskip-\ht0\relax%
384 \dp0=0pt\relax% NOTE: to prevent fonts like pnc to mess up the vertical alignment
400 \def\vlncordposi{0}% G
401 \def\vlncordposii{7}% D
402 \def\vlncordposiii{14}% A
403 \def\vlncordposiv{21}% E
406 % Demi-tons alphabétiques sans modification
407 \expandafter\def\csname vlnnotetoneofnameG=\endcsname{0}%
408 \expandafter\def\csname vlnnotetoneofnameG+\endcsname{1}%
409 \expandafter\def\csname vlnnotetoneofnameA-\endcsname{1}%
410 \expandafter\def\csname vlnnotetoneofnameA=\endcsname{2}%
411 \expandafter\def\csname vlnnotetoneofnameA+\endcsname{3}%
412 \expandafter\def\csname vlnnotetoneofnameB-\endcsname{3}%
413 \expandafter\def\csname vlnnotetoneofnameB=\endcsname{4}%
414 \expandafter\def\csname vlnnotetoneofnameB+\endcsname{5}%
415 \expandafter\def\csname vlnnotetoneofnameC-\endcsname{4}%
416 \expandafter\def\csname vlnnotetoneofnameC=\endcsname{5}%
417 \expandafter\def\csname vlnnotetoneofnameC+\endcsname{6}%
418 \expandafter\def\csname vlnnotetoneofnameD-\endcsname{6}%
419 \expandafter\def\csname vlnnotetoneofnameD=\endcsname{7}%
420 \expandafter\def\csname vlnnotetoneofnameD+\endcsname{8}%
421 \expandafter\def\csname vlnnotetoneofnameE-\endcsname{8}%
422 \expandafter\def\csname vlnnotetoneofnameE=\endcsname{9}%
423 \expandafter\def\csname vlnnotetoneofnameE+\endcsname{10}%
424 \expandafter\def\csname vlnnotetoneofnameF-\endcsname{9}%
425 \expandafter\def\csname vlnnotetoneofnameF=\endcsname{10}%
426 \expandafter\def\csname vlnnotetoneofnameF+\endcsname{11}%
427 \expandafter\def\csname vlnnotetoneofnameG-\endcsname{11}%
429 \expandafter\def\csname vlnshiftsymbol-\endcsname{\kern-0.7pt$\flat$}%
430 \expandafter\def\csname vlnshiftsymbol=\endcsname{}%
431 \expandafter\def\csname vlnshiftsymbol+\endcsname{$\sharp$}%
432 \def\vlnnotedrawtonebyname#1#2#3#4#5#6{%
433 \ifthenelse{\equal{#1}{.}}%
435 {\vlnlastposoctave#1\relax}%
436 \ifthenelse{\equal{#2}{.}}%
438 {\def\vlnlastletter{#2}}%
439 \ifthenelse{\equal{#3}{.}}%
441 {\def\vlnlastshift{#3}}%
442 \edef\tmp{\csname vlnnotetoneofname\vlnlastletter\vlnlastshift\endcsname}%
444 \count@\vlnlastposoctave\relax%
445 \multiply\count@ by12\relax%
446 \advance\vlnnotepos by\count@%
447 \ifthenelse{\equal{#4}{.}}%
448 {\count@\vlnlastcord}%
450 \advance\count@ by1\relax%
451 \advance\vlnnotepos by-\csname vlncordpos\romannumeral\count@\endcsname%
452 \edef\nam{\vlnlastletter\csname vlnshiftsymbol\vlnlastshift\endcsname}%
453 \vlnnotedraw crd{#4}pos{\the\vlnnotepos}fgr{#5}bow{#6}nam{\nam}tim%
459 \setbox0=\hbox{{\vlnpartfont{#1}}}%
460 \nobreak\vskip-0.3mm\relax%
461 \nobreak\vskip-\ht0\relax%
462 \dp0=0pt\relax% NOTE: to prevent fonts like pnc to mess up the vertical alignment
470 \dimen@\vlnstaffvdim%
471 \advance\dimen@ by -\vlnnotevdim\relax%
472 \advance\dimen@ by -\vlnnotevdim\relax%
473 \setbox0=\hbox{\color{colVlnBar}\vrule depth 0pt height \dimen@ width 0.1pt\relax}%
474 \nobreak\vskip\vlnnotevdim\relax%
480 \global\let\vlncrescleft\vlncrescright%
481 \xdef\vlncrescright{#1}%