% mtx.tex      © 2001–2016 Dirk Laurie     License: MIT (see file LICENSE)
%    Some code © 2001 André van Ryckeghem  License: GPL
% Corrections: see mtxtexdate, below.

% All TeX commands put directly into PMX files by M-Tx are defined below,
%   except the following:
% 1. \input mtx
% 2. User's own inline TeX
% 3. \mtxversion and \mtxdate are defined in prepmx itself
% 4. Utterly basic TeX commands like "\ " and "%"
% It is therefore possible for a TeXpert to tune the performance
%   of M-Tx without touching the preprocessor.

% Commands borrowed unchanged from André van Ryckeghem's mypmxdef.tex
%   have AVR prepended to their names.
% All other commands start with the letters "\mtx" except one:
%  "\:" is a short alias for "\relax" to save space on input line length

\ifx\mtxtexversion\undefined\else\endinput\fi 

\def\mtxtexversion{0.62}
\def\mtxtexdate{20 October 2016}
\let\:=\relax
\immediate\write10{%
mtxTeX \mtxtexversion\space<\mtxtexdate>} 

\input musixtex
\def\musixtexneeded{121}
\ifnum\mxvernumber<\musixtexneeded\immediate\write16{ }
\message{! Requires MusiXTeX Version \musixtexneeded. Please upgrade.}\fi

\input pmx      % needed here otherwise musixlyr does not load correctly
\input musixlyr
\ifx\assignlyricshere\undefined\message{! Your musixlyr.tex is too old}\fi

% M-Tx font definitions
% \mtxeightsf etc: defines \eightsf etc by analogy to \eightrm. 
% \mtxEightsf etc: same, but also immediately does \eightsf.
% \mtxPalatino: replaces Computer Modern font definitions of
%    \eightrm, \eightit, \eightbf etc by Palatino
% \mtxHelvetica: replaces Computer Modern font definitions of
%    \eightsf etc by Helvetica

\def\mtxeightsf{\font\eightsf=cmss8}
\def\mtxEightsf{\mtxeightsf\eightsf}

\def\mtxtensf{\font\tensf=cmss10}
\def\mtxTensf{\mtxtensf\tensf}

\def\mtxelevensf{\font\elevensf=cmss10 scaled \magstephalf}
\def\mtxElevensf{\mtxelevensf\elevensf}

\def\mtxtwelvesf{\font\twelvesf=cmss12}
\def\mtxTwelvesf{\mtxtwelvesf\twelvesf}

\def\mtxbigsf{\font\Bigtype=cmss9 scaled \magstep1}
\def\mtxBIgsf{\font\Bigtype=cmss9 scaled \magstep2}
\def\mtxBIGsf{\font\BIGtype=cmss9 scaled \magstep3}
\def\mtxBIGsf{\font\BIGtype=cmss9 scaled \magstep4}

\def\mtxPalatino{
\font\eightrm=pplr at 8truept
\font\eightbf=pplb at 8truept
\font\eightit=pplri at 8truept

\font\tenrm=pplr at 10truept
\font\tenbf=pplb at 10truept
\font\tenit=pplri at 10truept

\font\elevenrm=pplr at 11truept
\font\elevenbf=pplb at 11truept
\font\elevenit=pplri at 11truept

\font\twelverm=pplr at 12truept
\font\twelvebf=pplb at 12truept
\font\twelveit=pplri at 12truept

\font\bigtype=pplb at 14truept
\font\Bigtype=pplb at 17truept
\font\BIgtype=pplb at 20truept
\font\BIGtype=pplb at 25truept
}

\def\mtxHelvetica{
  \def\mtxeightsf{\font\eightsf=\phvr at 8truept}
  \def\mtxtensf{\font\tensf=\phvr at 10truept}
  \def\mtxelevensf{\font\elevensf=\phvr at 11truept}
  \def\mtxtwelvesf{\font\twelvesf=\phvr at 12truept}
}

\def\mtxInstrfont{\twelvebf}
\def\mtxAllsf{\mtxeightsf\mtxtensf\mtxElevensf\mtxtwelvesf\mtxBigsf\mtxBIGsf}

\def\sit\eightit \def\srm\eightrm \def\sbf\eightbf \def\ssf\eightsf
% \def\elevenpt{\def\rm\elevenrm \def\it\elevenit \def\bf\elevenbf}

% M-Tx music sizes

\def\mtxTinySize{\tinyvalue}
\def\mtxSmallSize{\smallvalue}
\def\mtxNormalSize{\normalvalue}
\def\mtxLargeSize{\largevalue}
\def\mtxHugeSize{\Largevalue}

% musixlyr interface

% TODO: use musixlyr 'here' commands, e.g as in the following line
\def\mtxAt#1{\lyrraisehere{#1\internote}}%
% not emitted by prepmx yet

