Recording and storing Midi data with arduino and midi shield
The Arduino MIDI Library allows you to read and write MIDI messages, but only in real time.

Storing MIDI data makes sense only with timestamps, so you have to call millis() or micros() when you receive a message.

How to actually store the data is something that you have to design yourself; which data structure to use depends on what you want to do with the data later.