# Reversing a Group's Volume Knob's Value (Far Left is 100%)



## Justin Miller (Nov 9, 2017)

Curious if there is a script to reverse a knob's value (assigned to a group's volume).

Purpose: Single knob that blends between close mic and room mic positions (far left is only close mic group, far right is only room mic group).

Also, on a little more ambitious approach, is it possible to blend in another group that's value is at 100% when the knob is at 12 o'clock, while being at 0 if at min and max value (far left and right)?


----------



## EvilDragon (Nov 9, 2017)

Just reversing won't make it equal-power curve, it would go with Kontakt's scaling curve, which is logarithmic, but is not good for crossfading between two soundsources just by reversing the engine parameter value. This is best done with a lookup table that already has an equal-power curve "built into it" (which is a bit more involving to create, but I already have it created so here it is).



Mix knob is your regular mix, InOut knob is your _ambitious approach _(you'd probably need to use the SECOND set_engine_par only for what you want to do, add a third group.

BTW, in case this _ambitious approach_ to be done with ONE knob, you can do it with Mix knob as above (goes 0-1000), and this line:


```
set_engine_par($ENGINE_PAR_VOLUME, %vol_ep[1000 - abs(($Mix - 500) * 2)], 2, -1, -1)
```


Hopefully I don't need to explain the last three numbers in set_engine_par. If in doubt, check KSP reference


----------



## Justin Miller (Nov 19, 2017)

Wow man, thanks a ton! That seemed to really do the trick. I've swapped things out to use a slider instead so I could use a custom graphic.
Sorry it's taken me a while to get around to this, been recording bands all week :D

Here's the code so far--I'm sure that somewhere in there it could be more efficient, but things seem to be breathing atm. (I left out the table in this post, but it's in my code--it made the post have too many characters):







on init

make_perfview

message("")

make_perfview
set_ui_height_px(420)
set_script_title("BALANCE")
set_control_par_str($INST_WALLPAPER_ID,$CONTROL_PAR_PICTURE,"wallpaper1")
set_control_par_str($INST_ICON_ID, $CONTROL_PAR_PICTURE, "wallpaper1")



{Arrays}
{close microphone group declarations}
declare %close[3] := (0, 1, 2)

{overhead microphone group declarations}
declare %oh_soft[3] := (3, 4, 5)

{room microphone group declarations}
declare %room_soft[3] := (6, 7, 8)

{Conastants}
declare const $NUM_REPS := 3 {declares constant - round robin amount}

{Variables}
declare $rr_rep := 0 {declares round robin repetition}



{MIX KNOB}
declare ui_slider $Mix (0, 1000)
move_control_px($Mix, 222, 116)
{ hide the slider parts }
hide_part($Mix, $HIDE_PART_BG .or. $HIDE_PART_MOD_LIGHT .or. $HIDE_PART_TITLE .or. $HIDE_PART_VALUE)
{ assign the image file } 
set_control_par_str(get_ui_id($Mix), $CONTROL_PAR_PICTURE, "SampleXmixKnob") 
{ control how mouse movements should affect the control }
set_control_par(get_ui_id($Mix), $CONTROL_PAR_MOUSE_BEHAVIOUR, -500)

message("")

end on




on ui_control ($Mix)
{Close Mic Groups Knob Control -- reversed so knob at LEFT is max value}
set_engine_par($ENGINE_PAR_VOLUME, %vol_ep[1000 - $Mix], 0, -1, -1)
set_engine_par($ENGINE_PAR_VOLUME, %vol_ep[1000 - $Mix], 1, -1, -1)
set_engine_par($ENGINE_PAR_VOLUME, %vol_ep[1000 - $Mix], 2, -1, -1)

{OH Mic Groups Knob Control -- 12 o clock is max value, while left and right are 0}
set_engine_par($ENGINE_PAR_VOLUME, %vol_ep[1000 - abs(($Mix - 500) * 2)], 3, -1, -1)
set_engine_par($ENGINE_PAR_VOLUME, %vol_ep[1000 - abs(($Mix - 500) * 2)], 4, -1, -1)
set_engine_par($ENGINE_PAR_VOLUME, %vol_ep[1000 - abs(($Mix - 500) * 2)], 5, -1, -1)


{Room Mic Groups Knob Control - standard, right is max value, left is zero}
set_engine_par($ENGINE_PAR_VOLUME, %vol_ep[$Mix], 6, -1, -1)
set_engine_par($ENGINE_PAR_VOLUME, %vol_ep[$Mix], 7, -1, -1)
set_engine_par($ENGINE_PAR_VOLUME, %vol_ep[$Mix], 8, -1, -1)

end on




on note

$rr_rep := ($rr_rep + 1) mod $NUM_REPS

end on


----------



## Phonographic (Apr 22, 2022)

EvilDragon said:


> Just reversing won't make it equal-power curve, it would go with Kontakt's scaling curve, which is logarithmic, but is not good for crossfading between two soundsources just by reversing the engine parameter value. This is best done with a lookup table that already has an equal-power curve "built into it" (which is a bit more involving to create, but I already have it created so here it is).
> 
> 
> 
> ...



Hi EvilDragon. Thanks for all you posts and your giving we lean a great deal from you. I have a question around this array that you have posted. When applying it to $ENGINE_PAR_SEND_EFFECT_DRY_LEVEL on the IR Verb, I notice that the max value is equal to 12db (629961 in your array) I am trying to get that value to be 0db so that when the bypass is engaged that there is no sudden volume change. the %vol_ep[] volume curve is perfect but the range is not suitable to the DRY level. 0db is equal to 396484. That would be a perfect Max variable for this particular array in this application. Do you have any suggestions in how to achieve this?


----------



## EvilDragon (Apr 22, 2022)

This array is intended for group volume, where ~630000 is 0 dB. For dry/wet there is a different array that has the proper scaling.









Dry/Wet control of inserts


Eyo=) I wanted to send the "Dry/Wet" controls of the plate reverb insert (in slot 1 of the "insert effects") to the GUI... Is this possible? Thanks=)




www.native-instruments.com


----------



## Phonographic (Apr 22, 2022)

Amazing! Thank you. Works perfectly.


----------

