Plug'n Script Button
-
- KVRer
- 28 posts since 25 Aug, 2018
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.
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.
-
Blue Cat Audio Blue Cat Audio https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=39981
- KVRAF
- 6335 posts since 8 Sep, 2004 from Paris (France)
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.
-
- KVRist
- 316 posts since 28 May, 2011
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.
-
- KVRist
- 316 posts since 28 May, 2011
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:
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.
-
- KVRer
- Topic Starter
- 28 posts since 25 Aug, 2018
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
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
-
- KVRer
- Topic Starter
- 28 posts since 25 Aug, 2018
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?
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?
-
- KVRer
- Topic Starter
- 28 posts since 25 Aug, 2018
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:
<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.
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><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.
-
- KVRist
- 316 posts since 28 May, 2011
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. 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.
I've made a new demo for you, grab it on GitHub: https://github.com/ilyaorlovru/plug-n-script-examples
or here in attachments. 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.
-
- KVRer
- Topic Starter
- 28 posts since 25 Aug, 2018
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.
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.
-
- KVRer
- Topic Starter
- 28 posts since 25 Aug, 2018
Figured it out. Some stupid assumptions on my part.
Thank you, Ilya.
Thank you, Ilya.
-
- KVRer
- Topic Starter
- 28 posts since 25 Aug, 2018
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: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.
I retried putting settings in:
Code: Select all
void initialize() {
inputParameters[0]=40;
inputParameters[1]=100;
}
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.
-
- KVRist
- 316 posts since 28 May, 2011
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.
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.