% mtx.tex      © 2001–2016 Dirk Laurie     License: MIT (see file LICENSE)
%    Some code © 2001 André van Ryckeghem  License: GPL
%    Revised font-handling copyright 2019 Bob Tennent License:  GPL

% 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.63c}
\def\mtxtexdate{15 January 2019}
\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
% \mtxTimes: replaces Computer Modern font definitions of
%    \eightrm, \eightit, \eightbf etc by Times
% \mtxHelvetica: replaces Computer Modern font definitions of
%    \eightsf etc by Helvetica

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

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

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

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

% define "big" Sans fonts for "italic" as well as "Roman"

\font\mtxfrtsf=cmss12 scaled \magstep1
\font\mtxfrtsi=cmssi12 scaled \magstep1

\font\mtxsvtsf=cmss12 scaled \magstep2
\font\mtxsvtsi=cmssi12 scaled \magstep2

\font\mtxtwtysf=cmss12 scaled \magstep3
\font\mtxtwtysi=cmssi12 scaled \magstep3

\font\mtxtwfvsf=cmss12 scaled \magstep4
\font\mtxtwfvsi=cmssi12 scaled \magstep4

\def\mtxPalatino{
  \input musixplt
  \def\bigtype{\bigfont\bf}
  \def\Bigtype{\Bigfont\bf}
  \def\BIgtype{\BIgfont\bf}
  \def\BIGtype{\BIGfont\bf}
  \elevenrm
}

\def\mtxTimes{
  \input musixtmr
  \def\bigtype{\bigfont\bf}
  \def\Bigtype{\Bigfont\bf}
  \def\BIgtype{\BIgfont\bf}
  \def\BIGtype{\BIGfont\bf}
  \elevenrm
}

\def\mtxHelvetica{
  \font\mtxeightsf=phvr8t at 8pt
  \font\mtxtensf=phvr8t at 10pt
  \font\mtxelevensf=phvr8t at 11pt
  \font\mtxtwelvesf=phvr8t at 12pt

  \font\mtxfrtsf=phvr8t scaled \magstep2
  \font\mtxfrtsi=phvro8t scaled \magstep2 

  \font\mtxsvtsf=phvr8t scaled \magstep3
  \font\mtxsvtsi=phvro8t scaled \magstep3

  \font\mtxtwtysf=phvr8t scaled \magstep4
  \font\mtxtwtysi=phvro8t scaled \magstep4

  \font\mtxtwfvsf=phvr8t scaled \magstep5
  \font\mtxtwfvsi=phvro8t scaled \magstep5
}

\def\mtxAllsf{
  \def\bigtype{
     \let\rm\mtxfrtsf
     \let\it\mtxfrtsi
     \rm
   }
  \def\Bigtype{
     \let\rm\mtxsvtsf
     \let\it\mtxsvtsi
     \rm
   }
  \def\BIgtype{
     \let\rm\mtxtwtysf
     \let\it\mtxtwtysi
     \rm
   }
  \def\BIGtype{
     \let\rm\mtxtwfvsf
     \let\it\mtxtwfvsi
     \rm
   }
  \mtxelevensf
}


\def\mtxInstrfont{\twelvebf}

% \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
