# Convolution Menu Issue



## The Darris (Aug 2, 2014)

Hello Scripters. It is I, the scripting noob coming to you live with a fairly confusing question. I will do my best to explain.

I am converting an old Kore Sample Pack to Kontakt as I hate Kore but love the sounds in the pack. Since some of the percussion sounds are quite dry, I would like to have my own custom convolution interface on the gui. I am using the free M7-Bricasti convolutions as well as a simple Pre-Delay, Early and Late controls followed by the Convolution list. The problem I am facing is that I can't get the convolutions to load or for the convolution to get off of being bypassed when I select a convolution from the list. My convolutions are in my Samples folder for located in my libraries main folder. It uses this path.

Library Main/Sample/IR Samples/Name of IR.wav

The script I have currently from other tips is the one listed below but it doesn't work (no script errors though). I still haven't figured out how to sync up the Early and Late and Pre Delay controls yet. Any help with that too would be awesome. Thanks.

-Chris

Entire Current Instrument Script:

on init
set_ui_height_px(140)
make_perfview
message("")
declare $count := 0

declare ui_menu $IR
add_menu_item ($IR, " -Empty-",-1)
add_menu_item ($IR, "Amsterdam Hall", 0)
add_menu_item ($IR, "Berliner Hall", 1)
add_menu_item ($IR, "Vienna Hall", 2)
add_menu_item ($IR, "Concert Hall", 3)
add_menu_item ($IR, "Large Hall", 4)
add_menu_item ($IR, "Medium Hall", 5)
add_menu_item ($IR, "Small Hall", 5)
move_control_px($IR,426,30)


declare ui_knob $K1(0,1000000,1) 
set_knob_unit($K1,$KNOB_UNIT_DB) 
set_knob_defval ($K1,500000) 
make_persistent($K1) 
read_persistent_var($K1)
set_text($K1,"Pre Delay")
move_control_px($K1,426,80)
$K1 := get_engine_par($ENGINE_PAR_GAIN1,-1,1,1) 
set_knob_label($K1,get_engine_par_disp($ENGINE_PAR_GAIN1,-1,1,1))

declare ui_knob $K2(0,1000000,1) 
set_knob_unit($K2,$KNOB_UNIT_DB) 
set_knob_defval ($K2,500000) 
make_persistent($K2) 
read_persistent_var($K2)
set_text($K2,"Early")
move_control_px($K2,526,30)
$K2 := get_engine_par($ENGINE_PAR_GAIN1,-1,1,1) 
set_knob_label($K2,get_engine_par_disp($ENGINE_PAR_GAIN1,-1,1,1))

declare ui_knob $K3(0,1000000,1) 
set_knob_unit($K3,$KNOB_UNIT_DB) 
set_knob_defval ($K3,500000) 
make_persistent($K3)
read_persistent_var($K3) 
set_text($K3,"Late")
move_control_px($K3,526,80)
$K3 := get_engine_par($ENGINE_PAR_GAIN1,-1,1,1) 
set_knob_label($K3,get_engine_par_disp($ENGINE_PAR_GAIN1,-1,1,1))

{End of GUI Generator on init definitions}
end on

function update_knobs

$K1 := get_engine_par($ENGINE_PAR_GAIN1,-1,0,1) 
set_knob_label($K1,get_engine_par_disp($ENGINE_PAR_GAIN1,-1,1,1))
$K2 := get_engine_par($ENGINE_PAR_GAIN2,-1,0,1) 
set_knob_label($K2,get_engine_par_disp($ENGINE_PAR_GAIN2, -1 ,1,1)) 
$K3 := get_engine_par($ENGINE_PAR_GAIN3,-1,0,1) 
set_knob_label($K3,get_engine_par_disp($ENGINE_PAR_GAIN3, -1 ,1,1))
end function

on ui_update

