LaTeX

pmx

Precompiler for MusiXTeX

pmx is a precompiler for MusiXTeX, which has a much easier syntax then MusiXTeX itself.
PMX Bei PMX wird mit dem ASCII-Editor die Quelldatei <dateiname>.pmx erstellt. Der Befehl pmxab <dateiname> erstellt daraus die Datei <dateiname>.tex, die dann wie oben beschrieben weiterbearbeitet wird.

Save the following code as ~/Documents/programming/latex/music_latex/pmx/haydn_quatuor.pmx

PMX-File with Music: haydn_quatuor.pmx
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
% PRAEAMBEL
4 4 4 4 0 6 0 -1
1 1 16 .085
Vc
Va
Vl II
Vl I
batt
./
% CORPUS
Ab
It92ivcvavlvl
w180m
h
Allegro
% Takt 1
d8-- Df o. d+ o. d o. d o. r d o. d o. d o. /
f8- Df o. f o. f o. f o. r f o. f o. f o. /
r8 a Df o. a o. a o. r a o. a o. a o. /
a2+ Df d- /

% Takt 2
r8 d o. d o. d o. r e o. e o. e o. /
r8 g o. g o. g o. r g o. g o. g o. /
r8 b o. b o. b o. r cs o. c o. c o. /
e2 a- /


% Takt 3-4
f8 s e f cs s d4 a | b2 s a4 s o. r Rb /
a2 t a4 t .cs- | d8 s e f d s e4 o. r /
d8 s cs d e s e s d c s a1+ s g s | f s g f e s d8 o. d o. cs4 r /
d8 s cs d e s g s f e s a | d4- zd+ cn1 s b a gs s a4 o. r /

Because the pmx is a precompiler for LaTeX we need one more command in our shell.

Commands in tcsh (Shell - Terminal)
1.pmxab haydn_quatuor

This creates following files:
haydn_quatuor.mid
haydn_quatuor.pml
haydn_quatuor.tex

That's interesting: we have a Midi-File, which you are able to listen too! The TeX-File haydn_quatuor.tex looks like follows:

