Plug'n Script Button

Official support for: bluecataudio.com
RELATED
PRODUCTS
Plug'n Script$99.00Buy

Post

Aloha,

Anyone have a suggestion on how to implement a "Reset Button" to restore knobs to initial values.
This shouldn't be an on/off button. It's not a dual state button but something that either triggers a method in the script or somehow does something in KUIML to reset values to initial values.

thanks.

Post

The easiest way is to create an action button (either IMAGE_ACTION_BUTTON or INVISIBLE_ACTION_BUTTON) with a script action that performs the reset.

Post

Greg, here's an example for you:

Code: Select all

	<!-- demo controls -->
	<ROW>
		<COLUMN>
			<CUS_DARK_BLUE_KNOB param_id="custom_param0" />
			<PARAM_TEXT param_id="custom_param0" />
		</COLUMN>
		<COLUMN>
			<CUS_DARK_BLUE_KNOB param_id="custom_param1" />
			<PARAM_TEXT param_id="custom_param1" />
		</COLUMN>
	</ROW>
	
	<!-- action to reset input params to default values -->
	<ACTION id="reset_all" type="Script" 
		script="custom_param0 = $script_input_param0_default$;custom_param1 = $script_input_param1_default$;"	requires="custom_param0;custom_param1;$script_input_param0_default$;$script_input_param1_default$" />
	
	<!-- widget "button"-like -->
	<WIDGET background_color="#007700" text_color="#FFFFFF" v_margin="5" h_margin="10">
		<TEXT id="reset_text" value="Reset to default!">
			<INVISIBLE_ACTION_BUTTON id="reset_inv_button" action_id="reset_all" cursor="system::hand" width="100%" height="100%" />
		</TEXT>
	</WIDGET>
	
	<!-- a small "animation trick" to slightly move text when button is pressed -->
	<PARAM_MULTI_LINK from="reset_inv_button.pushed" to="reset_text.h_offset;reset_text.v_offset" />
Last edited by ilyaorlov on Fri Feb 21, 2020 7:16 am, edited 1 time in total.

Post

There's also another way to do this (a bit more sofisticated probably):
instead of scripts use PARAM_LINK to link default value to param value, and use INVISIBLE_PARAM_TOGGLE_SWITCH to toggle that PARAM_LINK enabled/disabled state.

Here's an example:

Code: Select all

<TEXT value="Reset several controls to default values" />
	<!-- demo controls -->
	<ROW v_margin="10" spacing="5">
		<COLUMN>
			<CUS_DARK_BLUE_KNOB param_id="custom_param0" />
			<PARAM_TEXT param_id="custom_param0" />
		</COLUMN>
		<COLUMN>
			<CUS_DARK_BLUE_KNOB param_id="custom_param1" />
			<PARAM_TEXT param_id="custom_param1" />
		</COLUMN>
		<COLUMN>
			<CUS_DARK_BLUE_KNOB param_id="custom_param2" />
			<PARAM_TEXT param_id="custom_param2" />
		</COLUMN>
	</ROW>
	
	<!-- make links from default value to param value, disabled by default -->
	<PARAM_LINK id="linkdef0" from="custom_param0.default" to="custom_param0" enabled="false" />
	<PARAM_LINK id="linkdef1" from="custom_param1.default" to="custom_param1" enabled="false" />
	<PARAM_LINK id="linkdef2" from="custom_param2.default" to="custom_param2" enabled="false" />
	<!-- link all links to enable/disable at once -->
	<PARAM_MULTI_LINK from="linkdef0.enabled" to="linkdef1.enabled;linkdef2.enabled" />

	<!-- widget "button"-like enabling first link (all other links follow) -->
	<WIDGET background_color="#007700" text_color="#FFFFFF" v_margin="5" h_margin="10">
		<TEXT id="reset_tx" value="Reset to default!">
			<INVISIBLE_PARAM_TOGGLE_SWITCH id="rst_inv_button" param_id="linkdef0.enabled" cursor="system::hand" width="100%" height="100%" />
		</TEXT>
	</WIDGET>
	
	<!-- a small "animation trick" to slightly move text when button is pressed -->
	<PARAM_MULTI_LINK from="rst_inv_button.pushed" to="reset_tx.h_offset;reset_text.v_offset" />
