class library: DUGen - the server now handles audio-rate inputs correctly
[supercollider.git] / SCClassLibrary / Platform / linux / extMIDIOut.sc
blobc82393ff5f43d44db1f39b2ed69c5485dd98a4e7
1 + MIDIOut{
2         // uid is not set by connect, in order to enable several connections to one output. set the uid directly, if you only want to send data to one MIDI destination.
3         connect{ arg device = 0;
4                 MIDIOut.connect( port, device );
5                 /*
6                 var cuid, dest;
7                 if(device.isNumber, {
8                         if(device >= 0, {
9                                 if(MIDIClient.initialized.not,{ MIDIClient.init });
10                                 if ( device > MIDIClient.destinations.size, {
11                                         cuid = device;
12                                 },{
13                                         dest = MIDIClient.destinations.at(device);
14                                         if(dest.isNil,{
15                                                 "MIDIClient failed to init".warn;
16                                         },{
17                                                 cuid = MIDIClient.destinations.at(device).uid;
18                                         })
19                                 })
20                         },{
21                                 cuid = device;
22                         });
23                 },{
24                         if(device.isKindOf(MIDIEndPoint), {cuid = device.uid}); // else error
25                         });
26                         MIDIOut.connectByUID( port,cuid );*/
27         }
28         disconnect{ |cuid|
29                 var res;
30                 MIDIOut.disconnect( port, cuid );
31                 //              MIDIOut.disconnectByUID(port,cuid);
32                 // reset the uid to 0
33                 // uid = 0;
34         }
35         *connect { arg outport=0, device=0;
36                 var uid,dest;
37                 if(MIDIClient.initialized.not,{ MIDIClient.init });
38                 if(device.isNumber, {
39                         if(device >= 0, {
40                                 if ( device > MIDIClient.destinations.size, {
41                                         dest = MIDIClient.destinations.select{ |it| it.uid == device }.first;
42                                         if(dest.isNil,{
43                                                 ("MIDI device with uid"+device+ "not found").warn;
44                                         },{
45                                                 uid = dest.uid;
46                                         })
47                                 },{
48                                         dest = MIDIClient.destinations.at(device);
49                                         if(dest.isNil,{
50                                                 "MIDIClient failed to init".warn;
51                                         },{
52                                                 uid = MIDIClient.destinations.at(device).uid;
53                                         })
54                                 })
55                         },{
56                                 uid = device;
57                         });
58                 },{
59                         if(device.isKindOf(MIDIEndPoint), {uid = device.uid}); // else error
60                 });
61                 this.connectByUID(outport,uid);
62         }
63         *disconnect { arg outport=0, device=0;
64                 var uid,dest;
65                 if(device.isKindOf(MIDIEndPoint), {uid = device.uid});
66                 if(device.isNumber, {
67                         if(device.isPositive, {
68                                 if ( device > MIDIClient.destinations.size, {
69                                         dest = MIDIClient.destinations.select{ |it| it.uid == device }.first;
70                                         if(dest.isNil,{
71                                                 ("MIDI device with uid"+device+ "not found").warn;
72                                         },{
73                                                 uid = dest.uid;
74                                         })
75                                 },{
76                                         uid = MIDIClient.destinations.at(device).uid
77                                 });
78                         },{
79                                 uid = device;
80                         });
81                 });
82                 this.disconnectByUID(outport,uid);
83         }
84         *connectByUID {arg outport, uid;
85                 _ConnectMIDIOut
86         }
87         *disconnectByUID {arg outport, uid;
88                 _DisconnectMIDIOut
89         }