# Categorizing groups into release triggers and normal groups based on their names



## kotori (Sep 30, 2006)

Hi everyone,
I wrote a script that is supposed to figure out which groups are release triggers and which are not based on their names. Eg. group having names starting/ending with 'release' or 'rls' are categorized as release triggers. I post the code here in case it's of use to anybody. Due to the silliness of the find_group function which returns 0 instead of -1 when it doesn't find a group, it's not possible to categorize the first group so it is always treated as a non-release group.

In case you try this on your instruments and find patterns not included here, please post them.

_Edit:_ Note that the script will only work if the name of the release group is the same as a normal group except that it has a string added to the front or end. 
_Edit2:_ I changed the code to be easier to read and extend.

Cheers,
Nils
----------------------------------------------------------------------------------------------------------

*function* find_release_group(group_name) _{ try to find a release group with the given name }_
``*declare* index
``index := find_group(group_name)
``*if* index # 0
````is_release[index] := TRUE
``*end if*
*end function*

*on init*``
``*declare* *const* TRUE := 1
``*declare* i
``*declare* j``
``*declare* is_release[512]```_{ for each group 0 or 1 depending on whether it's a release group }_
``
``_{ prefixes / suffixes for release trigger groups }_
``*declare* *const* NUM_REL_NAMES := 10
``*declare* !rls_names[NUM_REL_NAMES]
``rls_names[0] := 'RT'
``rls_names[1] := 'rt'
``rls_names[2] := 'rls'
``rls_names[3] := 'Rls'
``rls_names[4] := 'RLS'
``rls_names[5] := 'release'
``rls_names[6] := 'Release'``
````````
``find_release_group('Group Release')
``find_release_group('Group release')
``find_release_group('Group rls')
``*for* i := 0 *to* NUM_GROUPS-1````
````*for* j := 0 *to* NUM_REL_NAMES-1
``````_{ try to add suffixes/prefixes to the name of current group separated by 1 or 2 spaces }_
``````find_release_group(group_name(i) & ' '``& rls_names[j])
``````find_release_group(group_name(i) & ' ' & rls_names[j])
``````find_release_group(rls_names[j]``& ' '``& group_name(i))
``````find_release_group(rls_names[j]``& ' ' & group_name(i))
````*end for*````
````find_release_group('Group ' & (i+1) & ' release')
``*end for*``
````
``*for* i := 0 *to* NUM_GROUPS-1````
````_{ If there are multiple groups with the same name, find_group
will only find the first occurance. If find_group of the
current group's name results in an earlier index these two
groups must have the same name and hence the same release status }_
````is_release[ i ] := is_release[ find_group(group_name(i)) ]
``*end for*``
``
``message("") _{ clear any find_group error messages }_````
``
``_{ ---------------------- Display code --------------------------- }_
``*declare* ui_label R(2, 6)``_{ list of release groups }_
``*declare* ui_label NR(2, 6) _{ list of non-release groups }_
``set_text(R, 'release groups:')
``set_text(NR, 'normal groups:')``
``*for* i := 0 *to* NUM_GROUPS-1
````*if* is_release[ i ] = TRUE
``````add_text_line(R, group_name(i))
````*else*
``````add_text_line(NR, group_name(i))
````*end if*
``*end for*
*end on*


----------



## Thonex (Sep 30, 2006)

Wow Nils,

What a great idea!!!

This will make a great module and could be implemented into TKT scripts and many others.

Thanks for sharing.

Cheers,

T


----------



## kotori (Sep 30, 2006)

Thanks Andrew! :smile: 

At first I had a serious problems with multiple groups having the same name. For example, say you have an instrument with four groups: "sus", "sus Release", "sus2", "sus Release". It is not possible to directly compare strings in KSP, so my script operates by concatenating different strings with the name of each group and searching for groups with these names. For example, it will find the group "sus" and search for "sus" + " Release". However, the find_group function will only return the first occurance so at fist I thought that it was impossible to categorize the second "sus Release" group. But then I realized that if find_group(group_name(i)) = j then group _i_ and _j_ must have the same name and can be categorized the same.


----------



## gmet (Sep 30, 2006)

Hi Nils,

In EWQLSO the release samples are named as follows:

sus-vib "on" _- normal sample_
sus-vib "rel" _- release sample_

in other words the "rel" is already in inverted commas, so how would you enter this in the script as I presume you cannot have two sets of inverted commas:

find_release_group(group_name(i) & ' "rel" ') 
find_release_group('"rel" ' & group_name(i))


----------



## steff3 (Sep 30, 2006)

Great script.

I wish we could ask a group those infos (as there is a release button). For release it is usual that developers use this appreviations. 
A few days ago I thought about how to tell forward playing samples from reverse playing samples. The source module of the group know about that info but on can not get it (not even talking about controlling it).

Well, maybe name the groups thus like is the easiest way to do it.

just think out loud, sorry

best


----------



## kotori (Sep 30, 2006)

Justin M @ Sat Sep 30 said:


> Hi Nils,
> 
> In EWQLSO the release samples are named as follows:
> 
> ...



It seems that there indeed is a way to do this (by "commas" I assume you mean quotation marks). As far as I know this is undocumented but it seems it's possible to use backslash as an escape character, so it would be: "sub-vib "on"". 

Unfortunately that name will not be automatically recognized by my script. The script can recognize groups start/ending with a certain string but only if some other group has a name with that part stripped. For example, if there were a "sus-vib" and a "sus-vib rel" the script could add "rel" at the end of the normal group to form the full name. However in your case, "rel" cannot be added at the end of normal group's name to form the name of the release group.

Steffen, yes the introspective capabilities of KSP are rather limited. Renaming the groups could be a way.

Nils


----------



## gmet (Sep 30, 2006)

Thanks for the reply Nils.

Just to add confusion I have also found that in EWQLSO the sample groups are named:

instrument name patch type 'on' _- normal samples_
instrument name patch type 'rel' _- release samples_ 
(quotes are part of the text)

but in the updated Pro XP patches the sample groups are named:

instrument name 'patch type' _- normal samples_
instrument name 'patch type *RT* other text' _- release samples_ 
(quotes are part of the text)

The release samples in EWQLSO do not work well with scripts (VSL release samples seem to be OK though) and I was hoping that an edited version of the above script could be used to turn off all release samples with one click of a button rather than having to edit each patch/group manually. Do you think this could be done?

Justin


----------



## kotori (Sep 30, 2006)

Justin M @ Sat Sep 30 said:


> [...]but in the updated Pro XP patches the sample groups are named:
> 
> instrument name 'patch type' _- normal samples_
> instrument name 'patch type *RT* other text' _- release samples_
> ...



Hi Justin,
Yes I think that could be done. Such a script would have to turn these groups off so if any other scripts then turns all groups on there would be a problem. But only some scripts do this. The second group name pattern is much better, but if this is doable depends on this 'other text'. What is this text? Is it constant or does it change?

Nils


----------



## gmet (Sep 30, 2006)

Hi Nils,

I'll give you an example of the solo trumpet 2 from the EWQLSO Pro XP:

ST2 'Sus nv' _- normal sample_
ST2 'Sus nv p *RT* nc-1' _- release samples_
ST2 'Sus nv p *RT* nc-2'
ST2 'Sus nv m *RT* nc-1'
ST2 'Sus nv m *RT* nc-2'
ST2 'Sus nv f *RT* nc-1'

I understand that there are different release samples for each dynamic but I have no idea what nc-1/2 are for as only the nc-1 samples actually trigger. Altough I have noticed that the release trigger time in Source (in the group editor) gets progresivley less for each RT sample.

This however is not consistent throughout (which is a frustrating aspect of this library!) as this is another example (3 Cellos):

3 VCS 'Sus Vib p'
3 VCS 'Sus Vib p *RT*'
3 VCS 'Sus Vib f'
3 VCS 'Sus Vib f *RT*'

Having thought about this a bit more it would be useful to have a button to turn off the release samples but also a button to turn off the non-release (i.e. normal) samples. I remember a thread on this subject suggesting setting up two identical instruments on the same midi channel - one without release samples to use scripts and another with just release samples that would trigger as normal.

I hope I have described this well enough and, as ever, I really appreciate your help on the subject.

Justin


----------



## kotori (Sep 30, 2006)

Thanks for the clear explanation Justin. Your second example should already be covered by the script given above. Regarding the first example, are nc-1 and nc-2 the only alternatives and what dynamics other than p, m and f are there?

Edit: Oh, I missed the '-character. If these are part of the name it will unfortunately not work.


----------



## gmet (Sep 30, 2006)

Hi Nils - you are right the second example deosn't work (becuase of the ' character)

As I said earlier the naming conventions are not consistent, I have had a look at as many as I can, but without going through every patch I dont know what variables there are. Here are as many as I have found:

*EWQLSO Pro XP:*

instrument name 'patch type' _- normal samples_ 
instrument name 'patch type dynamics RT other text' _- release samples_ 

Other text:

nc-lng (can be present or not)
nc-sht (can be present or not)
nc-med (can be present or not)
nc-1 (can be present or not)
nc-2 (can be present or not)

RT:

rt or RT (always present)

Dynamics:

p,m,f (can be present or not)

*EWQLSO:*

instrument name patch type 'on' _- normal samples _
instrument name patch type 'rel' _- release samples_


----------



## kotori (Sep 30, 2006)

Thanks for posting this info Justin. Unfortunately it seems it is not possible to use it in this script due to the '-characters. 
Coupled with all instrument names and patch types it might still be possible to do something, but then it would be customized specifically for the EWQLSO and not a general purpose solution.


----------



## gmet (Oct 1, 2006)

OK thanks Nils,

I have had a go at this myself based on the TCS script:

*on init*
``_{ Defeat K2's release triggering so we can optionally do it with the script }_
``SET_CONDITION(NO_SYS_SCRIPT_RLS_TRIG)
``
``*declare* ui_label $Rls_Info (3,1)
``move_control($Rls_Info,1,1)
``set_text($Rls_Info," Select the Release Group from this drop-down list -->")

``*declare* ui_label $Mute_Info (1,1)
``move_control($Mute_Info,5,1)
``set_text($Mute_Info," Mute Button -->")```
````
``_{ --------- Instrument Release Group Menu --------- }_``
``*declare* $gmx````_{ Group or Menu Index for Release Drop-Down }_
``*declare* ui_menu $Rls_Grp
``move_control($Rls_Grp,4,1)
````add_menu_item($Rls_Grp,"No Release Grp",-1)
````add_menu_item($Rls_Grp,group_name(0),0)```_{ There is always a group 0 }_
````$gmx := 1
````_{ If there is no group $gmx, group_name will return }_
````_{ the string "" and, if no real }_
````_{ group has that name, find_group will return zero. }_
````_{ At that point, the 'while' condition will fail. }_
````*while* ($gmx = find_group(group_name($gmx)))
``````add_menu_item($Rls_Grp,group_name($gmx),$gmx)
``````inc($gmx)
````*end while*``````
``_{ --------- Instrument Release Mute --------- }_
``*declare* ui_button $Mute_Release
``move_control($Mute_Release,6,1)```
`````
``_{ --------- Save/Restore the following with preset/patch ---------- }_ 
``make_persistent($Mute_Release)
``message("") 
*end on* _{ init }_

*on note*
_{ If there is a release group selected and the mute release button is selected, disable it }_
*if* (($Rls_Grp >= 0) *and* ($Mute_Release = 1))
````disallow_group($Rls_Grp)
*end if*
*end on* _{note}_

*on release*
disallow_group($ALL_GROUPS)
````*if* (($Rls_Grp >= 0) *and* ($Mute_Release = 0))
``````allow_group($Rls_Grp)
````*end if*
````allow_group($ALL_GROUPS)
*end on* _{ release }_


It works a treat but I cant come up with a way of selecting multiple release groups.

BTW I tried your above script with some Opus One samples (snare_drum+RC) and it did not select the group named "Group rls" as a release sample.

Justin


----------



## kotori (Oct 1, 2006)

Justin M @ Sun Oct 01 said:


> [...]It works a treat but I cant come up with a way of selecting multiple release groups.
> 
> BTW I tried your above script with some Opus One samples (snare_drum+RC) and it did not select the group named "Group rls" as a release sample.
> 
> Justin



Hi Justin,
If you want to have multiple release groups you could use an array and let the user select groups which should be added or deleted from a menu and then display the names of the selected ones on a text label. You might find the array functions in the source code for the APS script useful. Btw. there's now a $NUM_GROUPS variable so you don't have to use the "$gmx = find_group(group_name($gmx))" trick unless you want to be backwards compatible with K2.0.

Thanks for pointing that out about "Group rls". I made a mistake when I refactored the script, but this has now been corrected (I changed the code in the first post above).

Cheers,
Nils


----------



## gmet (Oct 1, 2006)

Thanks Nils I'll give this a try.

BTW - when you compile your above script you get a compilation error "index not declared"

Justin


----------



## kotori (Oct 1, 2006)

Justin M @ Sun Oct 01 said:


> BTW - when you compile your above script you get a compilation error "index not declared"



Strange, because I don't. Please send me a PM if the problem persists and you want any help.


----------



## gmet (Oct 6, 2006)

Nils - I have found the answer to the problem with compiling the script:

I was using Shift+Insert to insert the script into the compiler - this causes a compile error. Using Control+V works. I tried this with other uncompiled scripts and got the same result.

Is this obvious or is it worth pointing out to others?

Justin


----------



## gmet (Oct 26, 2006)

Nils,

It took some time but here is the result:

_{Justins script to mute muliple release samples in EWQLSO}_
*on init*
``SET_CONDITION(NO_SYS_SCRIPT_RLS_TRIG)
``
``*declare* ui_label $Rls_Info (3,1)
``move_control($Rls_Info,1,1)
``set_text($Rls_Info,"Set # of Rel Gps.....then select Rel Gps from drop down list(s)")

``*declare* ui_label $Mute_Info (1,1)
``move_control($Mute_Info,5,1)
``set_text($Mute_Info," Mute Button -->")

``*declare* ui_value_edit $num_rel (0,6,1)
``$num_rel := 0
``make_persistent($num_rel)
``set_text($num_rel, "# of Rel Gps")
``move_control($num_rel,4,1)
``````
``*declare* ui_menu $group1
``move_control($group1,0,0)
``make_persistent($group1)
``*declare* ui_menu $group2
``move_control($group2,0,0)
``make_persistent($group2)
``*declare* ui_menu $group3
``move_control($group3,0,0)
``make_persistent($group3)
``*declare* ui_menu $group4
``move_control($group4,0,0)
``make_persistent($group4)
``*declare* ui_menu $group5
``move_control($group5,0,0)
``make_persistent($group5)
``*declare* ui_menu $group6
``move_control($group6,0,0)
``make_persistent($group6)
``*declare* @name
``*declare* $i
``$i := -1
``*while* ($i <= $NUM_GROUPS-1)
````*if* ($i >= 0)
``````@name := group_name($i)
````*else*
``````@name := ""
````*end if*
````add_menu_item($group1, @name, $i)
````add_menu_item($group2, @name, $i)
````add_menu_item($group3, @name, $i)
````add_menu_item($group4, @name, $i)````
````add_menu_item($group5, @name, $i)
````add_menu_item($group6, @name, $i)
````inc($i)
``*end while*
````
``*declare* ui_button $Mute_Release
``move_control($Mute_Release,6,1)```
``make_persistent($Mute_Release)
``message("") 
*end on* _{ init }_

