]> Git — Sourcephile - julm/violon-tex.git/blob - violon.sty
Ajout : possibilité d'indiquer la durée d'une note via sa largeur.
[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 % Moteur
43 % Constantes
44 % Couleurs
45 \definecolor{colVlnBowUp}{rgb}{0.24,0.92,0.24}%
46 \definecolor{colVlnBowDn}{rgb}{1,0,0}%
47 \definecolor{colVlnBowU}{rgb}{0.24,0.92,0.24}%
48 \definecolor{colVlnBowD}{rgb}{1,0,0}%
49 \definecolor{colVlnLineHalfTone}{gray}{0.75}%
50 \definecolor{colVlnLineHalfToneBase}{gray}{0.25}%
51 % Cordes
52 \def\vlncordposofE{0}%
53 \def\vlncordposofA{1}%
54 \def\vlncordposofD{2}%
55 \def\vlncordposofG{3}%
56 \expandafter\def\csname vlncordposof.\endcsname{.}%
57 % Portée
58 % Déclarations
59 \newdimen\vlnhalftonelinevdim
60 \newskip\vlnhalftonelineskip%
61 \newskip\vlntonesskip%
62 % Initialisations
63 \vlnhalftonelinevdim=0.5pt%
64 \vlntonesskip=0pt\relax%
65 \vlnhalftonelineskip=5pt\relax%
66 \advance\vlnhalftonelineskip by -\vlnhalftonelinevdim%
67 \def\vlnhalftoneline{%
68 {\color{colVlnLineHalfTone}\hrule depth 0pt height \vlnhalftonelinevdim width \hsize }}%
69 \def\vlnbasehalftoneline{%
70 {\color{colVlnLineHalfToneBase}\hrule depth 0pt height \vlnhalftonelinevdim width \hsize }}%
71 \def\toneskip{%
72 \advance\vlntonesskip by\vlnhalftonelineskip%
73 \advance\vlntonesskip by\vlnhalftonelinevdim%
74 \vskip\vlnhalftonelineskip%
75 }%
76 \def\vlnfivehalftonelines{%
77 \toneskip\vlnhalftoneline%
78 \toneskip\vlnhalftoneline%
79 \toneskip\vlnhalftoneline%
80 \toneskip\vlnhalftoneline%
81 \toneskip\vlnbasehalftoneline%
82 }%
83 \def\allhalftonelines{%
84 \vlnfivehalftonelines%
85 \vlnfivehalftonelines%
86 \vlnfivehalftonelines%
87 \vlnfivehalftonelines%
88 }%
89 \gdef\vlnlines{%
90 \vlnbasehalftoneline%
91 \allhalftonelines%
92 \advance\vlntonesskip by\vlnhalftonelinevdim%
93 \vskip-\vlntonesskip%
94 }%
95 % Notes
96 % Déclarations
97 % Variables
98 \newskip\vlnnotevskip%
99 \newskip\vlnnotevskipbase%
100 \newskip\vlnnotehskip%
101 \newskip\vlnnotehskipbase%
102 \newdimen\vlnnotevdim%
103 \newdimen\vlnnotevdimmore%
104 \newdimen\vlnnotehdim%
105 \newdimen\vlnnotehdimbase%
106 \newcount\vlnlastfinger%
107 \newcount\vlnlastposbase%
108 \newcount\vlnlastposunit%
109 % Initialisations
110 \vlnnotevskip=0pt\relax%
111 \vlnnotevskipbase=0pt\relax%
112 \vlnnotehskip=0pt\relax%
113 \vlnnotehskipbase=0pt\relax%
114 \vlnnotevdim=\vlnhalftonelinevdim%
115 \vlnnotevdimmore=1pt\relax%
116 \vlnnotehdimbase=2cm\relax%
117 \advance\vlnnotevdim by \vlnnotevdimmore%
118 \advance\vlnnotevdim by \vlnnotevdimmore%
119 \def\vlnlastbow{}%
120 \def\vlnlastcord{}%
121 \def\vlnlasttimenum{}%
122 \def\vlnlasttimeden{}%
123 \def\vlnnotehdimmodetim{1}%
124 \def\vlnnotehdimmodetxt{}%
125 \parindent=0pt\relax%
126 \parskip=0pt\relax%
127 \parfillskip=0pt\relax%
128 \def\vlnlastfingerpos{%
129 \csname vlnlastfingerpos\romannumeral\vlnlastfinger\endcsname%
130 }%
131 \def\vlntimefrac#1/#2{%
132 \leavevmode%
133 \hbox{#1}%
134 \kern-.4ex\lower.3ex\hbox{\bfseries\tiny /}%
135 \kern-.3ex\lower.6ex\hbox{#2}%
136 }%
137 \def\vlndoatnote#1#2#3#4{%
138 \nointerlineskip%
139 \vlnnotevskip\vlnhalftonelineskip%
140 \advance\vlnnotevskip by \vlnhalftonelinevdim\relax%
141 \multiply\vlnnotevskip by #1\relax%
142 \advance\vlnnotevskip by -\vlnnotevdimmore\relax%
143 \vskip\vlnnotevskip\relax%
144 \vskip-\vlnnotevskip\relax%
145 \vskip\vlnnotevskip\relax%
146 \vrule depth 0pt height 0pt width \vlnnotehskip\relax%
147 \setbox0=#3%
148 \advance\vlnnotevskip by \ht0\relax%
149 #2%
150 \box0%
151 #4%
152 \vskip-\vlnnotevskip\relax%
153 \nointerlineskip%
154 }%
155 \def\vlnnextnote{%
156 \advance\vlnnotehskip by \vlnnotehdim\relax%
157 }%
158 \def\vlnnote crd#1pos#2fgr#3bow#4tim#5#6{%
159 % Durée
160 \ifthenelse{\equal{#5/#6}{\vlnlasttimenum/\vlnlasttimeden}}%
161 {}%
162 {\ifthenelse{\equal{#5/#6}{./.}}%
163 {}%
164 {\vlndoatnote{#2}%
165 {}%
166 {\ifthenelse{\equal{#5}{.}}%
167 {}%
168 {\def\vlnlasttimenum{#5}}%
169 \ifthenelse{\equal{#6}{.}}%
170 {}%
171 {\def\vlnlasttimeden{#6}}%
172 \vlnnotehdim\vlnnotehdimbase%
173 \ifthenelse{\equal{}{\vlnnotehdimmodetim}}%
174 {}%
175 {\multiply\vlnnotehdim by\vlnlasttimeden\relax%
176 \divide\vlnnotehdim by\vlnlasttimenum\relax%
177 }%
178 \ifthenelse{\equal{}{\vlnnotehdimmodetxt}}%
179 {}%
180 {\vbox to0pt{%
181 \setbox0=\hbox{%
182 \ifthenelse{\equal{\vlnlasttimeden}{1}}%
183 {{\vlntimefont{\vlnlasttimenum}}}%
184 {\vlntimefrac{\vlntimefont{\vlnlasttimenum}}/{\vlntimefont{\vlnlasttimeden}}}%
185 }%
186 \vskip\vlnnotevdim\relax%
187 \vskip0.2mm\relax%
188 \dp0=0pt\relax%
189 \box0}%
190 }%
191 }%
192 {}%
193 }%
194 }%
195 % Archet
196 \ifthenelse{\equal{#4}{C}}%
197 {\ifthenelse{\equal{U}{\vlnlastbow}}%
198 {\def\vlnlastbow{D}}%
199 {\def\vlnlastbow{U}}}%
200 {\ifthenelse{\equal{#4}{.}}%
201 {}%
202 {\def\vlnlastbow{#4}}}%
203 \vlndoatnote{#2}%
204 {\begingroup\expandafter\color{colVlnBow\vlnlastbow}}%
205 {%
206 \hbox{%
207 \vrule depth 0pt height \vlnnotevdim width \vlnnotehdim\relax%
208 }%
209 }%
210 {\endgroup}%
211 % Doigts
212 \ifthenelse{\equal{#3}{.}}%
213 {}%
214 {\vlnlastfinger#3\relax}%
215 \ifthenelse{\equal{#2}{\vlnlastfingerpos}}%
216 {}%
217 {%
218 \expandafter\def\csname vlnlastfingerpos\romannumeral\vlnlastfinger\endcsname{#2}\relax%
219 \vlndoatnote{#2}%
220 {}%
221 {\vbox to0pt{%
222 \setbox0=\hbox{{\vlnfingerfont{\the\vlnlastfinger}}}%
223 \vskip-0.2mm\relax%
224 \vskip-\ht0\relax%
225 %\vskip-\dp0\relax%
226 \dp0=0pt\relax% NOTE: to prevent fonts like pnc to mess up the vertical alignment
227 \hskip\vlnnotehdim\relax%
228 \hskip-\wd0\relax%
229 \box0}}%
230 {}%
231 }%
232 % Cordes
233 \ifthenelse{\equal{#1}{\vlnlastcord}}%
234 {}%
235 {\ifthenelse{\equal{#1}{.}}%
236 {}%
237 {\def\vlnlastcord{#1}%
238 \vlndoatnote{#2}%
239 {}%
240 {\vbox to0pt{%
241 \count@#1\relax%
242 \advance\count@ by 1\relax%
243 \setbox0=\hbox{{\vlncordfont{\@Roman\count@}}}%
244 \vskip\vlnnotevdim\relax%
245 \vskip0.2mm\relax%
246 \hskip\vlnnotehdim\relax%
247 \hskip-\wd0\relax%
248 \box0}}%
249 {}%
250 }%
251 }%
252 \vlnnextnote%
253 \nointerlineskip%
254 }%
255 \def\n#1#2#3#4#5#6#7{%
256 \ifthenelse{\equal{#1}{+}}%
257 {\advance\vlnlastposbase by 1\relax}%
258 {\ifthenelse{\equal{#1}{-}}%
259 {\advance\vlnlastposbase by -1\relax}
260 {\ifthenelse{\equal{#1}{.}}%
261 {}%
262 {\vlnlastposbase#1\relax}}}%
263 \ifthenelse{\equal{#2}{+}}%
264 {\advance\vlnlastposunit by 1\relax}%
265 {\ifthenelse{\equal{#2}{-}}%
266 {\advance\vlnlastposunit by -1\relax}%
267 {\ifthenelse{\equal{#2}{.}}%
268 {}%
269 {\vlnlastposunit#2\relax}}}%
270 \count@\vlnlastposbase\relax%
271 \multiply\count@ by5\relax%
272 \advance\count@ by\vlnlastposunit\relax%
273 \vlnnote crd{\csname vlncordposof#3\endcsname}%
274 pos{\the\count@}fgr{#4}bow{#5}tim{#6}{#7}%
275 }%
276