# Help me make a detune knob -1 / +1 semitone



## loolaphonic (Jan 15, 2014)

Hi I'm sampling a couple of instruments and I'd like to create a knob that simply does -1 to +1 detune (with full range of in-between values) I'm struggling to work out how. 

Can anyone help??

Thanks


----------



## d.healey (Jan 15, 2014)

Here you go, this only works for one group but is easily adapted with the addition of a while loop if you want it to apply to more or all groups.


```
on init
	declare ui_knob $knb_tune(486100,513900,1)

	set_control_par(get_ui_id($knb_tune),$CONTROL_PAR_DEFAULT_VALUE,500000)
end on

on ui_control($knb_tune)
	set_engine_par($ENGINE_PAR_TUNE,$knb_tune,0,-1,-1)
end on
```


----------



## mk282 (Jan 15, 2014)

Or perhaps clearer like so:


```
on init
    declare ui_knob $Detune (-100,100,1)
    $Detune := 0
    set_knob_defval($Detune,0)
    make_persistent($Detune)
end on

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


----------



## loolaphonic (Jan 15, 2014)

Thanks! - that's exactly what I wanted...
Can you show me how I can make it effect all groups? Where to add the while loop? Thanks


----------



## d.healey (Jan 15, 2014)

Like so 


```
on init 
    declare ui_knob $knb_tune(486100,513900,1) 
    $knb_tune := 500000
    set_control_par(get_ui_id($knb_tune),$CONTROL_PAR_DEFAULT_VALUE,500000) 

    declare $i

 end on 

 on ui_control($knb_tune) 

	$i := 0

	while ($i < $NUM_GROUPS-1)
	    set_engine_par($ENGINE_PAR_TUNE,$knb_tune,$i,-1,-1) 
	end while
 end on
```


----------



## polypx (Jan 15, 2014)

while ($i < $NUM_GROUPS) 

lose the "-1" for all groups


----------



## d.healey (Jan 15, 2014)

Quite right, I'm used to using for loops and the -1 is automatic for me


----------



## loolaphonic (Jan 16, 2014)

Thanks!
It looks like using it without the all group option is actually better, where possible. Using a relatively powerful 8-core windows machine with RME PCI interface at a latency of 128 I get lots of crackles - with only one instrument.... It must be very demanding on the processor, unless there is another way.

Thanks again


----------



## mk282 (Jan 16, 2014)

Depends on how many groups you have...


----------



## loolaphonic (Jan 16, 2014)

For future reference can i specify which groups it affects?

For example can I do something like affect only groups 1,2,3? In which bit would I need to specify that? e.g.

while ($i < $NUM_GROUPS 1,2,3) 

[I know that is incorrect - but just wondering how to do it]
[...apologies for knowing so little on the syntax here]


----------



## mk282 (Jan 16, 2014)

You use $i < 3 then, not $i < $NUM_GROUPS.


----------



## loolaphonic (Mar 30, 2014)

Hi - thanks for these replies.
I'm still struggling to select just 2 groups.
If I explain: I'd like to select groups 23 and 38. But not any of the other groups.
How would I select just those groups for this detune knob. If I can achieve this then i'm all sorted. Many thanks


----------



## mk282 (Mar 30, 2014)

Don't use any loops, just use two set_engine_par commands pointing to your specific groups.


----------



## loolaphonic (Mar 30, 2014)

Gah I'm trying but to no avail...
Would you mind showing me? (sorry)


----------



## d.healey (Mar 30, 2014)

```
set_engine_par($ENGINE_PAR_TUNE,$knb_tune,23,-1,-1) 
set_engine_par($ENGINE_PAR_TUNE,$knb_tune,38,-1,-1)
```


----------



## loolaphonic (Mar 30, 2014)

Thanks


----------

