This is an example that generates a sixteenth-note rhythm, formats the information as MIDI note messages with midiformat, and stores them in a seq object, which can be saved as a MIDI file with the write message.
Max can interface with other applications via ReWire. Max can act as either a ReWire host or a ReWire client. Max can be a client to an open host application just by choosing "ad_rewire" as the MSP audio driver in the DSP Status window. Alternatively, you can use Max as the host (mixer) application by including the rewire~ object in your program.