*on ui_control*($num_rel)
````*if* ($num_rel >= 1)
``````move_control($group1, 1, 2)
````*else*
``````move_control($group1, 0, 0)
````*end if*
*if* ($num_rel >= 2)
``````move_control($group2, 2, 2)
````*else*
``````move_control($group2, 0, 0)
````*end if*
*if* ($num_rel >= 3)
``````move_control($group3, 3, 2)
````*else*
``````move_control($group3, 0, 0)
````*end if*
*if* ($num_rel >= 4)
``````move_control($group4, 4, 2)
````*else*
``````move_control($group4, 0, 0)
````*end if*
*if* ($num_rel >= 5)
``````move_control($group5, 5, 2)
````*else*
``````move_control($group5, 0, 0)
````*end if*
*if* ($num_rel >= 6)
``````move_control($group6, 6, 2)
````*else*
``````move_control($group6, 0, 0)
````*end if*
*end on* _{ui_control}_

*on note*
_{ If there is a release group selected and the mute release button is selected, disable it }_
*if* (($group1 >= 0) *and* ($Mute_Release = 1))
````disallow_group($group1)
*end if*
*if* (($group2 >= 0) *and* ($Mute_Release = 1))
````disallow_group($group2)
*end if*
*if* (($group3 >= 0) *and* ($Mute_Release = 1))
````disallow_group($group3)
*end if*
*if* (($group4 >= 0) *and* ($Mute_Release = 1))
````disallow_group($group4)
*end if*
*if* (($group5 >= 0) *and* ($Mute_Release = 1))
````disallow_group($group5)
*end if*
*if* (($group6 >= 0) *and* ($Mute_Release = 1))
````disallow_group($group6)
*end if*
*end on* _{note}_