\def\mtxSetLyrics#1#2{\setlyrics{#1}{#2}}
\def\mtxCopyLyrics#1#2{\copylyrics{#1}{#2}}
\def\mtxAssignLyrics#1#2{\assignlyrics{#1}{#2}}
\def\mtxAuxLyr#1{\auxlyr{#1}}
\def\mtxLyrlink{\lyrlink}
%
% 2003-08-05, scancm@biobase.dk: corrected definition of \mtxLowLyrlink
%
\def\mtxLowLyrlink{\lowlyrlink}
\def\mtxLyricsAdjust#1#2{\setsongraise{#1}{#2\internote}}
\def\mtxAuxLyricsAdjust#1#2{\auxsetsongraise{#1}{#2\internote}}
\def\mtxLyrModeAlter#1{\lyrmodealter{#1}}
\def\mtxLyrModeNormal#1{\lyrmodenormal{#1}}
\def\mtxBM{\beginmel}
\def\mtxEM{\endmel}
\def\mtxAuxBM{\auxlyr\mtxBM}
\def\mtxAuxEM{\auxlyr\mtxEM}

% Other macros

\def\mtxTenorClef#1{\settrebleclefsymbol{#1}\treblelowoct}
\def\mtxVerseNumber#1{#1 }
\def\mtxInterInstrument#1#2{\setinterinstrument{#1}{#2\Interligne}}
\def\mtxStaffBottom#1{\gdef\atnextline{\stafftopmarg #1\Interligne}}
\def\mtxGroup#1#2#3{\grouptop{#1}{#2}\groupbottom{#1}{#3}}
\def\mtxPageHeight#1{\vsize #1}
\def\mtxTwoInstruments#1#2{\vbox{\hbox{#1}\hbox{#2}}}
\def\mtxTitleLine#1{\gdef\mtxTitle{#1}}
\def\mtxComposerLine#1#2{\gdef\mtxPoetComposer{#1\hfill #2}}
\def\mtxInstrName#1{{\mtxInstrfont #1}}
\def\mtxSetSize#1#2{\setsize{#1}{#2}}
\def\mtxDotted{\dotted}
\let\mathflat\flat
\let\mathsharp\sharp
\def\flat{\musixfont\char'062}
\def\sharp{\musixfont\char'064}
%\def\mtxSharp{\raise1ex\hbox{\musicsmallfont\char'064}}
%\def\mtxFlat{\raise1ex\hbox{\musicsmallfont\char'062}}
\def\mtxSharp{\raise1ex\hbox{\sharp}}
\def\mtxFlat{\raise1ex\hbox{\flat}}
\def\mtxIcresc{\icresc}
\def\mtxTcresc{\tcresc}
\def\mtxCresc#1{\crescendo{#1\elemskip}}
\def\mtxIdecresc{\icresc}
\def\mtxTdecresc{\tdecresc}
\def\mtxDecresc#1{\decrescendo{#1\elemskip}}
\def\mtxPF{\ppff}
\def\mtxLchar#1#2{\lchar{#1}{#2}}
\def\mtxCchar#1#2{\cchar{#1}{#2}}
\def\mtxZchar#1#2{\zchar{#1}{#2}}
\def\mtxVerseNumberOffset{3}
\def\mtxVerse{\loffset{\mtxVerseNumberOffset}\lyr}
\makeatletter
\def\comma#1{\check@staff\raise1.2\internote\llap{\BIGfont'\kern#1\noteskip}\fi}
\makeatother

%\def\mtxVerse{%
%  \znotes\minlyrspace=-10cm%     to inhibit right-shifting of the numbers
%         \llyr\lyroffset{-2}%    make the numbers stand off to the left
%         \lyr%                   post the numbers
%  \en}

% Commands taken from André van Ryckeghem's mypmxdef.tex
% Page layout: Letter/A4, A4 only, Letter/A4 centered, A3 
% Use only with plain TeX: these do not interact seamlessly with 
% LaTeX page layout commands!
\def\AVRpagforletaiv{%
\hoffset=-12.4mm\hsize=210mm\advance\hsize-23mm% A4 10mm margin
\voffset-15.4mm\vsize=11in\advance\vsize-20mm\advance\vsize-12pt}% letter 10 mm margin
\def\AVRpagforaiv{%
\hoffset=-12.4mm\hsize=210mm\advance\hsize-23mm%
\voffset=-15.4mm\vsize=297mm\advance\vsize-20mm\advance\vsize-12pt}%
\def\AVRpagforaivc{%
\hoffset=-12.4mm\hsize=210mm\advance\hsize-23mm%
\voffset=-7.4mm\vsize=11in\advance\vsize-20mm\advance\vsize-12pt}%
\def\pagforaiii{%
\hoffset=-5.4mm\hsize=297mm\advance\hsize-37mm%
\voffset=-5.4mm\vsize=420mm\advance\vsize-37mm\advance\vsize-12pt}%

% Next command adapted from AVR's code. Use thus:
%  \footline=\mtxFootLine{P1}{P2}{P3}{P4}{P5}
% The footline on pages 3 and 4 look like this:
%     P1 - P2           P3          P4 - P5      3
%  4  P5 - P4           P3          P2 - P1
% Each parameter should contain its own font selector, or inherit
%   whatever was in effect.
\def\mtxFootline#1#2#3#4#5{\ifodd\pageno%
{{{#1}{\rm~---~}{#2}} \hfill {#3} \hfill {#4}{\rm~---~}{#5}{\rm ~~~ }{\bf \folio }}%
\else
{{\bf \folio}{\rm ~~~ }{#5}{\rm~---~}{#4} \hfill {#3} \hfill {#2}{\rm~---~}{#1}}%
\fi}

% M-Tx default settings

\sepbarrules
\mtxPalatino
\elevenrm     % this will be the lyrics font unless overridden

\immediate\write10{=== end of mtx.tex ===}
\endinput
