2022-03-26 04:51:50 +00:00
|
|
|
// Class for binding to a TouchOSC interface
|
|
|
|
|
|
|
|
|
|
|
|
TouchOSC {
|
2022-04-02 03:58:49 +00:00
|
|
|
var <net, <controls;
|
2022-03-26 04:51:50 +00:00
|
|
|
|
|
|
|
*new { | ip, port |
|
|
|
|
^super.new.init(ip, port)
|
|
|
|
}
|
|
|
|
|
2022-04-02 03:58:49 +00:00
|
|
|
init { | ip, port |
|
|
|
|
net = NetAddr(ip, port);
|
2022-04-02 04:09:03 +00:00
|
|
|
controls = Dictionary();
|
2022-03-27 00:04:56 +00:00
|
|
|
}
|
2022-03-26 04:51:50 +00:00
|
|
|
|
2022-04-02 03:58:49 +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;
|
|
|
|
}
|
|
|
|
|
2022-04-24 06:38:10 +00:00
|
|
|
button { | url, default, apply |
|
2022-04-02 03:58:49 +00:00
|
|
|
var ctrl = TouchOSCControl(this, url, apply, default);
|
|
|
|
ctrl.init();
|
|
|
|
controls.put(url, ctrl);
|
|
|
|
^ctrl;
|
2022-03-27 01:05:42 +00:00
|
|
|
}
|
|
|
|
|
2022-04-24 06:38:10 +00:00
|
|
|
slider { | url, default, scale, apply |
|
2022-04-02 03:58:49 +00:00
|
|
|
var ctrl = TouchOSCControlScale(this, url, apply, default, scale);
|
|
|
|
ctrl.init();
|
|
|
|
controls.put(url, ctrl);
|
|
|
|
^ctrl;
|
|
|
|
}
|
|
|
|
|
2022-04-24 06:38:10 +00:00
|
|
|
xy { | url, default, scale1, scale2, apply |
|
2022-04-02 03:58:49 +00:00
|
|
|
var ctrl = TouchOSCControlXY(this, url, apply, default, scale1, scale2);
|
|
|
|
ctrl.init();
|
|
|
|
controls.put(url, ctrl);
|
|
|
|
^ctrl;
|
2022-03-27 01:05:42 +00:00
|
|
|
}
|
|
|
|
|
2022-04-24 06:38:10 +00:00
|
|
|
v { | url |
|
2023-04-15 05:48:28 +00:00
|
|
|
^if( controls.at(url).isNil.not,
|
|
|
|
{ controls.at(url).value },
|
|
|
|
{ ("v: No control with url" + url).postln }
|
2022-04-24 06:38:10 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
v_ { | url, v |
|
2023-04-15 05:48:28 +00:00
|
|
|
^if( controls.at(url).isNil.not,
|
|
|
|
{ controls.at(url).value_(v) },
|
|
|
|
{ ("v_: No control with url" + url).postln }
|
|
|
|
);
|
2022-04-24 06:38:10 +00:00
|
|
|
}
|
2022-03-27 01:05:42 +00:00
|
|
|
|
2023-09-30 05:01:51 +00:00
|
|
|
s_ { | url, v |
|
|
|
|
^if( controls.at(url).isNil.not,
|
|
|
|
{ controls.at(url).send_(v) },
|
|
|
|
{ ("s_: No control with url" + url).postln }
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-04-02 03:58:49 +00:00
|
|
|
}
|
2022-03-27 01:05:42 +00:00
|
|
|
|