# Mute Sample within Group?



## JustinW (Oct 17, 2008)

From the lack of responses I would reckon this is not possible.

I have been pursuing a different path to the same solution, but running into some problems maybe some of you can help me out with.

Basically I have a button that will mute all the samples within my "main" group (which in reality is a 7 different groups).

But I also want the user to be able to select a specific sample within that "main" group which I was hoping could be done through a drop down menu.

Which I was going to accomplish by using the _on ui control_ function (sorry for poor terminology) disallow group ["example" to "example"] as many times as I needed to mute the samples I wish not to be played.

But the issue here is, like I already stated I am also using the "main" group on/off button which I wish to override the drop down sample selector menu.

So my question is, is there a better way to accomplish this? I am sure this is making no sense, but if one could be so generous to PM me I can send you the wip script.

SO to sum it up:

I have 28 groups, each of which are grouped into "main" groups of 7. I want to be able to mute each 4 "main" group individually (which I have accomplished), but I also want a drop down menu to be able to select a specific sample from each of those main groups individually, but not play unless the on/off button is 1, but also not override the on/off button if chosen when it is not engaged.

TIY. and sorry if this is sounding giberrish.


----------



## gmet (Oct 18, 2008)

Justin (nice name BTW!)

I wrote the attached script some time ago to mute multiple release samples. I am sure it could be edited to suit your needs.

Justin


----------



## JustinW (Oct 18, 2008)

Ok I am trying a different approach again, since the two buttons/drop down menu seemed to interfere with each other.

I am trying now to mute specific groups via a ui_menu, but every time I put in this code:



> case 0 {grp1}
> disallow_group(0)
> disallow_group(1)
> disallow_group(3)
> ...


 
which I repeate several times for the different cases each muting a different group.

Kontakt Crashes...

anyone know why this would happen?


tiy :wink:

EDIT: apparently I can not use disallow group in a ui_menu, at least that is what kontakt told when it did not crash.........dang!


----------



## gregjazz (Oct 18, 2008)

JustinW @ Sat Oct 18 said:


> EDIT: apparently I can not use disallow group in a ui_menu, at least that is what kontakt told when it did not crash.........dang!



You could have an array with the off/on values of all the groups. That way you can modify the values of the array in any callback. Then the actual disallow/allow group functions would be called in the on_note callback in a "for...end for" loop.


----------



## JustinW (Oct 18, 2008)

gregjazz @ Sat Oct 18 said:


> JustinW @ Sat Oct 18 said:
> 
> 
> > EDIT: apparently I can not use disallow group in a ui_menu, at least that is what kontakt told when it did not crash.........dang!
> ...


Ahh ok!

Now I have to figure out how to write that code! 

If anyone can point me in the right direction for that I would be much obliged!


----------



## gregjazz (Oct 19, 2008)

JustinW @ Sat Oct 18 said:


> gregjazz @ Sat Oct 18 said:
> 
> 
> > JustinW @ Sat Oct 18 said:
> ...



Sorry, it's really late here, so I will only write fragments of code: (using KScript)

In "on init" you have:

_declare const $total_groups := 100 {or you could have a variable to count the number of groups in the instrument}
declare %group_state[$total_groups]
declare $group
_

Disallowed groups are 0, allowed are 1. So adjust the values in the %group_state array. Keep in mind that there might be a few points where you want to set all the values to 0 (to clear the currently enabled groups) and then a few select ones to 1.

Then in the on_note callback you have:

_disallow_group[$ALL_GROUPS]
for $group := 0 to $total_groups - 1
if (%group_state[$group] = 1)
enable_group[$group]
end if
end for_

So that's the general idea of being able to enable and disable groups from any callback. Sorry, it's really late here, so hopefully this all makes sense.


----------



## JustinW (Oct 19, 2008)

Thank you much Greg!


----------