end on
on ui_control($K1) 
set_engine_par($ENGINE_PAR_GAIN1,$K1,-1,1,1) 
set_knob_label($K1,get_engine_par_disp($ENGINE_PAR_GAIN1, -1 ,1,1)) 
end on
on ui_control($K2)
set_engine_par($ENGINE_PAR_GAIN2,$K2,-1,1,-1)
set_knob_label($K2,get_engine_par_disp($ENGINE_PAR_GAIN2,-1,1,1))
end on
on ui_control($K3)
set_engine_par($ENGINE_PAR_GAIN2,$K3,-1,1,-1)
set_knob_label($K3,get_engine_par_disp($ENGINE_PAR_GAIN3,-1,1,1))
end on
on ui_control($IR)
if ($IR = -1)
set_engine_par($ENGINE_PAR_SEND_EFFECT_BYPASS,1,-1,0,0)
else
set_engine_par($ENGINE_PAR_SEND_EFFECT_BYPASS,0,-1,0,0)
load_ir_sample(get_folder($GET_FOLDER_PATCH_DIR) & "Samples/IR Samples/Amsterdam Hall.wav",0,1)
end if
end on


----------



## d.healey (Aug 3, 2014)

I always put impulse samples in the resources >> ir_samples folder. That way you don't have to mess around with paths, Kontakt just finds them.

I noticed some mistakes in your code:
When you are bypassing the reverb you have the 'generic' parameter set to 0, but when you are loading an IR you have it set to 1 - is it an insert or is it a send?

You should give your knobs more descriptive names but I'm assuming K1 is for predelay - if so, why this: set_engine_par($ENGINE_PAR_GAIN1,$K1,-1,1,1) ? That will set the gain of an insert effect, it won't affect the reverb at all. Also you have it set for slot 1 but your bypass and ir_load are set for slot 0. The KSP Reference manual has a list of all the engine parameter constants for each effect, the convolution reverb ones are in the Send Effects section - page 130 of the K4 reference.

Anyway, here's how I would do it.


```
on init

	declare const $CONVO_SLOT := 1 {The FX slot your convolution reverb is in}
	declare ui_menu $mnu_impulses

	add_menu_item($mnu_impulses, "No Reverb", 0)
	add_menu_item($mnu_impulses, "Impulse 1", 1)
	add_menu_item($mnu_impulses, "Impulse 2", 2)
	add_menu_item($mnu_impulses, "Impulse 3", 3)
	add_menu_item($mnu_impulses, "Impulse 4", 4)

	declare ui_knob $knb_predelay(0, 1000000, 1)

end on

on ui_control($mnu_impulses)

	set_engine_par($ENGINE_PAR_SEND_EFFECT_BYPASS, 0, -1, $CONVO_SLOT, 1) {Unbypass the convolution reverb}

	select($mnu_impulses)

		case 0
			set_engine_par($ENGINE_PAR_SEND_EFFECT_BYPASS, 1, -1, $CONVO_SLOT, 1) {Bypass the convolution reverb - I'm assuming its an insert effect here, but if not just change the last parameter}

		case 1
			load_ir_sample("impulse1.wav", $CONVO_SLOT, 1)
		case 2
			load_ir_sample("impulse2.wav", $CONVO_SLOT, 1)
		case 3
			load_ir_sample("impulse3.wav", $CONVO_SLOT, 1)
		case 4
			load_ir_sample("impulse4.wav", $CONVO_SLOT, 1)
	end select

end on

on ui_control($knb_predelay)

	set_engine_par($ENGINE_PAR_IRC_PREDELAY, $knb_predelay, -1, $CONVO_SLOT, 1)

end on
```


----------



## The Darris (Aug 3, 2014)

Thanks Total Exposure.

Now, the main question was answered and fixed so thank you for that. However, I have the Pre Delay set back up with the correct format to control the CONVO Pre Delay but when I increase its value in my GUI to, let's say (300 ms) I am only getting 0.03ms in the Pre Delay down in the Insert FX for the Convolution Reverb.

