58 lines
960 B
Python
58 lines
960 B
Python
// Class for binding to a TouchOSC interface
|
|
|
|
|
|
TouchOSC {
|
|
var <net, <controls;
|
|
|
|
*new { | ip, port |
|
|
^super.new.init(ip, port)
|
|
}
|
|
|
|
init { | ip, port |
|
|
net = NetAddr(ip, port);
|
|
controls = Dictionary();
|
|
}
|
|
|
|
send { | url ... oargs |
|
|
net.sendMsg(url, *oargs)
|
|
}
|
|
|
|
button { | url, default, apply |
|
|
var ctrl = TouchOSCControl(this, url, apply, default);
|
|
ctrl.init();
|
|
controls.put(url, ctrl);
|
|
^ctrl;
|
|
}
|
|
|
|
slider { | url, default, scale, apply |
|
|
var ctrl = TouchOSCControlScale(this, url, apply, default, scale);
|
|
ctrl.init();
|
|
controls.put(url, ctrl);
|
|
^ctrl;
|
|
}
|
|
|
|
xy { | url, default, scale1, scale2, apply |
|
|
var ctrl = TouchOSCControlXY(this, url, apply, default, scale1, scale2);
|
|
ctrl.init();
|
|
controls.put(url, ctrl);
|
|
^ctrl;
|
|
}
|
|
|
|
v { | url |
|
|
^if( controls.at(url).isNil.not, {
|
|
controls.at(url).value
|
|
},
|
|
nil
|
|
);
|
|
}
|
|
|
|
v_ { | url, v |
|
|
^if( controls.at(url).isNil.not, {
|
|
controls.at(url).value_(v)
|
|
},
|
|
nil);
|
|
}
|
|
|
|
}
|
|
|