134 lines
1.9 KiB
Python
134 lines
1.9 KiB
Python
|
|
|
|
TouchOSCControl {
|
|
var <touchOSC, <url, apply, <value;
|
|
|
|
*new { | touchOSC, url, apply, value |
|
|
^super.newCopyArgs(touchOSC, url, apply, value)
|
|
}
|
|
|
|
init {
|
|
OSCdef.new(
|
|
'osc' ++ url,
|
|
{ | msg, time |
|
|
value = msg[1];
|
|
apply.value(value, time)
|
|
},
|
|
url
|
|
);
|
|
apply.value(value, 0);
|
|
this.send();
|
|
}
|
|
|
|
value_ { |newval|
|
|
value = newval;
|
|
apply.value(value, 0);
|
|
this.send();
|
|
}
|
|
|
|
send {
|
|
touchOSC.send(url, value);
|
|
}
|
|
}
|
|
|
|
TouchOSCControlScale : TouchOSCControl {
|
|
var scale;
|
|
|
|
*new { | touchOSC, url, apply, value, scale |
|
|
^super.newCopyArgs(touchOSC, url, apply, value, scale)
|
|
}
|
|
|
|
init {
|
|
OSCdef.new(
|
|
'osc' ++ url,
|
|
{ | msg, time |
|
|
value = scale.tovalue(msg[1]);
|
|
apply.value(value, time);
|
|
},
|
|
url
|
|
);
|
|
apply.value(value, 0);
|
|
this.send();
|
|
}
|
|
|
|
send {
|
|
touchOSC.send(url, scale.toctrl(value));
|
|
}
|
|
|
|
}
|
|
|
|
TouchOSCControlXY : TouchOSCControl {
|
|
var scale1, scale2;
|
|
|
|
*new { | touchOSC, url, apply, value, scale1, scale2 |
|
|
^super.newCopyArgs(touchOSC, url, apply, value, scale1, scale2)
|
|
}
|
|
|
|
init {
|
|
OSCdef.new(
|
|
'osc' ++ url,
|
|
{ | msg, time |
|
|
value[0] = scale1.tovalue(msg[1]);
|
|
value[1] = scale2.tovalue(msg[2]);
|
|
apply.value(value, time);
|
|
},
|
|
url
|
|
);
|
|
apply.value(value, 0);
|
|
this.send();
|
|
}
|
|
|
|
send {
|
|
touchOSC.send(url, scale1.toctrl(value[0]), scale2.toctrl(value[1]));
|
|
}
|
|
|
|
}
|
|
|
|
|
|
TouchOSCLabel {
|
|
var <touchOSC, <url, <value;
|
|
|
|
*new { | touchOSC, url, value |
|
|
^super.newCopyArgs(touchOSC, url, value)
|
|
}
|
|
|
|
init {
|
|
this.send();
|
|
}
|
|
|
|
value_ { |newval|
|
|
value = newval;
|
|
this.send();
|
|
}
|
|
|
|
send {
|
|
touchOSC.send(url, value);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
TouchOSCScale {
|
|
var <min, <max;
|
|
|
|
*new { | min, max |
|
|
^super.newCopyArgs(min, max)
|
|
}
|
|
|
|
tovalue { | c | ^c.linlin(0, 1, min, max) }
|
|
|
|
toctrl { | v | ^v.linlin(min, max, 0, 1) }
|
|
|
|
}
|
|
|
|
// todo - better validation so that you can't set min as 0
|
|
|
|
TouchOSCScaleExp : TouchOSCScale {
|
|
|
|
tovalue { | c | ^c.linexp(0, 1, min, max) }
|
|
|
|
toctrl { | v | ^v.explin(min, max, 0, 1) }
|
|
|
|
}
|
|
|