# Release sample tuning



## tanders (Sep 25, 2009)

Dear all,

When using some tuning script I would like to also tune any release samples. The script Microtuning that comes with Kontakt does not do that.

So, I tried doing it myself, but without success so far. I tried to simply tune the current event ID in the release callback with something like 

change_tune($EVENT_ID,detuning_amount_in_millicent,0)

After much playing around with this approach I realised that seemingly I am changing the pitch at the end of the "main" sample, but not the release sample. So, does the release sample have a different ID? Are there other approaches to detune a release sample? 

Thank you very much! 

Best,
Torsten Anders


----------



## polypx (Sep 25, 2009)

Torsten

What I've done in the past is script the release group as well, rather than using the Release Trigger setting in Kontakt. So all groups are set to normal trigger mode.

Something like this :


```
on note
disallow_group($ALL_GROUPS)  
allow_group($normal_group)
change_tune($EVENT_ID, $Detune, 0)
end on

on release
disallow_group($ALL_GROUPS)  
allow_group($release_group)
change_tune($EVENT_ID, $Detune, 0)
$OFF_ID := play_note($EVENT_NOTE, $EVENT_VELOCITY, 0, 0)
change_tune($OFF_ID, $Detune, 0)
end on
```


In fact, if you just script the Releases yourself, the Kontakt built in Microtune works fine.

cheers
Dan


----------



## gmet (Sep 26, 2009)

Here is a way of finding the release groups:


> *on init*
> SET_CONDITION(NO_SYS_SCRIPT_RLS_TRIG)
> *declare* $normal_group _{normal groups}_
> *declare* $release_group _{release groups}_
> ...



Hope it helps,

Justin


----------



## germancomponist (Sep 26, 2009)

Interesting is to add a very slow chorus to the release samples. especially when they have a room information like EWQLSO.


----------



## polypx (Sep 26, 2009)

Justin! What a great script! 
A script to take release groups and make them behave! I love it.


----------



## tanders (Sep 26, 2009)

Dear Justin,

Thank you very much indeed!! Unfortunately I don't have the time tonight anymore to try it out, but I will come back and report how I got on with it.

Best
Torsten


----------



## tanders (Sep 30, 2009)

Dear Justin,

Finally I had some time to understand and test the script you kindly provided. This script greatly helped me to tune release samples even for instruments where I don't know the name of their groups or group indices. However, your script can be simplified a bit. For example, there is no "manual" triggering of the "main" note needed and hence no $parent_id etc.

For the record I posted a slightly simplified version below. This version should work out of the box, although in this simple for it is of course only a demonstration. Again, thank you very much! 

Best
Torsten

*on init*
``SET_CONDITION(NO_SYS_SCRIPT_RLS_TRIG)
``*declare* $normal_group _{ normal groups }_
``*declare* $release_group _{ release groups }_
``*declare* $OFF_ID _{ release sample ID }_``
``*declare* $new_tuning _{ retune value for note in millicent }_
``*declare* $new_tuning2 _{ test: retune release sample differently }_
``$new_tuning := -50000 _{ note tuned quarter tone down }_
``$new_tuning2 := 50000 _{ for testing, release sample tuned quarter tone up }_
*end on*

*on note*
``_{ activate normal and deactivate release groups }_
``disallow_group($ALL_GROUPS)
``$normal_group := 0
``*while* ($normal_group <= $NUM_GROUPS-1)
````*if* (_get_engine_par($ENGINE_PAR_RELEASE_TRIGGER, $normal_group, -1, -1) = 0)
``````allow_group($normal_group)
````*end if*
````inc($normal_group)
``*end while*
``change_tune($EVENT_ID, $new_tuning, 0)
*end on*

*on release*
``_{ activate release groups and deactivate normal groups }_
``disallow_group($ALL_GROUPS)
``$release_group := 0
``*while* ($release_group <= $NUM_GROUPS-1)
````*if* (_get_engine_par($ENGINE_PAR_RELEASE_TRIGGER, $release_group, -1, -1) # 0)
``````allow_group($release_group)``````
````*end if*
````inc($release_group)
``*end while*
``_{ "manually" trigger release sample with same pitch and velocity as original event }_``````
``$OFF_ID := play_note($EVENT_NOTE, $EVENT_VELOCITY, 0, 0) 
``change_tune($OFF_ID, $new_tuning2, 0)```
*end on*


----------



## tanders (Sep 30, 2009)

BTW: I meanwhile extended the Microtuning script by NI to tune release samples properly using the approach above. In addition, I made this script compatible with other scripts that somehow change the tuning (e.g., portamento or vibrato) by changing the tuning relatively instead of absolutely (seems this works now nicely in Kontakt 3.5, I vaguely recall I could not get this working in earier versions of Kontakt). Finally, my adapted script allows to change the tuning on the fly by CC messages. 

I am happy to share this script. Should things like this go to the thread "Get your custom Kontakt 2 Scripts here"?

Thank you! 

Best,
Torsten Anders


----------

