--- /dev/null
+<HTML>
+<HEAD><TITLE>
+Mup MIDI output
+</TITLE></HEAD>
+<BODY>
+<P>
+ <A HREF="pstools.html"><-- previous page</A>
+
+ <A HREF="index.html">Table of Contents</A>
+<H1>
+MIDI OUTPUT
+</H1>
+<P>
+Mup will optionally produce MIDI output
+<A HREF="cmdargs.html#moption">(using the -m command line argument).</A>
+Mup is first and foremost a music publication program,
+so its MIDI capabilities have a few limitations.
+However, the MIDI output is quite useful for "proofreading"
+(or perhaps we should say "proof-listening").
+It is often easier to spot a typo in Mup input by
+listening to it than to look at the output. Mup provides enough MIDI
+control to do virtually all of what MIDI supports, and will be adequate
+for many people. Others however, may find they want a separate MIDI editor
+for really serious MIDI work.
+</P>
+<P>
+The following section assumes a general knowledge of MIDI. If you are not
+familiar with MIDI, there are many books available on the subject
+at most music stores or computer book stores.
+</P>
+<P>
+Each
+<A HREF="param.html#vscheme">voice</A>
+is put on a separate MIDI track. The first track contains
+general information such as key and time signature. The next track will be for
+staff 1, voice 1. If staff 1 has a second voice, that will be the next
+track, otherwise it will be voice 1 of staff 2, if any, and so forth,
+one track for each voice, top to bottom.
+</P>
+<P>
+Output is in MIDI file format 1, with a default of 120 quarter notes
+per minute, 192 ticks per quarter note. MIDI channel 1 is used by default for
+all voices. If you want to use different instrument sounds for different
+voices, you will need to specify a different channel for each voice, then
+specify the MIDI "program" for that voice. This is demonstrated in some
+of the examples later in this section.
+</P>
+<P>
+Mup MIDI output will handle
+<A HREF="bars.html">repeats</A>
+and
+<A HREF="bars.html#endings">first and second endings,</A>
+but it does not know anything about "D.S. al coda" or anything of that sort.
+It is possible to work around this limitation to some extent using
+<A HREF="macros.html">macros.</A>
+For example, a section between a "sign" and a "jump to coda" symbol could
+be put inside a macro definition, then the macro can be called. Then later
+in the piece, where the "D. S." occurs the macro can be called again if MIDI
+is defined. For example:
+<BR><PRE>
+// an introductory section, ends with a sign
+1: c;d;e;f;
+mussym above all: 5 "sign";
+bar
+
+// define macro for section between sign and
+// symbol to "jump to coda"
+define SECTION
+1: g;a;g;;
+mussym above all: 5 "coda";
+bar
+@
+
+// print/play the section just defined by
+// the macro
+SECTION
+
+// now do the music up to the D.S.
+1: e;f;2g;
+ital above 1: 1 "D. S. al Coda";
+dblbar
+
+// human player would now flip back to
+// the sign, so do the MIDI equivalent:
+// play that section again.
+ifdef MIDI
+ SECTION
+endif
+
+// now do the coda
+1: e;d;2c;
+rom above 1: 0 "Coda";
+endbar
+</PRE><BR>
+</P>
+<P>
+Mup mainly just outputs the note information.
+Mup will recognize
+<A HREF="octave.html">octave marks,</A>
+and move notes up or down appropriately.
+It recognizes
+<A HREF="pedal.html">piano pedal marks.</A>
+It does not attempt to interpret tempo or dynamics marks
+specified by
+<A HREF="textmark.html">"rom," "boldital," etc. or ornaments in</A>
+<A HREF="mussym.html">"mussym" statement.</A>
+It does interpret
+<A HREF="bars.html#reh">rehearsal marks</A>
+as cue points.
+It handles
+<A HREF="chrdattr.html#chstyle">grace notes,</A>
+<A HREF="roll.html">rolls,</A>
+<A HREF="chrdattr.html#slashes">slashes,</A>
+and
+<A HREF="ichdattr.html#alt">alternation groups.</A>
+You can control how legato the music is by using
+<A HREF="param.html#release">the Mup "release" parameter.</A>
+</P>
+<P>
+Some styles of music are often
+written in "swing time," meaning the
+players are expected to play pairs of notes with the first twice
+as long as the second, even though they are written as if they were the
+same duration, or as if the first were three times as long as the second.
+The most common example would be where the written notation shows
+two eighth notes like 8;; or a dotted rhythm like 8.;16;
+but the musician "knows" that the composer really intended it
+to be played as if it were a triplet {4;8;}3;
+The
+<A HREF="param.html#swing">swingunit</A>
+parameter can be used to get Mup MIDI output to automatically follow
+that performance convention.
+</P>
+<P>
+A MIDI editing program will probably be necessary to add some effects.
+However, it is possible to specify certain directives for MIDI.
+They are of the form:
+<BR><PRE>
+<B>midi</B> <I>S V</I><B>:</B> <I>begintime "keyword=value";</I>
+</PRE><BR>
+The <I>S</I> and <I>V</I> specify the staff and voice for which the directive is
+to apply. As elsewhere in Mup, an omitted voice will default to voice 1,
+and both staff and voice can be given as a list.
+Certain keywords apply to the entire score. In that case the form
+<BR><PRE>
+<B>midi all:</B> <I>begintime "keyword=value";</I>
+</PRE><BR>
+is used instead.
+The items specified using "all" are placed on the first track, the track
+containing score-wide information. They are not applied to the
+voices on the other tracks.
+</P>
+<P>
+The <I>begintime</I>, as elsewhere in Mup,
+gives the beat into the measure where the MIDI output is to be placed.
+If notes are to be turned on or off at the same instant in time as the
+<I>begintime</I>, first all "note off" commands are generated, then the "midi"
+command events, then "note on" commands.
+</P>
+<P>
+The <I>keyword=value</I> gives specific information of
+what MIDI output to generate. The following keywords are currently supported:
+<TABLE BORDER=4>
+<TR>
+<TD><B>keyword</B></TD> <TD><B>values</B></TD> <TD><B>meaning</B></TD> <TD><B>midi S V</B></TD> <TD><B>midi all</B></TD>
+</TR>
+<TR>
+<TD>program</TD> <TD>0-127</TD> <TD>program change (new instrument)</TD> <TD>yes</TD> <TD>no</TD>
+</TR>
+<TR>
+<TD>parameter</TD> <TD>0-127,0-127</TD> <TD>parameter</TD> <TD>yes</TD> <TD>yes</TD>
+</TR>
+<TR>
+<TD>channel</TD> <TD>1-16</TD> <TD>channel</TD> <TD>yes</TD> <TD>no</TD>
+</TR>
+<TR>
+<TD>chanpressure</TD> <TD>0-127</TD> <TD>channel pressure (after touch)</TD> <TD>yes</TD> <TD>yes</TD>
+</TR>
+<TR>
+<TD>tempo</TD> <TD>10-1000</TD> <TD>tempo, quarter notes per minute</TD> <TD>no</TD> <TD>yes</TD>
+</TR>
+<TR>
+<TD>seqnum</TD> <TD>0-65535</TD> <TD>sequence number</TD> <TD>yes</TD> <TD>yes</TD>
+</TR>
+<TR>
+<TD>text</TD> <TD>text</TD> <TD>text meta event</TD> <TD>yes</TD> <TD>yes</TD>
+</TR>
+<TR>
+<TD>copyright</TD> <TD>text</TD> <TD>copyright notice</TD> <TD>yes</TD> <TD>yes</TD>
+</TR>
+<TR>
+<TD>name</TD> <TD>text</TD> <TD>sequence/track name</TD> <TD>yes</TD> <TD>yes</TD>
+</TR>
+<TR>
+<TD>instrument</TD> <TD>text</TD> <TD>instrument name</TD> <TD>yes</TD> <TD>yes</TD>
+</TR>
+<TR>
+<TD>marker</TD> <TD>text</TD> <TD>marker meta event</TD> <TD>yes</TD> <TD>yes</TD>
+</TR>
+<TR>
+<TD>cue</TD> <TD>text</TD> <TD>cue point</TD> <TD>yes</TD> <TD>yes</TD>
+</TR>
+<TR>
+<TD>port</TD> <TD>0-127</TD> <TD>MIDI port</TD> <TD>yes</TD> <TD>yes</TD>
+</TR>
+<TR>
+<TD>onvelocity</TD> <TD>1-127</TD> <TD>note on velocity</TD> <TD>yes</TD> <TD>no</TD>
+</TR>
+<TR>
+<TD>offvelocity</TD> <TD>0-127</TD> <TD>note off velocity</TD> <TD>yes</TD> <TD>no</TD>
+</TR>
+<TR>
+<TD>hex</TD> <TD>hex data</TD> <TD>arbitrary MIDI data</TD> <TD>yes</TD> <TD>yes</TD>
+</TR>
+</TABLE>
+
+</P>
+<P>
+The keywords can be abbreviated to their first three or more letters,
+except "chanpressure" which requires at least five letters to differentiate
+it from "channel" ("cha" or "chan" will be interpreted as channel).
+In most cases, the "=" is followed by either a number or some text. Exceptions
+to this are discussed in the next few paragraphs.
+</P>
+<P>
+The "parameter" keyword is followed by 2 numbers, separated by a comma.
+The first is the parameter number, the second is the parameter value.
+Thus to set parameter 7 (which is the volume parameter) to 90 for voice
+2 of staff 3, starting at the beginning of the measure, you can use:
+<BR><PRE>
+midi 3 2: 0 "parameter=7,90";
+</PRE><BR>
+</P>
+<P>
+The "onvelocity" and "offvelocity" keywords can have one or more values,
+separated by commas. If there is only one value, it applies to all notes
+in each chord. If there is more than one value, the first value applies
+to the top note of the chord, the second value to the second-from-the-top
+note, and so forth. If there are more notes in a chord than there are
+values specified, the last value specified applies to all of the remaining
+notes. So, for example, if you want to emphasize the top note of each
+chord because it is the melody, you can specify two values, as in
+<BR><PRE>
+midi 1: 1 "onvelocity=76, 60";
+</PRE><BR>
+which would cause the top note to have a velocity of 76 and all other
+notes to have a velocity of 60.
+</P>
+<P>
+The "hex" form can be used to insert any arbitrary MIDI data into
+the MIDI file. The value consists of any even number of hexadecimal digits.
+Spaces and tabs can be included in the value field for readability.
+</P>
+<P>
+Note that Mup uses the MIDI standard,
+which numbers instruments from 0 through 127,
+but some MIDI playback programs follow a convention of numbering them
+from 1 through 128.
+</P>
+<P>
+Here are some examples:
+<BR><PRE>
+midi all: 0 "tempo=72";
+midi 1-2 1-2: 0 "channel=2"; 0 "program=14"; 3.5 "program=76";
+midi all: 3 "hex= ff 00 02 00 01"; // sequence number 1
+midi 3,6: 0 "channel=5"; 0 "prog=15"; 0 "instr=dulcimer";
+// set parameter 7 (usually volume) to 100
+midi 2: "par = 7, 100";
+</PRE><BR>
+</P>
+<P>
+Here is a more extensive example of how midi commands might be used
+in a song:
+<BR><PRE>
+score
+ staffs=2
+ vscheme=2o
+
+staff 2
+ clef=bass
+
+voice 2 2
+ // Make the bottom voice more staccato
+ release=50
+
+music
+
+// Set the tempo.
+// Start out at 108 quarter notes per minute,
+// but on count 4, slow down to 96 per minute.
+midi all: 0 "tempo=108"; 4 "tempo=96";
+
+// Put each voice on a different channel
+// using a different instrument sound.
+// The program numbers correspond to the
+// General MIDI sounds as noted.
+midi 1 1: 0 "channel=1"; 0 "program=68"; //oboe
+midi 1 2: 0 "channel=2"; 0 "program=11"; //vibraphone
+midi 2 1: 0 "channel=6"; 0 "program=60"; //french horn
+midi 2 2: 0 "channel=4"; 0 "program=35"; //fretless bass
+
+// Make the top voice louder, and put an
+// accent on the third beat
+midi 1 1: 0 "onvelocity=86"; 3 "onvelocity=100"; 4 "onvel=86";
+
+// Set maximum reverb on french horn part,
+// starting at the second beat.
+// (Reverb is parameter 91)
+midi 2 1: 2 "parameter=91, 127";
+
+// Set chorus on oboe to 75, from the beginning.
+// (Chorus is parameter 93)
+midi 1 1: 0 "param=93, 75";
+
+// Pan the bass part to middle of left side.
+// (Pan is parameter 10, with a value of 0 being hard left,
+// 64 in the center, and 127 being hard right, so 32 is
+// half way to the left.)
+midi 2 2: 0 "parameter=10, 32";
+
+// Now the music to be played...
+1 1: e;d;2c;
+1 2: c;b-;2g-;
+2 1: g;f;2e;
+2 2: c;g-;2c;
+bar
+</PRE><BR>
+</P>
+<HR>
+<P>
+ <A HREF="pstools.html"><-- previous page</A>
+ <A HREF="index.html">Table of Contents</A></P>
+</BODY></HTML>