LaTeX-File with Music (created with haydn_quatuor.pmx): haydn_quatuor.tex
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
%%%%%%%%%%%%%%%%%
%
% haydn_quatuor.tex
%
%%%%%%%%%%%%%%%%
\input musixtex
\input pmx
\setmaxslurs{24}\setmaxinstruments{24}%
\smallmusicsize%
\nopagenumbers
\tracingstats=2\relax
\hsize=510pt
\vsize740pt
\def\nbinstruments{4}
\setstaffs11
\setclef16
\setname1{Vc}
\setstaffs21
\setclef23
\setname2{Va}
\setstaffs31
\setclef30
\setname3{Vl II}
\setstaffs41
\setclef40
\setname4{Vl I}
\generalsignature{-1}%
\generalmeter\meterC%
\parindent 43pt
\elemskip1pt\afterruleskip1.000pt\beforeruleskip0pt\relax
\stafftopmarg0pt\staffbotmarg5\Interligne\interstaff{10}\relax
\readmod{haydn_quatuor}
\startmuflex\startpiece\addspace\afterruleskip%
\bigaccid%
\znotes&&&\zcharnote{16}{\titles{2.0}{}{0}{}{0}{}{0}}\en%
% Bar count 1
\pnotes{2.00}\ibu1{'B}0\pmxdyn{-9}0\f\lpz{`D}\qb1D\lpz{'D}\qb1D\lpz D%
\qb1D\lpz D\tbu1\qb1D\ds\ibu1D0\lpz D\qb1D\lpz D\qb1D\lpz D\tbu1\qb1D&%
\ibu2{`f}0\pmxdyn{-6}0\f\lpz f\qb2f\lpz f\qb2f\lpz f\qb2f\lpz f%
\tbu2\qb2f\ds\ibu2f0\lpz f\qb2f\lpz f\qb2f\lpz f\tbu2\qb2f&\ds\ibu3b0%
\pmxdyn{-10}0\f\lpz a\qb3a\lpz a\qb3a\lpz a\tbu3\qb3a\ds\ibu3b0\lpz a%
\qb3a\lpz a\qb3a\lpz a\tbu3\qb3a&\zcharnote{16}{\bigfont\kern-30pt %
Allegro}\pmxdyn{-5}0\f\hu{'a}\sk\sk\sk\hu{`d}\en%
% Bar count 2
\xbar
\pnotes{2.00}\ds\ibu1{'D}0\lpz D\qb1D\lpz D\qb1D\lpz D\tbu1\qb1D\ds%
\ibl1E0\upz E\qb1E\upz E\qb1E\upz E\tbl1\qb1E&\ds\ibu2{`g}0\lpz g\qb2g%
\lpz g\qb2g\lpz g\tbu2\qb2g\ds\ibu2g0\lpz g\qb2g\lpz g\qb2g\lpz g%
\tbu2\qb2g&\ds\ibu3b0\lpz b\qb3b\lpz b\qb3b\lpz b\tbu3\qb3b\ds\ibu3c0%
\lpz c\bigsh c\qb3c\lpz c\qb3c\lpz c\tbu3\qb3c&\hu e\sk\sk\sk\hu a\en%
% Bar count 3
\xbar
\pnotes{2.00}\ibl1{'E}0\isluru0F\qb1F\qb1E\qb1F\tslur0C\bigsh C%
\tbl1\qb1C\qu D\sk\qu A&\islurd0a\hu a\sk\sk\sk\tslur0a\qup a&\ibu3d0%
\islurd0d\qb3d\bigsh c\qb3c\qb3d\tslur0e\tbu3\qb3e\ibu3e{-2}\islurd0e%
\qb3e\tbu3\qb3d\ibu3f4\tslur0c\qb3c&\ibu4d0\islurd0d\qb4d\bigsh c\qb4c%
\qb4d\tslur0e\tbu4\qb4e\ibu4f1\islurd0g\qb4g\qb4f\tslur0e\qb4e\en%
\pnotes{1.41}&\bigsh{`c}\cu c&\islurd0{'a}\nbbu3\qb3a\tslur0{`g}%
\tbu3\qb3g&\tbu4\qb4{'a}\en%
% Bar count 4
\xbar
\pnotes{1.41}\islurd0{'B}\hu B&\ibu2{`e}0\islurd1d\qb2d\sk\qb2e\sk\qb2f%
\sk\tslur1d\tbu2\qb2d&\ibbu3f0\islurd1f\qb3f\qb3g\qb3f\tslur1e\tbu3\qb3e%
\ibu3d0\lpz d\qb3d\sk\lpz d\tbu3\qb3d&\zq{'d}\qu{`d}\sk\sk\sk%
\ibbu4{'b}{-2}\islurd1c\bigna c\qb4c\qb4b\qb4a\ast{.31}\tslur1{`g}\sh g%
\tbu4\qb4g\en%
\pnotes{2.83}\tslur0G\lpz{'A}\qu A\qp&\lpz{`e}\qu e\qp&\bigsh c\qu c\qp&%
\lpz{'a}\qu a\qp\en%
\endpiece
\vfill\eject\endmuflex
\bye

Look closer to this code: it is different to the LaTeX-Example exp_01.tex! It is written in old legacy TeX-dialect, which you have to compile differently then our first LaTeX-Example exp_01.tex

Commands in tcsh (Shell - Terminal) for the plain TeX-file haydn_quatuor.tex
1.etex haydn_quatuor

This creates new files:
haydn_quatuor.log
haydn_quatuor.mx1

Commands in tcsh (Shell - Terminal) for the plain TeX-file haydn_quatuor.tex and haydn_quatuor.mx1
1.musixflx haydn_quatuor

This creates the new file:
haydn_quatuor.mx2 And now we pass etex again:

Commands in tcsh (Shell - Terminal) for the plain TeX-file haydn_quatuor.tex and haydn_quatuor.mx2
1.etex haydn_quatuor

This creates the new file:
haydn_quatuor.dvi which we need to transform into a pdf-file:

Commands in tcsh (Shell - Terminal) for the plain dvi-file haydn_quatuor.dvi
1.dvipdf haydn_quatuor

Pretty complicate, isn't it? If you really want to work with pmx music encoding, safe the following shell-script to compile everything from beginning to end:

Shell-script to compile a pmx file compile_pmx.sh:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
#!/bin/tcsh

# or for bash: #!/bin/bash

# This shell script is removing the extension first, if you enter the command
# by error like ./compile_musix.sh file-name.pmx
#

set name=`echo $1 | cut -f1 -d'.'`

echo "file name is now $name !"

if ( -e "$name.mx1" ) then
rm -f $name.mx1 $name.mx2

echo "$name.mx1 and $name.mx2 are removed."
else
echo "$name.mx1 and $name.mx2 does not exist, so I proceed directly to compile $name"
endif

echo "Now I will compile your music-file $name.tex from scratch ..."

pmxab $name
etex $name
musixflx $name
etex $name
dvipdf $name
open $name.pdf

Save this script, and next time, compiling your next, issue the following command in your shell:

Command for your shell-script in tcsh (Shell - Terminal) for your file.pmx
1../compile_pmx.sh file[.pmx]

The extension .pmx is useless, in other words: you only need to enter the basename. But if you forget about it, the script is caring of it and removes the extension .pmx for you.