How to attach Attack from the volume envelope to a knob in KSP?
I have most of the code set up to achieve this but I believe I am just not understanding how to use set_engine_par to call upon the attack parameter. I believe since it is a modulator that there is something more to it but I have not been able to figure it out. I have included a screenshot of my current code. It lets me apply it but it doesn't actually affect the attack time.
Comments
-
An exemple in the KSP manual: verything lies in the last three digits corresponding to the group on a 0 basis.
It seems complicated at first but as you write and code, it improves in understanding.
0 -
I did find this example and tried following it, but then I started having problems with the "VOL_ENV" portion of the get_mod_idx command. I renamed it manually like it says in the manual but I get a warning saying that it is not recognized. I tried the same thing with the default name of the envelope and it still did not work. Can you look through my code and see if anything is off?
0 -
This sticky thread is quite useful when it comes to modulators:
As for the ENGINE_PAR_ATTACK, you can also do:on init
declare $i
declare ui_slider $attack(0,1000000)
make_persistent($attack)
end on on ui_control($attack)
$i := 0
while ($i<$NUM_GROUPS)
set_engine_par($ENGINE_PAR_ATTACK,$attack,$i,0,0)
inc($i)
end while
end on1 -
Thank you so much for the code and the thread! Is it possible you can explain the while loop, specifically how it works with the $i<$NUM_GROUPS condition and the set_engine_par conditions? How does incrementing through different groups make it work?
0 -
A while loop lets you apply the same command to different groups or slots without repeating the code.
- $i is the counter:
$i := 0
starts the loop at 0, but you can start at any number.
- The Loop Condition:
while ($i < $NUM_GROUPS)
the loop runs as long as$i
is less than$NUM_GROUPS
$NUM_GROUPS
is a built-in KSP variable that tells you how many groups there are in a Kontakt instrument. The first group is always group index 0.
- Inside the Loop:
set_engine_par($ENGINE_PAR_ATTACK, $attack, $i, 0, 0)
this sets the attack parameter for the current group$i
inc($i)
this increases$i
by 1, so the next loop works on the next group
- Ending the Loop:
end while
the loop stops when$i
is no longer less than$NUM_GROUPS
Note that you can achieve the same result with less code if you use Sublime Text Editor to write your scripts. Example:
for i:= 0 to NUM_GROUPS - 1 set_engine_par(ENGINE_PAR_ATTACK, attack, i, 0, 0) end for0 - $i is the counter:
-
Thanks for the breakdown, I am just still confused as to how you are able to target the volume envelope without mentioning it in the code. From the thread you had provided they had mentioned using get_mod_idx which makes sense but for whatever reason when I change the "ENV_ADHSR_VOLUME" name or just use that one it doesn't work.
A better way to pose my initial question would be how does cycling through the different groups find the Attack parameter if my instrument is only in one group?
0 -
I had ended up removing the while loop to see if it would still work and it did. But now I understand that you had gotten the 0 values in your set_engine_par and get_engine_par from the (Group:0, Index:0,Generic:0) that is attached to ENV_AHDSR_VOLUME. I had been overcomplicating it with the whole get_mod_idx, so this does simplify it, thanks again for your help!
0 -
Unless you need to control the modulator's intensity, there's no practical reason to target a specific modulator name just to adjust the ADSR values. The sticky thread covers almost everything about modulators, and I highly recommend checking it out and running some tests in a fresh .nki file.
Note that my example using the while loop lets you control the attack levels of all your available groups.0
Categories
- All Categories
- 19 Welcome
- 1.5K Hangout
- 62 NI News
- 785 Tech Talks
- 4.1K Native Access
- 16.5K Komplete
- 2K Komplete General
- 4.3K Komplete Kontrol
- 5.7K Kontakt
- 1.6K Reaktor
- 378 Battery 4
- 845 Guitar Rig & FX
- 429 Massive X & Synths
- 1.3K Other Software & Hardware
- 5.8K Maschine
- 7.3K Traktor
- 7.3K 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