# Mic positions & individual groups + sample start



## MA-Simon (Dec 3, 2013)

I found a very nice drumkit while walking my village. (On an event called "Sperrmüll" in Germany, I don't know the english word unfortunally. Leo translation is: bulky item, which seems suspiciously odd.). Currently in the sampling phase.

My main problem is: How do I get kontakt to know that I want to asign a controller only to specific groups ( 12-22 ) etc.

There will be about 4-8 Instrument positions which I would like to control individually.

-> 11 rr groups x 8 = 88 groups.

each with:
-Volume control
-Pan control
-Delay control


*Questions:

-> How to asign individual groups to a controller?
-> Delay = sample start. Is it possible to set sample starts to about 30msecs late?
Maybe even make an custom delay input on the ui?*

(I wont even mention purging of single groups because: Sounds rather complicated.)


----------



## kotori (Dec 3, 2013)

MA-Simon @ Tue Dec 03 said:


> -> How to asign individual groups to a controller?


In the Group Editor in Kontakt make sure that the checkbox is checked only for the groups that you want to add a specific CC modulator to. 



> -> Delay = sample start. Is it possible to set sample starts to about 30msecs late?


This can be implemented by either letting the script delay notes by 30 msec or by including 30 msec of silence at the beginning of samples. If you do the latter you can use the S.MOD (sample start modulation range) setting to make it possible to modulate the sample start of samples even in DFD mode.

RR support is very poor in Kontakt, so I would recommend using a script for this. Here's something to get you started. It maintains a separate RR state for each instrument and also has a sample start offset knob (you need to use Sampler mode or set the S.MOD range of samples loaded in DFD mode for this to have any effect):

[pre]*on init*
*declare* *const* $lowest_midi_note := 60 { midi note number of the lowest mapped note }
*declare* *const* $num_RR := 11 { number of round-robins}
*declare* *const* $num_instruments := 8 { number of instruments }

*declare* %instrument_rr[$num_instruments] { current round-robin state for each instrument }
*declare* $inst { instrument of the current note, a value in the range 0-7 }
*declare* $group_index { group index to use for the current note }

*declare* *ui_knob* $soffset(0, 30, 1) { sample start offset }
set_knob_unit($soffset, $KNOB_UNIT_MS)
make_persistent($soffset)
*end on*

*on note*
ignore_event($EVENT_ID)
*if* (in_range($EVENT_NOTE, $lowest_midi_note, $lowest_midi_note+$num_instruments-1))
{ determine the instrument index}
$inst := $EVENT_NOTE-$lowest_midi_note

{ go to the next RR state for this instrument }
%instrument_rr[$inst] := (%instrument_rr[$inst]+1) *mod* $num_RR

{ determine the group index }
$group_index := $num_RR * $inst+%instrument_rr[$inst]

{ activate only that group and play the note with the right sample start offset }
disallow_group($ALL_GROUPS)
allow_group($group_index)
play_note($EVENT_NOTE, $EVENT_VELOCITY, $soffset*1000, -1)
*end* *if*
*end on*

[/pre]

The script assumes, when calculating the group index, that you first have 11 rr groups for the first instrument, then 11 rr groups for the next and so on. You will have to modify the value of the $lowest_midi_note constant to match the midi number of the lowest mapped midi note. Good luck!

/Nils


----------



## MA-Simon (Dec 3, 2013)

Thank you Nils! Very helpfull!

A couple of questions though:


```
[quote]
declare %instrument_rr[$num_instruments]  { current round-robin state for each instrument }
  declare $inst                             { instrument of the current note, a value in the range 0-7 }
  declare $group_index                      { group index to use for the current note }[/quote]
```

Should I rename these variables to instrument01_rr / inst01 / group_index01 for each of the instruments or should I just add the 0-7 numbers somewhere in the script?



> -> How to asign individual groups to a controller?


I actually meant something completely different. Sorry for the poor description. 
I meant how can I assign - lets say- group 11-22 to a specific knob on the ui. Like a microphone position. Not the cc controles. (But please correct me if I need tho add cc for this!)


----------



## kotori (Dec 3, 2013)

MA-Simon @ Tue Dec 03 said:


> Should I rename these variables to instrument01_rr / inst01 / group_index01 for each of the instruments or should I just add the 0-7 numbers somewhere in the script?



You only need to specify values for the constants (the lines that includes "const"), so no. Btw. please note that the script assumes that you map samples chromatically.



> > -> How to asign individual groups to a controller?
> 
> 
> I actually meant something completely different. Sorry for the poor description.
> I meant how can I assign - lets say- group 11-22 to a specific knob on the ui. Like a microphone position. Not the cc controles. (But please correct me if I need tho add cc for this!)



I do not understand what you mean by "assign group 11-22 to a knob". Do you mean that you want to select the instrument used via a knob rather than selecting a certain keyboard key?


----------



## MA-Simon (Dec 3, 2013)

> I do not understand what you mean by "assign group 11-22 to a knob". Do you mean that you want to select the instrument used via a knob rather than selecting a certain keyboard key?



I meant something like individual volume controls on the ui where you have different sample-groups for each instrument:

Instrument A = Group 1-11 (Kontakt sample groups)
Instrument B = Group 12-22

So if I would use the Instument A volume dial on the UI it would then only lower the volume of the samples in group 1-11.

Thanks again for your help!


----------



## mk282 (Dec 3, 2013)

That would be:


```
on init
    declare ui_knob $Vol1 (0,631000,1)

    declare $i

    set_knob_unit($Vol1,$KNOB_UNIT_DB)
    set_knob_defval($Vol1,500000)

    { using actual value from the first group in the RR chain }
    set_knob_label($Vol1,get_engine_par_disp($ENGINE_PAR_VOLUME,0,-1,-1))

    make_persistent($Vol1)

    message("")
end on

on ui_control ($Vol1)
    $i := 0 { first group }
    while ($i < 11) { sweep the loop to the last group }
        set_engine_par($ENGINE_PAR_VOLUME,$Vol1,$i,-1,-1)
        inc($i)
    end while
    set_knob_label($Vol1,get_engine_par_disp($ENGINE_PAR_VOLUME,0,-1,-1))
end on
```


----------



## MA-Simon (Dec 4, 2013)

It workts! o-[][]-o (I am on Kontakt 4 btw. I do have 5, but I selected 4 for this)

Here are 4 test knobs, Vol1, Vol2, Pan1 & Pan2.

Somehow though, Vol2 and Pan2 wont update properly on the ui.
Did I miss something?
Is there a special ksp tag for posting?

Thanks again! 



> on init
> make_perfview
> set_ui_height (3)
> 
> ...


----------



## andreasOL (Dec 4, 2013)

...without having Kontakt before me:

You update $Vol2 and $Pan2 with the value of the first group of groups (0-10) instead of the seconds group of groups (11-21), i.e. replace


```
set_knob_label($Vol2,get_engine_par_disp($ENGINE_PAR_VOLUME,0,-1,-1))
```

with


```
set_knob_label($Vol2,get_engine_par_disp($ENGINE_PAR_VOLUME,11,-1,-1))
```

Same for $Pan2
This is for the ICB and the UI callbacks.

Cheers,
Andreas


----------



## MA-Simon (Dec 4, 2013)

Ah! Thanks!

Always wondered what these numbers are there for. 

Edit: Works!


----------



## mk282 (Dec 4, 2013)

set_engine_par(<parameter>,<value>,<group>,<slot>,<generic>)

<generic> being:

* in case of effect parameters: -1 group FX, 0 send FX, 1 insert FX
* in case of internal modulators (LFO, envelope...): modulator target ID (use find_target(<group>,find_mod(<group>,<modulator name>),<target name>))
* in case of external modulators (velocity, CC, pitch bend, aftertouch...): -1

<slot> is used for modulator ID in case of internal modulators (just use find_mod(<group>,<modulator name>))



It's all mentioned in KSP Reference.


----------



## MA-Simon (Dec 4, 2013)

Thank you!  
Will be saved for further investigation.


----------

