Inherits from NSObject
Declared in MIKMIDIDeviceManager.h

Overview

MIKMIDIDeviceManager is used to retrieve devices and virtual endpoints available on the system, as well as for connecting to and disconnecting from MIDI endpoints. It is a singleton object.

To get a list of devices available on the system, call availableDevices. Virtual sources can be retrieved by calling virtualSources and -virtualDevices, respectively. All three of these properties, are KVO compliant, meaning they can be observed using KVO for changes, and (on OS X) can be bound to UI elements using Cocoa bindings.

MIKMIDIDeviceManager is also used to connect to and disonnect from MIDI endpoints, as well as to send and receive MIDI messages. To connect to a MIDI source endpoint, call connectInput:error:eventHandler:. To disconnect, call -disconnectInput:. To send MIDI messages/commands to an output endpoint, call sendCommands:toEndpoint:error:.

Tasks

Properties

availableDevices

@property (nonatomic, readonly) NSArray *availableDevices
Discussion

An NSArray containing MIKMIDIDevice instances representing MIDI devices connected to the system.

This property is Key Value Observing (KVO) compliant, and can be observed to be notified when devices are connected or disconnected. It is also suitable for binding to UI using Cocoa Bindings (OS X only).

Declared In

MIKMIDIDeviceManager.h

connectedInputSources

@property (nonatomic, readonly) NSArray *connectedInputSources
Discussion

An NSArray of MIKMIDISourceEndpoint instances that are connected to at least one event handler.

Declared In

MIKMIDIDeviceManager.h

virtualDestinations

@property (nonatomic, readonly) NSArray *virtualDestinations
Discussion

An NSArray containing MIKMIDIDestinationEndpoint instances representing virtual MIDI destinations (outputs) on the system.

This property is Key Value Observing (KVO) compliant, and can be observed to be notified when virtual destinations appear or disappear. It is also suitable for binding to UI using Cocoa Bindings (OS X only).

Declared In

MIKMIDIDeviceManager.h

virtualSources

@property (nonatomic, readonly) NSArray *virtualSources
Discussion

An NSArray containing MIKMIDISourceEndpoint instances representing virtual MIDI sources (inputs) on the system.

This property is Key Value Observing (KVO) compliant, and can be observed to be notified when virtual sources appear or disappear. It is also suitable for binding to UI using Cocoa Bindings (OS X only).

Declared In

MIKMIDIDeviceManager.h

Class Methods

sharedDeviceManager

+ (instancetype)sharedDeviceManager
Discussion

Used to obtain the shared MIKMIDIDeviceManager instance. MIKMIDIDeviceManager should not be created directly using +alloc/-init or +new. Rather, the singleton shared instance should always be obtained by calling this method.

Return Value

The shared MIKMIDIDeviceManager instance.

Declared In

MIKMIDIDeviceManager.h

Instance Methods

connectInput:error:eventHandler:

- (id)connectInput:(MIKMIDISourceEndpoint *)endpoint error:(NSError **)error eventHandler:(MIKMIDIEventHandlerBlock)eventHandler
Discussion

Used to connect to a MIDI input/source endpoint. Returns a token that must be kept and passed into the disconnectInput:forConnectionToken: method.

Parameters

endpoint

An MIKMIDISourceEndpoint instance that should be connected.

error

If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.

eventHandler

A block which will be called anytime incoming MIDI messages are received from the endpoint.

Return Value

A connection token to be used to disconnect the input, or nil if an error occurred. The connection token is opaque.

Declared In

MIKMIDIDeviceManager.h

disconnectInput:forConnectionToken:

- (void)disconnectInput:(MIKMIDISourceEndpoint *)endpoint forConnectionToken:(id)connectionToken
Discussion

Disconnects a previously connected MIDI input/source endpoint. The connectionToken argument must be a token previously returned by connectInput:error:eventHandler:. Only the event handler block passed into the call that returned the token will be disconnected.

Parameters

endpoint

The MIKMIDISourceEndpoint instance from which to disconnect.

connectionToken

The connection token returned by connectInput:error:eventHandler: when the input was connected.

Declared In

MIKMIDIDeviceManager.h

sendCommands:toEndpoint:error:

- (BOOL)sendCommands:(NSArray *)commands toEndpoint:(MIKMIDIDestinationEndpoint *)endpoint error:(NSError **)error
Discussion

Used to send MIDI messages/commands from your application to a MIDI output endpoint. Use this to send messages to a connected device, or another app connected via virtual MIDI port.

Parameters

commands

An NSArray containing MIKMIDICommand instances to be sent.

endpoint

An MIKMIDIDestinationEndpoint to which the commands should be sent.

error

If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.

Return Value

YES if the commands were successfully sent, NO if an error occurred.

Declared In

MIKMIDIDeviceManager.h