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