2-d control binding is working

main
Mike Lynch 2022-03-27 12:44:53 +11:00
parent 94be9f50f7
commit 2350e9cf6b
2 changed files with 32 additions and 9 deletions

View File

@ -14,13 +14,12 @@ TouchOSC {
controls = ();
}
add1d { | url, min, max, default, apply |
var scale = TouchOSCScale(min, max, default);
add1d { | url, scale, apply |
controls.put(url, TouchOSCControl(url, scale, apply));
}
add2d { | name, scale1, scale2, apply |
add2d { | url, scale1, scale2, apply |
controls.put(url, TouchOSCControl2d(url, scale1, scale2, apply));
}
addradio { | name, apply |

View File

@ -7,7 +7,7 @@
TouchOSCControl {
var <url, <scale, <value, apply;
var <url, <value, apply, scale;
*new { | url, scale, apply |
^super.new.init(url, scale, apply)
@ -18,10 +18,6 @@ TouchOSCControl {
scale = ascale;
apply = aapply;
value = scale.default;
this.oscdef();
}
oscdef {
OSCdef.new(
'osc' ++ url,
{ | msg |
@ -31,10 +27,38 @@ TouchOSCControl {
url
);
}
}
// inheritance is too awkward or I don't understand it well enough
TouchOSCControl2d {
var <url, <value, scale1, scale2, apply;
*new { | url, scale1, scale2, apply |
^super.new.init(url, scale1, scale2, apply)
}
init { | aurl, ascale1, ascale2, aapply |
url = aurl;
scale1 = ascale1;
scale2 = ascale2;
apply = aapply;
value = [ scale1.default, scale2.default ];
OSCdef.new(
'osc' ++ url,
{ | msg |
value[0] = scale1.tovalue(msg[1]);
value[1] = scale2.tovalue(msg[2]);
apply.value(value);
},
url
);
}
}
TouchOSCScale {
var <min, <max, <default;