% PROJECT: MusixTeX PreProcessor
% FILE   : mpp.tex
% TITLE  : include file for MusixTeX
% AUTHOR : JCNieuwenhuizen
% COMMENT: for now, all is based upon T.392. (scrappy Egler 0.50 support) 
%          some extra changes can be found at bottom
%
% copyright (c) FlowerSoft 1995
%

% musixtex includes
%
\input musixtex
\input musixadd
%

\catcode`@=11 % treat at signs as letters

% determine version and author of musixtex
%
\def\Egler{Egler}
\def\Taupin{Taupin}
\def\setversion#1#2;{%
	\ifx T#1%
		\let\mxauthor\Taupin%
		\def\mxversionnumber{0#2}%
	\else%
		\let\mxauthor\Egler%
		\def\mxversionnumber{#1#2}%
	\fi%
}
\expandafter\setversion\mxversion;
\immediate\write0{ author: \mxauthor }
\immediate\write0{ version: \mxversionnumber }
%


% spacing stuff
%
%  \y@v\noteskip \multiply\y@v\n@v
%\qn@width and \elemskip
%
%\def\notesh{\vnotes\p@seven\elemskip}% 16th trio
%\def\notesh{\vnotes1.4\elemskip}% 16th trio
\def\notesh{\vnotes\elemskip}%        16th trio
%\def\notes{\vnotes2\elemskip}%       16th
%\def\notesp{\vnotes2\h@lf\elemskip}% 16th point=8 trio
%\def\Notesh{\vnotes1\h@lf\elemskip}% 8th trio, ok but bit too tight
%\def\Notesh{\vnotes2.25\elemskip}%    8th trio
\def\Notesh{\vnotes2\elemskip}%       8th trio
%\def\Notes{\vnotes3\elemskip}%       8th
\def\NOtesh{\vnotes4\elemskip}%       4 trio


% rename silly name of :||:
%
\let\rightleftrepeat\leftrightrepeat
%

% some handy macros
%
\def\emtpy{}
\def\gobble#1{}
\def\ugobble#1{}
\def\lgobble#1{}
\def\atswap#1#2{\zcharnote{#2}{#1}}
\let\uatswap\atswap
\let\latswap\atswap
\def\finger#1#2{\atswap{{\smalltype\bf#1}}{#2}}
\let\ufinger\finger
\let\lfinger\finger
%

% text
%
\ifx\mxauthor\Taupin
	\def\text#1#2{\atswap{{\ppffstyle #1}}{#2}}
\else % Egler
	\def\text#1#2{\atswap{{\normdyn #1}}{#2}}
\fi
%
\let\utext\text
\let\ltext\text
%

% xplets
%
\def\xplet#1{\atswap{\xpletstyle{#1}}}
\let\uxplet\xplet
\let\lxplet\xplet
%

% direction for bowing
%
\ifx\mxauthor\Taupin
	\def\uupbow{\atswap{\upbow}}
	\def\lupbow{\atswap{\upbow}}
	\def\udownbow{\atswap{\downbow}}
	\def\ldownbow{\atswap{\downbow}}
\else % Egler
% this is still a patch Egler 0.50. 
% spacing is not right
	\def\uupbow{\atswap{\ubow}}
	\def\lupbow{\atswap{\ubow}}
	\def\udownbow{\atswap{\dbow}}
	\def\ldownbow{\atswap{\dbow}}
\fi
%

% rename fermata
%
\ifx\mxauthor\Taupin
        \def\ufermata{\fermataup}
	\def\lfermata{\fermatadown}
\else % Egler
	\def\lfermata{\dfermata}
\fi
%

% rename trille/shake
%
\def\utrille#1{\text{\hbox to 0pt{tr\hss}}{#1}}
\def\ushake#1{\rlap{\shake{#1}}}
%
%\def\ucsh#1{\raise3\Interligne\hbox{\hsk\hsk\csh{#1}\bsk\bsk}}
%\def\ucsh#1{\raise3\Interligne\hbox{\hsk\hsk\csh{#1}\bsk}}
\def\ucsh#1{\raise3\Interligne\rlap{\hsk\csh{#1}}}
%
\voffset-10mm
\vsize270mm
\hsize192mm
\parindent5mm


% rename notes
% 
\let\lwh\lw
\let\rwh\rw
\let\zc\zq
\let\zcc\zq
\let\zccc\zq
\let\lc\lq
\let\lcc\lq
\let\lccc\lq
\let\rc\rq
\let\rcc\rq
\let\rccc\rq
%

% missing note macros:
% completing set is easier 
%
% whole note
%
\def\rwp#1{\pt{#1}\rw{#1}}
\def\lwp#1{\pt{#1}\lw{#1}}
%
% half note
%
\def\rhup#1{\pt{#1}\rhu{#1}}
\def\rhlp#1{\pt{#1}\rhl{#1}}
\def\lhup#1{\pt{#1}\lhu{#1}}
\def\lhlp#1{\pt{#1}\lhl{#1}}
%
\def\rhup#1{\pt{#1}\rhu{#1}}
\def\rhlp#1{\pt{#1}\rhl{#1}}
\def\lhup#1{\pt{#1}\lhu{#1}}
\def\lhlp#1{\pt{#1}\lhl{#1}}
%
% quarter note
%
\def\rqup#1{\pt{#1}\rqu{#1}}
\def\rqlp#1{\pt{#1}\rql{#1}}
\def\lqup#1{\pt{#1}\lqu{#1}}
\def\lqlp#1{\pt{#1}\lql{#1}}
%\def\rqp#1{\pt{\rq{#1}}
\def\rqp#1{\rq{.#1}}
\def\lqp#1{\pt\lq{#1}}
\def\rqb#1#2{\rq{#2}}
\def\lqb#1#2{\lq{#2}}
%
% eighth note
%
\def\rcup#1{\pt{#1}\rcu{#1}}
\def\rclp#1{\pt{#1}\rcl{#1}}
\def\lcup#1{\pt{#1}\lcu{#1}}
\def\lclp#1{\pt{#1}\lcl{#1}}
%\let\rc\rq
%\let\lc\lq
\def\rc#1{\rq{#1}}
\def\lc#1{\lq{#1}}
\def\rcp#1{\pt\rq{#1}}
\def\lcp#1{\pt\lq{#1}}
%
\ifx\mxauthor\Egler
	\let\rhl\rhd
	\let\lhl\lhd
	\let\lql\lqd
	\let\rcu\rcd
	\let\lcl\lcd
\fi
%

%shifted points
\def\rpt#1{\kern\qn@width\advancefalse\pt{{#1}}\kernm\qn@width}
\def\rppt#1{\kern\qn@width\advancefalse\ppt{{#1}}\kernm\qn@width}
%

% redefine rests:
% stupid names, but impossible to compose automatically
%
\ifx\mxauthor\Taupin
	\let\whs\pause
	\let\ccs\qs
	\let\cccs\hs
	\let\hs\hpause
	\let\qs\qp
	%\let\qsp\qpp
	\def\qsp{\qp\ds}
	\def\qps{\qp\ds}
	%\let\cs\ds
	\def\cs{\ds}
	\let\csp\dsp
	\let\ccsp\qsp
	\let\ccccs\qqs
	\let\cccl\cccd
\else % Egler
% should we have a version check here?
%\ifdim\mxversionnumber pt>0.49pt 
	\let\whs\pause
	\let\ccs\eer
	\let\cccs\eeer
	\let\hs\hr
	\let\qs\qr
	\def\qsp{\qr\er}
	\def\qps{\qr\er}
	\def\cs{\er}
	\def\csp{\eer\ds}
\fi

% what's this?
%
\let\zqs\qs
\def\zcs{\cs}
%

% rename accents: 
% wrong names for portato, staccato, pizzicato (not an accent)
%
\ifx\mxauthor\Taupin
	\let\upt\ust
	\let\lpt\lst
	\let\ust\upz
	\let\lst\lpz
	\let\usp\uppz
	\let\lsp\lppz
	\let\ufz\usfz
	\let\lfz\lsfz
	\let\bupt\bust
	\let\bupt\bust
	\let\blpt\blst
	\let\bust\bupz
	\let\blst\blpz
	\let\busp\buppz
	\let\blsp\blppz
\else %Egler
% should we have a version check here?
%\ifdim\mxversionnumber pt>0.49pt 
	\let\usf\usf
	\let\lsf\dsf
	\let\upt\ust
	\let\lpt\dst
	\let\ust\upz
	\let\lst\dpz
	\let\usp\uppz
	\let\lsp\dppz
	\let\ufz\usfz
	\let\lfz\dsfz
	\let\bupt\bust
	\let\blpt\bdst
	\let\bust\bupz
	\let\blst\bdpz
	\let\busp\buppz
       	\let\blsp\bdppz
\fi
\def\thesubtitle{}
\def\thelefttitle{}
\def\therighttitle{}
\def\thecomposer{}
\def\thetempo{}
\def\themetron{}
\let\composer\righttitle
%
%complete accidentals
\def\dna#1{\lna{#1}\na{#1}}
\def\ldna#1{\llna{#1}\lna{#1}}
\def\lldna#1{\lllna{#1}\llna{#1}}
\def\twosmallvalue{1.6} % barf
\def\threesmallvalue{2.4}
\def\llna#1{\loffset\twosmallvalue{\na{#1}}}
\def\llfl#1{\loffset\twosmallvalue{\fl{#1}}}
\def\llsh#1{\loffset\twosmallvalue{\sh{#1}}}
\def\lldfl#1{\loffset\twosmallvalue{\dfl{#1}}}
\def\lldsh#1{\loffset\twosmallvalue{\dsh{#1}}}
\def\lllna#1{\loffset\threesmallvalue{\na{#1}}}
%
% bar numbering
\def\barnumbering#1{
  \ifnum#1=\z@\nobarnumbers
  \else\barnumbers\def\freqbarno{#1}\fi}

% really boxed barnumbers

\def\wbarno@x{\lastbarpos\lin@pos \writ@volta
  \ifx\iv@sw\@ne
    \i@v\lin@pos \let\iv@sw\empty \let\tx@V\tx@v
    \ifx\pv@sw\empty \let\v@sw\@ne \fi
  \else
    \n@iii\barno \divide\n@iii\freqbarno\relax
    \ifnum\n@iii=\lastbarno
    \else \y@\altplancher \advance\y@\systemheight \advance\y@\tw@\internote
%      \raise\y@\llap{\it\the\barno\kernm\qn@width}\fi
      \advance\y@\raisebarno\raise\y@\llap{\putbarno\kernm\qn@width}\fi
  \fi
  \n@iii\barno \divide\n@iii\freqbarno\relax \lastbarno\n@iii }

\def\italic{\it\the\barno}
\def\boxed{\boxit{\eightbf\the\barno}}
\def\putbarno{\italic}
\def\writebarno{\putbarno}
\let\old@systemnumbers\systemnumbers
\def\systemnumbers{\gdef\raisebarno{\f@ur\internote}\old@systemnumbers}
\def\writebarno{\putbarno}
\def\raisebarno{\@ne\internote}
%
\let\idecresc\icresc

\def\smallsk{\off{\smallvalue\qn@width}}
\def\smallsk{\hsk}
\def\smallsk{\off{\qu@rt\noteskip}}
\def\smallsk{\off{\smallvalue\elemskip}}
%no occasionally small accidentals
\bigaccid
\def\putdynamics#1{\llap{#1\hskip.2em}}
%\batchmode


\def\MoreInstrumentDefs{
        \vsize280mm
        \voffset-20mm
        \smallmusicsize
        \def\ppffstyle{\ppffsixteen}
        \def\directstyle{\tenit}
	\def\xpletstyle{\eightit}
}
\def\OneInstrumentDef{
        \normalmusicsize
        \def\ppffstyle{\ppfftwenty}
        \def\directstyle{\twelveit}
        \def\xpletstyle{\tenit}
} 
\def\CommonTitleDefs{
        \hbox to\hsize{{\hfill\BIGtype\bf\thetitle\hfill}}
        \medskip\medskip
        \hbox to\hsize{{\hfill\Bigtype\thesubtitle\hfill}}
        \medskip
        \hbox to\hsize{{\hfill\bigtype\bf\therighttitle\thecomposer}}
        \hbox to\hsize{{\hfill\eightrm typeset by MusixTeX}}
%      \hbox to\hsize{{\hfill\eightrm and mpp}}
        \hbox to\hsize{{\hfill\eightrm and music2tex}}
        \medskip
        \hbox to\hsize{{\hskip20mm\bigtype\bf\thelefttitle\hskip6mm
        \medtype\rm\thetempo\hskip6mm
        \ifx\themetron\empty\else\raise.2ex
        \hbox{\medtype\rm\Notes\expandafter\metron\themetron\en}\fi\hfill}}
        \bigskip
         \startmuflex
}

% additional Egler 0.50 changes 
%
\ifx\mxauthor\Egler
	\immediate\write0{ \Egler stuff }
% these seem to have gone
	\let\startmuflex\relax
	\let\endmuflex\relax
% this has changed too, ignore for now!
	\def\metron#1{}
% and lots of macros are renamed.
	\let\alaligne\nextline
	\let\Interligne\Interline
	\let\ppffstyle\normdyn
\fi

% Egler 0.50: more "l" to "d" translations
%
\ifx\mxauthor\Egler
	\immediate\write0{ more \Egler stuff }
	\let\Ibl\Ibd
	\let\Ibll\Ibdd
	\let\Iblll\Ibddd
	\let\Ibllll\Ibdddd
	\let\nbl\nbd
	\let\nbbl\nbbd
	\let\nbbbl\nbbbd
	\let\nbbbbl\nbbbbd
	\let\tbl\tbd
	\let\tbbl\tbbd
	\let\tbbbl\tbbbd
	\let\tbbbbl\tbbbbd
	\let\hl\hd
	\let\hlp\hdp
	\let\hlpp\hdpp
	\let\ql\qd
	\let\qlp\qdp
	\let\qlpp\qdpp
	\let\cl\cd
	\let\clp\cdp
	\let\clpp\cdpp
	\let\ccl\ccd
	\let\cclp\ccdp
	\let\cclpp\ccdpp
\fi

\catcode`@=12 % at signs are no longer letters

%% end: mpp.tex
