# Semi-tone tuning



## d.healey (Mar 9, 2014)

Hello,

I have a slider in my script that is linked to the group tuning, going from -12 to +12 semitones. I'm trying to work out how to make it snap to each semi-tone rather than go through each cent. I'm sure there is a formula for this but I've been unable to work it out, does anyone have the solution?

Thanks


----------



## jesusginard (Mar 9, 2014)

Hi David, 

I've tried to do it and I think it's working good 


```
on init
	declare ui_slider $tune(-12,12)
	$tune:=0
end on

on ui_control($tune)
	set_engine_par($ENGINE_PAR_TUNE,500000+($tune*13888),0,-1,-1)
end on
```


----------



## d.healey (Mar 9, 2014)

Thanks man, that's perfect. How did you arrive at 13888?


----------



## mk282 (Mar 10, 2014)

1000000/72, since there are 72 semitones of range for the Tune control.


----------



## jesusginard (Mar 10, 2014)

Well, I did it in half. In 500000 there have to be 36, so 500000/36 = 13888


----------



## mk282 (Mar 10, 2014)

Same thing differently written :D


----------



## d.healey (Mar 10, 2014)

Aha, as simple as that. Thanks again!


----------

