MIDI_INFO

typedef struct _MIDI_INFO 
{
    ULONG           Key;
#define MIDI_INFO_KEY       (*(ULONG *)"Midi")
        KSPIN_LOCK      DeviceSpinLock;
    #if DBG
        BOOLEAN         LockHeld;
    #endif
        LARGE_INTEGER   RefTime;
        LIST_ENTRY      QueueHead;
        PVOID           HwContext;
        PMIDI_INTERFACE_ROUTINE HwStartMidiIn, HwStopMidiIn;
        BOOLEAN      (* HwMidiRead)(struct _MIDI_INFO *, PUCHAR);
        VOID         (* HwMidiOut)(struct _MIDI_INFO *, PUCHAR, int);
        BOOLEAN         fMidiInStarted;
        UCHAR           InputPosition;
        UCHAR           InputBytes;
        UCHAR           MidiInputByte[64];
} MIDI_INFO, *PMIDI_INFO;
 

The MIDI_INFO structure contains context information for an external MIDI device.

Members
Key
Internal only, for debugging. Should be “Midi”.
DeviceSpinLock
Internal only. Used for DPC synchronization.
LockHeld
Internal only. Used for debugging.
RefTime
Used by soundlib.lib to store the start time of an I/O operation, as reference for time stamps.
QueueHead
Internal only. Points to a buffer queue for MIDI input requests.
HwContext
Pointer to a driver-defined structure containing device-specific hardware information. Typically used by functions pointed to by the HwStartMidiIn, HwStopMidiIn, HwMidiRead, and HwMidiOut members.
HwStartMidiIn
Pointer to a driver-supplied function that programs the MIDI hardware to start recording. The function type is MIDI_INTERFACE_ROUTINE.

The function is called when SoundMIDIDispatch receives a IOCTL_MIDI_SET_STATE command. See \src\mmedia\soundlib\midi.c.

HwStopMidiIn
Pointer to a driver-supplied function that programs the MIDI hardware to stop recording. The function type is MIDI_INTERFACE_ROUTINE.

The function is called when SoundMIDIDispatch receives a IRP_MJ_CLEANUP command. For more information, see \src\mmedia\soundlib\midi.c.

HwMidiRead
Pointer to a driver-supplied function that reads one input byte. This operation might only consist of fetching the next byte from a buffer that was filled by an ISR. (An example is MPU401 support in sndblst.sys.) The function type is:
BOOLEAN (* HwMidiRead)(struct _MIDI_INFO *, PUCHAR)

The _MIDI_INFO* parameter points to a MIDI_INFO structure and the PUCHAR parameter receives the read byte. The function returns TRUE if a byte was read, and FALSE otherwise.

The function is called when SoundMIDIDispatch receives a IRP_MJ_READ command. For more information, see \src\mmedia\soundlib\midi.c.

This function executes at an IRQL of DISPATCH_LEVEL, so it cannot be pageable and it cannot reference pageable code or data. Also, the only synchronization method it can use is calling KeStallExecutionProcessor.

HwMidiOut
Pointer to a driver-supplied function that commands the MIDI hardware to write a string of bytes. Function type is:
VOID (* HwMidiOut)(struct _MIDI_INFO *, PUCHAR, int)

The first parameter points to a MIDI_INFO structure, the second parameter points to a mapped buffer of bytes, and the third parameter contains the buffer size.

The function is called when SoundMIDIDispatch receives a IOCTL_MIDI_PLAY command. For more information, see \src\mmedia\soundlib\midi.c.

fMidiInStarted
Internal only. Indicates a MIDI input operation is in progress.
InputPosition
Internal only. Pointer to an internal input buffer.
InputBytes
Internal only. Count of bytes in internal input buffer.
MidiInputByte
Internal only. Pointer to internal input buffer.
Comments

A single MIDI_INFO structure can be used to support simultaneous MIDI input and output. MIDI_INFO is defined in midi.h.

Allocate a MIDI_INFO structure from the nonpaged memory pool by calling ExAllocatePool, then zero it by calling RtlZeroMemory. To initialize a MIDI_INFO structure, call SoundInitMidiIn.

To create a MIDI device object, call SoundCreateDevice and specify a MIDI_INFO structure pointer for the DeviceSpecificData parameter.