The lpData member of the MIDIHDR structure points to a stream buffer, and the dwBufferLength member specifies the actual size of this buffer. The dwBytesRecorded member of MIDIHDR specifies the number of bytes in the buffer that are actually used by the MIDI events; this value must be less than or equal to the value specified by dwBufferLength.
Each of the MIDI events in the stream buffer is specified by a MIDIEVENT structure, which contains the time for the event, a stream identifier, an event code, and, when appropriate, parameters for the event. Each of these MIDIEVENT structures must begin on a doubleword boundary. If necessary, pad bytes must be added to the end of the structure to ensure that the next one starts on a doubleword boundary.