summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/musixtex/musixbar.tex
blob: 5e748aae6d3cbf9db843bbcb8f3a34269f241b37 (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
148
%%%%%%%%%% Hiding/printing bar lines individually %%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Here comes a bunch of rather general macros which enable printing or 
% hiding barlines for each staff and inter-staff space individually:
%
% Mthimkhulu Molekwa <MMolekwa@rrs.co.za>

\ifx\indivbarrules\undefined\else\endinput\fi

\immediate\write16{MusiXBAR printing or hiding seperate bar lines 1.01\space<23 Februar 2000>}%

\edef\catcodeat{\the\catcode`\@}\catcode`\@=11

%\makeatletter

\newdimen\barline@depth
  
\def\rul@indiv#1{%
  \n@loop
    \Comp@High
    \expandafter\ifx\csname s@b\romannumeral\noinstrum@nt\endcsname\relax
      \multiply\barline@depth -1\relax
      \advance\barline@depth\altitude
    \else
      \barline@depth=0pt\relax
    \fi
    {\expandafter\ifx\csname h@bl\romannumeral\noinstrum@nt\endcsname 1%
       \y@v=0pt\relax
     \fi
     \raise\altitude\rlap{\vrule\@depth\barline@depth\@width#1\@height\y@v}}%
    \barline@depth\altitude
    \advance\barline@depth\y@v
  \repeat
  \addspace#1}

\def\rul@indiv@#1{\n@loop{\prul@indiv@#1}\repeat\addspace#1}

\def\prul@indiv@#1{%
      \y@v\interportee \C@Inter\advance\y@v-\stem@skip
      \expandafter\ifx\csname s@b\romannumeral\noinstrum@nt\endcsname\relax
        \multiply\barline@depth -1\relax
        \advance\barline@depth\altitude
      \else
        \barline@depth=0pt\relax
      \fi
      {\expandafter\ifx\csname h@bl\romannumeral\noinstrum@nt\endcsname 1%
         \y@v=0pt\relax
       \fi
      \p@loop
        \raise\altportee\rlap{%
          \vrule\@depth\barline@depth\@width#1\@height\y@v}%
        \count@portee
      \repeat}%
      \barline@depth\altitude
      \advance\barline@depth\y@v}

%== Required to use the following macros
\def\indivbarrules{%
  \let\writ@rule\rul@indiv
  \sepbarrule 1}

\def\Indivbarrules{%
  \let\writ@rule\rul@indiv@
  \sepbarrule 1}

%== separates bar line of specified instrument from one of previous instrument
\def\sepbarrule#1{\expandafter\let\csname s@b\romannumeral#1\endcsname 1}

%== connects bar line of specified instrument to one of previous instrument
\def\conbarrule#1{%
  \if 1#1\else\expandafter\let\csname s@b\romannumeral#1\endcsname\relax\fi}
  
%== hides bar line for specified instrument
\def\hidebarrule#1{\expandafter\let\csname h@bl\romannumeral#1\endcsname 1}
  
%== shows bar line for specified instrument
\def\showbarrule#1{\expandafter\let\csname h@bl\romannumeral#1\endcsname\relax}

%== separates barlines in multistaff instruments
\def\rul@sep@#1{\n@loop{\prul@sep#1}\repeat\addspace#1}

\def\prul@sep#1{%
      \y@v\interportee \C@Inter\advance\y@v-\stem@skip
      \p@loop
        \hbox{\raise\altportee\rlap{%
          \vrule\@depth\hlthick\@width#1\@height\y@v}}%
        \count@portee\repeat}

\def\Sepbarrules{\let\writ@rule\rul@sep@ }

%-\makeatother

\catcode`\@=\catcodeat
\endinput

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Here comes an example of how to use these macros

%%%%% Pre-amble
\input musixtex
\input musixbar

\instrumentnumber3
\setmeter3{{\meterfrac{3}{4}}}
\setmeter2{{\meterfrac{2}{4}}}
\setmeter1{{\meterfrac{3}{8}}}
\nobarnumbers
\indivbarrules
\sepbarrule2
\sepbarrule3

%%%%% Spacing
\beforeruleskip=0.5\afterruleskip
\interinstrument=4\Interligne

%%%%% Macros
\let\ni\nextinstrument

%%%%% Music
\linegoal2
\startpiece\addspace\afterruleskip
\NOtes\pt f\qa f\ni\qa f\ni\qa f\en
\hidebarrule2\hidebarrule3\bar
\NOtes\multnoteskip{.333}\Tqbu fff\ni\qa f\ni\qa f\en
\showbarrule2\bar
\NOtes\pt f\qa f\ni\qa f\ni\qa f\en
\hidebarrule2\showbarrule3\bar
\NOtes\multnoteskip{.333}\Tqbu fff\ni\qa f\ni\qa f\en
\showbarrule2\hidebarrule3\bar
\NOtes\pt f\qa f\ni\qa f\ni\qa f\en
\hidebarrule2\bar
\NOtes\multnoteskip{.333}\Tqbu fff\ni\qa f\ni\qa f\en
\showbarrule2\showbarrule3\bar
\NOtes\pt f\qa f\ni\qa f\ni\qa f\en
\hidebarrule2\hidebarrule3\bar
\NOtes\multnoteskip{.333}\Tqbu fff\ni\qa f\ni\qa f\en
\showbarrule2\bar
\NOtes\pt f\qa f\ni\qa f\ni\qa f\en
\hidebarrule2\showbarrule3\bar
\NOtes\multnoteskip{.333}\Tqbu fff\ni\qa f\ni\qa f\en
\showbarrule2\hidebarrule3\bar
\NOtes\pt f\qa f\ni\qa f\ni\qa f\en
\hidebarrule2\bar
\NOtes\multnoteskip{.333}\Tqbu fff\ni\qa f\ni\qa f\en
\showbarrule2\showbarrule3\stoppiece
\bye