]> Git — Sourcephile - julm/violon-tex.git/blob - violon.sty
Premier commit.
[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 \newcount\vlnlastfinger%
106 % Initialisations
107 \vlnnotevskip=0pt\relax%
108 \vlnnotevskipbase=0pt\relax%
109 \vlnnotehskip=0pt\relax%
110 \vlnnotehskipbase=0pt\relax%
111 \vlnnotevdim=\vlnhalftonelinevdim%
112 \vlnnotevdimmore=1pt\relax%
113 \vlnnotehdim=1em\relax%
114 \advance\vlnnotevdim by \vlnnotevdimmore%
115 \advance\vlnnotevdim by \vlnnotevdimmore%
116 \def\vlnlastbow{}%
117 \def\vlnlastcord{}%
118 \def\vlnlasttimenum{}%
119 \def\vlnlasttimeden{}%
120 \newcount\vlnlastposbase%
121 \newcount\vlnlastposunit%
122 \parindent=0pt\relax%
123 \parskip=0pt\relax%
124 \parfillskip=0pt\relax%
125 \def\vlnlastfingerpos{%
126 \csname vlnlastfingerpos\romannumeral\vlnlastfinger\endcsname%
127 }%
128 \def\vlntimefrac#1/#2{%
129 \leavevmode%
130 \hbox{#1}%
131 \kern-.4ex\lower.3ex\hbox{\bfseries\tiny /}%
132 \kern-.3ex\lower.6ex\hbox{#2}%
133 }%
134 \def\vlndoatnote#1#2#3#4{%
135 \nointerlineskip%
136 \vlnnotevskip\vlnhalftonelineskip%
137 \advance\vlnnotevskip by \vlnhalftonelinevdim\relax%
138 \multiply\vlnnotevskip by #1\relax%
139 \advance\vlnnotevskip by -\vlnnotevdimmore\relax%
140 \vskip\vlnnotevskip\relax%
141 \vskip-\vlnnotevskip\relax%
142 \vskip\vlnnotevskip\relax%
143 \vrule depth 0pt height 0pt width \vlnnotehskip\relax%
144 \setbox0=#3%
145 \advance\vlnnotevskip by \ht0\relax%
146 #2%
147 \box0%
148 #4%
149 \vskip-\vlnnotevskip\relax%
150 \nointerlineskip%
151 }%
152 \def\vlnnextnote{%
153 \advance\vlnnotehskip by \vlnnotehdim\relax%
154 }%
155 \def\vlnnote crd#1pos#2fgr#3bow#4tim#5#6{%
156 % Archet
157 \ifthenelse{\equal{#4}{C}}%
158 {\ifthenelse{\equal{U}{\vlnlastbow}}%
159 {\def\vlnlastbow{D}}%
160 {\def\vlnlastbow{U}}}%
161 {\ifthenelse{\equal{#4}{.}}%
162 {}%
163 {\def\vlnlastbow{#4}}}%
164 \vlndoatnote{#2}%
165 {\begingroup\expandafter\color{colVlnBow\vlnlastbow}}%
166 {%
167 \hbox{%
168 \vrule depth 0pt height \vlnnotevdim width \vlnnotehdim\relax%
169 }%
170 }%
171 {\endgroup}%
172 % Doigts
173 \ifthenelse{\equal{#3}{.}}%
174 {}%
175 {\vlnlastfinger#3\relax}%
176 \ifthenelse{\equal{#2}{\vlnlastfingerpos}}%
177 {}%
178 {%
179 \expandafter\def\csname vlnlastfingerpos\romannumeral\vlnlastfinger\endcsname{#2}\relax%
180 \vlndoatnote{#2}%
181 {}%
182 {\vbox to0pt{%
183 \setbox0=\hbox{{\vlnfingerfont{\the\vlnlastfinger}}}%
184 \vskip-0.2mm\relax%
185 \vskip-\ht0\relax%
186 %\vskip-\dp0\relax%
187 \dp0=0pt\relax% NOTE: to prevent fonts like pnc to mess up the vertical alignment
188 \hskip\vlnnotehdim\relax%
189 \hskip-\wd0\relax%
190 \box0}}%
191 {}%
192 }%
193 % Cordes
194 \ifthenelse{\equal{#1}{\vlnlastcord}}%
195 {}%
196 {\ifthenelse{\equal{#1}{.}}%
197 {}%
198 {\def\vlnlastcord{#1}%
199 \vlndoatnote{#2}%
200 {}%
201 {\vbox to0pt{%
202 \count@#1\relax%
203 \advance\count@ by 1\relax%
204 \setbox0=\hbox{{\vlncordfont{\@Roman\count@}}}%
205 \vskip\vlnnotevdim\relax%
206 \vskip0.2mm\relax%
207 \hskip\vlnnotehdim\relax%
208 \hskip-\wd0\relax%
209 \box0}}%
210 {}%
211 }%
212 }%
213 % Durée
214 \ifthenelse{\equal{#5/#6}{\vlnlasttimenum/\vlnlasttimeden}}%
215 {}%
216 {\ifthenelse{\equal{#5/#6}{./.}}%
217 {}%
218 {\vlndoatnote{#2}%
219 {}%
220 {\ifthenelse{\equal{#5}{.}}%
221 {}%
222 {\def\vlnlasttimenum{#5}}%
223 \ifthenelse{\equal{#6}{.}}%
224 {}%
225 {\def\vlnlasttimeden{#6}}%
226 \vbox to0pt{%
227 \setbox0=\hbox{%
228 \ifthenelse{\equal{\vlnlasttimeden}{1}}%
229 {{\vlntimefont{\vlnlasttimenum}}}%
230 {\vlntimefrac{\vlntimefont{\vlnlasttimenum}}/{\vlntimefont{\vlnlasttimeden}}}%
231 }%
232 \vskip\vlnnotevdim\relax%
233 \vskip0.2mm\relax%
234 \dp0=0pt\relax%
235 \box0}}%
236 {}%
237 }%
238 }%
239 \vlnnextnote%
240 \nointerlineskip%
241 }%
242 \def\n#1#2#3#4#5#6#7{%
243 \ifthenelse{\equal{#1}{+}}%
244 {\advance\vlnlastposbase by 1\relax}%
245 {\ifthenelse{\equal{#1}{-}}%
246 {\advance\vlnlastposbase by -1\relax}
247 {\ifthenelse{\equal{#1}{.}}%
248 {}%
249 {\vlnlastposbase#1\relax}}}%
250 \ifthenelse{\equal{#2}{+}}%
251 {\advance\vlnlastposunit by 1\relax}%
252 {\ifthenelse{\equal{#2}{-}}%
253 {\advance\vlnlastposunit by -1\relax}%
254 {\ifthenelse{\equal{#2}{.}}%
255 {}%
256 {\vlnlastposunit#2\relax}}}%
257 \count@\vlnlastposbase\relax%
258 \multiply\count@ by5\relax%
259 \advance\count@ by\vlnlastposunit\relax%
260 \vlnnote crd{\csname vlncordposof#3\endcsname}%
261 pos{\the\count@}fgr{#4}bow{#5}tim{#6}{#7}%
262 }%
263