Kontakt - Buttons controlling sliders and retaining values

Sampler and Sampling discussion (techniques, tips and tricks, etc.)
Post Reply New Topic
RELATED
PRODUCTS

Post

I have two buttons and one slider. I had both buttons control the same slider.

I press button1 and adjust the slider to, let's say, value 80. Then, I press button2 and adjust the slider to value 30. When I press button1 again, the value stays 30, doesn't go back to 80.

Is there a way to retain those values using one slider for various buttons?

I've been using the method of one slider for each button, showing slider1 and hiding all the others when I press button1 and so on. But I have lots of buttons and that converts into lots of sliders... :?

Sorry if this question has been asked before. It seems pretty relevant, so I've been digging into the forum but haven't found anything about it. Thanks in advance.

Post

When you hit button one, and move the slider, store the value in one variable (say "Button1_Slider").

When you hit button two, and move the slider, store the value in (say) "Button2_Slider".

Now, when you hit either button, update the slider with the value stored in the variable for it first, to restore it's state from either button mode.

Post

If you need to be able to automate/MIDI learn those sliders individually, don't do this multiplexing thing (using one control for several targets). If, on the other hand, you don't care about automating those sliders, sure, go ahead.

I would use an array instead of individual variables, though.

Post

Thanks, beely. That's a good way to do it.

ED, in my case, depends. Thanks for reminding me of that. =)

Post

Ok, I don't have a DAW to host it installed at the moment, I'll have to try it in a few days:

Code: Select all

on init
	declare ui_switch $switch1
	declare ui_switch $switch2
	declare ui_slider $slider(0,100)
	declare $slider_btn1
	declare $slider_btn2

	make_persistent($switch1)
	make_persistent($switch2)
	make_persistent($slider)
	make_persistent($slider_btn1)
	make_persistent($slider_btn2)

	set_control_par(get_ui_id($switch1),$CONTROL_PAR_AUTOMATION_ID,0)
	set_control_par(get_ui_id($switch2),$CONTROL_PAR_AUTOMATION_ID,1)
	set_control_par(get_ui_id($slider),$CONTROL_PAR_AUTOMATION_ID,2)
	set_control_par_str(get_ui_id($switch1),$CONTROL_PAR_AUTOMATION_NAME,"Switch 1")
	set_control_par_str(get_ui_id($switch2),$CONTROL_PAR_AUTOMATION_NAME,"Switch 2")
	set_control_par_str(get_ui_id($slider),$CONTROL_PAR_AUTOMATION_NAME,"Slider")
end on

on ui_control($slider)
	if($switch1=1)
		$slider_btn1 := $slider
	else
		$slider_btn2 := $slider
	end if
end on

on ui_control($switch1)
	$switch1 := 1
	$switch2 := 0
	if($switch1=1)
		$slider := $slider_btn1
	end if
end on

on ui_control($switch2)
	$switch1 := 0
	$switch2 := 1
	if($switch2=1)
		$slider := $slider_btn2
	end if
end on
https://imgur.com/a/n5u8y

I EDITED THE CODE.

This would reduce my script quite a bit. Switches can be automated, so perhaps they are a better choice. Do you guys think I can get away with this? :hihi:

Post

Don't use automation if you will multiplex sliders like that, I thought I was clear about that. It won't work (or rather: automation will apply only to the currently selected value depending on how switches are set up, which is really, REALLY bad). :) Just disallow automation ($CONTROL_PAR_ALLOW_AUTOMATION set to 0) on those controls, don't assign automation IDs.

Post

So, for example, if you are reusing a single onscreen control (say, "FILTER") for different purposes - would the better approach be to have two different filter controls with different automation ID's, and show/hide the desired one as necessary, and still therefore have "both" filter controls available for automation?

And what happens with MIDI learning to the onscreen FILTER knob?

Post

That is correct - if you need to control two filter cutoffs, especially via host automation or MIDI, you should use two individual controls, rather than multiplex one. MIDI learn is the same as host automation, just lower resolution (128 steps instead of 32-bit float), so which filter cutoff gets automated would depend on the button that chooses to which filter the control is going to point to. Which is of course, very bad.

Post

Cool, thanks for the confirmation!

Post

Yes, makes total sense, ED and beely. Thanks so much! :wink:

Post Reply

Return to “Samplers, Sampling & Sample Libraries”