# Kontakt 5 routing



## Lindon (Feb 18, 2013)

Any one know of a way in KSP to route channels to specific outputs?

--- cant seem to find anything in the manual, where-as I can route groups to channels OR outputs but not channels TO outputs...


LP


----------



## TBAudio (Feb 18, 2013)

It's in the amplifier section of each bus, near the bottom right, same place you set volume and pan. Just go to instrument buses above insert effects and select the bus you want to route.


edit...oops. I just realized you asked if you can do it via ksp. That i'm not sure. sorry


----------



## Lindon (Feb 18, 2013)

...errr I said "in KSP" not in the interface...

will this work:

set_engine_par($ENGINE_PAR_OUTPUT_CHANNEL,4,-1,-1,$NI_BUS_OFFSET + 4)


- to set the fifth bus( $NI_BUS_OFFSET + 4) out the 5th output(number 4)?


----------



## TBAudio (Feb 18, 2013)

...errr yeah, i feel kinda stupid about that. I pulled out the ksp manual and started trying to see if I could get it working via ksp. So far I haven't had the right bit of luck. you would hope it would be the same as changing a group output, but using the bus offset instead of the group number. this didn't seem to work though when I just tried it.


----------



## TBAudio (Feb 18, 2013)

Ok... got it working in kontakt. your line was correct. this seems to basically be it.


```
on init
    declare ui_menu $bus1out
    add_menu_item($bus1out,"1",0)
    add_menu_item($bus1out,"2",1)
    add_menu_item($bus1out,"3",2)
    add_menu_item($bus1out,"4",3)
end on


on ui_control ($bus1out)
    set_engine_par($ENGINE_PAR_OUTPUT_CHANNEL,$bus1out,-1,-1,$NI_BUS_OFFSET + 0) 
end on
```

I should of known this straight out as it's the exact same syntax as changing bus volume or pan. just a different engine parameter. Anyway, good to know


----------



## mk282 (Feb 18, 2013)

If you don't want to write $NI_BUS_OFFSET all the time, you can just use 1024-1030 instead to point to one of 16 busses.


----------



## Signals (Feb 25, 2013)

TBAudio @ Mon Feb 18 said:


> Ok... got it working in kontakt. your line was correct. this seems to basically be it.



I'm current doing the KSP for a drum kit project. 

Any idea how to apply the script only to various groups so they go to various outputs?

For example, group SnareTopMic goes to output bus 1, and group SnareBottomMic goes to bus 2. 

Also if it's round robining between 10 samples (SnareTopMic1, SnareTopMic2, etc), I take it I would be better of programming the round robining in KSP at this point, wouldn't?

I'm guessing all the busses are by default stereo busses? 

Thanks for the help,

Alex


----------



## Lindon (Feb 26, 2013)

Funnily enough its a drum project I'm doing too...

The way we've done this is each RR group is routed to an internal Kontakt 5 bus: e.g. Kick groups -> Bus 0, Snare groups -> Bus 1 etc. etc.

..and we dont manage the RR activities, we leave that to Kontakt...

Then its possible to route the bus output to a defined kontakt output using the code above.


----------



## Signals (Feb 26, 2013)

Ahh, I think get what you're saying! So really there's not much scripting at all involved then?

Just some knobs to control group velocities and panning and that's pretty much it I guess.

I don't mean to be tooooo noobish, but could someone explain to me exactly what 

" set_engine_par($ENGINE_PAR_OUTPUT_CHANNEL,$bus1out,-1,-1,$NI_BUS_OFFSET + 0) 
"

is doing in that bit of code? Particularly "$bus1out,-1,-1,$NI_BUS_OFFSET + 0)" what are the -1 and -1 referring to exactly? I've seen numbers used to locate group fx and that sort of thing, is it directing Kontakt to the location of the bus changing parameters?


----------



## Sasje (Feb 26, 2013)

Signals @ Tue Feb 26 said:


> is doing in that bit of code? Particularly "$bus1out,-1,-1,$NI_BUS_OFFSET + 0)" what are the -1 and -1 referring to exactly? I've seen numbers used to locate group fx and that sort of thing, is it directing Kontakt to the location of the bus changing parameters?




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

-1 means it's not used, or bypasses something. <group ID> is almost never used.


----------



## Lindon (Feb 26, 2013)

Try looking up set_engine_par in the KSP manual for a full description..


----------



## noisyblocks (Dec 9, 2017)

Man I cannot get this to work. I'm trying to route a specific group to a specific BUS but unless I go into the Kontakt editor and CLICK output > BUS 1 button in the group's amp section, it never routes there from the script.

What am I missing? Shouldn't this do it?


```
declare ui_switch $myBusSwitch
blah blah...

on ui_control($myBusSwitch)
    set_engine_par($ENGINE_PAR_OUTPUT_CHANNEL,$myBusSwitch,$myGroupNumber,-1,$NI_BUS_OFFSET+0)
end on
```


----------



## EvilDragon (Dec 9, 2017)

