Language

MidiClient Class

Definition

Main entry point to use MIDI in MacOS X and iOS.

public class MidiClient : CoreMidi.MidiObject
type MidiClient = class
    inherit MidiObject
Inheritance
MidiClient

Remarks

The MidiClient class is your gateway to communicate with the MIDI subsystem on MacOS and iOS.

You typically will create an instance of MidiClient with a name that identifies this particular client, connect to the various events that are exposed to this class and create both input and output midi ports using the CreateInputPort(String)CreateOutputPort(String) methods.

client = new MidiClient ("CoreMidiSample MIDI CLient");
client.ObjectAdded += delegate(object sender, ObjectAddedOrRemovedEventArgs e) {
	Console.WriteLine ("Object {0} added to {1}", e.Child, e.Parent);
};
client.ObjectRemoved += delegate(object sender, ObjectAddedOrRemovedEventArgs e) {
	Console.WriteLine ("Object {0} removed to {1}", e.Child, e.Parent);
};
client.PropertyChanged += delegate(object sender, ObjectPropertyChangedEventArgs e) {
	Console.WriteLine ("Property {0} changed on {1}", e.PropertyName, e.MidiObject);
};
client.ThruConnectionsChanged += delegate {
	Console.WriteLine ("Thru connections changed");
};
client.SerialPortOwnerChanged += delegate {
	Console.WriteLine ("Serial port changed");
};

//
// Create your input and output ports
//
outputPort = client.CreateOutputPort ("CoreMidiSample Output Port");
inputPort = client.CreateInputPort ("CoreMidiSample Input Port");

// Print out packets when we receive them
inputPort.MessageReceived += delegate(object sender, MidiPacketsEventArgs e) {
    Console.WriteLine ("Got {0} packets", e.Packets.Length);
};

The following events will be raised on your MidiClient instance: IOError, ObjectAdded, ObjectRemoved, PropertyChanged, SerialPortOwnerChanged, SetupChanged and ThruConnectionsChanged

Constructors

Name Description
MidiClient(String)

Creates a new MidiClient.

Properties

Name Description
Handle

Handle (pointer) to the unmanaged object representation.

(Inherited from MidiObject)
Name

Name of this MidiClient.

Methods

Name Description
CreateInputPort(String)

Creates a new MIDI input port.

CreateOutputPort(String)

Creates a new MIDI output port.

CreateVirtualDestination(String, MidiError)
CreateVirtualSource(String, MidiError)
Dispose()

Releases the resources used by the MidiObject object.

(Inherited from MidiObject)
Dispose(Boolean)

Releases the resources used by the MidiClient object.

GetData(IntPtr) (Inherited from MidiObject)
GetDictionaryProperties(Boolean)

Returns the object properties as a dictionary.

(Inherited from MidiObject)
GetString(IntPtr) (Inherited from MidiObject)
RemoveProperty(String) (Inherited from MidiObject)
SetData(IntPtr, NSData) (Inherited from MidiObject)
SetString(IntPtr, String) (Inherited from MidiObject)
ToString()

Events

Name Description
IOError

Raised when an I/O error occurs on a MIDI driver, for example when a device is disconnected.

ObjectAdded

Raised when an object (such as a device, entity, or endpoint) is added to the MIDI system.

ObjectRemoved

Raised when an object (such as a device, entity, or endpoint) is removed from the MIDI system.

PropertyChanged

Raised when a property of an object in the MIDI system changes.

SerialPortOwnerChanged

Raised when the owner of a serial port changes.

SetupChanged

Raised when the MIDI system's configuration changes, for example when devices are added, removed, or their properties change. The notification is coalesced and sent once after a series of changes.

ThruConnectionsChanged

Raised when a MIDI thru connection in the system is created or destroyed.

Applies to

See also