TITLE:: MIDIClient
summary:: Basic access to MIDI on your computer
categories:: External Control>MIDI
related:: Classes/MIDIIn, Classes/MIDIOut, Classes/MIDIFunc, Classes/MIDIdef, Guides/MIDI, Guides/UsingMIDI

DESCRIPTION::
MIDIClient is the core class that provides access to the MIDI subsystem on your computer.

See the link::Guides/UsingMIDI:: helpfile for practical considerations and techniques for using MIDI in SC.

CLASSMETHODS::

private:: prInit, prDisposeClient, prInitClient, prList


METHOD:: init
Initializes the MIDIClient, checks which available MIDI sources and destinations there are, and opens as many connections as desired.

ARGUMENT:: inports
the number of MIDI input connections to open; if code::nil:: then opens as many inports as there are MIDI sources.

ARGUMENT:: outports
the number of MIDI output connections to open; if code::nil:: then opens as many outports as there are MIDI destinations.

ARGUMENT:: verbose
A flag whether or not to post the MIDI sources and destinations that were found. Default is true.


METHOD:: initialized
A flag that tells whether of not the MIDIClient has been initialized.



METHOD:: disposeClient
Cleans up the MIDIClient. After using this method, you will have to reinitialize the MIDIClient before you can use MIDI again.



METHOD:: list
Created the list of available sources and destinations.


METHOD:: sources
The list of available MIDI sources, including SuperCollider's own sources.

returns:: A code::List:: of code::MIDIEndPoints::

METHOD:: externalSources
The list of available MIDI sources, excluding SuperCollider's own sources. Only on Linux the list of code::sources:: and code::externalSources:: differs.

returns:: A code::List:: of code::MIDIEndPoints::

METHOD:: destinations
The list of available MIDI destinations, including SuperCollider's own destinations.

returns:: A code::List:: of code::MIDIEndPoints::

METHOD:: externalDestinations
The list of available MIDI destinations, excluding SuperCollider's own destinations. Only on Linux the list of code::destinations:: and code::externalDestinations:: differs.

returns:: A code::List:: of code::MIDIEndPoints::

METHOD:: restart
Restart the MIDIClient.


METHOD:: myinports
The number of input ports that SuperCollider created. This is mainly useful to know on the Linux platform.


METHOD:: myoutports
The number of output ports that SuperCollider created. This is mainly useful to know on the Linux platform.

METHOD:: getClientID
Linux only. This gets the client ID by which the MIDIClient is defined in the ALSA subsystem. It can be used to identify whether a port is belonging to this client or another one.

On non-linux systems, it posts a warning and returns nil.

EXAMPLES::

code::
MIDIClient.init;

MIDIClient.disposeClient;

MIDIClient.init( verbose: false );
::
