Bypass Switch For ASDR
Hi, I'm trying to produce a bypass switch to control the Envelope Bypass.
This is the code that I've been trying to use, but I think I have an error in there?
Any help would be appreciated.
{----Declaring Envelope Bypass Button----}
declare ui_button $Env_Byp
$Env_Byp := 1
declare $Env_Byp_ID
$Env_Byp_ID := get_ui_id ($Env_Byp)
set_text ($Env_Byp,"")
make_persistent ($Env_Byp)
read_persistent_var ($Env_Byp)
move_control_px ($Env_Byp,256,178)
set_control_par_str ($Env_Byp_ID,$CONTROL_PAR_PICTURE,"ds_bypass_button")
on ui_control ($Env_Byp)
if ($Env_Byp=1)
set_engine_par ($ENGINE_PAR_INTMOD_BYPASS,$Env_Byp,1,find_mod(0,"ENV_BYP"),-1)
else
set_engine_par ($ENGINE_PAR_INTMOD_BYPASS,$Env_Byp,0,find_mod(0,"ENV_BYP"),-1)
end if
end on
Comments
-
Hi @EvilDragon maybe something for you?
0 -
The mention "end on" is missing just before the part "on ui_control ($Env_Byp)" _
And at the very beginning of your script, start with: on init
Then, you may not see your button ($Env_Byp) so it will be necessary to modify its position in pixels: currently, it is like this. move_control_px ($Env_Byp,256,178) .
Something else; to see your script when you close the KSP editor, you must write at the very beginning of the script "make_perfview " _
0 -
there's a few things wrong on the OP's code. And some things that could be optimized:
on init declare ui_button $Env_Byp declare $Env_Byp_ID $Env_Byp := 1 $Env_Byp_ID := get_ui_id ($Env_Byp) set_text ($Env_Byp,"") make_persistent ($Env_Byp) read_persistent_var ($Env_Byp) move_control_px ($Env_Byp,256,178) set_control_par_str ($Env_Byp_ID,$CONTROL_PAR_PICTURE,"ds_bypass_button") end on on ui_control ($Env_Byp) set_engine_par($ENGINE_PAR_INTMOD_BYPASS,$Env_Byp,0,find_mod(0,"ENV_AHDSR"),-1) end on
The post was missing the "on init" at the top and the "end on" after the set_control_par_str. No big deal but, please pay attention.
2nd thing: The string to identify the modulator could be wrong, it was "ENV_BYP". Unless the OP changed manually the name of the modulator, that would not work. By default ADSR modulators have the name "ENV_AHDSR".
And last but not least, you don't need an if statement. The state of the button is either 0 or 1, you can play directly with that, like I have done on the example above.
In your version you confused the group argument with the value argument and you had it "1" in one line and "0" on the other, so the function was trying to set the state of the bypass for group "1". Nope nope.
Use the above instead.
1
Categories
- All Categories
- 19 Welcome
- 1.4K Hangout
- 60 NI News
- 735 Tech Talks
- 3.9K Native Access
- 15.9K Komplete
- 1.9K Komplete General
- 4.1K Komplete Kontrol
- 5.5K Kontakt
- 1.5K Reaktor
- 364 Battery 4
- 817 Guitar Rig & FX
- 416 Massive X & Synths
- 1.2K Other Software & Hardware
- 5.5K Maschine
- 7K Traktor
- 7K Traktor Software & Hardware
- Check out everything you can do
- Create an account
- See member benefits
- Answer questions
- Ask the community
- See product news
- Connect with creators