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\vlnstaffhalftonelinevdim%
67 \newskip\vlnstaffhalftonelinevskip%
68 \newskip\vlnstaffvdim%
70 \vlnstaffhalftonelinevdim=0.5pt%
71 \vlnstaffvdim=0pt\relax%
72 \vlnstaffhalftonelinevskip=4pt\relax%
73 \advance\vlnstaffhalftonelinevskip by-\vlnstaffhalftonelinevdim%
74 \def\vlnstaffhalftoneline{%
75 {\color{colVlnLineHalfTone}\hrule depth 0pt height \vlnstaffhalftonelinevdim width \hsize }}%
76 \def\vlnbasehalftoneline{%
77 {\color{colVlnLineHalfToneBase}\hrule depth 0pt height \vlnstaffhalftonelinevdim width \hsize }}%
78 \def\vlnstafftoneskip{%
79 \advance\vlnstaffvdim by\vlnstaffhalftonelinevskip%
80 \advance\vlnstaffvdim by\vlnstaffhalftonelinevdim%
81 \vskip\vlnstaffhalftonelinevskip%
83 \def\vlnstafffivehalftonelines{%
84 \vlnstafftoneskip\vlnstaffhalftoneline%
85 \vlnstafftoneskip\vlnstaffhalftoneline%
86 \vlnstafftoneskip\vlnstaffhalftoneline%
87 \vlnstafftoneskip\vlnstaffhalftoneline%
88 \vlnstafftoneskip\vlnbasehalftoneline%
90 \def\vlnstaffallhalftonelines{%
91 \vlnstafffivehalftonelines%
92 \vlnstafffivehalftonelines%
93 \vlnstafffivehalftonelines%
94 \vlnstafffivehalftonelines%
98 \vlnnotehskip=0pt\relax%
99 \vlnstaffvdim=0pt\relax%
100 \vlnbasehalftoneline%
101 \vlnstaffallhalftonelines%
102 \advance\vlnstaffvdim by\vlnstaffhalftonelinevdim%
103 \vskip-\vlnstaffvdim%
108 \newskip\vlnnotevskip%
109 \newskip\vlnnotevskipbase%
110 \newskip\vlnnotehskip%
111 \newskip\vlnnotehskipbase%
112 \newdimen\vlnnotevdim%
113 \newdimen\vlnnotevdimmore%
114 \newdimen\vlnnotehdim%
115 \newdimen\vlnnotehdimbase%
116 \newcount\vlnlastfinger%
117 \newcount\vlnlastposbase%
118 \newcount\vlnlastposunit%
119 \newcount\vlnnotepos%
120 \newcount\vlnlastpos%
122 \vlnnotevskip=0pt\relax%
123 \vlnnotevskipbase=0pt\relax%
124 \vlnnotehskip=0pt\relax%
125 \vlnnotehskipbase=0pt\relax%
126 \vlnnotevdim=\vlnstaffhalftonelinevdim%
127 \vlnnotevdimmore=1pt\relax%
128 \vlnnotehdimbase=2cm\relax%
129 \advance\vlnnotevdim by\vlnnotevdimmore%
130 \advance\vlnnotevdim by\vlnnotevdimmore%
133 \def\vlnlasttimenum{}%
134 \def\vlnlasttimeden{}%
135 \def\vlnnotehdimmodetim{1}%
136 \def\vlnnotehdimmodetxt{}%
137 \parindent=0pt\relax%
139 \parfillskip=0pt\relax%
140 \def\vlnlastposfinger{%
141 \csname vlnlastposfinger\romannumeral\vlnlastfinger\endcsname%
143 \def\vlnlastfingerpos{%
144 \csname vlnlastfingerpos\romannumeral\vlnlastpos\endcsname%
146 \def\vlntimefrac#1/#2{%
149 \kern-.4ex\lower.3ex\hbox{\bfseries\tiny /}%
150 \kern-.3ex\lower.6ex\hbox{#2}%
152 \def\vlndoatnote#1#2#3#4{%
154 \vlnnotevskip\vlnstaffhalftonelinevskip%
155 \advance\vlnnotevskip by\vlnstaffhalftonelinevdim\relax%
156 \multiply\vlnnotevskip by#1\relax%
157 \advance\vlnnotevskip by-\vlnnotevdimmore\relax%
158 \vskip\vlnnotevskip\relax%
159 \vskip-\vlnnotevskip\relax%
160 \vskip\vlnnotevskip\relax%
161 \vrule depth 0pt height 0pt width \vlnnotehskip\relax%
163 \advance\vlnnotevskip by \ht0\relax%
167 \vskip-\vlnnotevskip\relax%
171 \advance\vlnnotehskip by\vlnnotehdim\relax%
173 \def\vlnnotedraw crd#1pos#2fgr#3bow#4tim#5#6{%
175 \ifthenelse{\equal{#2}{.}}%
177 {\vlnlastpos#2\relax}%
179 \ifthenelse{\equal{#5/#6}{\vlnlasttimenum/\vlnlasttimeden}}%
181 {\ifthenelse{\equal{#5/#6}{./.}}%
183 {\vlndoatnote{\vlnlastpos}%
185 {\ifthenelse{\equal{#5}{.}}%
187 {\def\vlnlasttimenum{#5}}%
188 \ifthenelse{\equal{#6}{.}}%
190 {\def\vlnlasttimeden{#6}}%
191 \vlnnotehdim\vlnnotehdimbase%
192 \ifthenelse{\equal{}{\vlnnotehdimmodetim}}%
194 {\multiply\vlnnotehdim by\vlnlasttimenum\relax%
195 \divide\vlnnotehdim by\vlnlasttimeden\relax%
197 \ifthenelse{\equal{}{\vlnnotehdimmodetxt}}%
201 \ifthenelse{\equal{\vlnlasttimeden}{1}}%
202 {{\vlntimefont{\vlnlasttimenum}}}%
203 {\vlntimefrac{\vlntimefont{\vlnlasttimenum}}/{\vlntimefont{\vlnlasttimeden}}}%
205 \vskip\vlnnotevdim\relax%
207 \hskip\vlnnotehdim\relax%
217 \ifthenelse{\equal{#4}{C}}%
218 {\ifthenelse{\equal{U}{\vlnlastbow}}%
219 {\def\vlnlastbow{D}}%
220 {\def\vlnlastbow{U}}}%
221 {\ifthenelse{\equal{#4}{.}}%
223 {\def\vlnlastbow{#4}}}%
224 \vlndoatnote{\vlnlastpos}%
225 {\begingroup\expandafter\color{colVlnBow\vlnlastbow}}%
228 \vrule depth 0pt height \vlnnotevdim width \vlnnotehdim\relax%
233 \ifthenelse{\equal{#3}{.}}%
235 {\vlnlastfinger#3\relax}%
236 \ifthenelse{\equal{\the\vlnlastfinger}{\vlnlastfingerpos}\AND\equal{\the\vlnlastpos}{\vlnlastposfinger}}%
239 \expandafter\edef\csname vlnlastfingerpos\romannumeral\vlnlastpos\endcsname{\the\vlnlastfinger}\relax%
240 \expandafter\edef\csname vlnlastposfinger\romannumeral\vlnlastfinger\endcsname{\the\vlnlastpos}\relax%
241 \vlndoatnote{\vlnlastpos}%
244 \setbox0=\hbox{{\vlnfingerfont{\the\vlnlastfinger}}}%
248 \dp0=0pt\relax% NOTE: to prevent fonts like pnc to mess up the vertical alignment
253 \ifthenelse{\equal{#1}{\vlnlastcord}}%
255 {\ifthenelse{\equal{#1}{.}}%
257 {\def\vlnlastcord{#1}%
258 \vlndoatnote{\vlnlastpos}%
261 \setbox0=\hbox{{\vlncordfont{%
263 \advance\count@ by1\relax%
265 \or 0\or I\or II\or III%
267 \vskip\vlnnotevdim\relax%
277 \def\vlncordposi{0}% G
278 \def\vlncordposii{7}% D
279 \def\vlncordposiii{14}% A
280 \def\vlncordposiv{21}% E
283 \def\vlnnotedrawtone#1#2#3#4#5{%
284 \ifthenelse{\equal{#1}{.}}%
286 {\vlnlastposbase#1\relax}%
287 \ifthenelse{\equal{#2}{.}}%
289 {\vlnlastposunit#2\relax}%
290 \ifthenelse{\equal{#3}{.}}%
291 {\vlnnotepos\vlnlastcord\relax}%
292 {\vlnnotepos#3\relax}%
293 \advance\vlnnotepos by1\relax%
294 \expandafter\vlnnotepos-\csname vlncordpos\romannumeral\vlnnotepos\endcsname\relax%
295 \ifthenelse{\equal{\the\vlnlastposbase}{0}}%
296 {\advance\vlnnotepos by\vlnlastposunit\relax}%
297 {\edef\tmp{\the\vlnlastposbase\the\vlnlastposunit}%
298 \advance\vlnnotepos by\tmp\relax}%
300 \vlnnotedraw crd{#3}pos{\the\vlnnotepos}fgr{#4}bow{#5}tim%
302 \def\vlnnoteshift#1{%
304 \modulo{\count@}{#1}%
305 \advance\count@ by1\relax%
306 \edef\tmp{\csname vlnnoteshift\romannumeral\count@\endcsname}%
307 \ifthenelse{\equal{\tmp}{}}%
309 {\advance\vlnnotepos by\tmp\relax}%