.TH MPUSEND 3  MIDI
.UC 4
.SH NAME
\fLMpuSend\fR, \fLMpuSet\fR, \fLMpuFlush\fR, \fLMpuSetTrack\fR, \fLZeroMpuCmdCnt\fR \- buffer up and transmit packets of midi commands
.SH SYNOPSIS
.ft L
cc ... -lmidi
.br
#include <midi.h>
.ft R
.sp
.ft L
.ft L

\fBMpuSend\fP\fR (\fLmidi\fP, \fLcmds\fP) 
.ft R
.na
.nf
.in +5
.in -5
.fi
.ft R

Write the \fLcmds\fP to the \fLmidi\fP device.
\fLmidi\fP is a file descriptor obtained with \fLopen(MidiDevice,2)\fP
(for instance), and \fLcmds\fP is a \fL0\fP-terminated list of MPU-401 commands.
For example, before playing notes with \fLNoteOn()\fP, \fLNoteOff()\fP,
the device could be initialized with:
.Cs
MpuSend(midi, MPU_RESET, MPU_MIDI_THRU_OFF, 0)
.Ce
The \fLcmds\fP are buffered up and the whole packet sent in one \fLwrite()\fP.
.in +5

.in -5

\fBMpuSet\fP\fR (\fLc\fP) 
.ft R
.na
.nf
.in +5
unsigned char \fLc\fP;
.in -5
.fi
.ft R

Append \fLc\fP to \fLMpuCmdBuf\fP (a global buffer of midi commands).
At any time, the buffer contains \fLMpuCmdCnt\fP commands.
.in +5

.in -5

\fBMpuFlush\fP\fR (\fLf\fP) 
.ft R
.na
.nf
.in +5
.in -5
.fi
.ft R

Write the buffered commands in \fLMpuCmdBuf\fP to \fLf\fP.
Return \fL1\fP if something went wrong, \fL0\fP otherwise.
.in +5

.in -5

\fBMpuSetTrack\fP\fR (\fLf\fP, \fLn\fP) 
.ft R
.na
.nf
.in +5
.in -5
.fi
.ft R

Set the current track on \fLf\fP (a midi device) to \fLn\fP.
\fLn\fP is 0-7, or \fLMPU_TR_COM\fP (midi command track),
or \fLMPU_TR_COND\fP (conductor track).
Tracks 0-7 are used for play data.  See \fLMidiPlayInit\fP
and \fL/usr/midi/src/bin/play.c\fP.
.in +5

.in -5

\fBZeroMpuCmdCnt\fP\fR ()
.ft R
.na
.nf
.in +5
.in -5
.fi
.ft R

Zero the \fLMpuCmdBuf\fP.  Done after an \fLMpuFlush()\fP.
.in +5

.in -5
.ft R
.SH AUTHOR
Michael Hawley, Lucasfilm Ltd.
(dagobah!mike)