Finally, do you use a special script writing app because I hate doing this in Kontakt and notepad is crap too. Any recs?


----------



## d.healey (Aug 3, 2014)

The Darris @ Sun Aug 03 said:


> However, I have the Pre Delay set back up with the correct format to control the CONVO Pre Delay but when I increase its value in my GUI to, let's say (300 ms) I am only getting 0.03ms in the Pre Delay down in the Insert FX for the Convolution Reverb.



Your knob must go from 0 - 1000000 you then read the value back to update the knob's display value using the command get_engine_par_disp().

You have two choices for a dedicated script editor, both made by Nil's Liberg.
http://www.nilsliberg.se/ksp/
http://www.vi-control.net/forum/viewtop ... ht=sublime


----------



## The Darris (Aug 3, 2014)

So basically, after reading your advice and checking out the KSP REF, I have come up with this:

declare ui_knob $knb_predelay(0, 1000000, 100)
get_engine_par_disp($ENGINE_PAR_IRC_PREDELAY, $knb_predelay, -1, $CONVO_SLOT, 1)

However, I get a Red error saying highlighting the last line that says { 'end on' expected }. I have an end on command following the get_engine_par_disp line.

You have to forgive me when I say, the KSP Ref is quite difficult for me to understand in most sections (o) . I am kinda following you with some of this but just assume I have no idea what you are talking about..most of the time. :D Nevertheless, I am grateful for your help. I wish VI-Control had a dedicated Skype channel for KSP stuff for scripters to chat help each other on the fly versus forums, it would be more efficient imo.


----------



## d.healey (Aug 3, 2014)

You need the ratio set to 1, why did you set it to 100? 

Also re-read the bit of the manual about get_engine_par_disp and see if you can work out where you went wrong with that command  better you figure it out for yourself than I give you all the answers. - Look at the example below the command reference.



> I wish VI-Control had a dedicated Skype channel for KSP stuff for scripters to chat help each other on the fly versus forums


I'd never get any work done then 

I have tutorials (http://www.xtant-audio.com (www.xtant-audio.com)) - not free but some free ones are on the way. Also there is a really good intro tutorial on Nil's website that you must read if you haven't already!


----------



## The Darris (Aug 3, 2014)

Thanks man!! I will check all those sources out.


----------



## d.healey (Aug 3, 2014)

No problem. If you can't figure it out just post again and I'll give you the answer


----------



## The Darris (Aug 3, 2014)

Okay, just when I don't get a script error something new happens. Again, I am following instructions in the KSP but it is very hard for me to understand the scripts and how they apply to my situation and what I am doing.

This is my current script up to the knob controls. I am getting zero errors but the knob continually displays "0.00ms" and when moved to full up, it only controls the Pre-delay in the convolution fx up to 11.9ms. 

I honestly wish I could understand this better because I don't want to be spoon fed but I am completely lost. I understand a lot of the other aspects of scripting but when it comes to actually scripting GUI controls to the difference control parameters in the effects, I just don't get it. Again, you are helping me out which I am truly grateful for. So thank you.


----------



## kb123 (Aug 3, 2014)

If you are struggling to get parameters to work, why don't you try my GUI generator. It wont do everything for you, but it will give you a good idea of how things work. Its meant as a learning tool.

http://www.musikbits.com/


----------



## d.healey (Aug 3, 2014)

I see no script


----------



## The Darris (Aug 3, 2014)

kb123 @ Sun Aug 03 said:


> If you are struggling to get parameters to work, why don't you try my GUI generator. It wont do everything for you, but it will give you a good idea of how things work. Its meant as a learning tool.
> 
> http://www.musikbits.com/



Thanks, I've been using it but like you said, it is a learning tool which has helped. Unfortunately it doesn't seem to help with the current issue I am having.


----------



## The Darris (Aug 3, 2014)

Whoops :oops: :oops: 

on init 
set_ui_height_px(140) 
make_perfview 
message("") 
declare $count := 0

{Convolution Drop Down Menu List}
declare const $CONVO_SLOT := 1 {The FX slot your convolution reverb is in} 

declare ui_menu $mnu_impulses 

add_menu_item($mnu_impulses, "No Reverb", 0) 
add_menu_item($mnu_impulses, "Amsterdam Hall", 1) 
add_menu_item($mnu_impulses, "Berliner Hall", 2) 
add_menu_item($mnu_impulses, "Concert Hall", 3) 
add_menu_item($mnu_impulses, "Vienna Hall", 4) 
add_menu_item($mnu_impulses, "Large Hall", 5)
add_menu_item($mnu_impulses, "Medium Hall", 6)
add_menu_item($mnu_impulses, "Small Hall", 7)

{GUI CONTROLS/POSITIONS}

{CONVOLUTION MENU/LABEL}

move_control_px($mnu_impulses,326,80)

declare ui_label $lbl_convo(1,1)
set_text($lbl_convo,"Convolution")
move_control_px($lbl_convo,426,35)

{CONVOLUTION}

declare ui_knob $knb_predelay(0, 1000000, 1)
set_knob_unit($knb_predelay,$KNOB_UNIT_MS)
set_knob_defval ($knb_predelay,500000)
make_persistent($knb_predelay)
read_persistent_var($knb_predelay)
set_text($knb_predelay, "Pre Delay")
move_control_px($knb_predelay,426,80)
set_engine_par($ENGINE_PAR_IRC_PREDELAY, $knb_predelay, -1, $CONVO_SLOT, 1)

$knb_predelay := get_engine_par ($ENGINE_PAR_IRC_PREDELAY, -1, $CONVO_SLOT, 1)
set_knob_label ($knb_predelay,_get_engine_par_disp...
($ENGINE_PAR_IRC_PREDELAY,-1, $CONVO_SLOT, 1))
end on


----------



## d.healey (Aug 3, 2014)

Remove this line "$knb_predelay := get_engine_par ($ENGINE_PAR_IRC_PREDELAY, -1, $CONVO_SLOT, 1) "

The knobs value 0 - 1000000 is different to the engine parameter display value. The knobs value determines the display value


----------



## The Darris (Aug 3, 2014)

Okay, so doing that. I still don't have any errors but the knob moves but doesn't display anything other than 0.00ms and In the insert fx convolution, the pre-delay remains untouched.


----------



## d.healey (Aug 3, 2014)

Is your effect definitely in insert slot 1? - it's zero indexed so the first slot is 0.


----------



## The Darris (Aug 3, 2014)

yes. It is in slot 1.


----------



## d.healey (Aug 3, 2014)

Looking are your script more closely, I don't see the on ui_control() callback for the knob


----------



## The Darris (Aug 3, 2014)

TotalComposure @ Sun Aug 03 said:


> Looking are your script more closely, I don't see the on ui_control() callback for the knob



That was it. Thanks. I will post more in this thread if I have issue with other perameters but I think just following your previous guidance, I should be good to go. Thank you very much TotalComposure. o-[][]-o


----------



## d.healey (Aug 3, 2014)

Glad it's working


----------



## The Darris (Aug 3, 2014)

Okay so I have working controls for the settings I want. But, I have noticed some weirdness when updating the script with small changes. The first one is that my "Output" control which controls the wetness, defaults to a crazy number of 39285..etc db and my "Size" control goes to 497142%. I am assuming I need to send a message that converts the values? I have taken a look at the math library and well.. ~o) 

Here is my current working script:

on init 
set_ui_height_px(140) 
make_perfview 
message("") 
declare $count := 0

{Convolution Drop Down Menu List}
declare const $CONVO_SLOT := 1 {The FX slot your convolution reverb is in} 

