File: MIDIClient.schelp

package info (click to toggle)
supercollider 1%3A3.13.0%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 80,292 kB
  • sloc: cpp: 476,363; lisp: 84,680; ansic: 77,685; sh: 25,509; python: 7,909; makefile: 3,440; perl: 1,964; javascript: 974; xml: 826; java: 677; yacc: 314; lex: 175; objc: 152; ruby: 136
file content (114 lines) | stat: -rw-r--r-- 3,692 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
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, Classes/MIDIEndPoint

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
Refresh the list of available sources and destinations.
If you have connected a MIDI device after MIDIClient initialization, you won't see it until this method is run.

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::

This is Linux specific code.
The function takes care of initializing MIDIClient, detects a MIDI device named SE25 and connects it to port 0 of SuperCollider.

code::
(
~connect_midi_devices = { arg device, name;
	// init or refresh MIDIClient end points
	if(MIDIClient.initialized == false) {
		MIDIClient.init;
	} {
		MIDIClient.list;
	};

	MIDIClient.sources.do({ arg endPoint;
		if(device.notNil and: { name.notNil} and: {endPoint.device == device} and: { endPoint.name == name }) {
			// catch exception thrown when already connected
			try {
				// connect SuperCollider out port 0 to MIDI device
				MIDIOut.connect(0, endPoint.uid);
			};
			try {
				// connect MIDI device to SuperCollider in port 0
				MIDIIn.connect(0, endPoint.uid);
			}
		}
	})

}
)

~connect_midi_devices.("SE25", "SE25 MIDI 1"); // test it now
::