% Additional macros I find useful.
% 

\ifx\undefined\debutmorceau
  \input musicnft
  \input musictex
\fi

% I don't want to try to figure out where the underfull boxes come from.
\hbadness = 10000


% \beat{SPACING}{TREBLE-STUFF}{BASS-STUFF}.  We can tell what clef we're
% in by looking at ut@ref.  0 = treble, 6 = bass, 1-4 = alto.  We set
% the spacing to be SPACING * \elemskip.
% 
\def\beat#1#2#3{%
  \noteskip = #1\elemskip % \noteskip = 1.1\noteskip
  \n@otes {\the\everystaff #3}|{\the\everystaff #2}\enotes
  \ignorespaces
}%

% \bbeat is the same, except for two instruments.  \beat should figure
% out what to do based on \nbinstruments. xx
%
\def\bbeat#1#2#3#4#5{%
  \noteskip = #1\elemskip
  \n@otes {\the\everystaff #5}|{\the\everystaff #4}%
         &{\the\everystaff #3}|{\the\everystaff #2}%
  \enotes
  \ignorespaces
}


% Abbreviation for a dotted #1 note at pitch #2, e.g., \dotted\zql D.
% 
\def\dotted#1#2{\pt{#2}#1{#2}}%


% Abbreviations for beams:
% 
% \@dobeam starts a beam and sets the first note.  #1 is the command to
% start the beam; #2 the command to set the first note.  #3, #4, and #5
% are the usual three arguments to beam commands.
% 
\def\@dobeam#1#2#3#4#5{%
  #1{#3}{#4}{#5}% Start the beam.
  #2{#3}{#4}% Do the first note.
}

% For when the note doesn't use the beam number.
\def\@dozbeam#1#2#3#4#5{%
  #1{#3}{#4}{#5}% Start the beam.
  #2{#4}% Do the first note.
}
% We can have both lower and upper beams, up to four strokes.
% \qh and \qb are used to put the notes on beams, as opposed to \ql and
% \qu.
% 
\def\ubeam{\@dobeam\ibu\qh}
\def\ubeamp{\@dobeam\ibu\qhp}
\def\zubeam{\@dozbeam\ibu\zq}
%
\def\ubbeam{\@dobeam\ibbu\qh}
\def\ubbeamp{\@dobeam\ibbu\qhp}
\def\zubbeam{\@dozbeam\ibbu\zq}
%
\def\ubbbeam{\@dobeam\ibbbu\qh}
\def\ubbbeamp{\@dobeam\ibbbu\qhp}
\def\zubbbeam{\@dozbeam\ibbbu\zq}
%
\def\ubbbbeam{\@dobeam\ibbbbu\qh}
\def\ubbbbeamp{\@dobeam\ibbbbu\qhp}
\def\zubbbbeam{\@dozbeam\ibbbbu\zq}

\def\lbeam{\@dobeam\ibl\qb}
\def\lbeamp{\@dobeam\ibl\qbp}
\def\zlbeam{\@dozbeam\ibl\zq}
%
\def\lbbeam{\@dobeam\ibbl\qb}
\def\lbbeamp{\@dobeam\ibbl\qbp}
\def\zlbbeam{\@dozbeam\ibbl\zq}
%
\def\lbbbeam{\@dobeam\ibbbl\qb}
\def\lbbbeamp{\@dobeam\ibbbl\qbp}
\def\zlbbbeam{\@dozbeam\ibbbl\zq}
%
\def\lbbbbeam{\@dobeam\ibbbbl\qb}
\def\lbbbbeamp{\@dobeam\ibbbbl\qbp}
\def\zlbbbbeam{\@dozbeam\ibbbbl\zq}


% And here's how to end the beams; #1 is the reference number, #2 the
% note pitch.
% 
\def\endubeam#1#2{\tbu{#1}\qh{#1}{#2}}
%\def\endubbeam#1#2{\tbbu{#1}\qh{#1}{#2}}
%\def\endubbbeam#1#2{\tbbbu{#1}\qh{#1}{#2}}
%\def\endubbbbeam#1#2{\tbbbbu{#1}\qh{#1}{#2}}
\def\endlbeam#1#2{\tbl{#1}\qb{#1}{#2}}
%\def\endlbbeam#1#2{\tbbl{#1}\qb{#1}{#2}}
%\def\endlbbbeam#1#2{\tbbbl{#1}\qb{#1}{#2}}
%\def\endlbbbbeam#1#2{\tbbbbl{#1}\qb{#1}{#2}}

% Similar abbreviations for ties.  #1 is the tie reference number, #2
% the note value.
% 
% These use half notes.
\def\lhltie#1#2{\@doltie\zhl{#1}{#2}}
\def\lhltiep#1#2{\@doltie{\dotted\zhl}{#1}{#2}}
\def\lhutie#1#2{\@doltie\zhu{#1}{#2}}
\def\lhutiep#1#2{\@doltie{\dotted\zhu}{#1}{#2}}
\def\@doltie#1#2#3{\itenl{#2}{#3}#1{#3}}

\def\uhltie#1#2{\@doutie\zhl{#1}{#2}}
\def\uhltiep#1#2{\@doutie{\dotted\zhl}{#1}{#2}}
\def\uhutie#1#2{\@doutie\zhu{#1}{#2}}
\def\uhutiep#1#2{\@doutie{\dotted\zhu}{#1}{#2}}
\def\@doutie#1#2#3{\itenu{#2}{#3}#1{#3}}

\let\endtie=\tten


% Ornaments.
% 
\def\trillo#1{\zcharnote{#1}{{\musicsixteen\char"57 }}}

% Just moving.
\def\skneg{\off{-\noteskip}}
\def\offset#1{\off{3pt}#1\off{-3pt}}



\def\oneinstrument{%
  \def\nbinstruments{1}	% One instrument
  \nbporteesi = 2	% Two staves.
  \cleftoksi = {6000}	% Bottom (first) staff is bass clef.
}
\def\twoinstruments{%
  \def\nbinstruments{2}
  \nbporteesi = 2	% Two staves for each.
  \nbporteesii = 2
  \let\beat = \bbeat
}

\def\interfacteur{12}	% Extra space between staves (default is 9).

% \beginscore{NOTESPACING} starts a score.  The spacing should be an
% optional parameter.
\def\beginscore#1{%
  \parindent = 0pt
  \debutmorceau
  \elemskip = #1%
  \computewidths
}

\def\endscore{\suspmorceau\end}