Last edited by ilyaorlov on Fri Feb 21, 2020 7:17 am, edited 1 time in total.

Post

Aloha Ilya,

Thank you. Extremely helpful.
I'll study these examples tonight.
I think I'll also try to figure out how to use you new Customizable skin to include a custom button image. viewtopic.php?f=52&t=539930

with aloha,
Greg

Post

action_id="reset_all" causes a KUIML Loading Error on refresh.
If I take the action_id from the INVISIBLE_ACTION_BUTTON the skin will display but the button won't work.
Is something special required in the script besides the script variables ?

Loading Error popup says something about <unrecognized token> in C:\Program Files\...\default.xml (15:20) also at (15:23)

Any suggestions? Can you point to a place in the manual with an example?

Post

Do you get these errors when plugin is exported or while working in P-n-S?
If you remove the whole code I've posted the error doesn't show up?

Post

Errors occur while working in PnS.
When entire Code in your example is removed, the script/KUIML to loads fine.

If I take out action_id="reset_all" from the INVISIBLE_ACTION_BUTTON the error goes away.

I'm using the first simple example you provided.
Here's a snippet of the button widget:

Code: Select all

	<!-- widget "button"-like -->
	<WIDGET background_color="#007700" text_color="#FFFFFF" v_margin="5" h_margin="10">
		<TEXT id="reset_text" value="Reset to default!">
			<INVISIBLE_ACTION_BUTTON id="reset_inv_button" action_id="reset_all" cursor="system::hand" width="100%" height="100%" />
		</TEXT>
	</WIDGET>
<TEXT id="reset_text" value="Reset to default!">
<INVISIBLE_ACTION_BUTTON id="reset_inv_button" action_id="reset_all" cursor="system::hand" width="100%" height="100%" />
</TEXT>

action_id needed to be removed in order for script/KUIML to load.
But of course the button does nothing then.

Post

Hey, Greg!
I've made a new demo for you, grab it on GitHub: https://github.com/ilyaorlovru/plug-n-script-examples
or here in attachments.
reset_multiple_controls_to_default_values.zip
The problem could be in multiple lines inside "script", which in my case worked ok, but your editor could probably add additional chars like "\r" when you copied and pasted. Try removing line breaks, making all the script in ACTION in one line. Also I started custom_params from 1, when they in fact start from 0. This could be also a reason for errors depending on your DSP params.

Anyway, try the scripts attached, hopefully they work fine.
You do not have the required permissions to view the files attached to this post.

Post

Aloha Ilya,

Your scripts work. There were line breaks included but removing them didn't change anything.
I'm going to have to compare code to find the error.
Thank you very much.

Post

:tu:

Post

Figured it out. Some stupid assumptions on my part.
Thank you, Ilya.

Post

You're welcome! I was in your shoes not so long time ago :) KUIML is tricky sometimes.

Post

So here's the latest thing: The button works fine but when the plugin first comes up, the defaults are ignored.
I retried putting settings in:

Code: Select all

void initialize() {
	inputParameters[0]=40;
	inputParameters[1]=100;
}
but that didn't work - knobs stayed the same. Not sure how to trigger that method in KUIML.

Also, when you use KUIML you need to have Custom Enabled turned on.
inputParametersSteps works fine when Custom Enabled is turned off.
But it's ignored when Custom Enabled is turned on.
There must be a KUIML parameter that sets the Parameter Steps for a control.
I definitely can't find that in the docs.

Post

Greg, here are the answers:

1) You should put default parameter values into inputParametersDefault:
array<double> inputParametersDefault={0,0...,0}

2) Yes, this is unclear. inputParametersSteps works only for auto-generated layouts. For your custom .kuiml you should/can give each of your controls this "steps" param individually with "positions_count" attribute. Like this:
<CUS_DARK_BLUE_KNOB param_id="custom_param0" positions_count="10" ... />

You can however link parameterSteps from the DSP to your knob like this (note that you should give your KNOB an "id" attribute).
<CUS_DARK_BLUE_KNOB param_id="custom_param0" id="myknob0" ...
<PARAM_LINK from="$script_input_param0_steps$" to="myknob0.positions_count"/>

Hope this helps.

Post Reply

Return to “Blue Cat Audio”