declare ui_menu $mnu_impulses 

add_menu_item($mnu_impulses, "No Reverb", 0) 
add_menu_item($mnu_impulses, "Amsterdam Hall", 1) 
add_menu_item($mnu_impulses, "Berliner Hall", 2) 
add_menu_item($mnu_impulses, "Concert Hall", 3) 
add_menu_item($mnu_impulses, "Vienna Hall", 4) 
add_menu_item($mnu_impulses, "Large Hall", 5)
add_menu_item($mnu_impulses, "Medium Hall", 6)
add_menu_item($mnu_impulses, "Small Hall", 7)

{GUI CONTROLS/POSITIONS}

{CONVOLUTION MENU/LABEL}

move_control_px($mnu_impulses,426,60)

declare ui_label $lbl_convo(1,1)
set_text($lbl_convo," Convolution")
move_control_px($lbl_convo,426,40)

{CONVOLUTION CONTROLS}

{PRE DELAY}
declare ui_knob $knb_predelay(0, 1000000, 1)
set_knob_unit($knb_predelay,$KNOB_UNIT_MS)
set_knob_defval ($knb_predelay,500000)
make_persistent($knb_predelay)
read_persistent_var($knb_predelay)
set_text($knb_predelay, "Pre Delay")
move_control_px($knb_predelay,426,80)

{CONVOLUTION WET SLIDER}
declare ui_knob $knb_wetness(0, 1000000, 1)
set_knob_unit($knb_wetness,$KNOB_UNIT_DB)
set_knob_defval ($knb_wetness,500000)
make_persistent($knb_wetness)
read_persistent_var($knb_wetness)
set_text($knb_wetness, "Output")
move_control_px($knb_wetness,526,40)

{CONVOLUTION SIZE}
declare ui_knob $knb_size(0, 1000000, 1)
set_knob_unit($knb_size,$KNOB_UNIT_PERCENT)
set_knob_defval ($knb_size,500000)
make_persistent($knb_size)
read_persistent_var($knb_size)
set_text($knb_size, "Size")
move_control_px($knb_size,526,80)

end on {END OF GUI CONTROL POSITIONS}

{ENGINE PARAMETERS}

{Pre Delay}
on ui_control($knb_predelay)
set_engine_par($ENGINE_PAR_IRC_PREDELAY, $knb_predelay, -1, $CONVO_SLOT, 1)
set_knob_label ($knb_predelay,_get_engine_par_disp...
($ENGINE_PAR_IRC_PREDELAY,-1, $CONVO_SLOT, 1))
end on

{Wetness Output Control}
on ui_control($knb_wetness)
set_engine_par($ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN, $knb_wetness, -1, $CONVO_SLOT, 1)
set_knob_label ($knb_wetness,_get_engine_par_disp...
($ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN,-1, $CONVO_SLOT, 1))
end on

{Late Reflections Control "SIZE"}
on ui_control($knb_size)
set_engine_par($ENGINE_PAR_IRC_LENGTH_RATIO_LR, $knb_size, -1, $CONVO_SLOT, 1)
set_knob_label ($knb_size,_get_engine_par_disp...
($ENGINE_PAR_IRC_LENGTH_RATIO_LR,-1, $CONVO_SLOT, 1))
end on

{EQ SETTINGS}

{Drop Down Menu Functions}

on ui_control($mnu_impulses) 

set_engine_par($ENGINE_PAR_SEND_EFFECT_BYPASS, 0, -1, $CONVO_SLOT, 1) {Unbypass the convolution reverb} 

select($mnu_impulses) 

