Outputting percentage value on label
Hi Guys,
I have adapted some code I found and it is working well, except the output the slider gives me is not a percentage but actually one of the %drywet values. How can I change the code attached so it shows percentage values on my label? (Tried to do a code block but said I had too many characters!)
Thanks in advance!
Best Answer
-
You can calculate the percentage before you set the text on your reverb label. Multiply the dry-wet value by 100 first, then divide by whatever your maximum dry-wet value is. Below I used the last value in your dry-wet array as said maximum. (fyi, if you instead multiply by 100 *after* dividing, you'll always get 0, which you don't want to do.)
declare $drywetpercent := %drywet[$reverb] * 100 / %drywet[1000] set_text($reverb_label, "Reverb " & $drywetpercent & " %")
0
Answers
-
I might recommend using the get_engine_par_disp() command instead of referencing your lookup array.
Something like:
on ui_control($reverb) set_text($reverb_label, get_engine_par_disp($ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, group, slot, generic) & "%" end on
0 -
Unfortunately this doesn't work as I am blending between the dry and wet in the reverb insert so I end up with -inf to 0% rather than 0-100%
0 -
You can calculate the percentage before you set the text on your reverb label. Multiply the dry-wet value by 100 first, then divide by whatever your maximum dry-wet value is. Below I used the last value in your dry-wet array as said maximum. (fyi, if you instead multiply by 100 *after* dividing, you'll always get 0, which you don't want to do.)
declare $drywetpercent := %drywet[$reverb] * 100 / %drywet[1000] set_text($reverb_label, "Reverb " & $drywetpercent & " %")
0 -
That's sorted it, thank you!
0 -
Just use the value of your slider.
$reverb -> label := $reverb / 10 & "." & $reverb mod 10 & " %"
0
Categories
- All Categories
- 19 Welcome
- 1.5K Hangout
- 62 NI News
- 785 Tech Talks
- 4.1K Native Access
- 16.6K Komplete
- 2K Komplete General
- 4.3K Komplete Kontrol
- 5.7K Kontakt
- 1.6K Reaktor
- 379 Battery 4
- 846 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