Your code sets the instrument bus 1 output somewhere. You need to put $NI_BUS_OFFSET+x instead $myBusSwitch in order to route a group $myGroupNumber to bus x+1.


----------



## noisyblocks (Dec 9, 2017)

Life saver! Didn't see this particular syntax mentioned anywhere. TG for ED and VI-control


----------



## EvilDragon (Dec 9, 2017)

That particular syntax is mentioned in KSP reference... It's just generalized and you have to do a bit of trial and error to fully figure it out. But it IS well-explained.


----------



## noisyblocks (Dec 9, 2017)

$NI_BUS_OFFSET IS well explained everywhere as a var in the <generic> slot but I've never seen it mentioned as an option in the <value> slot. Would never have known to do this. What page # do you see this listed on?

Trial and error is always an option, but a reference manual is supposed to help the user avoid that


----------



## EvilDragon (Dec 9, 2017)

Page 214, Engine Parameter Variables > Instrument, Source and Amp Module, bottom of page.


----------



## noisyblocks (Dec 9, 2017)

I've seen this page many times and I don't understand how that changes anything. There's nothing here--nor any examples in the code, I'd add--to suggest that $NI_BUS_OFFSET can be used in the <value> slot. *All* the examples in the reference manual show it in the <generic> slot. How would we know?


----------



## noisyblocks (Dec 9, 2017)

...and it's not like routing groups to an output BUS via the script is uncommon! 

Dear NI, I love you, but seriously, how difficult is it to show a few *examples* explaining how things can be used?

I'll even write it for you:

set_engine_par($ENGINE_PAR_OUTPUT_CHANNEL,$NI_BUS_OFFSET+0,<group>,-1,$NI_BUS_OFFSET+0)

Voila!


----------



## EvilDragon (Dec 9, 2017)

The list on page 214 shows values that you need to use. *Values*. Not <generic>.


----------



## Tod (Dec 9, 2017)

Hi Mario, if I may, this brings up a question. Is $NI_BUS_OFFSET an ever changing variable or is it a fixed variable? Would it be possible to assign $NI_BUS_OFFSET values to an array for example?


----------



## EvilDragon (Dec 9, 2017)

It's a constant with value of 1024.


----------



## noisyblocks (Dec 10, 2017)

Exactly, yet nowhere on that page does say "values", only "*Engine Parameter Variables*" <-- which is everything. (I can use $NI_BUS_OFFSET+0 in a <slot>? OK, what does that DO?)

It's no secret that the KSP ref manual can be thin and this is a pretty good example. "Read the manual" they say. I did! And I still don't know the answer! <-- What does that say about the manual?

Anyway, I think for someone with several years working with KSP (EvilDragon!) this stuff must seem quite obvious, but to the rest of us...


----------



## beely (Dec 10, 2017)

I implemented this recently, and it seemed straightforward enough - various numbers let you direct/target the parameter at different things (insert effects vs send effects, groups vs buses etc).

I found it helped to define my own constants, so rather than writing a blind "-1" in a call, I'd be using "APPLIES_TO_INSTRUMENT" which was my own constant with a value of -1. This helps keep the code much more readable and see to what calls are applying.

As ever (with coding in general), the first time you do this, you have to spend a little time working out how to address the various targets you want, but once you've done it a bit, and developed your own constants to use, then it's really straightforward from then on.


----------



## noisyblocks (Dec 10, 2017)

Yeah that's really true; learning how all these different parameters/controls/modulators can be hooked up differently is a massively important part of understanding KSP.

I had to go back and re-re-re-read the section on get_engine_par (p. 155) to understand what ED was getting at: on a get_engine_par call $NI_BUS_OFFSET suddenly becomes a "thing to control" versus just a "thing that outputs". A PARAMETER!

But with no examples showing this particular usage it gets lost in the noise...which is why we're on here asking dumb questions 

Were it not for ED, Kotori, Big Bob, etc making this stuff clear, I submit that there'd be a good 25% less Kontakt instruments on the market...


----------



## EvilDragon (Dec 10, 2017)

noisyblocks said:


> on a get_engine_par call $NI_BUS_OFFSET suddenly becomes a "thing to control" versus just a "thing that outputs".



Errr, no, that's wrong. On a set_engine_par() call using $ENGINE_PAR_OUTPUT engine parameter, $NI_BUS_OFFSET becomes "a thing to control", a value that can be inputted for the group output to be adjusted. get_engine_par() would just get you the current output value (integer number), it wouldn't set anything (obviously).


----------



## Tod (Dec 10, 2017)

EvilDragon said:


> It's a constant with value of 1024.



Okay thanks Mario, I've got a project coming up where it could be handy to index it.


----------



## noisyblocks (Dec 10, 2017)

oops I meant *set_engine_par*...we're no longer just looking at $NI_BUS_OFFSET as a global audio router but as something with a value that can be read/used to control something else. That's really crucial to understanding how to use these in KSP.


----------



## EvilDragon (Dec 10, 2017)

Yep, exactly.


----------

