summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/musixtex/tuplet.tex
blob: 0dcb7aca469d284df00572a10fdd3bc7fb0c544c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
%
%   tuplet.tex - conventional tuplet brackets for MusiXTeX.
%   Col. G. L. Sicherman.  Last revised 2003-05-17.
%
%   MusiXTeX is free software, licensed under the GNU General Public
%   License.  This file is also free software.  You may use it and
%   modify it as you please so long as you leave this message intact.
%
%   To use this file with MusiXTeX, refer to it in your source code
%   after MusiXTeX:
%
%       \input musixtex
%       \input tuplet
%
%   This file uses macros defined in musixtex.tex.
%
%   Standard MusiXTeX uses \uptrio and \downtrio to print tuplet brackets.
%   This file defines \uptuplet and \downtuplet, with the same arguments:
%
%       #1 : starting pitch
%       #2 : width of bracket, in (\noteskip)s
%       #3 : slope of bracket, in multiples of 1-1/8 degrees
%
%   The user defines the text to appear in the opening as \tuplettxt.
%   This is to avoid conflicting with the \txt in standard MusiXTeX.
%
%   Examples:
%
%       Draw a triplet bracket over the notes, starting at pitch "p",
%       1.25\noteskip wide, with a slope up of 3-3/8 degrees:
%
%           \uptuplet p{1.25}3
%
%       Draw a sextuplet bracket over the notes, starting at pitch "a",
%       2.5\noteskip wide, with a slope down of 4-1/2 degrees:
%
%           \def\tuplettxt{\smallppff 6\/\/}
%           \downtuplet{a}{2.5}{-4}
%
%   Send comments, complaints, and bouquets to the Colonel at
%   <colonel@monmouth.com>.
%
\makeatletter % Names of internal macros contain atpersats.

% Standard MusiXTeX prints a small "3" (or other number) within
% the bracket.  Here we print the "3" in an opening in the bracket,
% so we need not use a small font.
%
% The double italic correction compensates for centering the number
% on the bracket line.

\def\tuplettxt{\smallppff3\/\/}

%%% The rest is adapted from standard MusixTeX.

\newdimen\y@vii % x of right end of left part of bracket.
\newdimen\y@viii % x of left end of right part of bracket.
\newdimen\y@ix
\newbox\tuptxtb@x

% v@rline #1=height[dimen] #2=length[dimen] #3=slope (1\eqiv 1.125degree)
% (comments and ideas from Ian Collier)              (from -20 upto 20 )
% This macro is used by some of the others which follow,
% using it directly it must be set in zero box

\def\v@rline#1#2#3{\n@v#3\y@i#2%
  \setbox\tuptxtb@x\hbox{\hskip1pt\tuplettxt\hskip1pt}%
  \y@vii=\h@lf\y@i\advance\y@vii-\h@lf\wd\tuptxtb@x%
  \n@ii-\tw@nty \min@n@v\n@ii
  \max@n@v\tw@nty \n@iii\n@v
  \ifnum\n@v<\z@ \n@v-\n@v \advance\n@v\tw@nty \fi % offset to lower linechars
  \advance\n@v\@xxix
  \setbox\ch@box\hbox{\mxsps\char\n@v}%
  \ifdim\y@vii<\wd\ch@box \y@vii\wd\ch@box\fi% At least one whole segment!
  \y@viii=\y@i\advance\y@viii-\y@vii%
  \y@iv\wd\ch@box \y@ii\qu@rt\p@ \y@ii\n@iii\y@ii \y@iii\z@
  \raise#1\internote\hbox{\mxsps\char\n@iv
%
% Build bracket with slanted line segments of width 10pt.
% Left part of bracket:
%
    \loop\ifdim\y@iv<\y@vii\raise\y@iii\copy\ch@box
    \advance\y@iv\wd\ch@box \advance\y@iii\y@ii \repeat
%
% last element
%
%  \finalheight=2.5\completewidth
%  \finalheight=\n@iii\finalheight
%  \divide\finalheight by 100
%  \advance\overlapwidth by -\completewidth
%  \stepheight=-2.5\overlapwidth
%  \stepheight=\n@iii\stepheight
%  \divide\stepheight by 100
%  \advance\curheight by \stepheight
%  \kern -\overlapwidth \raise\curheight \box\ch@box
%
  \y@ix=\y@vii\advance\y@ix-\y@iv\hbox to\y@ix{\hss}%
  \y@ix\y@vii\advance\y@ix-\wd\ch@box%
  \y@iii\n@iii\y@ix\y@iii2\h@lf\y@iii\divide\y@iii\@c\raise\y@iii\copy\ch@box%
%
% Text:
%
  \y@v2\h@lf\y@i \y@v\n@iii\y@v \divide\y@v\@c%
  \y@ix=-\y@vii \advance\y@ix\h@lf\y@i \advance\y@ix-\h@lf\wd\tuptxtb@x%
  \hbox to\y@ix{\hss}%
  \y@iii\h@lf\y@v \raise\y@iii\vbox to\z@{%
  \vss{\copy\tuptxtb@x}\vss}
  \y@ix=\y@viii \advance\y@ix-\h@lf\y@i \advance\y@ix-\h@lf\wd\tuptxtb@x
  \hbox to\y@ix{\hss}% To start of right part. No-op unless bracket is short.
%
% Right part of bracket:
%
  \y@iii2\h@lf\y@viii \y@iii\n@iii\y@iii \divide\y@iii\@c%
  \y@iv=\y@viii \advance\y@iv\wd\ch@box%
  \loop\ifdim\y@iv<\y@i\raise\y@iii\copy\ch@box%
  \advance\y@iv\wd\ch@box \advance\y@iii\y@ii \repeat
%
% Finish off the right part:
%
  \y@iii\y@i\advance\y@iii-\wd\ch@box\y@iii2\h@lf\y@iii\y@iii\n@iii\y@iii%
  \y@ix=\y@i\advance\y@ix-\y@iv\hbox to\y@ix{\hss}%
  \divide\y@iii\@c%
  \raise\y@iii\copy\ch@box%
%
  \raise\y@v\hbox{\mxsps\char\n@iv}}}
%
% y@i   =complete length
% y@ii  =height of linechar
% y@iii =current height
% y@iv  =current width
% y@v   =height of ending line
% y@vii =width of left segment of bracket
% y@viii=y@vii + width of opening
% y@ix  =adjustment register
%
% n@iii=slope
% n@iv =(number of char for hooks)
% n@v  =slope (number of linechar)

\def\X@bkt#1#2#3{\y@v#2\noteskip \advance\y@v\wn@width
  \inhgetn@i#1\relax \rlap{\kernm\p@ne\qn@width\v@rline\n@i\y@v{#3}}}

\def\uptuplet{\n@iv22\X@bkt}
\def\downtuplet{\n@iv21\X@bkt}

\makeatother
\endinput