Kontakt 4 - Show absolute MIDI values (0-127) of a knob

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

Post

Hi

How can I show the absolute MIDI values of a knob (0-127) instead of percentages (0-100%) in the label below it?

Code: Select all

on init
	declare ui_knob $Volume (0,1000000,1)
	set_knob_defval ($Volume,630859)
	set_knob_unit ($Volume,$KNOB_UNIT_DB)
	$Volume := _get_engine_par ($ENGINE_PAR_VOLUME,-1,-1,-1)
	set_knob_label ($Volume,_get_engine_par_disp($ENGINE_PAR_VOLUME,-1,-1,-1))

	declare ui_label $label (1,1)
	move_control ($label,1,3)

end on

on ui_update
$Volume := _get_engine_par ($ENGINE_PAR_VOLUME,-1,-1,-1)
	set_knob_label($Volume,_get_engine_par_disp($ENGINE_PAR_VOLUME,-1,-1,-1))
	add_text_line($label,"MIDI val: " & $Volume)
end on

on ui_control ($Volume)
	_set_engine_par($ENGINE_PAR_VOLUME,$Volume,-1,-1,-1)
	set_knob_label ($Volume,_get_engine_par_disp($ENGINE_PAR_VOLUME,-1,-1,-1))
	add_text_line($label,"MIDI val: " & $Volume)
end on

Cheers
Last edited by hellishvictor on Fri Jun 02, 2017 9:37 am, edited 2 times in total.

Post

That knob is not showing percentages but dB :)

Either way, simplest would be dividing the $Volume knob value with 7874 to get the range of 0 to 127. Or changing the initial range of ui_knob, then multiplying that value with 7874 when setting the engine parameter.

Post

1000000 / 127 = 7874 :)

It works now, just had to add that after the last two $Volume with a "/":

Code: Select all

	add_text_line($label,"MIDI value: " & $Volume[b]/7874[/b])
Thank you :tu:

Locked

Return to “Instruments”