.TH CHECKSUM 3  MIDI
.SH NAME
CheckSum \- calculate checksum for system excl. dumps, etc.
.SH SYNOPSIS
.Cs
.in
cc ... \-lmidi
.sp
CheckSum(buf, len)
u_char *buf;
int len;
.in
.Ce
.SH DESCRIPTION
\fICheckSum()\fP
returns the 7-bit MIDI standard checksum required by most
system-exclusive dumps.
The checksum is the 7-bit two's complement of the sum of
the first \fIlen\fP-many bytes in \fIbuf\fP
(i.e. the number which, when added to all the specified bytes,
will give a 7-bit zero result).
The algorithm used is quite simple:
.Cs
register int i, s = 0;

for (i = len; --i >= 0; s -= buf[i]);
return(s & 0x7F);
.Ce
.SH AUTHOR
Peter Langston, Bell Communications Research
(bellcore!psl)
