Xeno-rat
Loading...
Searching...
No Matches
NAudio.Midi.MidiIn Class Reference

Represents a MIDI in device. More...

Inheritance diagram for NAudio.Midi.MidiIn:
Collaboration diagram for NAudio.Midi.MidiIn:

Public Member Functions

 MidiIn (int deviceNo)
 Opens a specified MIDI in device.
 
void Close ()
 Closes the current object by calling the Dispose method.
 
void Dispose ()
 Releases the unmanaged resources used by the MidiIn class and optionally releases the managed resources.
 
void Start ()
 Starts the MIDI input device.
 
void Stop ()
 Stops the MIDI input device.
 
void Reset ()
 Resets the MIDI input device to its default state.
 
void CreateSysexBuffers (int bufferSize, int numberOfBuffers)
 Creates sysex buffers for MIDI input.
 

Static Public Member Functions

static MidiInCapabilities DeviceInfo (int midiInDeviceNumber)
 Retrieves the capabilities of the specified MIDI input device.
 

Protected Member Functions

virtual void Dispose (bool disposing)
 Closes the MIDI out device.
 

Properties

static int NumberOfDevices [get]
 Gets the number of MIDI input devices available in the system.
 

Events

EventHandler< MidiInMessageEventArgsMessageReceived
 Called when a MIDI message is received.
 
EventHandler< MidiInMessageEventArgsErrorReceived
 An invalid MIDI message.
 
EventHandler< MidiInSysexMessageEventArgsSysexMessageReceived
 Called when a Sysex MIDI message is received.
 

Private Member Functions

void Callback (IntPtr midiInHandle, MidiInterop.MidiInMessage message, IntPtr userData, IntPtr messageParameter1, IntPtr messageParameter2)
 Callback function for handling MIDI input messages.
 
 ~MidiIn ()
 Cleanup.
 

Private Attributes

IntPtr hMidiIn = IntPtr.Zero
 
bool disposed = false
 
MidiInterop.MidiInCallback callback
 
IntPtr[] SysexBufferHeaders = new IntPtr[0]
 

Detailed Description

Represents a MIDI in device.

Constructor & Destructor Documentation

◆ MidiIn()

NAudio.Midi.MidiIn.MidiIn ( int deviceNo)
inline

Opens a specified MIDI in device.

Parameters
deviceNoThe device number
Here is the call graph for this function:

◆ ~MidiIn()

NAudio.Midi.MidiIn.~MidiIn ( )
inlineprivate

Cleanup.

Here is the call graph for this function:

Member Function Documentation

◆ Callback()

void NAudio.Midi.MidiIn.Callback ( IntPtr midiInHandle,
MidiInterop::MidiInMessage message,
IntPtr userData,
IntPtr messageParameter1,
IntPtr messageParameter2 )
inlineprivate

Callback function for handling MIDI input messages.

Parameters
midiInHandleHandle to the MIDI input device.
messageThe type of MIDI input message received.
userDataUser-defined data passed to the callback function.
messageParameter1The first parameter associated with the MIDI input message.
messageParameter2The second parameter associated with the MIDI input message.

This callback function is used to handle different types of MIDI input messages received from the MIDI input device. It switches on the type of message received and performs specific actions based on the message type. If the message type is Data, it raises the MessageReceived event with the packed MIDI message and milliseconds since MidiInStart as parameters. If the message type is Error, it raises the ErrorReceived event with the invalid MIDI message as a parameter. If the message type is LongData, it processes the pointer to MIDI header and milliseconds since MidiInStart to raise the SysexMessageReceived event with the sysex message bytes and milliseconds as parameters.

Here is the caller graph for this function:

◆ Close()

void NAudio.Midi.MidiIn.Close ( )
inline

Closes the current object by calling the Dispose method.

This method calls the Dispose method to release resources used by the current object.

Here is the call graph for this function:

◆ CreateSysexBuffers()

void NAudio.Midi.MidiIn.CreateSysexBuffers ( int bufferSize,
int numberOfBuffers )
inline

Creates sysex buffers for MIDI input.

Parameters
bufferSizeThe size of each buffer.
numberOfBuffersThe number of buffers to create.

This method creates sysex buffers for MIDI input. It allocates memory for each buffer, prepares the header, and adds the buffer to the MIDI input device.

Exceptions
MmExceptionThrown when there is an error in preparing or adding the buffer to the MIDI input device.
Here is the call graph for this function:

◆ DeviceInfo()

static MidiInCapabilities NAudio.Midi.MidiIn.DeviceInfo ( int midiInDeviceNumber)
inlinestatic

Retrieves the capabilities of the specified MIDI input device.

Parameters
midiInDeviceNumberThe number of the MIDI input device for which to retrieve the capabilities.
Returns
The capabilities of the specified MIDI input device.
Exceptions
MmExceptionThrown when an error occurs while retrieving the device capabilities.
Here is the call graph for this function:

◆ Dispose() [1/2]

void NAudio.Midi.MidiIn.Dispose ( )
inline

Releases the unmanaged resources used by the MidiIn class and optionally releases the managed resources.

Parameters
disposingtrue to release both managed and unmanaged resources; false to release only unmanaged resources.

This method releases the unmanaged resources used by the MidiIn class and optionally releases the managed resources. If disposing is true, this method disposes of all managed and unmanaged resources. If disposing is false, this method releases only the unmanaged resources. If the SysexBufferHeaders array has elements, it resets the MIDI input device, frees up all created and allocated buffers for incoming Sysex messages, and closes the MIDI input device handle.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dispose() [2/2]

virtual void NAudio.Midi.MidiIn.Dispose ( bool disposing)
inlineprotectedvirtual

Closes the MIDI out device.

Parameters
disposingTrue if called from Dispose
Here is the call graph for this function:

◆ Reset()

void NAudio.Midi.MidiIn.Reset ( )
inline

Resets the MIDI input device to its default state.

Exceptions
MmExceptionThrown when an error occurs while resetting the MIDI input device.
Here is the call graph for this function:

◆ Start()

void NAudio.Midi.MidiIn.Start ( )
inline

Starts the MIDI input device.

Exceptions
MmExceptionThrown when an error occurs while starting the MIDI input device.
Here is the call graph for this function:

◆ Stop()

void NAudio.Midi.MidiIn.Stop ( )
inline

Stops the MIDI input device.

Exceptions
MmExceptionThrown when an error occurs while stopping the MIDI input device.
Here is the call graph for this function:

Member Data Documentation

◆ callback

MidiInterop.MidiInCallback NAudio.Midi.MidiIn.callback
private

◆ disposed

bool NAudio.Midi.MidiIn.disposed = false
private

◆ hMidiIn

IntPtr NAudio.Midi.MidiIn.hMidiIn = IntPtr.Zero
private

◆ SysexBufferHeaders

IntPtr [] NAudio.Midi.MidiIn.SysexBufferHeaders = new IntPtr[0]
private

Property Documentation

◆ NumberOfDevices

int NAudio.Midi.MidiIn.NumberOfDevices
staticget

Gets the number of MIDI input devices available in the system.

Event Documentation

◆ ErrorReceived

EventHandler<MidiInMessageEventArgs> NAudio.Midi.MidiIn.ErrorReceived

An invalid MIDI message.

◆ MessageReceived

EventHandler<MidiInMessageEventArgs> NAudio.Midi.MidiIn.MessageReceived

Called when a MIDI message is received.

◆ SysexMessageReceived

EventHandler<MidiInSysexMessageEventArgs> NAudio.Midi.MidiIn.SysexMessageReceived

Called when a Sysex MIDI message is received.


The documentation for this class was generated from the following file: