What's new

Engine_par_tune

raidmarji

New Member
Hi All
I want to use ENGINE_PAR_TUNE to create changes in Octave (-3 to +3) and Semi -11 to 11), the manual is not clear.
Here is the script:
on init
declare ui_label $label (1,1)
set_text ($label,"Select Group:")
declare $count
declare ui_menu $group_menu
while ($count < $NUM_GROUPS)
add_menu_item ($group_menu,group_name($count ),$count)
inc($count)
end while
declare ui_knob $Octave (-3, 3, 1)
declare ui_knob $Semi (-11, 11, 1)
declare ui_knob $Tune (-3600, 3600, 100)


$Tune := _get_engine_par($ENGINE_PAR_TUNE,$group_menu,0,1)*24/10000-1200
move_control ($label,1,1)
move_control ($group_menu,1,2)
move_control ($Octave,2,1)
move_control ($Semi,3,1)
move_control ($Tune,4,1)
make_perfview
end on

on ui_control ($Tune)
_set_engine_par($ENGINE_PAR_TUNE,($Tune + 3600)*100000/720,$group_menu,0,-1)
end on
on ui_control ($group_menu)
$Tune := _get_engine_par($ENGINE_PAR_TUNE,$group_menu,0,1)*24/10000-1200
end on
 

EvilDragon

KSP Wizard
$ENGINE_PAR_TUNE uses values 0-1000000 to represent the full range of the control (-36.00 ... 36.00 semitones). Thankfully it has linear scaling, which means that one cent is (1000000 / 7200) = 138.888... Let's round it to 139. So one semitone would be 13889, and one octave is 166667. So here it makes sense to convert all your individual knob values to cents (one octave = 1200 cents, one semitone = 100 cents), sum that, then limit the range to (-3600, 3600) so that things don't go out of bounds, and multiply that with 139.
 
OP
R

raidmarji

New Member
$ENGINE_PAR_TUNE uses values 0-1000000 to represent the full range of the control (-36.00 ... 36.00 semitones). Thankfully it has linear scaling, which means that one cent is (1000000 / 7200) = 138.888... Let's round it to 139. So one semitone would be 13889, and one octave is 166667. So here it makes sense to convert all your individual knob values to cents (one octave = 1200 cents, one semitone = 100 cents), sum that, then limit the range to (-3600, 3600) so that things don't go out of bounds, and multiply that with 139.
Many Thanks
so I think i have to do something like this?
on ui_control ($Semi)
select ($Semi)
case 0 to case 23
yes?
 

EvilDragon

KSP Wizard
No. You just need to use some math. No select-case at all. Well, you will need to use some if-else to clamp the range to -3600 ... 3600, but that's it.
 
Top Bottom