Working .mid file reader.

Reading the MIDI .mid file format is the first step towards creating a
learning machine that imitates JSB!

TODO:
 -- extract dataset as (x, y) vector pairs
 -- convert sequence of y outputs to MIDI events
 -- impl write() method for .mid
Upgrade parser and prepare for writing.

Add new tests, too.
Fix units on us_per_quarter_note.

The set tempo command uses microseconds and not milliseconds. This makes
sense with the value 625000 observed in one JSB file!
Complete .mid write() and tests.

The .mid file format works very well with thorough test coverage. We
ensure that a file from the JSB collection may be read and serialized by
the lua.mid library and that the contents of the binary file will be
identical to the source file.
Change read() to take a FILE.

The read() and write() functions should have parallel API designs in
that they both take FILE.

Fix some docs.
Refactor code into smaller units.

The mid.lua file was unweildy. Factored out the event_parser and tests.
Also created COMMAND_NAMES table in preparation for simple filtering
functions that can filter tracks for command types. This will be useful
when constructing Torch datasets from MIDI.
Fix write() unknown command and add track filter.

Wrapping write method for text events in file:write() caused accidental
concatenation of string and boolean.

The track filter selects only the desired events types from track.events
and then returns a track with updated size and copied fields from the
source track. Will be used to extract note-related data.
Refactor module structure and add test script.

The module has sub-components that depend on one another. The init.lua
script exports only the public API for library clients as opposed to the
internal library API.
Improve command CODES catefories.

Add a 'system' table to the mid.event.CODES table.
Change ctype to midi.

The things that were called 'ctype' here are commonly referred to as
'mwidi events' on the Internet.
Begin types that allow building MIDI datasets.

These tools allow loading .mid files and rasterizing them so that they
may be used with Torch7 as input to learning machines.

Note that this is not complete as of this commit.
Extract points from rasterized MIDI.

Given a window size for both input and target, extract points from a
MIDI file by sliding the input and target windows sequentially along
the data.
Planning in main script.

Just laying out plans in a comment.
Teach the computer to play JSB.

A simple 2-layer NN is working in this example. There are so many TODOs
including better loss function, using convolutional layers, trying an
ensemble, using discretized veclocities and multiclass learners, etc.
Add simple docs.
Fix major bug in song data composition.

The delta times for MIDI events should be relative times between
successive events. This commit inclues an in-progress unit test for
datasets that ensures that a song loaded, rasterized, and then composed
will contain the same data. Presently, this is not possible for many
songs because start-stop sequences of the same note are lost in the
rasterized format.
Add perceptual loss.

Bigger penalties for false positives or false negatives.
Tweak Perceptual loss and model nonlinearity.

Use SoftPlus and transform input data to range [-1, 1]. Add SgdMomentum
trainer that uses momentum term.
Zero loss when output has no error.

Mask loss and loss gradient based on output matching the input.
Make compose() debounce match gen.