\chapter{Repeats} To replace a bar line with a left, right, or left-right repeat, use one of the commands \keyindex{leftrepeat}, \keyindex{rightrepeat} or \keyindex{leftrightrepeat} in place of \verb|\bar|. If a \verb|\leftrepeat| happens to come at the end of a system, it will automatically be moved to the start of the next system. If a \verb|\leftrightrepeat| happens to come at the end of a system, \musixtex\ will automatically post a right repeat at the end of the system and a left repeat at the beginning of the next. For example, \begin{music}\nostartrule \startextract \NOTes\ha g\en \leftrepeat \NOTes\ha h\en \leftrightrepeat \NOTes\ha i\en \rightrepeat \NOTEs\wh j\en \zendextract \end{music} \noindent has been coded as: \begin{quote}\begin{verbatim} \NOTes\ha g\en \leftrepeat \NOTes\ha h\en \leftrightrepeat \NOTes\ha i\en \rightrepeat \NOTEs\wh j\en \end{verbatim}\end{quote} To insert a right-repeat at a forced line break or at the end of a piece, use \verb|\setrightrepeat| \textit{before}\ \verb|\alaligne| or \verb|\endpiece|. In fact it is possible to use \keyindex{setleftrepeat}, \keyindex{setrightrepeat} or \keyindex{setleftrightrepeat} before any \keyindex{bar}, \keyindex{stoppiece} or \keyindex{changecontext}; but be aware that whereas \verb|\setrightrepeat| behaves properly if the bar is at the end of a system, \verb|\setleftrepeat| and \verb|\setleftrightrepeat| do not, placing the left-repeat symbol at the end of the system rather than at the beginning of the next system; see the \verb|\zleftrepeat| \verb|\zzleftrepeat| \verb|\zzleftrightrepeat| and \verb|\zzleftrightrepeat| commands described below. The following commands generate repeat symbols as usual, but are assumed to be in the \emph{middle} of a bar; that is, the bar counter is not incremented: \begin{itemize} \item[] \keyindex{zrightrepeat} \item[] \keyindex{zleftrepeat} \item[] \keyindex{zleftrightrepeat} \end{itemize} For example, to insert a left-repeat at a forced line break or at the beginning of a piece, simply use \verb|\zleftrepeat| immediately \textit{after} \verb|\startpiece| or \verb|\alaligne|. To insert a left-right repeat at a forced line break, use \verb|\setrightrepeat\alaligne\zleftrepeat|. The following commands are similar but force the mid-bar break to the end of a system: \begin{itemize} \item[] \keyindex{zzrightrepeat} \item[] \keyindex{zzleftrepeat} \item[] \keyindex{zzleftrightrepeat} \end{itemize} For \verb|\zzleftrepeat| and \verb|\zzleftrightrepeat|, the left-repeats occur at the beginning of the following system. The bar numbers are correctly adjusted, using \keyindex{writezbarno} for the continuation if \keyindex{systemnumbers} is in use. As an example, here is a \emph{bourr\'ee} by G.-F.~Handel coded using \verb|\zleftrepeat| at the beginning of the \textbf{A} section and \verb|\zzleftrightrepeat| between the \textbf{A} and the \textbf{B} sections: \begin{music} \smallmusicsize \generalmeter{\allabreve} \generalsignature{1} \startbarno=0 \nobarnumbers \nostartrule \startpiece\addspace\afterruleskip \systemnumbers \zleftrepeat% \znotes\ccn{10}{\boxit{\bf A}}\en \NOtes\qa d\en% \bar%1 \NOtes\qa{g}\qa{i}\qa{h}\qa{g}\en% \bar%2 \NOTes\ha{k}\ha{i}\en% \bar%3 \NOtes\qa{l}\qa{k}\qa{j}\qa{i}\en% \bar%4 \NOtes\qa j\en \NOTes\ha i\en% \zzleftrightrepeat% \znotes\ccn{10}{\boxit{\bf B}}\en \NOtes\qa k\en% \bar%5 \NOtes\qa{l}\qa{j}\qa{h}\en \Notes\ibl3i2\qb3i\tql3j\en% \bar%6 \NOtes\qa{k}\qa{i}\qa{g}\en \Notes\ibu3h2\qb3h\tqu3i\en% \bar%7 \NOtes\qa{j}\qa{i}\qa{h}\qa{g}\en% \bar%8 \Notes\ibu3h1\qb3{h}\qb3{g}\qb3{h}\tqu3i\en \NOtes\qa h\en \Notes\ibl3i2\qb3i\tql3j\en% \bar%9 \NOtes\qa k\en \Notes\ibl3i2\qb3i\tql3j\en \NOtes\qa k\en \Notes\ibl3j{-2}\qb3j\tql3i\en% \bar%10 \NOtes\qa j\en \Notes\ibu3h2\qb3h\tqu3i\en \NOtes\qa j\en \Notes\ibu3i{-2}\qb3i\tqu3h\en% \bar%11 \NOtes\qa{i}\qa{g}\en \NOtesp\tr{11}\qa{.h}\en \Notes\ca g\en% \bar%12 \NOTesp\ha{.g}\en% \setrightrepeat% \endpiece% \end{music} \noindent No explicit adjustment of \verb|\barno| was necessary. The right-repeat at the end of the \textbf{B}~section was produced by \verb|\setrightrepeat\endpiece|. \section{First and second endings (Voltas)}\index{volta} All volta commands must be entered right before the bar line command (or repeat, etc.) where they are to take effect. There are three commands that suffice to set all voltas. To start one, use \keyindex{Setvolta}\verb|{|\textit{text}\verb|}|; to terminate it with or without a vertical line, use \keyindex{endvolta} or \keyindex{endvoltabox} respectively. The text by default will be followed by a period. There are also various alternate commands (e.g., \verb|\setendvoltabox| is equivalent to \verb|\endvoltabox|). Some such alternate forms are used in the following example, but the first three mentioned above are all that are required: \medskip \begin{music} \parindent0pt \nostartrule \startpiece \addspace\afterruleskip \NOTEs\wh a\en\bar \NOTEs\wh b\en\setvoltabox{1.-3}\bar \NOTEs\wh c\en\setvolta4\setendvolta\rightrepeat \NOTEs\wh d\en\doublebar \NOTEs\wh e\en\bar \NOTEs\wh f\en\leftrepeat \NOTEs\wh g\en\bar \NOTEs\wh h\en\Setvolta1\bar \NOTEs\wh i\en\bar \NOTEs\wh j\en\Setvolta2\setendvoltabox\rightrepeat \NOTEs\wh i\en\bar \NOTEs\wh h\en\setendvoltabox \Endpiece \end{music} \noindent This was coded as \begin{quote}\begin{verbatim} \startpiece \addspace\afterruleskip \NOTEs\wh a\en\bar \NOTEs\wh b\en\setvoltabox{1.-3}\bar \NOTEs\wh c\en\setvolta4\setendvolta\rightrepeat \NOTEs\wh d\en\doublebar \NOTEs\wh e\en\bar \NOTEs\wh f\en\leftrepeat \NOTEs\wh g\en\bar \NOTEs\wh h\en\Setvolta1\bar \NOTEs\wh i\en\bar \NOTEs\wh j\en\Setvolta2\setendvoltabox\rightrepeat \NOTEs\wh i\en\bar \NOTEs\wh h\en\setendvoltabox \Endpiece \end{verbatim}\end{quote} \zkeyindex{leftrepeat}\zkeyindex{rightrepeat} If the volta only spans one measure and ends without a vertical segment, it can be specified simply by saying \keyindex{setvolta}\verb|{|\textit{text}\verb|}| before the bar line command that starts it, and it will automatically terminate at the second bar line command: \medskip \begin{music} \parindent0pt \nostartrule\startpiece \addspace\afterruleskip \NOTEs\wh a\en\bar \NOTEs\wh b\en\setvolta{1.-3}\bar \NOTEs\wh c\en\setvolta4\rightrepeat \NOTEs\wh d\en\bar \NOTEs\wh e\en\Endpiece \end{music} \noindent which was coded as: \begin{quote}\begin{verbatim} \parindent0pt \startpiece \addspace\afterruleskip \NOTEs\wh a\en\bar \NOTEs\wh b\en\setvolta{1.-3}\bar \NOTEs\wh c\en\setvolta4\rightrepeat \NOTEs\wh d\en\bar \NOTEs\wh e\en\Endpiece \end{verbatim}\end{quote} The height above the top staff line of the horizontal line in a volta symbol is determined by the token \keyindex{raisevolta} which is \verb|4\internote| by default. You can change this to any desired dimension. The period after the text can be removed by saying \verb|\def|\keyindex{voltadot}\verb|{}| and restored by \verb|\def|\keyindex{voltadot}\verb|{.}|\ . \section{Special symbols for repeating long sections} Four special symbols and corresponding macros are available, namely \keyindex{coda}~$p$, \keyindex{Coda}~$p$, and \keyindex{segno}~$p$, where $p$ specifies the pitch; and \keyindex{Segno} with no argument. Their behavior is illustrated in this example: \begin{music} \startextract \NOtes\segno n\en \bar \NOtes\coda n\en \NOtes\Segno\en \bar \NOtes\Coda n\en \endextract \end{music} \noindent which has been coded: \begin{quote}\begin{verbatim} \NOtes\segno m\en\bar \NOtes\coda m\en \NOtes\Segno\en\bar \NOtes\Coda m\en \end{verbatim}\end{quote} \section{Repeating a single bar} The special symbol for a single-bar repeat is generated by \keyindex{duevolte}, as shown in the following example: \begin{music} \generalmeter\meterC \setclef1\bass\setstaffs1{2} \startextract \NOtes|\qa{cegj}\en \def\atnextbar{\znotes\centerpause|\en}\bar \NOtes\qa{cdef}|\en \def\atnextbar{\znotes|\centerbar{\duevolte}\en}% \endextract \end{music} \noindent whose coding is: \begin{quote}\begin{verbatim} \generalmeter\meterC \setclef1\bass\setstaffs1{2} \startextract \NOtes|\qa{cegj}\en \def\atnextbar{\znotes\centerpause|\en}\bar \NOtes\qa{cdef}|\en \def\atnextbar{\znotes|\centerbar{\duevolte}\en}% \endextract \end{verbatim}\end{quote}