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.