[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-users] bilin



I've just added SimpleNumber.bilin : this has proved very useful when adjusting
sliders with a remote controller, like a midifader.

by setting the center of the output to the current view level, the center position of the controller keeps the old value. So when starting to edit a control, the midiFaderValue and the controlValue are stored and passed in the function like this:


adjust = { arg ctlVal, lastOutValue, lastCtlvalue;
		var val;
		val = ctlVal (lastCtlvalue, 0, 1, lastOutValue, 0, 1);
		slider.value = val;
};


this allows also an easy handling of pitchbend wheels, for example.


here is a working example:
(move the left slider to control the right, move the right to some other value and then control it again with the left)

// bilin
(
w = SCWindow("2 sliders", Rect(130,130,150,200));
w.view.decorator_(FlowLayout(w.view.bounds));
w.front;
x = SC2DTabletSlider(w, Rect(0, 0, 50, 180)).resize_(5);
y = SC2DTabletSlider(w, Rect(0, 0, 50, 180)).resize_(5);


x.mouseDownAction = { c = x.y; d = y.y };
x.action = { y.y = x.y.bilin(c, 0, 1, d, 0, 1); };
)


// biexp
(
w = SCWindow("2 sliders", Rect(130,130,150,200));
w.view.decorator_(FlowLayout(w.view.bounds));
w.front;
x = SC2DTabletSlider(w, Rect(0, 0, 50, 180)).resize_(5);
y = SC2DTabletSlider(w, Rect(0, 0, 50, 180)).resize_(5);


x.mouseDownAction = { c = x.y; d = y.y };
x.action = { y.y = x.y.biexp(c, 0.01, 1, d, 0, 1); };
)
--








.