PARAM
This element can be used to create custom parameters.
Attributes brief detailed show all inherited
Examples
The following example creates a single parameter and adds a control to change that parameter:
- <?xml version="1.0" encoding="utf-8" ?>
- <SKIN>
- <PARAM id="gain" max="20" min="-20" default="0" unit="dB" />
- <PARAM_TEXT_CONTROL param_id="gain" cursor="system::size_v" />
- </SKIN>
Other param types
The default 'real' param type is the most useful: it can keep floating point values (like 0.234, 6124.234 etc).
However other params types can sometimes be very handy:
- <?xml version="1.0" encoding="utf-8" ?>
- <SKIN>
- <!-- create different params -->
- <PARAM id="modes" type="enumeration" enum_values="Classic;Neutral;Modern" />
- <PARAM id="steps" type="integer" min="1" max="8" default="4" value_format=".0" />
- <PARAM id="enabled" type="boolean" default="false" />
- <!-- dropdown menu for enums -->
- <PARAM_TEXT param_id="modes">
- <INVISIBLE_PARAM_MENU_BUTTON param_id="modes" width="100%" height="100%" cursor="system::hand" />
- </PARAM_TEXT>
- <!-- dropdown menu for integer param -->
- <PARAM_TEXT param_id="steps">
- <INVISIBLE_PARAM_MENU_BUTTON param_id="steps" width="100%" height="100%" cursor="system::hand" />
- </PARAM_TEXT>
- <!-- on/off switch -->
- <PARAM_TEXT param_id="enabled" content="enabled: {value}" value_format=".0">
- <INVISIBLE_PARAM_BUTTON param_id="enabled" positions_count="2" width="100%" height="100%" cursor="system::hand" />
- </PARAM_TEXT>
- </SKIN>
Persistent, exposed, capturing, value_changed
Use "persistent" attribute to make this parameter remember its value even when the skin reloads.
Use "exposed" to expose it for scripting engine — when you need to read or write this parameter in the script.
Here are some examples of using "capturing" and "value_changed" to trigger events.
- <?xml version="1.0" encoding="utf-8" ?>
- <SKIN spacing="4">
- <!-- the parameter value will be remembered between reloads (persistent) -->
- <PARAM id="gain" max="20" min="-20" default="0" unit="dB" persistent="true" />
- <ROW spacing="10">
- <!-- an indicator showing when param is "capturing" -->
- <WIDGET id="indicator" background_color="#00DD00" opacity="0.1" width="20" height="20" />
- <PARAM_LINK from="gain.capturing" to="indicator.opacity" formula="0.1+x" />
- <!-- param control -->
- <PARAM_TEXT_CONTROL param_id="gain" cursor="system::size_v" width="60" />
- </ROW>
- <ROW>
- <!-- trigger capturing events -->
- <SCRIPT script="int capturing_fired = 0; " />
- <ACTION_TRIGGER event_id="gain.capturing.value_changed" condition_formula="gain.capturing != 0"
- script="
- capturing_fired++;
- hint_capturing = "`Capturing` fired: " + capturing_fired;
- " requires="hint_capturing" />
- <!-- capturing hint -->
- <STRING id="hint_capturing" />
- <TEXT string_id="hint_capturing" width="150" />
- </ROW>
- <ROW>
- <!-- trigger gain value changed -->
- <ACTION_TRIGGER event_id="gain.value_changed" script="
- if (gain > 10) {
- hint = "Gain is too big!";
- } else {
- hint = "";
- }
- " requires="hint;gain" />
- <!-- gain too big hint -->
- <STRING id="hint" />
- <TEXT string_id="hint" width="150" />
- </ROW>
- </SKIN>
Note that in line 35 we expose required params to scripting engine via requires="hint;gain". We could achieve the same using exposed="true" for the gain param and for the hint string.
Persistence_context and locked
These attributes are related to persistent="true" attribute. When you make a param persistent (meaning its value is kept even when you reload the script) this parameter value is also saved within the preset (and within the default preset, called "Init" internally). If you don't want the preset loading to change your persistent param value, you can either use locked="true" meta-attribute to prevent it (and you can lock or unlock on the fly using param_id.meta.locked), or you can use persistence_context="-Preset;Init" to permanently prevent this param from saving and loading with presets and default preset.
BeginCapture and EndCapture
These actions are needed when you want to change the input parameter value from the GUI via script, If you don't call these actions you may see that param was changed in the GUI, but not in the DSP (as well as in DAW automation).
Let's say you have a GUI script that is automating DSP gain parameter (custom_param0 in our case)
- <?xml version="1.0" encoding="utf-8" ?>
- <SKIN spacing="4">
- <!-- keep input parameter name in variable -->
- <VARIABLE id="GAIN" value="custom_param0" />
- <!-- display/control current value -->
- <PARAM_TEXT_CONTROL param_id="$GAIN$" />
- <!-- timer to trigger auto changes -->
- <TIMER refresh_time_ms="100" id="gain_timer" enabled="false" />
- <!-- prepare script variables -->
- <SCRIPT script="
- double last_gain = 0;
- double delta = 0.5;
- bool rising = true;
- " />
- <!-- trigger action on timer events -->
- <ACTION_TRIGGER event_id="gain_timer.elapsed" script="
- last_gain = $GAIN$;
- if (rising) {
- last_gain += delta;
- } else {
- last_gain -= delta;
- }
- if (last_gain > 6) rising = false;
- if (last_gain < -6) rising = true;
- /* update input parameter */
- $GAIN$.BeginCapture();
- $GAIN$ = last_gain;
- $GAIN$.EndCapture();
- " requires="$GAIN$.BeginCapture;$GAIN$.EndCapture" />
- <ROW spacing="5">
- <!-- indicators showing when timer is "enabled" -->
- <WIDGET id="indicator_green" background_color="#00DD00" opacity="0" width="20" height="20" />
- <WIDGET id="indicator_red" background_color="#DD0000" opacity="0" width="20" height="20" />
- <PARAM_LINK from="gain_timer.enabled" to="indicator_green.opacity" formula="x" />
- <PARAM_LINK from="gain_timer.enabled" to="indicator_red.opacity" formula="x" reverse="true" />
- </LAYER_STACK>
- <!-- click to enable/disable timer -->
- <PARAM_TEXT param_id="gain_timer.enabled" width="100" content="auto: {text_value}">
- <INVISIBLE_PARAM_BUTTON param_id="gain_timer.enabled" positions_count="2" width="100%" height="100%" cursor="system::hand" />
- </PARAM_TEXT>
- </ROW>
- </SKIN>
Works in LM Skin, but not in the default skin
Note, that for this script to work in default skin, you have to add this to "default.xml":
- <REQUIRED_OBJECTS object_ids="custom_param0.BeginCapture;custom_param0.EndCapture" />
On the DSP side there's a simple script adding a parameter using "params.as" extension (you can add it in traditional way as well), and printing it's value:
- string name="KUIML Test";
- #include "library/params.as"
- int GAIN;
- GAIN = ip("Gain", "dB", -40, 40, 0, ".1");
- }
- print("Gain: " + IP[GAIN]);
- }