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\vlnhalftonelinevdim
67 \newskip\vlnhalftonelineskip%
68 \newskip\vlntonesskip%
70 \vlnhalftonelinevdim=0.5pt%
71 \vlntonesskip=0pt\relax%
72 \vlnhalftonelineskip=4pt\relax%
73 \advance\vlnhalftonelineskip by -\vlnhalftonelinevdim%
74 \def\vlnhalftoneline{%
75 {\color{colVlnLineHalfTone}\hrule depth 0pt height \vlnhalftonelinevdim width \hsize }}%
76 \def\vlnbasehalftoneline{%
77 {\color{colVlnLineHalfToneBase}\hrule depth 0pt height \vlnhalftonelinevdim width \hsize }}%
79 \advance\vlntonesskip by\vlnhalftonelineskip%
80 \advance\vlntonesskip by\vlnhalftonelinevdim%
81 \vskip\vlnhalftonelineskip%
83 \def\vlnfivehalftonelines{%
84 \toneskip\vlnhalftoneline%
85 \toneskip\vlnhalftoneline%
86 \toneskip\vlnhalftoneline%
87 \toneskip\vlnhalftoneline%
88 \toneskip\vlnbasehalftoneline%
90 \def\allhalftonelines{%
91 \vlnfivehalftonelines%
92 \vlnfivehalftonelines%
93 \vlnfivehalftonelines%
94 \vlnfivehalftonelines%
99 \advance\vlntonesskip by\vlnhalftonelinevdim%
100 \vskip-\vlntonesskip%
105 \newskip\vlnnotevskip%
106 \newskip\vlnnotevskipbase%
107 \newskip\vlnnotehskip%
108 \newskip\vlnnotehskipbase%
109 \newdimen\vlnnotevdim%
110 \newdimen\vlnnotevdimmore%
111 \newdimen\vlnnotehdim%
112 \newdimen\vlnnotehdimbase%
113 \newcount\vlnlastfinger%
114 \newcount\vlnlastposbase%
115 \newcount\vlnlastposunit%
116 \newcount\vlnnotepos%
117 \newcount\vlnlastpos%
119 \vlnnotevskip=0pt\relax%
120 \vlnnotevskipbase=0pt\relax%
121 \vlnnotehskip=0pt\relax%
122 \vlnnotehskipbase=0pt\relax%
123 \vlnnotevdim=\vlnhalftonelinevdim%
124 \vlnnotevdimmore=1pt\relax%
125 \vlnnotehdimbase=2cm\relax%
126 \advance\vlnnotevdim by \vlnnotevdimmore%
127 \advance\vlnnotevdim by \vlnnotevdimmore%
130 \def\vlnlasttimenum{}%
131 \def\vlnlasttimeden{}%
132 \def\vlnnotehdimmodetim{1}%
133 \def\vlnnotehdimmodetxt{}%
134 \parindent=0pt\relax%
136 \parfillskip=0pt\relax%
137 \def\vlnlastposfinger{%
138 \csname vlnlastposfinger\romannumeral\vlnlastfinger\endcsname%
140 \def\vlnlastfingerpos{%
141 \csname vlnlastfingerpos\romannumeral\vlnlastpos\endcsname%
143 \def\vlntimefrac#1/#2{%
146 \kern-.4ex\lower.3ex\hbox{\bfseries\tiny /}%
147 \kern-.3ex\lower.6ex\hbox{#2}%
149 \def\vlndoatnote#1#2#3#4{%
151 \vlnnotevskip\vlnhalftonelineskip%
152 \advance\vlnnotevskip by\vlnhalftonelinevdim\relax%
153 \multiply\vlnnotevskip by#1\relax%
154 \advance\vlnnotevskip by-\vlnnotevdimmore\relax%
155 \vskip\vlnnotevskip\relax%
156 \vskip-\vlnnotevskip\relax%
157 \vskip\vlnnotevskip\relax%
158 \vrule depth 0pt height 0pt width \vlnnotehskip\relax%
160 \advance\vlnnotevskip by \ht0\relax%
164 \vskip-\vlnnotevskip\relax%
168 \advance\vlnnotehskip by\vlnnotehdim\relax%
170 \def\vlnnotedraw crd#1pos#2fgr#3bow#4tim#5#6{%
172 \ifthenelse{\equal{#2}{.}}%
174 {\vlnlastpos#2\relax}%
176 \ifthenelse{\equal{#5/#6}{\vlnlasttimenum/\vlnlasttimeden}}%
178 {\ifthenelse{\equal{#5/#6}{./.}}%
180 {\vlndoatnote{\vlnlastpos}%
182 {\ifthenelse{\equal{#5}{.}}%
184 {\def\vlnlasttimenum{#5}}%
185 \ifthenelse{\equal{#6}{.}}%
187 {\def\vlnlasttimeden{#6}}%
188 \vlnnotehdim\vlnnotehdimbase%
189 \ifthenelse{\equal{}{\vlnnotehdimmodetim}}%
191 {\multiply\vlnnotehdim by\vlnlasttimenum\relax%
192 \divide\vlnnotehdim by\vlnlasttimeden\relax%
194 \ifthenelse{\equal{}{\vlnnotehdimmodetxt}}%
198 \ifthenelse{\equal{\vlnlasttimeden}{1}}%
199 {{\vlntimefont{\vlnlasttimenum}}}%
200 {\vlntimefrac{\vlntimefont{\vlnlasttimenum}}/{\vlntimefont{\vlnlasttimeden}}}%
202 \vskip\vlnnotevdim\relax%
204 \hskip\vlnnotehdim\relax%
214 \ifthenelse{\equal{#4}{C}}%
215 {\ifthenelse{\equal{U}{\vlnlastbow}}%
216 {\def\vlnlastbow{D}}%
217 {\def\vlnlastbow{U}}}%
218 {\ifthenelse{\equal{#4}{.}}%
220 {\def\vlnlastbow{#4}}}%
221 \vlndoatnote{\vlnlastpos}%
222 {\begingroup\expandafter\color{colVlnBow\vlnlastbow}}%
225 \vrule depth 0pt height \vlnnotevdim width \vlnnotehdim\relax%
230 \ifthenelse{\equal{#3}{.}}%
232 {\vlnlastfinger#3\relax}%
233 \ifthenelse{\equal{\the\vlnlastfinger}{\vlnlastfingerpos}\AND\equal{\the\vlnlastpos}{\vlnlastposfinger}}%
236 \expandafter\edef\csname vlnlastfingerpos\romannumeral\vlnlastpos\endcsname{\the\vlnlastfinger}\relax%
237 \expandafter\edef\csname vlnlastposfinger\romannumeral\vlnlastfinger\endcsname{\the\vlnlastpos}\relax%
238 \vlndoatnote{\vlnlastpos}%
241 \setbox0=\hbox{{\vlnfingerfont{\the\vlnlastfinger}}}%
245 \dp0=0pt\relax% NOTE: to prevent fonts like pnc to mess up the vertical alignment
250 \ifthenelse{\equal{#1}{\vlnlastcord}}%
252 {\ifthenelse{\equal{#1}{.}}%
254 {\def\vlnlastcord{#1}%
255 \vlndoatnote{\vlnlastpos}%
258 \setbox0=\hbox{{\vlncordfont{%
260 \advance\count@ by1\relax%
262 \or 0\or I\or II\or III%
264 \vskip\vlnnotevdim\relax%
274 \def\vlncordposi{0}% G
275 \def\vlncordposii{7}% D
276 \def\vlncordposiii{14}% A
277 \def\vlncordposiv{21}% E
280 \def\vlnnotedrawtone#1#2#3#4#5{%
281 \ifthenelse{\equal{#1}{.}}%
283 {\vlnlastposbase#1\relax}%
284 \ifthenelse{\equal{#2}{.}}%
286 {\vlnlastposunit#2\relax}%
287 \ifthenelse{\equal{#3}{.}}%
288 {\vlnnotepos\vlnlastcord\relax}%
289 {\vlnnotepos#3\relax}%
290 \advance\vlnnotepos by1\relax%
291 \expandafter\vlnnotepos-\csname vlncordpos\romannumeral\vlnnotepos\endcsname\relax%
292 \ifthenelse{\equal{\the\vlnlastposbase}{0}}%
293 {\advance\vlnnotepos by\vlnlastposunit\relax}%
294 {\edef\tmp{\the\vlnlastposbase\the\vlnlastposunit}%
295 \advance\vlnnotepos by\tmp\relax}%
297 \vlnnotedraw crd{#3}pos{\the\vlnnotepos}fgr{#4}bow{#5}tim%
299 \def\vlnnoteshift#1{%
301 \modulo{\count@}{#1}%
302 \advance\count@ by1\relax%
303 \edef\tmp{\csname vlnnoteshift\romannumeral\count@\endcsname}%
304 \ifthenelse{\equal{\tmp}{}}%
306 {\advance\vlnnotepos by\tmp\relax}%