# Scripted Panning



## The Darris (Aug 6, 2014)

Is there an easy way to script a knob to separately pan a mapped section of the samples? For instance, a percussion patch that contains three different instruments mapped across the keyboard in sections but they are all recorded in stereo so when played together, they are right on top of each other. Is there a way to script the individual sections, easily, to allow a user more control over the sound? 

I have found that you can set a panned position with

on init
declare $pan_position
end on
on note
$pan_position := ($EVENT_NOTE * 2000 / 127) - 1000
change_pan ($EVENT_ID,$pan_position,0)
end on

Which would do a set panned position full left for C2 to G8 as per the KSP reference. What I want to do is control sections independently. Any guidance on how to accomplish that would be great. Thanks.

-Chris


----------



## d.healey (Aug 7, 2014)

If you can, put each of your sections into different groups and control the group pan parameter


----------



## The Darris (Aug 7, 2014)

That makes sense. So looking through the KSP, I found the Event Parameter Constant, "$EVENT_PAR_PAN" is this it? I don't see anything associated with a group pan option. Wouldn't that command though apply the pan to the overall instrument pan function? I guess I am wanting to control the pan feature found in the mapping editor so it can independently map the samples versus the instrument. Does that make sense?

With that said am I understanding the concept correctly here?

in order to get the individual panning control on the gui to affect the samples. I would need to setup an array that gives a name to the individual groups then through the work of any other knob/feature, assign those groups to the knob? Or would it be as simple as using a %GROUPS_SELECTED command when the knob is used that would affect them?


----------



## d.healey (Aug 7, 2014)

The Darris @ Thu Aug 07 said:


> That makes sense. So looking through the KSP, I found the Event Parameter Constant, "$EVENT_PAR_PAN" is this it? I don't see anything associated with a group pan option.



Event parameters control events using event IDs - for instance when you play a note you can control that note event's parameters.

What I'm suggesting is that you control the parameters of a group. This is an engine parameter, like volume or tune. In the group editor you will see there is also a pan control. So you need the parameter for controlling pan - it's ENGINE_PAR_PAN. and you control it using set_engine_par() just like you did for you're reverb. And that command allows you to specify a group to affect.

for example

```
set_engine_par($ENGINE_PAR_PAN, 1000000, 0, -1, -1)
```

If you don't specify a group if will control the whole instruments panning. Also, because this is an engine parameter the values run from 0 (100% left) to 1000000 (100% right). You can pull the display value in for showing to the user in a label in the same way you have for your reverb.




The Darris @ Thu Aug 07 said:


> I would need to setup an array that gives a name to the individual groups then through the work of any other knob/feature, assign those groups to the knob? Or would it be as simple as using a %GROUPS_SELECTED command when the knob is used that would affect them?



Never use group names in your script always use group numbers. I have never found an occasion where a group name was needed. If you use group names there are far more chances for mistakes to be made either in the script or through naming in the group editor.

I have never used %GROUPS_SELECTED, it's an array rather than a command (denoted by %). %GROUPS_SELECTED indicates groups that you have enabled for editing in the group editor. I think you may have been thinking of %GROUPS_AFFECTED. Again not something I have had cause to use. You should try and write you're scripts in such a way that you always know which groups will be affected by a given line of code.


----------

