Kontakt scripting for building my Sample Library

Hi :slightly_smiling_face: I wonder if anyone can advise on a scripting issue?

I’m doing my first library hopefully for Pianobook when ready. My knowledge is beginner (I used Stephen O’Connell’s free YouTube template and added extra bits)

All works great so far. Except that I have an issue with my newly added ‘Bypass’ buttons not changing their labels correctly on startup!

They are set to change to “ON” and “OFF” when pressed. They are performing their function fine (turning groups on and off) and labels change fine when you press the button.

But they are all incorrectly named on startup, or when you change to a snapshot😭

I have my full script on a txt file for perusal if anyone can help (perhapsf a bit much to paste!).

Alternatively, can anyone recommend other places I can look for help? :slightly_smiling_face:

1 Like

It’s a guess, but are you initialising the UI elements with a state/value that reflects how they should be set when the patch loads?

Thanks Ed, I think so, here is the first script for one of the buttons as an example:

Thinking about it, I probably should point out that for this instrument, these bypass buttons are for my groups. And so; when I bypass a group I am having it say “OFF”, and visa versa :blush:

declare ui_button $Bypass1

move_control_px ($Bypass1,16,170)

make_persistent($Bypass1)

set_text ($Bypass1, “ON”)

The result I have is that they all start with the label “ON” , regardless of what buttons are actually on or off, if I press the mouse on it, the button will then change correctly to “ON” or “OFF” but as soon as I load a new snapshot, every button says “ON” even if it isn’t :joy:

If it helps, the next bit is for the buttons to bypass the groups I have. I got it from Stephen’s other video, which explained I have to use the “on note” for this to work properly as groups are different (I forget the reason!)

on note

disallow_group($ALL_GROUPS)

if ($Bypass1=1)

allow_group(0)

else

disallow_group(0)

end if

(I also made sure to put “end on” afterwards)

Finally, I added this on ui_control part towards the end, to try and get the labels to switch correctly.

I think I adapted it from Stephen’s further video, but that was for switching between groups which isn’t what I’m doing, so I’m not sure if I have adapted it correctly!!

on ui_control($Bypass1)

if ($Bypass1=0)

set_text($Bypass1, “OFF”)

else

set_text($Bypass1, “ON”)

end if

end on

I get no error messages when I hit apply, and the instrument works fine, but just have this annoying button label issue :joy:

I think the issue might be that you aren’t explicitly setting a value for $Bypass1 (to 0 or 1) when you create it, to correspond with the value for the text. So something like:

declare ui_button $Bypass1
move_control_px ($Bypass1,16,170)
make_persistent($Bypass1)
set_text ($Bypass1, "ON")
$Bypass1 = 1 { this }
1 Like

Ah I’d not seen that before.. I have tried it, and at first Kontakt gave me an error saying it was expecting := rather than just = , so I did that, and then it accepted it, but still doesn’t seem to be doing the business for me!

(someone on the discord has also suggested it might be to do with needing a read_persistent_var script. I’m just looking at the sheet they have supplied to see if I can understand it :rofl: )

**just trying this now, may have fixed it! :upside_down_face: I’ll put the code in if it works!

SOLVED!

So I had a look at a video on YouTube as well regarding this read_persistent_var command , as I couldn’t understand the Kontakt Manual sheet someone showed me (being new to the whole thing).

And from that I changed my script to the below in the on init section. (I had to still keep my on ui_control script in place as well, or it didn’t work).

Here is the working changed code I have now used that has solved it! Now my buttons’ labels show correctly whenever I open the instrument or change to a snapshot.

	declare ui_button $Bypass1
	move_control_px ($Bypass1,16,170)
	make_persistent($Bypass1)
	read_persistent_var ($Bypass1)
if ($Bypass1=0)
	set_text($Bypass1, "OFF")
else
	set_text($Bypass1, "ON")
end if

So now I need to decide if I want to try adding buttons from Webknobman or leave that to Version 2 later :laughing:

1 Like

Very glad you solved the problem - I’m sorry for sending you down the wrong path.

1 Like

No probs it was helpful to get me to look at it in more detail :smiling_face_with_sunglasses:

All done with the UI. Had thought about fancy knobs etc but will leave that for V2.

Anyone had experience with things like Webnobman? Does it work ok?

I could submit now, but I think I need to spend some more time on making nki patches for it. Thought best to take the time and make it more instantly useable for people.

Hopefully I will package it right when I submit it to Pianobook down the line!

Submission finally done! Just got to wait for it to be checked over by the Pianobook Team😎

Hopefully I got the package put together correctly! Will see soon enough :joy:

1 Like

It’s finally on Pianobook!

Many thanks to the staff at Pianobook also for the work they do in going over everyones sample packs to check them over, it must be a lot of work, much appreciated!

If anyone is interested, here is “Night Bells” Please feel free to peruse :smiling_face_with_sunglasses:

I’m working on a demo currently so hopefully will finish that in near future.

1 Like

Congratulations Leigh!! Really looking forward to hearing your demo :smiling_face:

1 Like