Quark Connection & SmoothSlider

Hello,

I’ve got issues to understand why I can update values with the Quark connection from Sliders and not SmoothSliders from wslib.

Example :

(
~values = 10.collect { NumericControlValue() };
~sliders = 10.collect { /*Smooth*/Slider() };
~view = View(bounds:600@200).layout_(GridLayout.rows(~sliders)).front;
~connections = ConnectionList.make {
	~values.connectEach(\value, ~sliders, _.valueSlot);
	~sliders.connectEach(\value, ~values, _.valueSlot);
};
)

If I move the first Slider and then evaluate :

~values[0].value;

the slider updates well the values.
But If I change Slider to SmoothSlider, the value is not updated.
Why ?
How to update the value when I move a SmoothSlider ?

Many thanks,
Christophe

A gui item needs to emit a .changed(\value, value) signal, which you can connect to e.g. a NumericControlValue. This is not done by default… For normal View classes, doing view.signal(\value) automatically hooks up this signal in the views action, using the ViewActionUpdater class (check the source code for View:signal). SmoothSlider doesn’t derive from View, so it doesn’t get this automatically… I think if you do ViewActionUpdater.enable(slider), everything should work, assuming SmoothSlider still uses .value and .action …

1 Like

Thank you so much Scott for your answers and patience!

ViewActionUpdater.enable(slider) updates well the value, but I would like to trigger also the action of the View, for instance the String of the SmoothSlider.

In the example below connecting the MIDI Fighter Twister to SmoothSliders, the knobs of the Twister updates SmoothSliders and NumericControlValue.
But It does not trigger the action, i.e that changes the string.
I tried to change the propertyName without success.
How could I do that ?

~t = Twister(TwisterDevice(\mine, MIDIClient.sources[1]));
( 
~values = 16.collect { NumericControlValue() };
~sliders = 16.collect { SmoothSlider().action_({ |view| view.string = view.value.round(0.01)}) };
~view = View(bounds:600@200).layout_(GridLayout.rows(~sliders)).front;

~connections = ConnectionList.make {
	~values.connectEach(\value, ~sliders, _.valueSlot);
	~sliders.connectEach(\value, ~values, _.valueSlot);
	~sliders.do({ |slider| ViewActionUpdater.enable(slider) });
	// ~sliders.do({ |slider| ViewActionUpdater.enable(slider, propertyName:'valueAction') });
};

~t.knobs.do { |i, id| i.knobCV = ~values[id] };
)

Thanks again,
Christophe

I’m not totally clear on what you want to get, as I’m not that familiar with SimpleSlider. If you want to also set SimpleSlider:string in addition to SimpleSlider:value, you can just add a connection to that method. This would look like:

	~values.connectEach(\value, ~sliders, _.valueSlot(\string);

The argument to valueSlot points it to the string_ setting instead of value_, which is the default. Another way to write this more generally is:

	~values.connectEach(\value, ~sliders, _.methodSlot("string_(value)");

Check the documentation for methodSlot for a more full explanation of that form - but the valueSlot version above should do the right thing.

Hello,

What I wanted in the example I posted, is to trigger the action associated with the SmoothSlider (in this case to change the string, but it could be anything encapsulated within a function for action. It is like triggering .valueAction.

Many thanks,
Christophe

Thanks Scott for your input.
The code below, which connects together values, theTwister and SmoothSliders (associated with an action that changes a String) works well now :

(
~t = Twister(TwisterDevice(\mine, MIDIClient.sources[1]));
~values = 16.collect { NumericControlValue() };
~sliders = 16.collect { SmoothSlider().action_({ |view| view.string = view.value.round(0.01)}) };
~t.knobs.do { |i, id| i.knobCV = ~values[id] };
~view = View(bounds:600@200).layout_(GridLayout.rows(~sliders)).front;
~connections = ConnectionList.make {
	~values.connectEach(\value, ~sliders, _.valueSlot);
	~sliders.connectEach(\value, ~values, _.valueSlot);
	~sliders.do({ |slider| ViewActionUpdater.enable(slider) }); // necessary to update from SmoothSliders the values and so the Twister knobs
	~values.connectEach(\value, ~sliders, _.methodSlot("doAction")); // necessary to update action from SmoothSliders
};
)

But, if I change the last line of the above code to this one, only some Strings are showed are others not. Just to understand, why?

    ~values.connectEach(\value, ~sliders, _.valueSlot(\valueAction)); 

Many thanks again,
Christophe

I’m afraid I can’t tell you why your valueAction case doesn’t work. This should be exactly equivalent to calling e.g. slider.valueAction_(440.0) when the value changes. You might test SmoothSlider to see if this is even working correctly without the Connection stuff - SmoothSlider is a very old and unmaintained class, so it may be that it simply has some bugs/regressions since it was last touched in… 2014.

Everything else you’re doing looks totally correct! If you find any other gotchas, please post them.