OnlineMIDI provides an example of a simple interactive music system which can analyse MIDI note events live. An analysis window of three seconds (corresponding to a notion of the perceptual present) is used, with step size of 1 second.

Note that this class can't be used in combination with other MIDI code, since it overwrites MIDIIn.noteOn and MIDIIn.noteOff; you would need to adapt the class code if this is an issue.