TouchOSC/classes/TouchOSC.sc

64 lines
1.1 KiB
Python
Raw Normal View History

2022-03-26 04:51:50 +00:00
// Class for binding to a TouchOSC interface
TouchOSC {
var <net, <controls;
2022-03-26 04:51:50 +00:00
*new { | ip, port |
^super.new.init(ip, port)
}
init { | ip, port |
net = NetAddr(ip, port);
controls = Dictionary();
2022-03-27 00:04:56 +00:00
}
2022-03-26 04:51:50 +00:00
send { | url ... oargs |
net.sendMsg(url, *oargs)
}
2022-03-27 00:04:56 +00:00
2023-04-15 05:48:42 +00:00
label { | url, default |
var ctrl = TouchOSCLabel(this, url, default);
ctrl.init();
controls.put(url, ctrl);
^ctrl;
}
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 },
{ ("v: No control with url" + url).postln }
);
}
v_ { | url, v |
^if( controls.at(url).isNil.not,
{ controls.at(url).value_(v) },
{ ("v_: No control with url" + url).postln }
);
}
}