case 0 
set_engine_par($ENGINE_PAR_SEND_EFFECT_BYPASS, 1, -1, $CONVO_SLOT, 1) {Bypass the convolution reverb - I'm assuming its an insert effect here, but if not just change the last parameter} 
case 1 
load_ir_sample("Amsterdam Hall.wav", $CONVO_SLOT, 1) 
case 2 
load_ir_sample("Berliner Hall.wav", $CONVO_SLOT, 1) 
case 3
load_ir_sample("Concert Hall.wav", $CONVO_SLOT, 1) 
case 4
load_ir_sample("Vienna Hall.wav", $CONVO_SLOT, 1)
case 5
load_ir_sample("Large Hall.wav", $CONVO_SLOT, 1)
case 6
load_ir_sample("Medium Hall.wav", $CONVO_SLOT, 1)
case 7
load_ir_sample("Small Hall.wav", $CONVO_SLOT, 1)
end select 

end on


----------



## d.healey (Aug 3, 2014)

By defaults, do you mean when you ctrl+click on it?


----------



## The Darris (Aug 3, 2014)

TotalComposure @ Sun Aug 03 said:


> By defaults, do you mean when you ctrl+click on it?



Okay, so I reloaded a new instrument and convolution effects then applied the script. The values show zero across the board but the convolution effects don't automatically default to the GUI values. I'm assuming I need an additional line of code for each parameter to auto assign my directed defaults?


----------



## d.healey (Aug 3, 2014)

> I'm assuming I need an additional line of code for each parameter to auto assign my directed defaults?



Yes


----------



## The Darris (Aug 3, 2014)

Okay, so since I have the set_knob_defval set, I am assuming I need to use the

set_control_par(get_ui_id($test),$CONTROL_PAR_DEFAULT_VALUE,50) code per the KSP guide. 

At least this is all I found on this so far.

I applied this into my script in this format:

{Late Reflections Control "SIZE"}
on ui_control($knb_size)
set_engine_par($ENGINE_PAR_IRC_LENGTH_RATIO_LR, $knb_size, -1, $CONVO_SLOT, 1)
set_knob_label ($knb_size,_get_engine_par_disp...
($ENGINE_PAR_IRC_LENGTH_RATIO_LR,-1, $CONVO_SLOT, 1))
set_control_par(get_ui_id($knb_size),$CONTROL_PAR_DEFAULT_VALUE,50)
end on

No errors and no results.

My guess is I need something along the lines of 

set_control_par($ENGINE_PAR_IRC_LENGTH_RATIO_LR ............?


----------



## d.healey (Aug 3, 2014)

All you're doing with set_control_par is setting the controls default parameter but you've already done that with set_knob_defval.

The default value is the value the knob will return to when you control click on it. To set the knobs value when the instrument first loads you just use the normal method of setting the knob's value.

my_knob := my_value

so something like $knb_size := 500000


----------



## The Darris (Aug 3, 2014)

TotalComposure @ Sun Aug 03 said:


> All you're doing with set_control_par is setting the controls default parameter but you've already done that with set_knob_defval.
> 
> The default value is the value the knob will return to when you control click on it. To set the knobs value when the instrument first loads you just use the normal method of setting the knob's value.
> 
> ...



Adding that only made my GUI knob show 500000% until I moved it. Once I moved the GUI knob it adjusted to read the proper percent and synced with the LR Size control down in the convolution insert. Since the only thing I had to go of was :=, I wasn't able to find how that command applied to my situation in the KSP, can you be a little more specific?


----------



## d.healey (Aug 4, 2014)

If it's the display value you need then pull it in using get_engine_par_disp again.

$knb_size := get_engine_par_disp()


----------



## mk282 (Aug 4, 2014)

Nope, he needs get_engine_par() for that. _disp() is not going to work in that case, since it returns a string, not an integer.

So, he needs to do:

$knob_size := get_engine_par(...)

and then a:

set_knob_label($knob_size,get_engine_par_disp(...))

in init callback. Preferably BEFORE make_persistent for that knob.


Note: you also need to change _ER at the same time as _LR, since you have separate parameters for those (Size, Lowpass, Highpass).


BTW, you don't need set_knob_defval() at all in the ui_control callback. That kind of thing is done in init callback.


----------



## mk282 (Aug 4, 2014)

Also, using select-case for loading IRs is a bit inefficient in the amount of code it needs to do it. Generally you really only need a single string array, then read out the text from it both when loading the IR and when creating the menu entries necessary. And you don't need to add .wav extension there at all when putting your IRs in the NKR.


----------



## mk282 (Aug 4, 2014)

In short, this is how I would do it:


```
on init
	make_perfview
	set_ui_height_px(140)

	declare const $CONVO_SLOT := 1 {The FX slot your convolution reverb is in}

	declare $count
	declare !IR[7]
	!IR[0] := "Amsterdam Hall"
	!IR[1] := "Berliner Hall"
	!IR[2] := "Concert Hall"
	!IR[3] := "Vienna Hall"
	!IR[4] := "Large Hall"
	!IR[5] := "Medium Hall"
	!IR[6] := "Small Hall"

	declare ui_menu  $mnu_impulses
	declare ui_knob  $knb_predelay (0,1000000,1)
	declare ui_knob  $knb_size (0,1000000,1)
	declare ui_knob  $knb_wetness (0,795000,1)
	declare ui_label $lbl_convo (1,1)

	add_menu_item($mnu_impulses, "No Reverb",-1)
	while ($count < 7)
		add_menu_item($mnu_impulses,!IR[$count],$count)
		inc($i)
	end while

	$knb_predelay := get_engine_par($ENGINE_PAR_IRC_PREDELAY,-1,$CONVO_SLOT,1)
	$knb_size     := get_engine_par($ENGINE_PAR_IRC_LENGTH_RATIO_LR,-1,$CONVO_SLOT,1)
	$knb_wetness  := get_engine_par($ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN,-1,$CONVO_SLOT,1)

	set_knob_label($knb_predelay,get_engine_par_disp($ENGINE_PAR_IRC_PREDELAY,-1, $CONVO_SLOT, 1))
	set_knob_label($knb_size,get_engine_par_disp($ENGINE_PAR_IRC_LENGTH_RATIO_LR,-1, $CONVO_SLOT, 1))
	set_knob_label($knb_wetness,get_engine_par_disp($ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN,-1, $CONVO_SLOT, 1))

	move_control_px($mnu_impulses,426,60)
	move_control_px($knb_predelay,426,80)
	move_control_px($knb_size,526,80)
	move_control_px($knb_wetness,526,40)
	move_control_px($lbl_convo,426,40)
	
	set_text($knb_predelay, "Predelay")
	set_text($knb_size, "Size")
	set_text($knb_wetness, "Output")
	set_text($lbl_convo," Convolution")
	
	set_knob_unit($knb_predelay,$KNOB_UNIT_MS)
	set_knob_unit($knb_size,$KNOB_UNIT_PERCENT)
	set_knob_unit($knb_wetness,$KNOB_UNIT_DB)

	set_knob_defval ($knb_predelay,0)
	set_knob_defval ($knb_size,500000)
	set_knob_defval ($knb_wetness,397000)

	make_persistent($knb_predelay)
	make_persistent($knb_size)
	make_persistent($knb_wetness)

	message("")
end on


on ui_control($mnu_impulses)
	if $mnu_impulses = -1
		set_engine_par($ENGINE_PAR_SEND_EFFECT_BYPASS,1,-1,$CONVO_SLOT,1)
	else
		set_engine_par($ENGINE_PAR_SEND_EFFECT_BYPASS,0,-1,$CONVO_SLOT,1)
		load_ir_sample(!IR[$mnu_impulses],$CONVO_SLOT,1)
	end if
end on

on ui_control($knb_predelay)
	set_engine_par($ENGINE_PAR_IRC_PREDELAY,$knb_predelay,-1,$CONVO_SLOT,1)
	set_knob_label($knb_predelay,get_engine_par_disp($ENGINE_PAR_IRC_PREDELAY,-1,$CONVO_SLOT,1))
end on

on ui_control($knb_size)
	set_engine_par($ENGINE_PAR_IRC_LENGTH_RATIO_ER,$knb_size,-1,$CONVO_SLOT,1)
	set_engine_par($ENGINE_PAR_IRC_LENGTH_RATIO_LR,$knb_size,-1,$CONVO_SLOT,1)
	set_knob_label($knb_size,get_engine_par_disp($ENGINE_PAR_IRC_LENGTH_RATIO_LR,-1,$CONVO_SLOT,1))
end on

on ui_control($knb_wetness)
	set_engine_par($ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN,$knb_wetness,-1,$CONVO_SLOT,1)
	set_knob_label($knb_wetness,get_engine_par_disp($ENGINE_PAR_SEND_EFFECT_OUTPUT_GAIN,-1,$CONVO_SLOT,1))
end on
```

You don't need the full range for the reverb wet control, since that can clip the output way too easily. I have reduced it to +6 dB max, which is usually more than enough.


----------



## d.healey (Aug 4, 2014)

mk282 @ Mon Aug 04 said:


> Nope, he needs get_engine_par() for that. _disp() is not going to work in that case, since it returns a string, not an integer.



Of course! That's what I get for writing things when I've just woke up


----------



## The Darris (Aug 4, 2014)

Thanks mk282. Unfortunately, when I tested that script I got a few script errors that were simple to figure out but I am lost on the Line 27 error.

Line 27 = end while

Error reads: variable "$i" was not declared.

The previous line read....inc ($i)

Any clues as to why this is happening. So far, your format works with what I have found in the KSP.


----------



## Tod (Aug 4, 2014)

The Darris @ Mon Aug 04 said:


> Thanks mk282. Unfortunately, when I tested that script I got a few script errors that were simple to figure out but I am lost on the Line 27 error.
> 
> Line 27 = end while
> 
> ...



It look to me like $i should be $count, replace $i with $count.


----------



## The Darris (Aug 4, 2014)

Tod @ Mon Aug 04 said:


> The Darris @ Mon Aug 04 said:
> 
> 
> > Thanks mk282. Unfortunately, when I tested that script I got a few script errors that were simple to figure out but I am lost on the Line 27 error.
> ...



Sweet. Thank you all for your help. I've learned a lot about the scripting side so this was incredibly educational for me. I will continue to work on more controls with this GUI but that one was by far the hardest to grasp for me. I truly appreciate the help with it.

Cheers o-[][]-o 

Chris


----------



## The Darris (Aug 4, 2014)

Well, upon further testing, I just realized that mk282's script actually doesn't load my IR Samples like the previous version.

Should those samples be located in a different folder?


----------



## The Darris (Aug 6, 2014)

Bump: check previous comment.


----------



## d.healey (Aug 7, 2014)

Look at the code I provided for loading IRs then look at mks there is an important difference... '.wav'


----------



## The Darris (Aug 7, 2014)

Yeah I noticed that and I am not using that in my code. I copied his verbatim. The issue is I don't understand where my IR's need to be. He mentioned a .nkr but I don't understand how that is used in this situation.


----------



## d.healey (Aug 7, 2014)

The Darris @ Thu Aug 07 said:


> Yeah I noticed that and I am not using that in my code. I copied his verbatim.



You need to have '.wav' for it to work. See the example in the manual.



> The issue is I don't understand where my IR's need to be. He mentioned a .nkr but I don't understand how that is used in this situation.


Look up resource containers in the KSP reference manual


----------



## mk282 (Aug 18, 2014)

You do NOT need to have .wav written for it to work IF you are using a resource container. Proven and tested, as I use it like that all the time. You only need to use it when you load IRs the old way, using get_folder() and/or absolute/relative paths...


----------



## d.healey (Aug 18, 2014)

Ah, that's good to know


----------

