Help Needed: Kontakt Scripting Challenge with PGS Commands

Kamarrie
Kamarrie Member Posts: 1 Newcomer

Hi guys,


I've been exploring Kontakt scripting for a few weeks and trying out pgs. I found a tempo buttons script in a post in vi-control , placed it in slot 5, and set up my main script in slot 1. Everything works when I hit the buttons, but there's a snag. Pressing the first button runs through all three pgs commands on slot 5 and stops at 3. The second button goes through commands 2 and 3, stopping at 3.


When I comment out pgs 3, it stops at 2 when I hit the first or second buttons. They work fine individually, but the challenge is making them execute only the desired pgs command without going through all three.


I know I could integrate the slot 5 script into the main one, but I'm curious to figure out this puzzle for the exercise.



{Slot 1}

on init


make_perfview 

set_ui_height_px(150)


{PGS KEYS}

pgs_create_key(half, 1)

pgs_create_key(normal, 1)

pgs_create_key(double, 1)


{UI BUTTONS}

declare ui_button $half

move_control_px ($half, 170,54)


declare ui_button $normal 

move_control_px ($normal, 260,54)


declare ui_button $double

move_control_px ($double, 350,54)


end on



on ui_control ($half)

pgs_set_key_val(half, 0, $half)

$half := 1

$normal := 0

$double := 0

end on


on ui_control ($normal)

pgs_set_key_val(normal, 0, $normal)

$half := 0

$normal := 1

$double := 0

end on


on ui_control ($double)

pgs_set_key_val(double, 0, $double)

$half := 0

$normal := 0

$double := 1

end on 








{Slot 5}


on init

declare ui_button $half

declare ui_button $normal

declare ui_button $double

declare $speed_control

declare $the_event


end on


on pgs_changed



$half := pgs_get_key_val(half, 0)

$speed_control := -1

$half := 1

$normal := 0

$double := 0

set_event_par_arr($the_event, $EVENT_PAR_MOD_VALUE_ID, $speed_control * 500000, 1)

message("Half")


$normal := pgs_get_key_val(normal, 0)

$speed_control := 0

$normal := 1

$half := 0

$normal := 1

$double := 0

set_event_par_arr($the_event, $EVENT_PAR_MOD_VALUE_ID, $speed_control * 500000, 1)

message("Normal")


$double := pgs_get_key_val(double, 0)

$speed_control := 1

$half := 0

$normal := 0

$double := 1

set_event_par_arr($the_event, $EVENT_PAR_MOD_VALUE_ID, $speed_control * 500000, 1)

message("double")


end on


on note


$the_event := $EVENT_ID

set_event_par_arr($EVENT_ID, $EVENT_PAR_MOD_VALUE_ID, $speed_control * 500000, 1)


end on


on ui_control ($half)

$half := 1

$normal := 0

$double := 0

$speed_control := -1

set_event_par_arr($the_event, $EVENT_PAR_MOD_VALUE_ID, $speed_control * 500000, 1)


end on

on ui_control ($normal)

$half := 0

$normal := 1

$double := 0

$speed_control := 0

set_event_par_arr($the_event, $EVENT_PAR_MOD_VALUE_ID, $speed_control * 500000, 1)

end on

on ui_control ($double)

$half := 0

$normal := 0

$double := 1

$speed_control := 1

set_event_par_arr($the_event, $EVENT_PAR_MOD_VALUE_ID, $speed_control * 500000, 1)

end on

Back To Top