]> Git — Sourcephile - julm/violon-tex.git/blob - violon.sty
Correction : affichage des cordes : 0 I II puis III.
[julm/violon-tex.git] / violon.sty
1 % This file is part of Violon, a violin score engine.
2 % Copyright (C) 2009 Julien Moutinho
3 %
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.
8 %
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.
13 %
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/>.
16
17 % Any comment or contribution is welcome
18 % at julm arobase julm dot meeee dot eu.
19
20 % Déclaration
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)]%
26 % Bibliothèques
27 \usepackage{ifthen}%
28 \usepackage{color}%
29 % Polices
30 \gdef\ssssmall{%
31 \@setfontsize\sssmall{5pt}{5pt}}%
32 \gdef\sssmall{%
33 \@setfontsize\sssmall{6pt}{6pt}}%
34 \gdef\ssmall{%
35 \@setfontsize\ssmall\@viiipt\@ixpt}%
36 \gdef\vlnfingerfont{%
37 \fontfamily{pnc}\bfseries\sssmall}%
38 \gdef\vlncordfont{%
39 \fontfamily{pnc}\scshape\ssssmall}%
40 \gdef\vlntimefont{%
41 \fontfamily{pnc}\bfseries\ssssmall}%
42 % Algèbre
43 \newcount\@calc@mod@cnt%
44 \def\modulo#1#2{%
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%
49 }%
50 % Moteur
51 % Constantes
52 % Couleurs
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}%
59 % Portée
60 % Déclarations
61 \newdimen\vlnhalftonelinevdim
62 \newskip\vlnhalftonelineskip%
63 \newskip\vlntonesskip%
64 % Initialisations
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 }}%
73 \def\toneskip{%
74 \advance\vlntonesskip by\vlnhalftonelineskip%
75 \advance\vlntonesskip by\vlnhalftonelinevdim%
76 \vskip\vlnhalftonelineskip%
77 }%
78 \def\vlnfivehalftonelines{%
79 \toneskip\vlnhalftoneline%
80 \toneskip\vlnhalftoneline%
81 \toneskip\vlnhalftoneline%
82 \toneskip\vlnhalftoneline%
83 \toneskip\vlnbasehalftoneline%
84 }%
85 \def\allhalftonelines{%
86 \vlnfivehalftonelines%
87 \vlnfivehalftonelines%
88 \vlnfivehalftonelines%
89 \vlnfivehalftonelines%
90 }%
91 \gdef\vlnlines{%
92 \vlnbasehalftoneline%
93 \allhalftonelines%
94 \advance\vlntonesskip by\vlnhalftonelinevdim%
95 \vskip-\vlntonesskip%
96 }%
97 % Notes
98 % Déclarations
99 % Variables
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%
112 % Initialisations
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%
122 \def\vlnlastbow{}%
123 \def\vlnlastcord{}%
124 \def\vlnlasttimenum{}%
125 \def\vlnlasttimeden{}%
126 \def\vlnnotehdimmodetim{1}%
127 \def\vlnnotehdimmodetxt{}%
128 \parindent=0pt\relax%
129 \parskip=0pt\relax%
130 \parfillskip=0pt\relax%
131 \def\vlnlastfingerpos{%
132 \csname vlnlastfingerpos\romannumeral\vlnlastfinger\endcsname%
133 }%
134 \def\vlntimefrac#1/#2{%
135 \leavevmode%
136 \hbox{#1}%
137 \kern-.4ex\lower.3ex\hbox{\bfseries\tiny /}%
138 \kern-.3ex\lower.6ex\hbox{#2}%
139 }%
140 \def\vlndoatnote#1#2#3#4{%
141 \nointerlineskip%
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%
150 \setbox0=#3%
151 \advance\vlnnotevskip by \ht0\relax%
152 #2%
153 \box0%
154 #4%
155 \vskip-\vlnnotevskip\relax%
156 \nointerlineskip%
157 }%
158 \def\vlnnextnote{%
159 \advance\vlnnotehskip by\vlnnotehdim\relax%
160 }%
161 \def\vlnnotedraw crd#1pos#2fgr#3bow#4tim#5#6{%
162 % Durée
163 \ifthenelse{\equal{#5/#6}{\vlnlasttimenum/\vlnlasttimeden}}%
164 {}%
165 {\ifthenelse{\equal{#5/#6}{./.}}%
166 {}%
167 {\vlndoatnote{#2}%
168 {}%
169 {\ifthenelse{\equal{#5}{.}}%
170 {}%
171 {\def\vlnlasttimenum{#5}}%
172 \ifthenelse{\equal{#6}{.}}%
173 {}%
174 {\def\vlnlasttimeden{#6}}%
175 \vlnnotehdim\vlnnotehdimbase%
176 \ifthenelse{\equal{}{\vlnnotehdimmodetim}}%
177 {}%
178 {\multiply\vlnnotehdim by\vlnlasttimenum\relax%
179 \divide\vlnnotehdim by\vlnlasttimeden\relax%
180 }%
181 \ifthenelse{\equal{}{\vlnnotehdimmodetxt}}%
182 {}%
183 {\vbox to0pt{%
184 \setbox0=\hbox{%
185 \ifthenelse{\equal{\vlnlasttimeden}{1}}%
186 {{\vlntimefont{\vlnlasttimenum}}}%
187 {\vlntimefrac{\vlntimefont{\vlnlasttimenum}}/{\vlntimefont{\vlnlasttimeden}}}%
188 }%
189 \vskip\vlnnotevdim\relax%
190 \vskip0.2mm\relax%
191 \dp0=0pt\relax%
192 \box0}%
193 }%
194 }%
195 {}%
196 }%
197 }%
198 % Archet
199 \ifthenelse{\equal{#4}{C}}%
200 {\ifthenelse{\equal{U}{\vlnlastbow}}%
201 {\def\vlnlastbow{D}}%
202 {\def\vlnlastbow{U}}}%
203 {\ifthenelse{\equal{#4}{.}}%
204 {}%
205 {\def\vlnlastbow{#4}}}%
206 \vlndoatnote{#2}%
207 {\begingroup\expandafter\color{colVlnBow\vlnlastbow}}%
208 {%
209 \hbox{%
210 \vrule depth 0pt height \vlnnotevdim width \vlnnotehdim\relax%
211 }%
212 }%
213 {\endgroup}%
214 % Doigts
215 \ifthenelse{\equal{#3}{.}}%
216 {}%
217 {\vlnlastfinger#3\relax}%
218 \ifthenelse{\equal{#2}{\vlnlastfingerpos}}%
219 {}%
220 {%
221 \expandafter\edef\csname vlnlastfingerpos\romannumeral\vlnlastfinger\endcsname{#2}\relax%
222 \vlndoatnote{#2}%
223 {}%
224 {\vbox to0pt{%
225 \setbox0=\hbox{{\vlnfingerfont{\the\vlnlastfinger}}}%
226 \vskip-0.2mm\relax%
227 \vskip-\ht0\relax%
228 %\vskip-\dp0\relax%
229 \dp0=0pt\relax% NOTE: to prevent fonts like pnc to mess up the vertical alignment
230 \hskip\vlnnotehdim\relax%
231 \hskip-\wd0\relax%
232 \box0}}%
233 {}%
234 }%
235 % Cordes
236 \ifthenelse{\equal{#1}{\vlnlastcord}}%
237 {}%
238 {\ifthenelse{\equal{#1}{.}}%
239 {}%
240 {\def\vlnlastcord{#1}%
241 \vlndoatnote{#2}%
242 {}%
243 {\vbox to0pt{%
244 \setbox0=\hbox{{\vlncordfont{%
245 \count@#1\relax%
246 \advance\count@ by1\relax%
247 \ifcase\count@%
248 \or 0\or I\or II\or III%
249 \fi}}}%
250 \vskip\vlnnotevdim\relax%
251 \vskip0.2mm\relax%
252 \hskip\vlnnotehdim\relax%
253 \hskip-\wd0\relax%
254 \box0}}%
255 {}%
256 }%
257 }%
258 \vlnnextnote%
259 \nointerlineskip%
260 }%
261 % Cordes
262 \def\vlncordposi{0}% G
263 \def\vlncordposii{7}% D
264 \def\vlncordposiii{14}% A
265 \def\vlncordposiv{21}% E
266 % Crochets
267 \def\vlnnotehook{}%
268 \def\vlnnotedrawtone#1#2#3#4#5{%
269 \ifthenelse{\equal{#1}{.}}%
270 {}%
271 {\vlnlastposbase#1\relax}%
272 \ifthenelse{\equal{#2}{.}}%
273 {}%
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}%
284 \vlnnotehook%
285 \vlnnotedraw crd{#3}pos{\the\vlnnotepos}fgr{#4}bow{#5}tim%
286 }%
287 \def\vlnnoteshift#1{%
288 \count@\vlnnotepos%
289 \modulo{\count@}{#1}%
290 \advance\count@ by1\relax%
291 \edef\tmp{\csname vlnnoteshift\romannumeral\count@\endcsname}%
292 \ifthenelse{\equal{\tmp}{}}%
293 {}%
294 {\advance\vlnnotepos by\tmp\relax}%
295 }%