.TH M 5 "MIDI"
.SH NAME
m - music file format
.SH DESCRIPTION
\fIM\fP format is a variant of an older format known as ``MUTRAN format''
(see mutran(5)).
\fIM\fP format is designed to be easy for humans to read and edit,
and is particularly well suited to notation of multipart scores
(e.g. four-part harmonizations).
Filters exist to produce printed scores (both full and individual parts)
from \fIm\fP format, and to play m files on other, non-MIDI devices.
.PP
M format consists of control lines and data lines arranged such that
time proceeds downward with each part represented by a column of data
(and sometimes controls).
.SH "CONTROL LINES"
Control lines comprise an initial keyword followed by arguments.
The control keywords recognized are:
.IP #ARTIC
The ARTIC control specifies the articulation with which the notes are to be
played.  An argument of 1.0 makes the notes connected (\fIlegato\fP), while an
argument of 0.25 makes the notes sound for only the first quarter of their time
value (\fIstaccato\fP).
If there are fewer arguments than voices, the last argument will be used
for the extra voices; thus a single argument will set the articulation for
all the voices, but they can all be set individually if necessary.
The default value is 0.8 ( for all voices).
.IP #BAR
A measure ends here.  No arguments are used.
In scoring programs, a bar line is generated;
in \fIm2midi\fP, a Timing Clock With Measire End code is generated.
.IP #CHAN
This control assigns channels to the various voices (default is channel 1).
An decimal number argument in the range 1 to 16 is expected for each voice,
separated by whitespace.
.IP #CPQ
This control expects a single argument which sets the number of "clocks per
quarter" note.  This value must be chosen such that every note encountered
can be represented by an integral number of clocks; e.g. the presence of
eighth notes requires that CPG be a multiple of 2; dotted quarters require CPQ
to be divisible by 3; eighths \fIand\fP dotted quarters require CPQ to be a
multiple of 6, etc.
\(rh Fortunately this control is only required for output
to Votrax PSS speech synthesizers and is ignored by all other known programs.
.IP #METER
The METER control has two arguments which are the "numerator" and "denominator"
(respectively) of the time signature.
These are used by scoring programs primarily.
.IP #SOLO
This control specifies coarse volume information for each voice.
A single character argument, chosen from the following list,
is expected for each voice (separated by whitespace):
.br
.DT
.B \-
	This voice is silent (key velocity = 0)
.br
.B S
	This voice is soft (key velocity = 20)
.br
.B M
	This voice is of medium volume (key velocity = 60)
.br
.B L
	This voice is loud (key velocity = 100)
.br
Some programs may also allow decimal digits as arguments to the SOLO control
(e.g. m2mpu(1)).
The name SOLO was chosen as a reference to the "solo" buttons
on a mixing console.
.IP #TEMPO
The TEMPO control expects a single, numeric argument representing the number
of quarter notes per minute (mm).
.IP #TITLE
All arguments following the TITLE control are used as the name of the piece
by scoring programs (ignored by \fIm2midi\fP).
.IP #TRANS
This control causes scoring programs to transpose the voices by the indicated
amounts on the printed scores.  An argument is expected for each voice.
.IP #VOICES
The VOICES control defines the number of voices and associates a name with each
one.  Each voice is represented by an argument that can be any combination of
characters.  Whereas scoring programs will use the names provided here when
printing part scores, other programs may need this control to determine
how many voices are involved.
Therefore, i\fIthis control should precede all data and any controls
that expect an argument per voice.\fP
.IP #
Any line begining with a number sign
(a.k.a. ``sharp sign'', ``pound sign'', ``octothorpe'', ``hash mark'',
``scratch mark'', or ``the bottom right button on a touch-tone keypad'')
followed immediately by a <space> or <tab> character is considered a comment
and is ignored by all (well-behaved) programs.
Further, most programs will ignore any line beginning with a number sign
followed by an unrecognized keyword;
but beware of possible clashes with controls defined later.
.PP
In addition to these, programs may define controls for their own use.
It is recommended that such controls consist of the number sign followed
\fIimmediately\fP (with no intervening whitespace) by upper-case characters.
For instance, files containing melodies specified as scale-degrees (in the
socalled ``.sd'' format) add several controls \- #INIT, #CODING, #SCALE,
and #QUANT.
Further, \fImpp\fP, the music pre-processor defines several useful macro
controls; see mpp(1).
.SH Data Lines
Data lines consist of columns separated by whitespace.
The first column is the lyric and either contains one of
the special symbols ``\-'' or ``x'',
or any string of characters containing no whitespace.
``\-'' is understood by most programs
to be a placeholder and indicates that there is no associated lyric
and often no sound at all (rests are a good example).
``X'' is understood by most programs
to be a placeholder and indicates that although there is no associated lyric
there is some sound produced
(e.g. instrumental sounds, esp. drums).
All columns but the first contain notes encoded in a MUTRAN-like format.
.SH "M NOTE FORMAT"
.Cs
.in -0.8i
<Mnote>       :: <pitch><duration> | '\-'
<pitch>       :: <notename><octave> | <rest> | <tie>
<notename>    :: <letter> | <letter><accidental>
<letter>      :: 'C' | 'D' | 'E' | 'F' | 'G' | 'A' | 'B'
<accidental>  :: <sharp> | <flat>
<sharp>       :: '#' | '#' <sharp>
<flat>        :: 'b' | 'b' <flat>
<rest>        :: 'R'
<tie>         :: '('
<octave>      :: '\-1' | '0' | '1' | '2' | '3' | '4'
                      | '5' | '6' | '7' | '8' | '9'
<duration>    :: <tval> | <tval><tmod>
<tval>        :: 'W' | 'H' | 'Q' | 'E' | 'S' | 'T' | 'F'
<tmod>        :: <dot> | <plet>
<dot>         :: '.' | '.' <dot>
<plet>        :: 't' | '3' | '5' | '7' | '9'
.in +0.8i
.Ce
Octave numbers are the so-called ``scientific'' numbering;
``C4'' is middle C and ``B3'' is one half-step below it.
The time values (<tval>s) represent \fIw\fPhole, \fIh\fPalf, \fIq\fPuarter,
\fIe\fPighth, \fIs\fPixteenth, \fIt\fPhirty-second, and sixty-fourth
(\fIf\fPrill) notes, respectively.
When a tie is specified (with ``(''), the preceding note for that voice
is sustained for the additional time specified.
Note that ``\-'' as a note is understood to mean a silence with zero duration
(i.e. no note at all) and is just a placeholder.
Thus, ``C4q'', ``Rh.'', ``(e'', ``\-'', and ``Gb-1..''
are all valid m format notes.
.SH EXAMPLE
Here is a simple example (with as many control lines as possible)
of m format:
.Cs
.ta 0.8i +0.8i +0.8i +0.8i +0.8i +0.8i
% cat tbp.m
#TITLE	Teddy Bear's Picnic
# To be played ominously!
#METER	4 4
#CPQ	6
#TEMPO	150
#VOICES	Bass	Baritone	Tenor	Soprano
#TRANS	7	7	0	0
#SOLO	M	M	M	L
#CHAN	1	2	3	4
#BAR
Pic	D3q	D3q	D3q	D3q
-nic	D3q	D3q	G3q	B3q
time	C#3q	E3q	G3q	A#3q
for	D3q	G3q	G3q	B3q
#BAR
ted	C3qt	E3qt	G3qt	E4qt
-dy	B2et	E3et	G3et	B3et
bears	G2q	G3q	B3q	D4q
-	Rqt	Rqt	Rqt	Rqt
the	D3et	D3et	G3et	B3et
lit	C#3qt	E3qt	G3qt	A#3qt
-tle	D3et	G3et	G3et	B3et
#BAR
\0.
\0.
\0.
.Ce
.SH SEE ALSO
m2midi(1), m2p(1), m2v(1), midi2m(1), mpp(1), mutran(5)
.SH AUTHOR
Peter Langston, Bell Communications Research
(bellcore!psl)