*on release*
disallow_group($ALL_GROUPS)
````*if* (($group1 >= 0) *and* ($Mute_Release = 0))
``````allow_group($group1)
````*end if*
````*if* (($group2 >= 0) *and* ($Mute_Release = 0))
``````allow_group($group2)
````*end if*
````*if* (($group3 >= 0) *and* ($Mute_Release = 0))
``````allow_group($group3)
````*end if*
````*if* (($group4 >= 0) *and* ($Mute_Release = 0))
``````allow_group($group4)
````*end if*
````*if* (($group5 >= 0) *and* ($Mute_Release = 0))
``````allow_group($group5)
````*end if*
````*if* (($group6 >= 0) *and* ($Mute_Release = 0))
``````allow_group($group6)
````*end if*
````allow_group($ALL_GROUPS)
*end on* _{ release }_


----------



## Thonex (Oct 27, 2006)

Hey Justin,

Thanks for doing all of this.


I know when I get some time I'll really be able to appreciate your contribution here... since I do use EWQLSO quite a bit.

Thanks again.

Cheers,

T


----------



## gmet (Oct 29, 2006)

I am embarassed to report that the script actually deosnt work :oops: although in theory it should :???: 
It seems to trigger the release samples at the note on, and even when allowed the release samples are muted.

HELP!!

Justin



Justin M @ 26th October 2006 said:


> Nils,
> 
> It took some time but here is the result:
> 
> ...


----------



## gmet (Nov 3, 2006)

Nils - I apologise for sabotaging this thread with my problems, however I have found an anomaly with your script:

In the (VSL Opus 1 Oboe) OB_pV_sus+RS the first group is a release group (Group 1 Release) and the script recognises it as a normal group.

Justin


----------

