What's new

Change ui_knob for ui_slider

jesusginard

Active Member
Hello everyone,

I want to include this script "Unison X" script preset on my new library, but I want to include my own UI elements, so I have to change the knob to sliders. I do it but it doesn't work. Is it possible to make the same script using sliders instead of knobs?

on init

set_script_title("Unison X")
set_ui_height(2)
message("")
make_perfview

declare polyphonic $pan_L
declare polyphonic $pan_R
declare $voice_1
declare $voice_2
declare $voice_3
declare $voice_4
declare $voice_5
declare $voice_6
declare $voice_7
declare $voice_8
declare $voice_mod

declare ui_knob $Detune (0,50000,100000)
declare ui_knob $Spread (0,1000,10)
declare ui_knob $Voices (1,8,1)

$Voices := 2
$Detune := 35000
$Spread := 650

move_control($Voices,2,2)
move_control($Detune,3,2)
move_control($Spread,4,2)

make_persistent ($Voices)
make_persistent ($Detune)
make_persistent ($Spread)

set_control_help ($Voices,"Voices: Sets the number of voices played for each MIDI note.")
set_control_help ($Detune,"Detune: Sets the amount of detuning among the voices.")
set_control_help ($Spread,"Spread: Sets the amount of stereo spread among the voices")

end on

on note

{Voice 1}
ignore_event ($EVENT_ID)
$voice_1 := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,-1)
{Voice 2}
if ($Voices > 1)
{Voice 1 treatment}
change_pan($voice_1,$Spread,0)
change_vol($voice_1,-500*$Voices,1)
{Voice 2}
$voice_2 := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,-1)
change_tune($voice_2,$Detune ,0)
change_pan($voice_2,-$Spread,0)
change_vol($voice_2,-500*$Voices,1)
end if
{Voice 3}
if ($Voices > 2)
$voice_3 := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,-1)
change_tune($voice_3,-$Detune /8 * 4,0)
change_vol($voice_3,-500*$Voices,1)
if ($Voices = 3)
else
change_pan($voice_3,$Spread,0)
end if
end if
{Voice 4}
if ($Voices > 3)
$voice_4 := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,-1)
change_tune($voice_4,$Detune /8 * 4,0)
change_pan($voice_4,-$Spread,0)
change_vol($voice_4,-500*$Voices,1)
end if
{Voice 5}
if ($Voices > 4)
$voice_5 := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,-1)
change_tune($voice_5,-$Detune /8 * 6,0)
change_vol($voice_5,-500*$Voices,0)
if ($Voices = 5)
else
change_pan($voice_5,$Spread,1)
end if
end if
{Voice 6}
if ($Voices > 5)
$voice_6 := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,-1)
change_tune($voice_6,$Detune /8 * 6,0)
change_pan($voice_6,-$Spread,0)
change_vol($voice_6,-500*$Voices,1)
end if
{Voice 7}
if ($Voices > 6)
$voice_7 := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,-1)
change_tune($voice_7,-$Detune /8 * 2,0)
change_vol($voice_7,-500*$Voices,1)

if ($Voices = 7)
else
change_pan($voice_7,$Spread,0)
end if
end if
{Voice 8}
if ($Voices > 7)
$voice_8 := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,-1)
change_tune($voice_8,$Detune /8 * 2,0)
change_pan($voice_8,-$Spread,0)
change_vol($voice_8,-500*$Voices,1)
end if
end on
 
Replace these lines:

Code:
declare ui_knob $Detune (0,50000,100000)
declare ui_knob $Spread (0,1000,10)
declare ui_knob $Voices (1,8,1)

with these lines:

Code:
declare ui_slider $Detune (0,50000)
declare ui_slider $Spread (0,1000)
declare ui_slider $Voices (1,8)

Then add the code for loading custom images etc.
 
Is it possible to make the same script using sliders instead of knobs?
Sure, you have to re-declare the knobs as sliders as mk282 pointed. If you are talking about custom image sliders you have to refer to the Kontakt Player Developer Guide - just Google it, I think you will find that pdf. Have a look at the chapter "5.3.3 Skinning UI Elements".
 
Thank you very much, guys! It didn't work on the first place because I was puting the wrong values.

Thanks again!
 
Top Bottom