%%%%%%%%%%%%%%%%%%
%%              %%
%% pmx.tex      %%
%%              %%
%% Version 1.38 %%
%%              %%
%% 9 May 1998   %%
%%              %%
%%%%%%%%%%%%%%%%%%
\ifx\pmxnewclefs\undefined\else\endinput\fi
\immediate\write10%
{PMX, a Preprocessor for MusiXTeX, v1.3.8\space<9 May 1998>}%
%
\edef\catcodeat{\the\catcode`\@}\catcode`\@=11
%
\newif\ifolder%
%
%  Older fonts had clefs at different heights.  If you have the older 
%  version you should uncomment the following line
%\oldertrue%
%
%  The next 3 lines should be in musixmad.  They were omitted in 
%  some early versions!
%
%\newcount\s@Nx
%\newcount\s@Nxi
%\newcount\s@Nxii
%
%  Special clef change stuff
%
\newcount\reflect
\def\pmxnewclefs{\m@loop\s@l@ctclefs\o@c\a@c\repeat}%
\newtoks\pmxclefsym
\def\pmxclef#1#2{\ifnum#1=0\def\pmxclefsym{\smalltrebleclef}\else\ifnum#1<5%
\def\pmxclefsym{\smallaltoclef}\else\def\pmxclefsym{\smallbassclef}\fi\fi%
% Adjust height here for older clef default heights.
\reflect#2\ifolder\ifnum#1=0\advance\reflect-2\else\ifnum#1<5\advance\reflect-4%
\else\advance\reflect-6\fi\fi\fi%
\lcharnote{0}{\raise\reflect\internote\hbox{\pmxclefsym}}}%
%
%  Some ornaments
%
\def\grace#1#2#3{\off{-#1pt}{\tinynotesize\stdstemfalse#2\zcu{#3}}\off{#1pt}}%
\def\shlft#1#2{\off{-#1pt}\tinynotesize\stdstemfalse#2\normalnotesize\off{#1pt}}%
%\def\gaft#1#2{\bsk\roffset{#1}{\tinynotesize\stdstemfalse{#2}\normalnotesize}%
\def\gaft#1#2{\bsk\roffset{#1}{\tinynotesize\stdstemfalse#2\normalnotesize}%
\sk}%
%
%  The following keep octaviation out of brackets.
%
\def\Gshl#1{\off{-#1pt}\tinynotesize}%
\def\Gshr#1{\normalnotesize\off{#1pt}}%
\def\segnoo#1#2{\zcharnote{#2}{\kern#1pt\musicsmallfont\char"56}}
%
% Font for x-trill symbol.  Could make this more general.
%
%  Move this down to "iflongDCfontnames" block
%\font\xtrfont=cmsy10
\def\xtr#1{\zcharnote{#1}{\xtrfont\char"02}}
%
% Plus-trill
%
\def\ptr#1{\ptrx{#1}{1.8}{.35}}
\def\ptrx#1#2#3{\zcharnote{#1}{\raise.9\internote\hbox{%
\pcil\h@lf\qn@width\kern\pcil%
\razclef#2\internote\pcil#3\internote\kern-\h@lf\razclef\vrule height \h@lf\pcil 
depth \h@lf\pcil width \razclef\kern-\h@lf\razclef\kern-\h@lf\pcil\kern-.1pt
\vrule height \h@lf\razclef depth \h@lf\razclef width \pcil}}%
}%
%
%  Put in a number for an xtuplet.
%
\def\xnum#1#2#3{\off{#1\elemskip}\zcharnote{#2}{\eightit #3}%
\off{-#1\elemskip}}
%
%  accidental skips
%
\def\ast#1{\off{#1\elemskip}}
%
%  Check for and read a .mod file; open the .ask file
%
\newread\pmxmod
\def\readmod#1{\openin\pmxmod #1.mod\relax
\ifeof\pmxmod\else\input #1.mod\fi\closein\pmxmod} 
%
%  Stop-start slur macro
%
\def\csluru#1#2#3{\off{-2pt}\tslur#1{#2}\off{4pt}\isluru#1{#3}\off{-2pt}}%
\def\cslurd#1#2#3{\off{-2pt}\tslur#1{#2}\off{4pt}\islurd#1{#3}\off{-2pt}}%
%
%  Macros for optional small notes, usually w/ down stems.  Offset to center
%  them below a large note.  I used these in Matteis.
%
\def\smno#1{\roffset{.17}{\tinynotesize#1\normalnotesize}}%
\def\pmno#1{\roffset{.08}{\smallnotesize#1\normalnotesize}}%
\def\smq#1{\smno{\zql{#1}}}\def\smc#1{\smno{\zcl{#1}}}%
\def\smh#1{\smno{\zhl{#1}}}%
%
%  Single-digit meter symbol 
%
\newbox\workbox%
\def\meterN#1{\setbox\workbox=\vbox{\hbox{\ \meterfont #1}}%
\vbox to 8\internote{\offinterlineskip\vss\hbox to \wd\workbox{\hss
\meterfont #1\hss}\vss }}%
%
%  Meter symbol '3' with vertical slash
%
\def\meterIIIS{\kern\internote\raise\Interligne\hbox{\meterfont 3}%
\kern -2.0\internote
\vrule height 7\internote depth -\internote width0.3\internote
\kern 1.7\internote}%
%
% Fractional meter with a slash
%
\def\meterfracS#1#2{%
\kern\internote\raise2\Interligne\rlap{\meterfont #1}%\lower2\Interligne%
\hbox{\meterfont #2}%
\kern -1.85\internote
\vrule height 8\internote width0.3\internote
\kern 1.55\internote}%
%
%  *Symbols* for use in figures
%
\def\sharpfig{\musixchar92}
\def\flatfig{\musixchar90}
\def\natfig{\musixchar94}
\def\fsmsh{\llap{\musixchar92}}
\def\fsmfl{\llap{\musixchar90}}
\def\fsmna{\llap{\musixchar94}}
%
%  Macros for editorial accidentals
%
\def\esharp#1{\roffset{.3}{\zcharnote{#1}{\sharpfig}}}
\def\eflat#1{\roffset{.3}{\zcharnote{#1}{\flatfig}}}
\def\enat#1{\roffset{.3}{\zcharnote{#1}{\natfig}}}
%
%  Some fonts...for some reason my system can't do cmbx12 scaled \magstep4
%  9/17/97 Must redo the following 3 lines to permit EC/DC fonts
%
%\font\BIGfont=cmbx10 scaled\magstep4\font\Bigfont=cmbx10 scaled\magstep2
%\font\tempo=\fontid bx12% 
%\font\dyn=\fontid bx10% 
\iflongDCfontnames
\font\xtrfont=\fontid sy1000
\font\tempo=\fontid bx1200 
\font\dyn=\fontid bx1000 
\else\iflongECfontnames
\font\xtrfont=\fontid sy1000
\font\tempo=\fontid bx1200 
\font\dyn=\fontid bx1000 
\else
%\font\xtrfont=cmsy10
%\font\BIGfont=cmbx10 scaled\magstep4
%\font\Bigfont=cmbx10 scaled\magstep2
\font\xtrfont=\fontid sy10
\font\BIGfont=\fontid bx10 scaled\magstep4
\font\Bigfont=\fontid bx10 scaled\magstep2
\font\tempo=\fontid bx12% 
\font\dyn=\fontid bx10% 
\fi\fi
%
%  Continuation figure
%
\def\Cont#1#2{\advance\figdrop by #1\lower\figdrop\internote%
\hbox to \z@{\kern -0.3\noteskip%
\vbox{\hrule height 1.4\lthick width #2\noteskip}\hss}%
\advance\figdrop by -#1}%
%
%  Tiny C clef on line #1:  Will need to mod with new fonts 11-4-96
%
\newdimen\razclef\newdimen\symwid%
\newdimen\pcil %\ifnum\musicsize=20\pcil4pt\else\pcil3.25pt\fi%
\def\preclef#1#2{%
\ifnum#2=20\pcil4pt\else\pcil3.25pt\fi%
\symwid3.692\pcil%
\hbox{\vbox{\hrule height \lthick width \symwid}%
\kern-\symwid\raise\pcil\vbox{\hrule height \lthick width \symwid}%
\kern-\symwid\raise2\pcil\vbox{\hrule height \lthick width \symwid}%
\kern-\symwid\raise3\pcil\vbox{\hrule height \lthick width \symwid}%
\kern-\symwid\raise4\pcil\vbox{\hrule height \lthick width \symwid}%
\razclef-2.43\pcil\advance\razclef#1\pcil%
\kern-\symwid\raise\razclef\hbox to \symwid{\hss\smallaltoclef\hss}%
}}%
\def\namewpc#1#2#3#4#5{\raise#4pt\hbox to \parindent{\raise#5pt\hbox{#1}%
\hfill\preclef#2{#3}}}
%
%  Stuff for figure placements
%
%  9/17/97 redo font names
%
%\font\figfont=cmr10
\def\figfont{\normtype\rm}%
\newcount\figdrop
\figdrop=6
\newcount\sysno
\global\sysno=0\relax%
\def\Figu#1#2{\off{.9pt}\advance\figdrop by #1\lower\figdrop\internote%
\hbox to \z@{\figfont#2\hss}\off{-.9pt}\advance\figdrop by -#1}%
%
%  Special Figure macro for 2-bass parts
%
\def\Figt#1#2{\zcharnote{#1}{\kern.9pt\figfont#2}}%
%
%  Bar numbering
%
\systemnumbers%
\def\raisebarno{3.5\internote}%
\def\shiftbarno{3.5\internote}%
\newdimen\rbnbl\newdimen\sbnbl\newdimen\xrbn\newdimen\xsbn%
\newdimen\rbndim\newdimen\sbndim%
\global\rbndim\raisebarno\global\sbndim\shiftbarno%
\global\def\raisebarno{\rbndim}\global\def\shiftbarno{\sbndim}%
\global\rbnbl\rbndim\global\sbnbl\sbndim\global\xrbn0pt\global\xsbn0pt%
%
%  The following 2 macros are messy, but they retain \raisebarno as a macro and
%  retain original definition in musixtex for the end-of-line utility.
% 
\def\bnrs#1#2{%
%
% If here, baseline values will not change.  On exit, \rbndim will
% be the temporary value, \xrbn will be the increment (must save to check later;
% if <>0 then baseline hasn't changed!), and \rbnbl is still the baseline value.
%
 \global\xrbn#1\internote\global\advance\rbndim\xrbn%
 \global\xsbn#2\internote\global\advance\sbndim\xsbn%
}%
\def\writebarno{%
  \ifnum\barno>1%
    \boxit{\eightbf\the\barno\barnoadd}%
    \ifdim\raisebarno=\rbnbl%
      \empty%
    \else%
      \ifdim\xrbn=0pt%
        \global\rbnbl\raisebarno%
        \global\def\raisebarno{\rbndim}%
      \else%
        \global\xrbn0pt%
      \fi%
      \global\rbndim\rbnbl%
    \fi%
    \ifdim\shiftbarno=\sbnbl%
      \empty%
    \else%
      \ifdim\xsbn=0pt%
        \global\sbnbl\shiftbarno%
        \global\def\shiftbarno{\sbndim}%
      \else%
        \global\xsbn0pt%
      \fi%
      \global\sbndim\sbnbl%
    \fi%
  \fi%
}%
%
%  Make small accidentals the default
%
\smallaccid%
%
%  Put in a new time signature
%
\def\newtimes#1%
{\ifnum#1=0%
  \n@wbar\writ@newclefs\advance\barsinlin@\@ne%
  \wbarno@x\Writ@newsigns%
  \advance\n@skip0.3\afterruleskip\widthtyp@\@ne\t@rmskip%
  \Writ@meters\addspace\afterruleskip%
\else\ifnum#1=1%
  \alaligne 
\else
  \wbarno@x%
  \advance\n@skip-0.7\afterruleskip\widthtyp@\@ne\t@rmskip%
  \Writ@meters\addspace\afterruleskip%
\fi\fi}%
%
%  changecontext with no line break
%
\def\xchangecontext{\n@wbar\writ@newclefs
  \wbarno@x\Writ@newsigns\Writ@meters\addspace\afterruleskip}%
%
%  changecontext with forced line break and no barline
%
\def\zachangecontext{\advance\n@skip\beforeruleskip \widthtyp@\@ne \t@rmskip
  \zn@wbar \writ@newclefs \advance\barsinlin@\@ne 
  \Writ@newsigns\z@suspend\contpiece }
%
%  Dotted rests.
%
\def\qsp{\pt5\qs}\def\dsp{\pt5\ds}\def\qpp{\pt5\qp}
\def\pausep{\off{.33\qn@width}\pt5\off{-.33\qn@width}\pause}
%
%  Redefine headline to lower pagenumber.  The original defn:
%  \def\makeheadline{\vbox to\z@{\vskip-22.5\p@
%  \line{\vbox to8.5\p@{}\the\headline}\vss}\nointerlineskip}
%
\def\makeheadline{\vbox to\z@{\vskip-8\p@
  \line{\vbox to8.5\p@{}\the\headline}\vss}\nointerlineskip}
%
% Dot at arbitrary height above a top line of staff
%
\def\mdot#1{\zcharnote{8}{\kern-5.3pt\raise#1\internote\hbox{\musixchar0}}}
%
%  Better centerbar.  #2, #3 are filler space at left & right
%
\def\CenterBar#1#2#3{%
%\y@ii\lin@pos\advance\y@ii-\lastbarpos\advance\y@ii\cut@v%
\y@ii\lin@pos\advance\y@ii-\lastbarpos%
\advance\y@ii-#2pt\advance\y@ii-#3pt\kern-#3pt%
\kern-\h@lf\y@ii\lrlap{#1}\kern\h@lf\y@ii\kern#3pt}%
\def\mbrest#1#2#3{%
\CenterBar{%
\ifnum #1<10\raise 9\internote\lrlap{\meterfont #1}\fi
\ifcase #1%
   \relax%                                                      0
\or\lrlap{\pause\off{\qn@width}}%  qn@width ~ width{pause}      1
\or\lrlap{\PAuse\off{\txt@ff}}%      txt@ff ~ width{PAuse}      2
\or\lrlap{\PAuse\qsk\pause\off{\qn@width}}%                     3
%or\lrlap{\PAUSe\off{\txt@ff}}% changed because of the shape of 4
\or\lrlap{\PAUSe\off{0.5\txt@ff}}%                              4
\or\lrlap{\PAUSe\qsk\pause\off{\qn@width}}%                     5
\or\lrlap{\PAUSe\qsk\PAuse\off{\txt@ff}}%                       6
\or\lrlap{\PAUSe\qsk\PAuse\qsk\pause\off{\txt@ff}\off{\qn@width}}% 7
\or\lrlap{\PAUSe\qsk\PAUSe\off{\txt@ff}}%                       8
\or\lrlap{\PAUSe\qsk\PAUSe\qsk\pause\off{\txt@ff}\off{\qn@width}}% 9
\else\def\vertpart{\hbox{\vrule width.6pt height1.5\internote depth1.5\internote}}%
     \raise\f@ur\internote\hbox{%
     \vertpart\hbox{%
     \vrule width0.7\y@ii height.5\internote depth.5\internote%
     \kern-0.35\y@ii\raise5\internote\lrlap{\meterfont #1}\kern0.35\y@ii}%
     \vertpart}%
\fi}{#2}{#3}%
}%
%
% Titles
%
\def\titles#1#2#3#4#5#6#7{\kern-\lin@pos%
\kern-3.2\Interligne\kern-\parindent\kern-\afterruleskip%
\kern-\sign@skip%
\vbox{\vskip#1\Interligne
%\if#2\empty\relax\else\leftline{\Bigfont #2}\fi\vskip#3\Interligne%
%\if#4\empty\relax\else\centerline{\BIGfont #4}\fi\vskip#5\Interligne%
%\if#6\empty\relax\else\rightline{\Bigfont #6}\fi\vskip#7\Interligne}}%
\if#2\empty\relax\else\leftline{\Bigtype #2}\fi\vskip#3\Interligne%
\if#4\empty\relax\else\centerline{\BIGtype #4}\fi\vskip#5\Interligne%
\if#6\empty\relax\else\rightline{\Bigtype #6}\fi\vskip#7\Interligne}}%
%
% Slashes on stems
%
\def\usoff#1{%
% Set \pcil to (stem length)-9\Internote
  \ifnum#1>10
    \pcil-3.8\Internote
  \else
    \pcil#1\Internote
    \ifnum#1>3
      \pcil-.38\pcil\advance\pcil-.5\Internote
      \ifnum#1>7
        \advance\pcil.38\Internote
      \fi
    \else
      \ifnum#1<-2
        \pcil-\pcil\advance\pcil-5\Internote
      \else
        \pcil-2\Internote
      \fi
    \fi
  \fi
  \advance\pcil#1\Internote
}%
%
\def\us#1{\usoff{#1}%
  \raise\pcil\hbox{\loffset{.5}{\ibu009}\roffset{.5}{\tbu0}}}%
\def\ls#1{\reflect-#1\advance\reflect8 %
\usoff{\reflect}\advance\pcil-7\Internote%
  \lower\pcil\hbox{\loffset{.5}{\ibl009}\roffset{.5}{\tbl0}}}%
%
%  Thinner slashes, better coding
%
\newdimen\pmxtop\def\aslash#1#2#3{%
%
% #1 = note level relative to bottom line.  #2 = 0/1 for down/up stem
% #3 = 0/1 for down/up slash,  For downstem, reflect, do as up, then unreflect.
%
\ifcase#3\def\slchar{\char248}\or\def\slchar{\char184}\fi%
\ifcase#2\pmxtop-#1\internote\advance\pmxtop8\internote\or\pmxtop#1\internote%
\fi\advance\pmxtop4.66\interbeam\ifdim\pmxtop>11\internote\uptop{11}\uptop{12}%
\uptop{13}\uptop{14}\uptop{15}\uptop{16}\fi%
\ifdim\pmxtop<4\internote\pmxtop4\internote\fi%
%
% \pmxtop now top of stem for upstem.  Unreflect if downstem
%
\ifcase#2\pmxtop-\pmxtop\advance\pmxtop8\internote\ifcase#3%
\advance\pmxtop2.5\internote\or\advance\pmxtop.9\internote\fi%
\ccharnote0{\raise\pmxtop\hbox{\musictinyfont\slchar}}%
\or\ifcase#3\advance\pmxtop-.9\internote\or\advance\pmxtop-2.5\internote\fi%
\roff{\ccharnote0{\raise\pmxtop\hbox{\musictinyfont\slchar}}}\fi}%
\def\uptop#1{\ifdim\pmxtop>#1\internote\advance\pmxtop-.25\interbeam\fi}%
%
% Signature change at end of line
%
\def\sigatend#1#2{\setdoublebar\xbar\hardspace{-#2pt}\generalsignature{#1}%
\zchangecontext\hardspace{-#2pt}\advance\barno-1\let\barrul@\empty}%
%
%  Macros for beams
%
\def\rbbu#1{\roff{\tbbu{#1}}}
\def\rbbbu#1{\roff{\tbbbu{#1}}}
\def\rbbbbu#1{\roff{\tbbbbu{#1}}}
\def\rbbl#1{\roff{\tbbl{#1}}}
\def\rbbbl#1{\roff{\tbbbl{#1}}}
\def\rbbbbl#1{\roff{\tbbbbl{#1}}}
%
%  Stuff for second voice per staff
%
\def\nextvoice{%
\@ndstaff\reflect\noport@@\advance\noport@@-1\beginstaff\noport@@\reflect}%
%
%  Macros for moving slur starts and stops
%
\def\isu#1#2#3{\roffset{#3}{\isluru{#1}{#2}}}%
\def\isd#1#2#3{\roffset{#3}{\islurd{#1}{#2}}}%
\def\ts#1#2#3{\roffset{#3}{\tslur{#1}{#2}}}%
%
%  Replacement trill macros, to avoid overfull boxes on 1st pass
%
\let\savtr\trille\let\savTr\Trille%
\def\trille#1#2{\ifeof\inmux\else\savtr{#1}{#2}\fi}%
\def\Trille#1#2{\ifeof\inmux\else\savTr{#1}{#2}\fi}%
%
% Mordent as \rpar.  If dotted, must move dot to right.
%
\def\lpn#1{\loffset{.3}{\lpar{#1}}}%   '(' 
\def\rpn#1{\roffset{.3}{\rpar{#1}}}%   Beam or not, no dot [ ')' only ]
\def\clm#1#2{\mdot{#1}{#2}\cl{#2}}%          Non-beam, dot [ '.' + ')' + note ]
\def\cum#1#2{\mdot{#1}{#2}\cu{#2}}%
\def\qlm#1#2{\mdot{#1}{#2}\ql{#2}}%                 
\def\qum#1#2{\mdot{#1}{#2}\qu{#2}}%
\def\hlm#1#2{\mdot{#1}{#2}\hl{#2}}%                 
\def\hum#1#2{\mdot{#1}{#2}\hu{#2}}%
\def\qbm#1#2#3{\mdot{#2}{#3}\qb{#1}{#3}}%    Beamed & dotted
\def\mdot#1#2{\roffset{.32}{\pt{#1}}\roffset{.24}{\rpar{#2}}}%
\def\lpnu#1{\smallnotesize\loffset{.3}{\zcharnote{#1}%
{\raise1pt\hbox{\musixchar3}}}\normalnotesize}% 
\def\lpnd#1{\smallnotesize\loffset{.3}{\zcharnote{#1}%
{\lower1pt\hbox{\musixchar3}}}\normalnotesize}% 
\def\rpnu#1{\smallnotesize\roffset{.6}{\zcharnote{#1}%
{\raise1pt\hbox{\musixchar4}}}\normalnotesize}%
\def\rpnd#1{\smallnotesize\roffset{.6}{\zcharnote{#1}%
{\lower1pt\hbox{\musixchar4}}}\normalnotesize}%
%
% For use with mid-bar signature changes, to permit using \ast machinery
%
\def\rdoff{\let\toff\off\let\off\addspace}%
%
% For raising arpeggios by .5/internote
%
\def\raisearp#1#2{\zcharnote{#1}{%
  \raise.5\internote\hbox{%
  \uplap{\leaders\hbox{\musixchar70}\vskip#2\Interligne}}}}
%
% New Movement Macro
%
\def\newmovement#1#2{\let\holdstop\stoppiece\let\holdcont\contpiece%
%\ifnum#2=0\def\endset{\setdoubleBAR}\else\def\endset{\empty}\fi%
\ifcase#2\def\endset{\setdoubleBAR}\or\def\endset{\setdoublebar}\or%
\def\endset{\setrightrepeat}\fi%
 \def\stoppiece{\endset\holdstop\vskip#1\internote%
\let\stoppiece\holdstop}%
 \def\contpiece{\startpiece\addspace\afterruleskip\let\contpiece\holdcont}%
}%
%
%  Redefinitions for moving dots vertically by x\interligne and
%  horizontally by y headwidths.  Should work for all kinds of dotted notes.
%  Usage: \def\C@Point#1#2{\PMXpt{.0}{-.2}} (x and y hardwired by PMX)
% 
\global\let\C@Psave\C@Point%
\def\PMXpt#1#2{\ifodd\n@i\else\raise\internote\fi%
\hbox{\raise#1\internote\hbox{\kern#2\qn@width\musixchar0\kernm#2\qn@width}}%
\global\let\C@Point\C@Psave}%
%
%  Shifted, pointed chord notes (Missing in musixtex.tex ???) 
%
\def\lhp#1{\loff{\zhp{#1}}}
\def\rhp#1{\roff{\zhp{#1}}}
\def\lqp#1{\loff{\zqp{#1}}}
\def\rqp#1{\roff{\zqp{#1}}}
%
%  Redefine to include \sk !!!
%
\def\liftpause#1{\C@ps\@l@v@n\si@{#1}\sk}
\def\lifthpause#1{\C@ps\t@n\f@ur{#1}\sk}
\def\liftpausep#1{\reflect#1\advance\reflect2%
\wholeshift{\raise\reflect\Interligne\hbox{\pt0}}\liftpause{#1}}%
\def\lifthpausep#1{\reflect#1\advance\reflect2%
\wholeshift{\raise\reflect\Interligne\hbox{\pt0}}\lifthpause{#1}}%
%
\catcode`\@=\catcodeat
