Kontakt - Script for set the MIDI CC7 volume range

VST, AU, AAX, CLAP, etc. Plugin Virtual Instruments Discussion
Post Reply New Topic
RELATED
PRODUCTS
Kontakt

Post

Hi everybody

Ok, the volume range of a instrument can be set when a knob is declared:

Code: Select all

declare ui_knob $example(0,631000,1) {0 dB}
or

Code: Select all

declare ui_knob $example(0,500000,1) {-6.0 dB}
but I like to know if there's a way to replace the value with the help of two switches, putting a variable whose value change when one of the switches is trigger, something like:

Code: Select all

declare ui_knob $example(0,[b]$value[/b],1)
and later on ui_control a if ($b = 1) then $value = 631000 or something like that.

I have done a script hat does something similar, but not totally exact, since the knob start to respond when its half way:

Code: Select all

on init
	make_perfview 
	set_ui_height(2)
	declare $volume

	declare ui_switch $a
    set_text($a,"0.0db")
	$a := 0

	declare ui_switch $b
    set_text($b,"-6.0db")
	$b := 0

	declare ui_knob $MasterVol (0,1000000,1)
	set_knob_unit ($MasterVol,$KNOB_UNIT_DB)
    set_text($MasterVol,"Volume")

	message ("")
end on


{ UI_UPDATE }
on ui_update
$volume := $MasterVol
	if (get_engine_par($ENGINE_PAR_VOLUME,-1,-1,-1) # $volume)
		$volume := get_engine_par($ENGINE_PAR_VOLUME,-1,-1,-1)
	end if

	$MasterVol := _get_engine_par($ENGINE_PAR_VOLUME,-1,-1,-1) {el knob coge el volumen del slider}
	set_knob_label($MasterVol,_get_engine_par_disp($ENGINE_PAR_VOLUME,-1,-1,-1))
end on

{ UI_CONTROL }
on ui_control($a)
	if ($a = 1)
		$b := 0
	end if
end on

on ui_control($b)
	if ($b = 1)
		$a := 0
	end if
end on

on ui_control ($MasterVol)
	if ($a = 1)
		$volume := $MasterVol
		_set_engine_par($ENGINE_PAR_VOLUME,$MasterVol - 369000,-1,-1,-1)  {{0 dB}
		set_knob_label($MasterVol,_get_engine_par_disp($ENGINE_PAR_VOLUME,-1,-1,-1))
	end if

	if ($b = 1)
		$volume := $MasterVol
		_set_engine_par($ENGINE_PAR_VOLUME,$MasterVol - 500000,-1,-1,-1)  {-6.0 dB}
		set_knob_label($MasterVol,_get_engine_par_disp($ENGINE_PAR_VOLUME,-1,-1,-1))
	end if

	if ($a = 0 and $b = 0)
		$volume := $MasterVol
		_set_engine_par($ENGINE_PAR_VOLUME,$MasterVol,-1,-1,-1)
		set_knob_label($MasterVol,_get_engine_par_disp($ENGINE_PAR_VOLUME,-1,-1,-1))
	end if

end on
Any help will be appreciated.
Cheers

Post

Nobody?

Post

This is unnecessary since any user can set the CC7 range for themselves in Instrument Options.

Post Reply

Return to “Instruments”