# Release trigger counter based on key position (sample length)



## KrisY (Mar 28, 2018)

I got an instrument that has release samples. The groups have key ranges from C0 or below up to C5. The lengths of the samples are also very different, from *40s* at *C0* to *10s* at *C5*.

When *release trigger counter* is used to control the release sample volume over time (0-25s), the different key ranges that range in sample length can´t really be used over a whole layer. The volume of release samples at C5 is way to high compared to the correct volume at C0. Since this is an entirely time based control, it is not possible to work with on these samples, key instruments.

So, while volume control is possible individually through the *key position* modulator, it´s not possible to use the key position module to _modulate_ the release trigger counter module, not from what I can see. But that would be ideal.

If this is not possible, is there another way to do this? Is there a way to control the release trigger counter´s percent value by key position?

This is surely an issue with every key instrument ever produced including release samples.

I have around 4-5 key-release sample groups in need of modulation and filtering, but the current method I´m contemplating is to divide the key rangers manually in different groups. This is not ideal as it is going to require a ton of different groups (up to about 30-40 groups just for one of several release groups, when divided).

Thanks for any help!


----------



## shapednoise (Mar 28, 2018)

Xlnt question. 
I'm watching with interest!


----------



## KrisY (Mar 28, 2018)

shapednoise said:


> Xlnt question.
> I'm watching with interest!



Welcome to the interest panel, shapednoise!  Here´s another thread from another user who is having / had the same issue. Note length based release trigger counter volume control:

https://vi-control.net/community/threads/release-trigger-counter-and-key-position.54385/

I´ve opted for some _hints_ on his final solution over there too.


----------



## EvilDragon (Mar 29, 2018)

The way to tweak this is by using the modulation shaper in table mode on the release trigger counter modulator. This way you can adjust the amount of volume decrease for each key separately.


----------



## KrisY (Mar 29, 2018)

EvilDragon said:


> The way to tweak this is by using the modulation shaper in table mode on the release trigger counter modulator. This way you can adjust the amount of volume decrease for each key separately.



Okay, I have tried this on the kontakt UI. But the table view is just a switch from the normal "point/dot" view, so to speak. So turning on table-view just gives me another way to tweak the time based modulation that the release trigger counter is supposed to be used for. There is no way to tweak the amount of effect of the release trigger counter modulation via key position, as it just lowers the entire volume and all shapes and forms of modulation of that specific key, when using the key position modulator. 

And by this I mean on the Kontakt sampler UI alone, not through any scripting. Is this solution you mention by scripting? Or by the UI? Could you show me in an image? 

Thanks for helping out!


----------



## EvilDragon (Mar 29, 2018)

Yes but you can use the modulation shaper table mode to adjust the _amount of volume reduction _done by release trigger counter differently for each key. That should help in scaling how much volume is cut for individual keys, for the same amount of time passed since the key was pressed. It should help. Alternatively, you'd script your own release triggering and just build your own tables for changing the volume of RTs.


----------



## KrisY (Mar 29, 2018)

EvilDragon said:


> Yes but you can use the modulation shaper table mode to adjust the _amount of volume reduction _done by release trigger counter differently for each key. That should help in scaling how much volume is cut for individual keys, for the same amount of time passed since the key was pressed. It should help. Alternatively, you'd script your own release triggering and just build your own tables for changing the volume of RTs.



Okay, that seems promising. But I don´t know how to do this. Do I have to add 2 different release trigger counters? Or how does it work?


----------



## EvilDragon (Mar 29, 2018)

No, on each modulator you have a modulation shaper button. Click it. Then activate the modulation shaper, then go to Table mode. Then edit each column within the keyrange to taste.


----------



## KrisY (Mar 29, 2018)

EvilDragon said:


> No, on each modulator you have a modulation shaper button. Click it. Then activate the modulation shaper, then go to Table mode. Then edit each column within the keyrange to taste.



Okay, if I do that I will have to use the key position modulation module, not the release trigger counter. This is the image I got, Kontakt 5.5.1. 






The two release trigger counter modulation modules do the same thing, no matter if they are in table view or not. Is this not what you are thinking of?


----------



## KrisY (Mar 31, 2018)

Thanks for all the help on this, *EvilDragon*. However, the Release Trig. Counter is not able to use any other modification than that of a time-based volume change, set by the time base, in ms, for every group as a whole. The Key Position, on the other hand, does do exactly that which you suggest. But it does not affect any time-base or anything I can use to affect the time of my desired volume change. It just nugges the entire volume of the release sample/s in the group for each key, also as a whole.

So I looked around on the other similar threads. One is by wavesfactory from 2016 and handles the same issue. The user has an issue with the release trigger counter (Release Trig. Counter) being uniform and thus not adhering to his samples being of different length. Here is that thread:

https://vi-control.net/community/threads/release-trigger-counter-and-key-position.54385/

They also have an example script that may or may not do what he intends to have happen. It´s a script (below here) that I do not myself understand fully, other than that it declares 2 separate user defined variables, one “$volume” and the other “$note_id”. These are used with constants or engine variables to calculate the decrease of volume in a linear fashion along/throughout the keyboard numbers. The number of the keys, that is.


```
on init

    declare $volume

    declare $note_id

end on


on release

    ignore_event($EVENT_ID)


    $note_id := play_note($EVENT_NOTE, $EVENT_VELOCITY, 0, -1)


    $volume := %NOTE_DURATION[$EVENT_NOTE]/5000*$EVENT_NOTE


    change_vol($note_id, -$volume, 1)

end on
```


