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 \def\romannumeralz#1{%
60 \ifnum#1>\z@\romannumeral#1\else\number#1\fi%
65 %\definecolor{colVlnBowU}{rgb}{0.24,0.92,0.24}%
66 %\definecolor{colVlnBowD}{rgb}{0.80,0,0}%
67 %\definecolor{colVlnBowU}{rgb}{0.30,0.75,0.75}%
68 \definecolor{colVlnBowU}{gray}{0.50}%
69 \definecolor{colVlnBowD}{gray}{0}%
70 \definecolor{colVlnBowN}{gray}{1}%
71 \definecolor{colVlnBowCord}{rgb}{0,1,0}%
72 \definecolor{colVlnBowFinger}{rgb}{0,0,0}%
73 \definecolor{colVlnBowFingerCord0}{rgb}{0,0,0}%
74 \definecolor{colVlnBowFingerCord1}{rgb}{0,0.66,0}%
75 \definecolor{colVlnBowFingerCord2}{rgb}{0,0,1}%
76 \definecolor{colVlnBowFingerCord3}{rgb}{1,0,0}%
77 \definecolor{colVlnBowName}{rgb}{1,0,0}%
78 \definecolor{colVlnBowNameOctave0}{rgb}{0,0,0}%
79 \definecolor{colVlnBowNameOctave1}{rgb}{0,0.66,0}%
80 \definecolor{colVlnBowNameOctave2}{rgb}{0,0,1}%
81 \definecolor{colVlnBowNameOctave3}{rgb}{1,0,0}%
82 \definecolor{colVlnLineHalfToneEven}{gray}{0.98}%
83 \definecolor{colVlnLineHalfToneOdd}{gray}{1}%
84 \definecolor{colVlnLineHalfToneFifth}{gray}{0.92}%
85 \definecolor{colVlnPart}{gray}{0}%
86 \definecolor{colVlnBar}{gray}{.85}%
87 \definecolor{colVlnCrescD}{rgb}{0,0.66,0}%
88 \definecolor{colVlnCrescU}{rgb}{1,0,0}%
91 \newdimen\vlnstaffhalftonelinevdim%
92 \newskip\vlnstaffvdim%
93 \def\vlnstaffvdimpre{3.25pt}%
94 \newskip\vlnstaffintervskip%
95 \newskip\vlnstaffvskip%
97 \def\vlnstaffhsize{\hsize}%
98 \def\vlnstaffmaxvsize{\textheight}%
99 \vlnstaffhalftonelinevdim=3pt%
100 \vlnstaffvdim=0pt\relax%
101 \vlnstaffvskip=0pt\relax%
102 \vlnstaffintervskip=\vlnstaffhalftonelinevdim\relax%
103 \multiply\vlnstaffintervskip by 2\relax%
104 \def\vlnstaffhalftoneline#1{%
105 {\color{colVlnLineHalfTone#1}\hrule depth 0pt height \vlnstaffhalftonelinevdim width \vlnstaffhsize }}%
106 \def\vlnstafftoneskip{%
107 \advance\vlnstaffvdim by\vlnstaffhalftonelinevdim%
110 \def\vlnstafffivehalftonelines{%
111 \vlnstaffhalftoneline{Odd}\vlnstafftoneskip%
112 \vlnstaffhalftoneline{Even}\vlnstafftoneskip%
113 \vlnstaffhalftoneline{Odd}\vlnstafftoneskip%
114 \vlnstaffhalftoneline{Even}\vlnstafftoneskip%
115 \vlnstaffhalftoneline{Fifth}\vlnstafftoneskip%
117 \def\vlnstaffallhalftonelines{%
118 \vlnstaffhalftoneline{Fifth}\vlnstafftoneskip%
119 \vlnstafffivehalftonelines%
120 \vlnstafffivehalftonelines%
121 \vlnstafffivehalftonelines%
122 \vlnstafffivehalftonelines%
123 \vlnstafffivehalftonelines%
126 \nobreak\vskip\vlnstaffvdimpre%
127 \nobreak\vskip\vlnstaffvdim%
128 \advance\vlnstaffvskip by\vlnstaffvdim\relax%
129 \count@\vlnstaffvskip\relax%
130 \advance\count@ by\vlnstaffvdim\relax%
131 \ifnum\count@>\vlnstaffmaxvsize%
132 \vlnstaffvskip=0pt\relax%
135 \advance\vlnstaffvskip by\vlnstaffintervskip\relax%
136 \nobreak\vskip\vlnstaffintervskip%
138 \vlnnotehskip=0pt\relax%
139 \vlnstaffvdim=0pt\relax%
140 \vlnstaffallhalftonelines%
141 \advance\vlnstaffvdim by\vlnstaffhalftonelinevdim%
142 \nobreak\vskip-\vlnstaffvdim%
147 \newskip\vlnnotevskip%
148 \newskip\vlnnotehskip%
151 \newdimen\vlnnotevdim%
152 \newdimen\vlnnotevdimmore%
153 \newdimen\vlnnotehdim%
154 \newdimen\vlnnotehdimbase%
155 \newcount\vlnlastfinger%
156 \newcount\vlnlastposbase%
157 \newcount\vlnlastposunit%
158 \newcount\vlnlastposoctave%
160 \def\vlnlastletter{}%
162 \newcount\vlnnotepos%
163 \newcount\vlnlastpos%
164 \gdef\vlncrescleft{}%
165 \gdef\vlncrescright{}%
167 \vlnnotevskip=0pt\relax%
168 \vlnnotehskip=0pt\relax%
169 \vlnnotevdim=\vlnstaffhalftonelinevdim%
170 \vlnnotevdimmore=1pt\relax%
171 \vlnnotehdimbase=2cm\relax%
172 %\advance\vlnnotevdim by\vlnnotevdimmore%
173 %\advance\vlnnotevdim by\vlnnotevdimmore%
175 \def\vlnlastrealbow{}%
177 \def\vlnlasttimenum{}%
178 \def\vlnlasttimeden{}%
179 \def\vlnnotehdimmodetim{t}%
180 \def\vlnnotehdimmodetxt{}%
181 \parindent=0pt\relax%
183 \parfillskip=0pt\relax%
184 \def\vlnlastposfinger{%
185 \csname vlnlastposfinger\romannumeralz\vlnlastfinger\endcsname%
187 \def\vlnlastfingerpos{%
188 \csname vlnlastfingerpos\romannumeralz\vlnlastpos\endcsname%
190 \def\vlnlastposname{%
191 \csname vlnlastposname\romannumeralz\vlnlastpos\endcsname%
193 \def\vlntimefrac#1/#2{%
196 \kern-.4ex\lower.3ex\hbox{\bfseries\tiny /}%
197 \kern-.3ex\lower.6ex\hbox{#2}%
199 \def\vlndoatnote#1#2#3#4{%
201 \vlnnotevskip=0pt\relax%
202 \advance\vlnnotevskip by\vlnstaffhalftonelinevdim\relax%
203 \multiply\vlnnotevskip by#1\relax%
204 \advance\vlnnotevskip by\vlnstaffhalftonelinevdim\relax%
205 %\advance\vlnnotevskip by-\vlnnotevdimmore\relax%
206 \nobreak\vskip\vlnnotevskip\relax%
207 \vrule depth 0pt height 0pt width \vlnnotehskip\relax%
209 \advance\vlnnotevskip by \ht0\relax%
213 \nobreak\vskip-\vlnnotevskip\relax%
217 \advance\vlnnotehskip by\vlnnotehdim\relax%
219 \def\vlnnotedraw crd#1pos#2fgr#3bow#4nam#5tim#6#7{%
221 \ifthenelse{\equal{#2}{.}}%
223 {\vlnlastpos#2\relax}%
225 \ifthenelse{\equal{#6}{.}}%
227 {\def\vlnlasttimenum{#6}}%
228 \ifthenelse{\equal{#7}{.}}%
230 {\def\vlnlasttimeden{#7}}%
231 \vlnnotehdim\vlnnotehdimbase%
232 \ifthenelse{\equal{}{\vlnnotehdimmodetim}}%
234 {\multiply\vlnnotehdim by\vlnlasttimenum\relax%
235 \divide\vlnnotehdim by\vlnlasttimeden\relax%
237 % Automatic staff break
238 \count@\vlnnotehskip\relax%
239 \advance\count@ by\vlnnotehdim\relax%
240 \ifnum\count@>\vlnstaffhsize\vlnstaff\fi%
241 \def\vlnnotehdimmodetxtdo{%
243 \ifthenelse{\equal{}{\vlnnotehdimmodetxt}}%
247 \ifthenelse{\equal{\vlnlasttimeden}{1}}%
248 {{\vlntimefont{\vlnlasttimenum}}}%
249 {\vlntimefrac{\vlntimefont{\vlnlasttimenum}}/{\vlntimefont{\vlnlasttimeden}}}%
251 \nobreak\vskip\vlnnotevdim\relax%
252 \nobreak\vskip0.2mm\relax%
253 \nobreak\hskip\vlnnotehdim\relax%
254 \nobreak\hskip-\wd0\relax%
259 \ifthenelse{\equal{#6/#7}{\vlnlasttimenum/\vlnlasttimeden}}%
261 {\vlndoatnote{\vlnlastpos}%
263 {\vlnnotehdimmodetxtdo}%
267 \ifthenelse{\equal{#4}{C}}%
268 {\ifthenelse{\equal{U}{\vlnlastrealbow}}%
269 {\def\vlnlastbow{D}}%
270 {\def\vlnlastbow{U}}}%
271 {\ifthenelse{\equal{#4}{.}}%
272 {\def\vlnlastbow{\vlnlastrealbow}}%
273 {\def\vlnlastbow{#4}}}%
274 \ifthenelse{\equal{\vlnlastbow}{N}}%
276 {\edef\vlnlastrealbow{\vlnlastbow}}%
277 \vlndoatnote{\vlnlastpos}%
278 {\begingroup\expandafter\color{colVlnBow\vlnlastbow}}%
281 \ifthenelse{\equal{\vlnlastbow}{N}}
284 \vrule depth 0pt height \vlnnotevdim width \vlnnotehdim\relax%
285 \nobreak\hskip-\vlnnotehdim\relax%
287 \divide\dimen@ by3\relax%
288 \dimen@@\vlnnotehdim%
289 \divide\dimen@@ by2\relax%
290 \ifthenelse{\equal{\vlncrescleft}{}}%
292 \ifthenelse{\equal{\vlncrescright}{}}%
296 \vrule depth 0pt height 0pt width \dimen@@\relax%
297 \color{colVlnCresc\vlncrescright}%
298 \vrule depth 0pt height \dimen@ width \dimen@@\relax%
302 \ifthenelse{\equal{\vlncrescright}{}}%
304 \color{colVlnCresc\vlncrescleft}%
305 \vrule depth 0pt height \dimen@ width \dimen@@\relax%
308 \color{colVlnCresc\vlncrescleft}%
309 \vrule depth 0pt height \dimen@ width \dimen@@\relax%
310 \color{colVlnCresc\vlncrescright}%
311 \vrule depth 0pt height \dimen@ width \dimen@@\relax%
314 \global\let\vlncrescleft\vlncrescright%
320 \ifthenelse{\equal{#1}{\vlnlastcord}}%
322 {\ifthenelse{\equal{#1}{.}}%
324 {\def\vlnlastcord{#1}%
325 %\vlndoatnote{\vlnlastpos}%
328 % \setbox0=\hbox{{\vlncordfont{%
330 % \advance\count@ by1\relax%
332 % \or 0\or 1\or 2\or 3%
334 % %\nobreak\vskip\vlnnotevdim\relax%
335 % %\nobreak\vskip0.2mm\relax%
336 % \nobreak\vskip-0.2mm\relax%
337 % \nobreak\vskip-\ht0\relax%
338 % \nobreak\hskip\vlnnotehdim\relax%
339 % \nobreak\hskip-\wd0\relax%
345 \ifthenelse{\equal{#3}{.}}%
347 {\vlnlastfinger#3\relax}%
348 \ifthenelse{\equal{\vlnlastbow}{N}%
349 % \OR\equal{\the\vlnlastfinger}{\vlnlastfingerpos}%
350 % \AND\equal{\the\vlnlastpos}{\vlnlastposfinger}%
351 % \AND\equal{\the\vlnlastcord}{\thevlnlastlastcord}%
355 \expandafter\edef\csname vlnlastfingerpos\romannumeralz\vlnlastpos\endcsname{\the\vlnlastfinger}%
356 \expandafter\edef\csname vlnlastposfinger\romannumeralz\vlnlastfinger\endcsname{\the\vlnlastpos}%
357 \vlndoatnote{\vlnlastpos}%
360 \setbox0=\hbox{{\vlnfingerfont{\the\vlnlastfinger}}}%
361 \nobreak\vskip\vlnnotevdim\relax%
362 \nobreak\vskip0.2mm\relax%
363 \dp0=0pt\relax% NOTE: to prevent fonts like pnc to mess up the vertical alignment
368 \ifthenelse{\equal{#5}{\vlnlastname}\AND\equal{#2}{\vlnlastpos}}%
371 \def\vlnlastname{#5}%
372 \expandafter\edef\csname vlnlastposname\romannumeralz\vlnlastpos\endcsname{#5}%
373 \ifthenelse{\equal{\vlnlastbow}{N}}%
375 {%\edef\vlnlastname{#5}%
376 \vlndoatnote{\vlnlastpos}%
379 \setbox0=\hbox{{\vlnnamefont{#5}}}%
380 \nobreak\vskip-0.275mm\relax%
381 \nobreak\vskip-\ht0\relax%
383 \dp0=0pt\relax% NOTE: to prevent fonts like pnc to mess up the vertical alignment
399 \def\vlncordposi{0}% G
400 \def\vlncordposii{7}% D
401 \def\vlncordposiii{14}% A
402 \def\vlncordposiv{21}% E
405 % Demi-tons alphabétiques sans modification
406 \expandafter\def\csname vlnnotetoneofnameG=\endcsname{0}%
407 \expandafter\def\csname vlnnotetoneofnameG+\endcsname{1}%
408 \expandafter\def\csname vlnnotetoneofnameA-\endcsname{1}%
409 \expandafter\def\csname vlnnotetoneofnameA=\endcsname{2}%
410 \expandafter\def\csname vlnnotetoneofnameA+\endcsname{3}%
411 \expandafter\def\csname vlnnotetoneofnameB-\endcsname{3}%
412 \expandafter\def\csname vlnnotetoneofnameB=\endcsname{4}%
413 \expandafter\def\csname vlnnotetoneofnameB+\endcsname{5}%
414 \expandafter\def\csname vlnnotetoneofnameC-\endcsname{4}%
415 \expandafter\def\csname vlnnotetoneofnameC=\endcsname{5}%
416 \expandafter\def\csname vlnnotetoneofnameC+\endcsname{6}%
417 \expandafter\def\csname vlnnotetoneofnameD-\endcsname{6}%
418 \expandafter\def\csname vlnnotetoneofnameD=\endcsname{7}%
419 \expandafter\def\csname vlnnotetoneofnameD+\endcsname{8}%
420 \expandafter\def\csname vlnnotetoneofnameE-\endcsname{8}%
421 \expandafter\def\csname vlnnotetoneofnameE=\endcsname{9}%
422 \expandafter\def\csname vlnnotetoneofnameE+\endcsname{10}%
423 \expandafter\def\csname vlnnotetoneofnameF-\endcsname{9}%
424 \expandafter\def\csname vlnnotetoneofnameF=\endcsname{10}%
425 \expandafter\def\csname vlnnotetoneofnameF+\endcsname{11}%
426 \expandafter\def\csname vlnnotetoneofnameG-\endcsname{11}%
428 \expandafter\def\csname vlnshiftsymbol-\endcsname{\kern-0.7pt$\flat$}%
429 \expandafter\def\csname vlnshiftsymbol=\endcsname{}%
430 \expandafter\def\csname vlnshiftsymbol+\endcsname{\kern-0.7pt$\sharp$}%
431 \def\vlnnotedrawtonebyname#1#2#3#4#5#6{%
432 \ifthenelse{\equal{#1}{.}}%
434 {\vlnlastposoctave#1\relax}%
435 \ifthenelse{\equal{#2}{.}}%
437 {\def\vlnlastletter{#2}}%
438 \ifthenelse{\equal{#3}{.}}%
440 {\def\vlnlastshift{#3}}%
441 \edef\tmp{\csname vlnnotetoneofname\vlnlastletter\vlnlastshift\endcsname}%
443 \count@\vlnlastposoctave\relax%
444 \multiply\count@ by12\relax%
445 \advance\vlnnotepos by\count@%
446 \ifthenelse{\equal{#4}{.}}%
447 {\count@\vlnlastcord}%
449 \advance\count@ by1\relax%
450 \advance\vlnnotepos by-\csname vlncordpos\romannumeralz\count@\endcsname%
451 \edef\nam{\vlnlastletter\csname vlnshiftsymbol\vlnlastshift\endcsname}%
452 \vlnnotedraw crd{#4}pos{\the\vlnnotepos}fgr{#5}bow{#6}nam{\nam}tim%
458 \setbox0=\hbox{{\vlnpartfont{#1}}}%
459 \nobreak\vskip-0.3mm\relax%
460 \nobreak\vskip-\ht0\relax%
461 \dp0=0pt\relax% NOTE: to prevent fonts like pnc to mess up the vertical alignment
469 \dimen@\vlnstaffvdim%
470 \advance\dimen@ by -\vlnnotevdim\relax%
471 \advance\dimen@ by -\vlnnotevdim\relax%
472 \setbox0=\hbox{{\color{colVlnBar}\vrule depth 0pt height \dimen@ width 0.1pt\relax}}%
473 \nobreak\vskip\vlnnotevdim\relax%
479 \global\let\vlncrescleft\vlncrescright%
480 \xdef\vlncrescright{#1}%