# Samples all in one group.



## moonunit (Feb 22, 2012)

Hi,
I'm experimenting with Kontakt and groups etc.
Was wondering if it is possible to have just one group and place all the samples I have in one group and then select the particular zone of samples I wanted for playing without it playing all the samples/zones in the group.
Is it possible to do this with some sort of switching system?

For example.If I have C1 to C5 of string sounds and then another zone of C1 to C5 of bass samples is it possible to have them all in one group and then select which one will be played by a switch/dial/slider/table etc so that they both don't play at the same time.

Thanks for any advise.


----------



## Mark Belbin (Feb 22, 2012)

Hey moonunit,

This post from Greg at Orange tree samples covers the basics of that:

http://www.orangetreesamples.com/blog/2 ... of-groups/

So say you do this, where the string samples are mapped to velocity one and brass to velocity two, and you have just one velocity of one articulation for each of the two instruments. Your script could be as simple as:


*on init*

_{each represents one mapped velocity, corresponding to one instrument; zero is omitted since velocity starts at one}_
*declare* ui_menu $current_instrument 
add_menu_item ($current_instrument, "Violin", 1)
add_menu_item ($current_instrument, "Bass", 2)

_{quietest note (input velocity of one) is -70dB. Volume will scale upward toward 0dB, linearly proportional to incoming velocity approaching 127}_

*declare* $volume_range := 70000 _{in millidecibels; given as 70dB}_

_{stores id of virtually triggered notes for further volume adjustment}_
*declare* %virtual_note_id[128]

_{duration of fade-out when a key is released, in microseconds; given as 100 ms}_
*declare* $release_time := 100000 

*end on*

*on note*

_{ignore incoming data}_
ignore_event ($EVENT_ID)

_{Play the note, but trigger the velocity that the desired instrument is mapped to, store its ID in array}_
%virtual_note_id[$EVENT_NOTE] := play_note ...
($EVENT_NOTE, $current_instrument, 0, -1)

