Pieces-O-MIDI is an interactive toy which takes one MIDI file as input and processes it to produce another MIDI file. You specify a MIDI file to use as input, along with the number of pieces into which it should be split. Those pieces are then “re-sequenced” by using the values of the notes in the same MIDI file.
The algorithm for Pieces-O-MIDI is written in KeyKit, and here's the source code.