# Play Note on certain groups only



## jdawg (Jun 26, 2013)

If I am trying an affect with play note, such as a sequencing in one group, and sustaining in another group, how do I ensure the play note is only triggering from group "X"

For instance a hold a chord and group "PAD" plays the chord polyphonically, BUT group "ARP" arpegiates this chord. 

Would I have to dissalow the arp groups on note, then immediately allow them and dissalow the pad groups, then trigger the arp, and do the same for every on note? 

thanking you


----------



## Big Bob (Jun 26, 2013)

> If I am trying an affect with play note, such as a sequencing in one group, and sustaining in another group, how do I ensure the play note is only triggering from group "X"



Sounds a little like you are putting the 'cart before the horse' :lol: 

Groups don't play notes but notes can control group selection. :? 

What do you envision is determining which group you want activated? For example, are you using some other control for that such as a menu, a CC, etc. Whatever control determines which group is to be activated can then also control how notes are processed (such as sustained, arpegiated, etc).

At least for me, your explanation of what you are trying to do is a little vague. :roll: 

Rejoice,

Bob


----------



## jdawg (Jun 26, 2013)

Thanks for you responce, 

for the sake of this idea lets say I have 2 groups

Group PAD (containing pad like synth samples)
&
Group Arp (containing short synth lead samples)

When I play a chord I want Group PAD to act as it normally would, but I would like Group Arp to be arpeggiated. 

At the moment the only way I can achieve this is with 2 instances of kontakt, 1 with the ARP factory script, one without, I was wondering if it was possible to have it all in 1 instrument, but just have a way of the arp only affecting a set group. 


thank you for your time


----------



## Big Bob (Jun 26, 2013)

Could I summarize it this way:

For each note/chord played, you want to create several effects with each effect enabling its own group?

In this context, an effect would be something like sustain the chord, arpeggiate the chord, etc.

If this is more or less what you are shooting for, yes, I think it could be done but, it will be rather tricky so it may depend on how capable you are at scripting. The general principal would be as follows:

When a note callback is triggered, first ignore the note and then start a series of effects involving that note. In your latest example, you would start two effects. Each effect will generate one or more notes related to the original and for each note generated, you will need to allow/disallow the groups assigned to that effect. The polyphonic component makes all this trickier because you have to distinguish a chord from a rapidly played arpeggio, etc. 

If you like I could maybe illustrate the general group enable mechanism by using a simpler monophonic example. Say something like like when you play and hold a single note, Group 0 plays just that note steadily until you release the key. On the other hand, Group 1 could play an arpeggiated series of that same note at a 2 per second rate. Something simpler like this might convey the general idea without being obscured by the polyphony complications.

Anyway, the short answer is Yes I think it can be done. :lol: 

Rejoice,

Bob


----------



## jdawg (Jun 26, 2013)

On theory this is working, I am leaving the slightest delay in the note so the sustained portion is allowed, then almost immedietly it is disallowed and the "arp" in this case just a played note is allowed. It works. I guess




> on init
> declare $ON := 1
> end on
> 
> ...


----------



## Big Bob (Jun 26, 2013)

OK, if that does it, I'm very happy for you :D


----------



## polypx (Jun 26, 2013)

JDawg, you don't need the delay to do that kind of thing, you can do it immediately, like this:

on note
ignore_event($ALL_EVENTS)
disallow_group($ALL_GROUPS)
allow_group(0)
play_note($EVENT_NOTE,$EVENT_VELOCITY,0,-1)

disallow_group($ALL_GROUPS)
allow_group(1)
play_note($EVENT_NOTE + 6,$EVENT_VELOCITY,0,-1)

end on

Edit -- I just put the +6 to make it easier to hear the second group.


----------



## AndreasHe (Jun 13, 2020)

Oh great, I was looking for that. (7 years later  )


----------



## polypx (Jun 13, 2020)

This forum is the best resource if you're learning KSP. Pretty much everything you're going to need is in here somewhere.


----------



## Suganthan (Jun 14, 2020)

Also, can we avoid using play_note()? And use


```
set_event_par_arr($EVENT_ID,$EVENT_PAR_ALLOW_GROUP,0,$ALL_GROUPS)
set_event_par_arr($EVENT_ID,$EVENT_PAR_ALLOW_GROUP,1,$allow_group_id)
```
instead?

In a recent script, I just saved the $EVENT_ID in a poly variable and used it to allow groups in the above like fashion. It worked fine here (also I used NO_SYS_SCRIPT_GROUP_START).

I also realized, this works only with existing event_ids only. If new notes are generated with play_note(), they don't get affected by the previous usage of set_event_par_arr.

In a nutshell,
* allow_groups, dissallow_groups before play_note()
* set_event_par_arr, after play_note()


----------



## EvilDragon (Jun 14, 2020)

You can indeed do exactly that on raw $EVENT_ID, or a variable that holds a valid (active) event ID.


----------

