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%
53 \definecolor{colVlnBowUp}{rgb}{0.24,0.92,0.24}%
54 \definecolor{colVlnBowDn}{rgb}{1,0,0}%
55 \definecolor{colVlnBowU}{rgb}{0.24,0.92,0.24}%
56 \definecolor{colVlnBowD}{rgb}{1,0,0}%
57 \definecolor{colVlnLineHalfTone}{gray}{0.90}%
58 \definecolor{colVlnLineHalfToneBase}{gray}{0.50}%
61 \newdimen\vlnhalftonelinevdim
62 \newskip\vlnhalftonelineskip%
63 \newskip\vlntonesskip%
65 \vlnhalftonelinevdim=0.5pt%
66 \vlntonesskip=0pt\relax%
67 \vlnhalftonelineskip=4pt\relax%
68 \advance\vlnhalftonelineskip by -\vlnhalftonelinevdim%
69 \def\vlnhalftoneline{%
70 {\color{colVlnLineHalfTone}\hrule depth 0pt height \vlnhalftonelinevdim width \hsize }}%
71 \def\vlnbasehalftoneline{%
72 {\color{colVlnLineHalfToneBase}\hrule depth 0pt height \vlnhalftonelinevdim width \hsize }}%
74 \advance\vlntonesskip by\vlnhalftonelineskip%
75 \advance\vlntonesskip by\vlnhalftonelinevdim%
76 \vskip\vlnhalftonelineskip%
78 \def\vlnfivehalftonelines{%
79 \toneskip\vlnhalftoneline%
80 \toneskip\vlnhalftoneline%
81 \toneskip\vlnhalftoneline%
82 \toneskip\vlnhalftoneline%
83 \toneskip\vlnbasehalftoneline%
85 \def\allhalftonelines{%
86 \vlnfivehalftonelines%
87 \vlnfivehalftonelines%
88 \vlnfivehalftonelines%
89 \vlnfivehalftonelines%
94 \advance\vlntonesskip by\vlnhalftonelinevdim%
100 \newskip\vlnnotevskip%
101 \newskip\vlnnotevskipbase%
102 \newskip\vlnnotehskip%
103 \newskip\vlnnotehskipbase%
104 \newdimen\vlnnotevdim%
105 \newdimen\vlnnotevdimmore%
106 \newdimen\vlnnotehdim%
107 \newdimen\vlnnotehdimbase%
108 \newcount\vlnlastfinger%
109 \newcount\vlnlastposbase%
110 \newcount\vlnlastposunit%
111 \newcount\vlnnotepos%
113 \vlnnotevskip=0pt\relax%
114 \vlnnotevskipbase=0pt\relax%
115 \vlnnotehskip=0pt\relax%
116 \vlnnotehskipbase=0pt\relax%
117 \vlnnotevdim=\vlnhalftonelinevdim%
118 \vlnnotevdimmore=1pt\relax%
119 \vlnnotehdimbase=2cm\relax%
120 \advance\vlnnotevdim by \vlnnotevdimmore%
121 \advance\vlnnotevdim by \vlnnotevdimmore%
124 \def\vlnlasttimenum{}%
125 \def\vlnlasttimeden{}%
126 \def\vlnnotehdimmodetim{1}%
127 \def\vlnnotehdimmodetxt{}%
128 \parindent=0pt\relax%
130 \parfillskip=0pt\relax%
131 \def\vlnlastfingerpos{%
132 \csname vlnlastfingerpos\romannumeral\vlnlastfinger\endcsname%
134 \def\vlntimefrac#1/#2{%
137 \kern-.4ex\lower.3ex\hbox{\bfseries\tiny /}%
138 \kern-.3ex\lower.6ex\hbox{#2}%
140 \def\vlndoatnote#1#2#3#4{%
142 \vlnnotevskip\vlnhalftonelineskip%
143 \advance\vlnnotevskip by\vlnhalftonelinevdim\relax%
144 \multiply\vlnnotevskip by#1\relax%
145 \advance\vlnnotevskip by-\vlnnotevdimmore\relax%
146 \vskip\vlnnotevskip\relax%
147 \vskip-\vlnnotevskip\relax%
148 \vskip\vlnnotevskip\relax%
149 \vrule depth 0pt height 0pt width \vlnnotehskip\relax%
151 \advance\vlnnotevskip by \ht0\relax%
155 \vskip-\vlnnotevskip\relax%
159 \advance\vlnnotehskip by\vlnnotehdim\relax%
161 \def\vlnnotedraw crd#1pos#2fgr#3bow#4tim#5#6{%
163 \ifthenelse{\equal{#5/#6}{\vlnlasttimenum/\vlnlasttimeden}}%
165 {\ifthenelse{\equal{#5/#6}{./.}}%
169 {\ifthenelse{\equal{#5}{.}}%
171 {\def\vlnlasttimenum{#5}}%
172 \ifthenelse{\equal{#6}{.}}%
174 {\def\vlnlasttimeden{#6}}%
175 \vlnnotehdim\vlnnotehdimbase%
176 \ifthenelse{\equal{}{\vlnnotehdimmodetim}}%
178 {\multiply\vlnnotehdim by\vlnlasttimenum\relax%
179 \divide\vlnnotehdim by\vlnlasttimeden\relax%
181 \ifthenelse{\equal{}{\vlnnotehdimmodetxt}}%
185 \ifthenelse{\equal{\vlnlasttimeden}{1}}%
186 {{\vlntimefont{\vlnlasttimenum}}}%
187 {\vlntimefrac{\vlntimefont{\vlnlasttimenum}}/{\vlntimefont{\vlnlasttimeden}}}%
189 \vskip\vlnnotevdim\relax%
199 \ifthenelse{\equal{#4}{C}}%
200 {\ifthenelse{\equal{U}{\vlnlastbow}}%
201 {\def\vlnlastbow{D}}%
202 {\def\vlnlastbow{U}}}%
203 {\ifthenelse{\equal{#4}{.}}%
205 {\def\vlnlastbow{#4}}}%
207 {\begingroup\expandafter\color{colVlnBow\vlnlastbow}}%
210 \vrule depth 0pt height \vlnnotevdim width \vlnnotehdim\relax%
215 \ifthenelse{\equal{#3}{.}}%
217 {\vlnlastfinger#3\relax}%
218 \ifthenelse{\equal{#2}{\vlnlastfingerpos}}%
221 \expandafter\edef\csname vlnlastfingerpos\romannumeral\vlnlastfinger\endcsname{#2}\relax%
225 \setbox0=\hbox{{\vlnfingerfont{\the\vlnlastfinger}}}%
229 \dp0=0pt\relax% NOTE: to prevent fonts like pnc to mess up the vertical alignment
230 \hskip\vlnnotehdim\relax%
236 \ifthenelse{\equal{#1}{\vlnlastcord}}%
238 {\ifthenelse{\equal{#1}{.}}%
240 {\def\vlnlastcord{#1}%
244 \setbox0=\hbox{{\vlncordfont{%
246 \advance\count@ by1\relax%
248 \or 0\or I\or II\or III%
250 \vskip\vlnnotevdim\relax%
252 \hskip\vlnnotehdim\relax%
262 \def\vlncordposi{0}% G
263 \def\vlncordposii{7}% D
264 \def\vlncordposiii{14}% A
265 \def\vlncordposiv{21}% E
268 \def\vlnnotedrawtone#1#2#3#4#5{%
269 \ifthenelse{\equal{#1}{.}}%
271 {\vlnlastposbase#1\relax}%
272 \ifthenelse{\equal{#2}{.}}%
274 {\vlnlastposunit#2\relax}%
275 \ifthenelse{\equal{#3}{.}}%
276 {\vlnnotepos\vlnlastcord\relax}%
277 {\vlnnotepos#3\relax}%
278 \advance\vlnnotepos by1\relax%
279 \expandafter\vlnnotepos-\csname vlncordpos\romannumeral\vlnnotepos\endcsname\relax%
280 \ifthenelse{\equal{\the\vlnlastposbase}{0}}%
281 {\advance\vlnnotepos by\vlnlastposunit\relax}%
282 {\edef\tmp{\the\vlnlastposbase\the\vlnlastposunit}%
283 \advance\vlnnotepos by\tmp\relax}%
285 \vlnnotedraw crd{#3}pos{\the\vlnnotepos}fgr{#4}bow{#5}tim%
287 \def\vlnnoteshift#1{%
289 \modulo{\count@}{#1}%
290 \advance\count@ by1\relax%
291 \edef\tmp{\csname vlnnoteshift\romannumeral\count@\endcsname}%
292 \ifthenelse{\equal{\tmp}{}}%
294 {\advance\vlnnotepos by\tmp\relax}%