_{Scale the note's volume based on incoming note velocity and the pre-defined volume range*}_
change_vol (%virtual_note_id[$EVENT_NOTE], -$volume_range + ...
(($volume_range * $EVENT_VELOCITY) / 127), 0)

*end on*

*on release*

_{stop the playback of the sample triggered when this key was pressed}_
fade_out(%virtual_note_id[$EVENT_NOTE], $release_time, 1)

*end on*

*Be sure to follow Greg's advice about disabling Kontakt's traditional volume/velocity response, or your samples will be all but inaudible, and your custom velocity/volume relationships from the scripts will be reflected with no accuracy at all!

It can all get a lot more complex, as I'm sure you know: round robins, more instruments, actual multi-sampled velocity levels, and other articulations will mean more complex selection of which velocity level of your group gets played...but hoping this helps in the meantime 

Mark

p.s./edit: Many kudos to Greg for sharing something that he could've treated as a trade-secret. It certainly benefitted me when I was working with an instrument that would've otherwise ended up with hundreds, maybe thousands of groups. >8o


----------



## moonunit (Feb 22, 2012)

Thanks for the reply-the script works great.Am I correct in deleteing the kontakt velocity control under the volume layer.
I notice there is a mention of change velo-Does this mean the sample to be played can be selected by changing velocity and then there is no need to use the playnote command?
What I am trying to do is avoid having to have lots and lots of lfo's,adsrs etc which,if I'm right in thinking you have to have for each group.
For example am I right in thinking that in Kontakt you cannot have say 20 groups all under the control of one common ADSR/LFO/Filter etc.
I know you could have ADSR/LFO/filter etc for each group,but is it possible to have just one instance of an ADSR/LFO/Filter etc that controls all the groups?

Don'y know if I'm explaining myself too well.
Thanks


----------



## Mike Greene (Feb 22, 2012)

moonunit @ Wed Feb 22 said:


> Am I correct in deleteing the kontakt velocity control under the volume layer.


Velocity is one of the "Modulation" inserts. Just delete it if it's there (for each group.) It's easy to confirm that it's gone, since soft or hard velocities would both sound at full volume, rather than dynamically.



moonunit @ Wed Feb 22 said:


> I notice there is a mention of change velo-Does this mean the sample to be played can be selected by changing velocity and then there is no need to use the playnote command?


Yep, that's right. Simply use the _change_velo(<ID-number>,<velocity>)_ command.



moonunit @ Wed Feb 22 said:


> I know you could have ADSR/LFO/filter etc for each group,but is it possible to have just one instance of an ADSR/LFO/Filter etc that controls all the groups?


I think you're right that you can't have ADSR envelopes or LFO's on the Instrument level, or controlling several groups at once. (Someone else might know better than I do, though.) Filters are available at the Instrument level, though.



Mark Belbin @ Wed Feb 22 said:


> p.s./edit: Many kudos to Greg for sharing something that he could've treated as a trade-secret. It certainly benefitted me when I was working with an instrument that would've otherwise ended up with hundreds, maybe thousands of groups.


I'll second that! This trick has been invaluable for me. Thanks Greg! o-[][]-o


----------



## moonunit (Feb 22, 2012)

Thanks everyone-I'm experimenting with this and the script-Great stuff


----------



## gregjazz (Feb 22, 2012)

Mark Belbin @ Wed Feb 22 said:


> p.s./edit: Many kudos to Greg for sharing something that he could've treated as a trade-secret. It certainly benefitted me when I was working with an instrument that would've otherwise ended up with hundreds, maybe thousands of groups. >8o


Thanks so much!! I'm glad the trick is proving useful to other people. Btw, it'll also make changing group settings (like group volume/pan, LFO settings, etc.) more efficient from the script, because the script doesn't have to loop through as many groups.


----------



## polypx (Feb 22, 2012)

I also love this trick of Greg's ... but just a small caution:

If you do this, velocity is no longer meaningful for other routings... such as Filter Cutoff or Attack Time, etc. 

At least, I haven't yet found a way to do both... perhaps using some of the freely assignable EVENT_PARs ? 

cheers, Dan


----------



## gregjazz (Feb 22, 2012)

Dan, you can always split up velocity differently. For example, in increments of 30. It won't have the same granularity as the full velocity range, but at least you can use filter cutoff, etc. (you'll have to use a custom input/output curve, of course)

Though, it'd be really nice if NI would implement some way for scripting to access the polyphonic capability of group effects/modulators.


----------



## polypx (Feb 22, 2012)

Well, what would be ideal might be if NI noticed the constant use of round robin by all developers and made that possible WITHIN a zone. That is, instead of a zone pointing to a single sample, it could point to a pool of samples. The zone could have the option of ordered or fisher-yates random choice within the zone. Yay! Groups begone!

The lengths we go to with KSP to solve problems that could more efficiently be dealt with at the source. Legato anyone?

Ah well.


----------



## moonunit (Feb 22, 2012)

I have been experimenting with the script here and have set up 4 layers each with the same string sample and have cycled through each zone in a sort of Round Robin way(I think).Thing is I was still getting that weird phased sound when I pressed the same key despite the fact I could see Kontaky cycling through the layers.
I detuned each layer very slightly and it made it sound better.
Is this what has to happen with Round Robins?Do you have to detune each zone slightly or move sample start points etc.
Thanks


----------



## gregjazz (Feb 22, 2012)

polypx @ Wed Feb 22 said:


> Well, what would be ideal might be if NI noticed the constant use of round robin by all developers and made that possible WITHIN a zone. That is, instead of a zone pointing to a single sample, it could point to a pool of samples. The zone could have the option of ordered or fisher-yates random choice within the zone. Yay! Groups begone!


Not to mention your solution would allow for unequal numbers of round-robin per note/dynamic. That would be soooo nice...


----------