So while I don´t understand the code properly yet, it´s clear what it intends to do. That being said, it´s still not solved as a thread but I´m guessing the author has solved it by now, somehow.

*Another solution* I found in some script is a table of numbers, that uses 128 numbers (one for every key on the keyboard), to define the exact length of each key. This is the code I found:


```
declare %Note_Length_Or_Perhaps_Any_Name_Here[128] := (...

    000,000,000,000,000,000,000,000,000,000,000,000, {C-2 to B-2}...

    350,350,350,350,350,350,350,350,350,350,350,350, {C-1 to B-1}...

    350,350,350,350,350,350,350,350,350,350,350,350, {C0 to B0}...

    346,342,338,334,330,326,322,318,314,310,306,300, {C1 to B1}...

    300,296,292,288,284,280,276,272,268,264,260,250, {C2 to B2}...

    246,242,238,234,230,226,222,218,214,210,206,204, {C3 to B3}...

    200,196,192,188,184,180,176,172,168,164,160,150, {C4 to B4}...

    146,142,138,134,130,126,122,118,114,110,106,104, {C5 to B5}...

    100,096,092,088,084,080,076,072,068,064,060,050, {C6 to B6}...

    050,050,050,050,050,050,050,050,050,050,050,050, {C7 to B7}...

    050,050,050,050,050,050,050,050)             {C8 to G8}
```


The numbers “350” is actually 35 seconds. The keys range from that to about 5 seconds on the 10th octave.

This just probably just says that every key has a specific length, it seems to do no more than that on it´s own. But more interestingly it gives an exact map of each key for any purpose. I could perhaps hook this up to the Release Trigger Counter, but how?

And how does the Release Trigger Counter actually work? Will it take modifications? Can it take change in volume based on this table above?

If not, we can not use this feature to anything of less than uniform length samples.


----------



## EvilDragon (Mar 31, 2018)

KrisY said:


> I could perhaps hook this up to the Release Trigger Counter, but how?



You can't modify how RTC modulator works - it's built into Kontakt and as such unmodifiable.

You would take the table above and do your own release triggering via scripting (not using Kontakt's internal RT feature), along with %NOTE_DURATION and change_vol() you can do pretty much the same thing.


Another way of dealing with this without any scripting (!) is simply having one group per key and then you adjust RTC for each key exactly as it needs to be. Kontakt can handle up to 4096 groups so that shouldn't be a problem.


----------



## KrisY (Apr 14, 2018)

Thanks a lot for your help. I´m skimming through some scripts that use these table-type solutions, but do not yet understand the scripting solutions. 

Your latest idéa was one I did not think would work (splitting key-ranges into groups), as it would use too much resources. I thought that it would be too much for a computer after having split the groups up into 50 units and applied different RTC:s (release trig. counters and key position modulation) on them all separately. Also having to connect them all to one knob for volume and dynamics processing was something I thought would harvest too much cpu-time, but it did not. That is, with my 8-thread i7 machine... Still have not tried this on a virtual machine running dual cores, nor a dual core real machine. But with this in mind I´m moving forward splitting the keyboard up into separate key-ranges. 

So, for anyone reading having this issue, the procedure would be as follows:
(for the next person with the issue...)

1. first mapping the whole piano, string release groups being 8 separate groups, originally just 5 groups, but duplicated in some occations for compensating for the length of keys across the velocity range (key down samples). Aka, some "PP" (pianissimo key-down) sample groups would not have the same corresponding release samples at the same time as the higher key down velocities. So a key being pressed at vel 127 would not get the "PP" release sample until after 20 seconds of a held key, whereas the same key at vel 20 would get this same sample after just 3 seconds. Before that it would use a staccato release sample. 

2. After mapping all groups as they are intended to be, I add the correct modulators and filters to all these 8 groups, the basic groups for all string release samples. Also here, I would add filters for compensating for differences in velocity, perhaps a HPF and LPF to go between higher-lower velocity ranges, for all layers/groups. As this would be the same for all later splits of groups, I will not have to do this again. 

3. Now I will check the file lengths at different key ranges. I´ll decide on a fair range, it does not have to be completely accurate per key, as the key instrument will sound organic past a certain perfection. Within 1-1,5 octaves of instances will most likely be enough. That makes it about 48-55 groups for the entirety of the string release samples. A lot, but not impossible to administer nor change after. 

4. Duplicating the groups into multiple ranges, deleting cells that do not belong etc. 

5. Making a button and a knob on a simple UI to simply be able to boost/reduce volume for all groups at once. To be pimped at a later time during UI creation. 

5.1. Other knobs of the same sort: Knob for "Dynamics amount" - just connecting the amount setting of all the RTC-modulators to one button, ranging from say, 80% to 100%, to make the instrument´s release samples correspond to the key-down groups´s dynamics setting. It´s usual to have a setting for instrument velocity dynamics, that just adjusts the actual volumes between layers. This knob could be attached to the filters as well, if needed. 

All-in-all, a pretty easy and rudimentary way of handling string instrument´s release triggering in a fairly realistic way. Only problem is the time it takes to make changes, having to adjust most layers´s (t(ms)) settings separately (the release trigger counter´s time base), but the table view maps or the line-based volume adjustments would be set in the beginning, way before splitting the original layers. 

Thanks for the help.


----------

