/*****************************************************************************/
/*                                                                           */
/*                                                                           */
/*              XXX  X     X  XXXX   XXXX    XXX   X   X  XXXXX              */
/*               X   XX   XX  X   X  X   X  X   X  X   X  X                  */
/*               X   X X X X  X   X  X   X  X   X  X   X  X                  */
/*               X   X  X  X  XXXX   XXXX   X   X  X   X  XXX                */
/*               X   X     X  X      X X    X   X  X   X  X                  */
/*               X   X     X  X      X  X   X   X   X X   X                  */
/*              XXX  X     X  X      X   X   XXX     X    XXXXX              */
/*                                                                           */
/*                                                                           */
/*                         Improve Music Roll Image                          */
/*                         Program by Wayne Stahnke                          */
/*                                                                           */
/*****************************************************************************/

/* Given a reduced scan of a production music roll this program improves the
    roll image by applying the Method of Least Squares.  It is invoked by a
    a command line of the form

            IMPROVE [arg1 [arg2 [arg3 [...]]]]

    where the command line arguments may be filenames (with or without paths
    and with or without extensions) or keywords.

    The first filename (which must be present) specifies the source file; its
    extension defaults to ".raw" if not provided.  When a second filename is
    present it specifies the target file; its extension defaults to ".raw" if
    not provided.  If the second filename is omitted, the source filename is
    the default target filename.

    The annotation filename and extension default to the source filename and
    ".ann" respectively.  Either or both of these defaults may be overridden
    by explicitly giving the desired annotation filename and extension.  The
    syntax is as follows:

            /ann:<filename>[.<extension>],

    and consequently all three relevant filenames and extensions are under the
    control of the operator.  Here is a complete list of the keywords that are
    supported:

    Syntax              Function                         Argument
    -------------------------------------------------------------------------
    /ann:<string>       override annotation filename     filename/extension
 *  /sparse             perform exhaustive search        (none)

    /n:<integer>        scale MIDI file step size        numerator
    /d:<integer>        scale MIDI file step size        denominator

 *  /al:<real>          override default acquire length  acquire length, mm
 *  /el:<real>          override default error length    error length, mm
    /ew:<integer>       override default error width     error width, ports
    /pa:<real>          override default page advance    page advance, mm
    /pl:<real>          override default page length     page length, mm
    /ps:<real>          accommodate paper slip           paper slip, rows
    /wl:<real>          override default white length    white length, mm
    /x:<integer>        exclude specified port           excluded port number

    The keywords are not normally used for a well-made roll in good condition.
    For exceptional rolls, the keyword that is most often needed is "/x" to
    ignore falsely placed holes, inserted by hand or caused by tears in the
    paper.  The "/x" keyword may be present multiple times in a command line,
    allowing any number of ports to be excluded. */
*   See footnotes
/*****************************************************************************/

Versions 12.49 and 12.64 increase the default acquire length from 375 to 500 mm while the default page length remains at 375 mm.

Versions 12.64 onwards have the /sparse option permanently enabled so the keyword is no longer required.

Version 12.65 introduces a new feature where the Acquire Length is automatically increased until skew correction can be established. If on rare occasions this proves to be a false lock, the /al: override may be deployed to modify this behaviour.

Error Length (/el:) is now defined in terms of punch rows with a default value of 32 rows.

Abrupt changes in the dynamic skew display suggest that skew correction has lost lock. Increasing the Acquire Length or decreasing the Page Length may help.