# Newbie Scripting Help



## farjedi (Dec 10, 2018)

Hello, 

I'm new to editing my own scripts and I've got a specific little project that I'm working on. 

I'm wanting to create a drum multi where I have a number of instruments within it, Kick, Snare..etc etc. Kick will be C1 for example. In the Kick instrument there will be around 6 or so different groups containing different types of kicks that all play when I press C1. 

So my script is basically a means to change pitch, volume, and more on the different groups on the UI.

I have to give credit to the guy at decent samples who did a scripting run through of a free instrument of his. I used his script as a starting point and got to learn what was going on referencing the KSP manual. 

So so far I have volume and pitch knobs for each group and I'm pretty confident I get the gist of how it's working.

Now I am stuck. There are two things I still want to do. One I know is possible and the other I'm not so sure. I can't figure how to assign solo and mute buttons to the UI. I have had a look online and searching here but to no avail. 

I've played with adding a switch or a button but that's as far I got. 

The second thing which I'm not sure can be done, but can I scroll through samples from the UI? I did have a look to see if there might be something, file selector seemed the likely candidate but the KSP reference is a bit esoteric for a novice as myself. 

Any help would be greatly appreciated! Many thanks.


----------



## Tod (Dec 10, 2018)

Solo and mute can be done in a few ways. The last time I did it I think I used an Inverter effects where I set the output to -inf dB (turned off), then I just bypassed it for unmuted and unbypassed it for muted.

Solo is a little more convoluted, and I used the same Inverters. You have to keep track of what's soloed and make sure the outputs that are soloed are unbypassed while the rest of the outputs are bypassed.

Regarding your various kicks, you say you've got them in different groups so you're half way there. I use drop down menus for this. Then you simply allow, disallow, groups in the "on note" call back according to the way you've selected them.


----------



## farjedi (Dec 10, 2018)

Hi Tod, thanks for your input. 

I managed to find some help with muting that seems pretty good. It's using a switch to toggle the volume of the group down to zero and then back to the stored volume of whatever it was set to before then. Pretty much what you suggest. Although I'm not entirely sure what Inverter effects are at this stage so may not have fully understood. 

If solo follows this pattern would the UI button have to send a message to all other groups to volume them down to 0? Seems pretty inefficient and fiddly way of going about it but perhaps there is no other way. ( I think this is what you said also) 

Still not sure how to go about being able to change sample from the UI. In order to play the drums all at once as a kit (same midi channel) I need to have each drum type sharing one key. In my groups there are maybe 50 or more kicks of different categories that I like to blend together to make new custom sounds. The ideal is to then be able to flick through samples in which ever group from the UI so I don't have to open Kontakt and do it from the sample scroll buttons. 

Perhaps there is another way of going about it if different drum sounds were on different midi channels and I spread the drums across all keys, and then has a Multi script that restricted channel 1 to only playing C1 (kick instrument) and perhaps being able to transpose the note value up and down via a button or switch to trigger other samples?


----------



## farjedi (Dec 10, 2018)

That last midi idea wouldn't work either on reflection


----------



## Tod (Dec 10, 2018)

farjedi said:


> I managed to find some help with muting that seems pretty good. It's using a switch to toggle the volume of the group down to zero and then back to the stored volume of whatever it was set to before then. Pretty much what you suggest. Although I'm not entirely sure what Inverter effects are at this stage so may not have fully understood.



Hi jarjedi, yeah, using the amplifier volume is basically the same thing, only it can be of more value doing something else. The inverter is just an effect that inverts the phase of the signal, which can also be valuable for inverting the phase of say, a top and bottom mic on the snare. However it's very simple and can be used in Group FX, Insert FX, or probably more importantly Bus FX, so for me was a better choice..

Regarding solo, yeah, like I said, solo can be a bit convoluted. But to get it done you'll have to do something along those lines. However, there are much better Kontakt scripters then I am who might have a better idea.



> Still not sure how to go about being able to change sample from the UI. In order to play the drums all at once as a kit (same midi channel) I need to have each drum type sharing one key. In my groups there are maybe 50 or more kicks of different categories that I like to blend together to make new custom sounds. The ideal is to then be able to flick through samples in which ever group from the UI so I don't have to open Kontakt and do it from the sample scroll buttons.



I mentioned drop down menus, that's a good way of selecting the different kicks. However, if you want to be able to select up to 50 different kicks so that you can mix and match them together, that's going to take a whole other approach. First of all you're going to have to have 50 different volume controller IDs and the means to put any number of them together at any time. I would suggest making one nki just for all the kicks. However, to be honest, if you do manage this, I think you might be disappointed in the outcome, but please don't let that stop you.


----------



## EvgenyEmelyanov (Dec 10, 2018)

Tod said:


> Solo and mute can be done in a few ways



I'd recommend using constant volume modulators for such cases *with some lag*. To avoid pops and clicks.


----------



## farjedi (Dec 11, 2018)

Tod said:


> Hi jarjedi, yeah, using the amplifier volume is basically the same thing, only it can be of more value doing something else. The inverter is just an effect that inverts the phase of the signal, which can also be valuable for inverting the phase of say, a top and bottom mic on the snare. However it's very simple and can be used in Group FX, Insert FX, or probably more importantly Bus FX, so for me was a better choice..
> 
> Regarding solo, yeah, like I said, solo can be a bit convoluted. But to get it done you'll have to do something along those lines. However, there are much better Kontakt scripters then I am who might have a better idea.
> 
> ...



Ah ok, I understand you now. 

Not to beat a dead horse but just to make sure I'm totally clear in my explanation of what I'm doing. I'm sure you've followed me but I just want to triple check as I'm totally new to this and unsure what is possible. 

I have one Instrument containing 6 groups of kick drums(various kick types), each group contains multiple samples. Each group now has a Volume, Tune, and mute button on the UI. Fantastic, and it's shaping into the workflow I'm after. So the only way I can scroll through the samples within each group from the UI is with a drop down menu?

One other idea, can Midi notes be transposed per group within a script. So if I hit C1 on my Keyboard a button on the UI could transpose up 1 semitone on Group 1 but leave all the other groups still on C1. This would mean I would have to some kind of midi filtering thing so only C1 was playable on a particular midi channel and place the samples up and down the keyboard, as opposed to all on C1.??


----------



## Tod (Dec 11, 2018)

farjedi said:


> I have one Instrument containing 6 groups of kick drums(various kick types), each group contains multiple samples.



So does each group contain just 1 kick type and the multiple samples are velocity layers?



> Each group now has a Volume, Tune, and mute button on the UI. Fantastic, and it's shaping into the workflow I'm after. So the only way I can scroll through the samples within each group from the UI is with a drop down menu?



Well, you've already got mute buttons, you could just turn them into radio buttons. There are also other ways to do this, it just depends on exactly what you're trying to do.



> One other idea, can Midi notes be transposed per group within a script. So if I hit C1 on my Keyboard a button on the UI could transpose up 1 semitone on Group 1 but leave all the other groups still on C1. This would mean I would have to some kind of midi filtering thing so only C1 was playable on a particular midi channel and place the samples up and down the keyboard, as opposed to all on C1.??



Yes, and here again, it depends on exactly what you're trying to do. You will need at least 2 conditions to decide which key to play. Or you could setup up an ID array with 6 elements to go along with your mute buttons.

Here are 2 ways you can determine which note plays in the "on note" callback along with examples. This is assuming the EVENT_NOTE is a C1(36) and you want it to play a C#1(37). 


```
change_note(<ID-number>,<note-number>)
    change_note($EVENT_ID,$EVENT_NOTE+1)

    play_note(<note-number>,<velocity>,<sample-offset>,<duration>)
    play_note($EVENT_NOTE+1,$EVENT_VELOCITY,0,-1)
```


----------



## farjedi (Dec 11, 2018)

Tod said:


> So does each group contain just 1 kick type and the multiple samples are velocity layers?
> 
> 
> 
> ...



Ok I'l try and clear it up. 

I am purely using single samples, no velocity layers at all. I make mainly electronic type beats. Currently I have 6 groups. These relate to different folders I have my samples organised in. Electronic Tight, ELectronic Boom, Low Punch, High Punch..etc 

In order to be able to play them as part of a kit with other sounds I just dragged a sample from each Kick folder onto C1 into the corresponding Kick group in a single Kontakt instrument. In order to scroll through samples on the different groups you have to have 'Selected Groups only' switched on, select the group, reselect the sample on C1 and then use the cursors to scroll through the different samples in the folder attached to that group. Quite a lot of clicks. 

This got me thinking about streamlining this and trying some scripting out. 

So as explained before, each group (Electronic tight, Electronic Boom etc) has it's own volume, pitch and mute on the UI. The final piece of this puzzle is to be able to select different kicks within these groups from the UI so I can easily, and with minimum clicks, make custom blends of kicks. 

And if this can be done then I'd like to make a random button or something like that just for fun. 

But I'm getting carried away. 

Hope this makes a little more sense. I think I may be able to upload pictures as I've made 3 posts now. Thanks for your help, you're a gent !


----------



## farjedi (Dec 11, 2018)

Forgot to ask about Radio buttons..!


----------



## Tod (Dec 11, 2018)

Hi farjedi, ha ha, actually I'm more confused now.  

So do you have a script started yet? If not where are you getting your volume control and mute buttons? You've brought "folders" into the equation, are these folders on your hard disk?

So you're dragging your samples in from your folders and selecting each group as you do this so that you basically end up with one kick in each group?



> In order to scroll through samples on the different groups you have to have 'Selected Groups only' switched on, select the group, reselect the sample on C1 and then use the cursors to scroll through the different samples in the folder attached to that group.



So you're able to scroll though the samples in a folder on your hard drive? If so, I'm not familiar with that and didn't realize that could be done with Kontakt, but that doesn't mean much, I'm sure there are many things I'm not aware of with Kontakt. 

So I'm still confused about the multiple samples, do you mean you have multiple samples in your folder that you can scroll through, or are you loading multiple samples in each group at the same time?



farjedi said:


> Forgot to ask about Radio buttons..!



Radio buttons are the buttons in your car radio where you can select different stations, but only one at a time, that's why they're called radio buttons. That's pretty easy to set up, you just have to keep track of the last and currently used button.

I think, and am quite sure, what you want to do can be easily done, ha ha, I'm just confused about exactly what you are doing.


----------



## Levitanus (Dec 11, 2018)

OK, let's decompose your 'features'


Spoiler: Let's make it like a dialog between "orderer" (O) and 'engineer' (E)






farjedi said:


> In order to be able to play them as part of a kit with other sounds I just dragged a sample from each Kick folder onto C1 into the corresponding Kick group in a single Kontakt instrument. In order to scroll through samples on the different groups you have to have 'Selected Groups only' switched on, select the group, reselect the sample on C1 and then use the cursors to scroll through the different samples in the folder attached to that group. Quite a lot of clicks.
> 
> This got me thinking about streamlining this and trying some scripting out.


E: OK, that's pretty easy: ui_menu for group selection and allow_group in on note callback, based on its value. 15 minutes to implement.



farjedi said:


> So as explained before, each group (Electronic tight, Electronic Boom etc) has it's own volume, pitch and mute on the UI.


E: not so easy. some buttons and sliders, aligned with each other, + value edit for group selection + control callbacks to make sliders and buttons work. Maybe some routing routine inside the instrument. 2 hours for the sketch and couple hours for refactoring.


farjedi said:


> make custom blends of kicks.


E: Oh, god, here is something needs to architect. I'd give you a plan in a day.


farjedi said:


> And if this can be done then I'd like to make a random button or something like that just for fun.


E: And one more layer of abstraction for this picture. I'll append to the project scheme.


farjedi said:


> Forgot to ask about Radio buttons..!


E: Emm... Are You sure what you want? 



And, if talk serious. The task is quite complicated to make a quick suggestion, and it has to be formed as "user-story" at first than decomposed to "engineer tasks".
At my quick look, first of all, organization of instrument has to be changed:
Still, this is drum library, we can get off any volume modulators from the group, and use only event volume.
So that's way hands will be unbounded to pack many samples per one note.
Still, this is not commercial product, You can be not bothered about sample named, and have one value_edit for setting the EVENT_VELOCITY per instrument as a switch. And place every kick sample to the personal velocity (first between 1 and 2, second between 2 and 3).
If you want to blend them, you can add a couple of value edits with range 0-127. If both are above zero – play two notes with different velocities and half volume of each event.

If you want to select one group per kit, use one ui_menu with groups attached and allow this group at on note, if a group is selected per instrument, so You have to place one menu for instrument and detect the key (instrument) in on note callback to select which group has to be allowed.
If You want to blend any sample from any group per instrument, so You need to place menu, aligned to every value edit of sample selection on an instrument and select allowed group, based on instrument, layer (first v_e or second v_e) and select velocity, based on current layer v_e. Not so scary, but needs to keep clean head and code.

The same with mixer

This looks like a quite complicated task, even if I would do it "for myself" without architecture "lookahead air" and pretty interface. And, I would reduce the complexity of Your idea. For example, use different nki for different instruments, or, maybe for different "kits" too, as was suggested. It saves time and reduces code.


----------



## EvilDragon (Dec 11, 2018)

I have an old script lying around that could be at the very least partially helpful here (yes, I would do certain things more efficiently these days, but ehhhh). It's basically made to support 8 groups, and up to 128 samples mapped within that group. So you map your oneshots chromatically, select which one you want to play, adjust its volume, pan, tuning, and choose an output for that group. Also, you can choose which MIDI note is going to play it. You can set multiple groups to the same MIDI note in order to layer stuff. Pretty neat.




It's just missing mute/solo, but that's not really hard to implement either.


----------



## farjedi (Dec 12, 2018)

Tod said:


> Hi farjedi, ha ha, actually I'm more confused now.
> 
> So do you have a script started yet? If not where are you getting your volume control and mute buttons? You've brought "folders" into the equation, are these folders on your hard disk?
> 
> ...



Ha ha, these things are as difficult to explain as they are to understand!. So I think I will upload some screenshots which I couldn't do because of the new user rule. I'll also post my script, in case anyone wants to try it or give pointers. I've stumbled on videos which is how I've compiled the code and then sought to understand what it's doing through referencing the KSP manual. 

I'll try and do this later on. Cheers Tod!


----------



## farjedi (Dec 12, 2018)

Levitanus said:


> OK, let's decompose your 'features'
> 
> 
> Spoiler: Let's make it like a dialog between "orderer" (O) and 'engineer' (E)
> ...



Thanks Levitanus. I think again that I'll be able to explain my self more clearly with visuals. It's probably not as complicated as I've made it sound. And I already have 3/4 of what I want to achieve or at least the minimum starting point for more features should I think of them. 

I think I understand your suggestion of placing samples on individual velocities and using velocity to select each one? But I'd still be able to have velocity control for each sample through the script? 

Interesting idea. Lots to consider.


----------



## farjedi (Dec 12, 2018)

EvilDragon said:


> I have an old script lying around that could be at the very least partially helpful here (yes, I would do certain things more efficiently these days, but ehhhh). It's basically made to support 8 groups, and up to 128 samples mapped within that group. So you map your oneshots chromatically, select which one you want to play, adjust its volume, pan, tuning, and choose an output for that group. Also, you can choose which MIDI note is going to play it. You can set multiple groups to the same MIDI note in order to layer stuff. Pretty neat.
> 
> 
> 
> ...




Thanks for that Evil Dragon. A lot to take in. I thought, as I scrolled through your script, ah I might be able to understand this, until I got to 'declare %CONTROL_PAR[$NUM_CONTROLS*13] :=' and realised the world I'm dipping my toe in is not for the faint of heart! 

But lots to study there, I'll definitely paste your script and try and learn from it and see where it takes me.


----------



## farjedi (Dec 12, 2018)

Here's what I got so far. I will add three more groups to this as I go along. At some point I'd like to reduce the size of the mute button so I can get a solo button next to it.






Here you can see that the titles of the volume knobs are abbreviations of the groups. As I've said each group contains a number of singe samples . Tod, if you navigate using the Kontakt file browser and drag a sample from a folder onto a key you can scroll through the contents of that folder and change sounds. You do this below where the highlighted 'selected groups only' is, it says 'Sample:(the name of sample)' and there are a couple of arrows for navigating between sounds to the right.

It's fiddly as I have to select the group I wish to change a sound on, then reselect the note on C1 in the mapping editor and then scroll through with the arrows I just mentioned.

I now have to decide on a solid way of changing samples within the groups out of the different ways it can be potentially done. My preference is to have a couple of small buttons beneath mute that will navigate back and forwards through the samples on the UI. Whether I use a midi method or velocity method, or other ideas that may arise, I'm not sure yet!! 

Tod, I hope this makes things a bit clearer!


----------



## Tod (Dec 12, 2018)

farjedi said:


> I thought, as I scrolled through your script, ah I might be able to understand this, until I got to 'declare %CONTROL_PAR[$NUM_CONTROLS*13] :=' and realised the world I'm dipping my toe in is not for the faint of heart!



Ha ha, when I read that in your post I thought, *What!!!!! *It threw me to because It looks very similar to internal variables, but it's not, they are just Mario's own variable names. Heh heh, I even checked the KSP manual. %CONTROL_PAR is an array variable and $NUM_CONTROLS is just a single variable.  

Go ahead and post some screenshots farjedi, I'd like to fully understand what you're trying to do.

I think I'll copy and paste Mario's script too, to check it out.* 
*
EDIT: Ha ha I see you posted already.


----------



## farjedi (Dec 12, 2018)

on init
make_perfview
set_ui_height(4)
set_ui_color(914526842h)

declare ui_knob $samp1Knob (0,1000000,1)
$samp1Knob:= 500000
move_control($samp1Knob,1,1)
set_text($samp1Knob, "El Tight")
make_persistent($samp1Knob)
read_persistent_var ($samp1Knob)
set_engine_par($ENGINE_PAR_VOLUME, $samp1Knob, 0, -1, -1)
set_knob_label($samp1Knob, get_engine_par_disp($ENGINE_PAR_VOLUME, 0, -1,-1))


declare ui_knob $samp1pitchKnob (0,1000000,1)
$samp1pitchKnob:= 500000
move_control($samp1pitchKnob,1,3)
set_text($samp1pitchKnob, "Pitch")
make_persistent($samp1pitchKnob)
read_persistent_var ($samp1pitchKnob)
set_engine_par($ENGINE_PAR_TUNE, $samp1pitchKnob, 0, -1, -1)
set_knob_label($samp1pitchKnob, get_engine_par_disp($ENGINE_PAR_TUNE, 0, -1,-1))

declare $volume1
declare ui_switch $samp1mute
move_control($samp1mute,1,5)
set_text ($samp1mute, "Mute")

declare ui_knob $samp2Knob (0,1000000,1)
$samp2Knob:= 500000
move_control($samp2Knob,2,1)
set_text($samp2Knob, "El Boom")
make_persistent($samp2Knob)
read_persistent_var ($samp2Knob)
set_engine_par($ENGINE_PAR_VOLUME, $samp2Knob, 1, -1, -1)
set_knob_label($samp2Knob, get_engine_par_disp($ENGINE_PAR_VOLUME, 1, -1,-1))


declare ui_knob $samp2pitchKnob (0,1000000,1)
$samp2pitchKnob:= 500000
move_control($samp2pitchKnob,2,3)
set_text($samp2pitchKnob, "Pitch")
make_persistent($samp2pitchKnob)
read_persistent_var ($samp2pitchKnob)
set_engine_par($ENGINE_PAR_TUNE, $samp2pitchKnob, 1, -1, -1)
set_knob_label($samp2pitchKnob, get_engine_par_disp($ENGINE_PAR_TUNE, 1, -1,-1))

declare $volume2
declare ui_switch $samp2mute
move_control($samp2mute,2,5)
set_text ($samp2mute, "Mute")

declare ui_knob $samp3Knob (0,1000000,1)
$samp3Knob:= 500000
move_control($samp3Knob,3,1)
set_text($samp3Knob, "El EX")
make_persistent($samp3Knob)
read_persistent_var ($samp3Knob)
set_engine_par($ENGINE_PAR_VOLUME, $samp3Knob, 2, -1, -1)
set_knob_label($samp3Knob, get_engine_par_disp($ENGINE_PAR_VOLUME, 2, -1,-1))


declare ui_knob $samp3pitchKnob (0,1000000,1)
$samp3pitchKnob:= 500000
move_control($samp3pitchKnob,3,3)
set_text($samp3pitchKnob, "Pitch")
make_persistent($samp3pitchKnob)
read_persistent_var ($samp3pitchKnob)
set_engine_par($ENGINE_PAR_TUNE, $samp3pitchKnob, 2, -1, -1)
set_knob_label($samp3pitchKnob, get_engine_par_disp($ENGINE_PAR_TUNE, 2, -1,-1))

declare $volume3
declare ui_switch $samp3mute
move_control($samp3mute,3,5)
set_text ($samp3mute, "Mute")
end on

on ui_control($samp1Knob)
set_engine_par($ENGINE_PAR_VOLUME, $samp1Knob, 0, -1, -1)
set_knob_label($samp1Knob, get_engine_par_disp($ENGINE_PAR_VOLUME, 0, -1,-1))
end on

on ui_control($samp1pitchKnob)
set_engine_par($ENGINE_PAR_TUNE, $samp1pitchKnob, 0, -1, -1)
set_knob_label($samp1pitchKnob, get_engine_par_disp($ENGINE_PAR_TUNE, 0, -1,-1))
end on

on ui_control($samp1mute)

if ($samp1mute = 1)
$volume1 := get_engine_par($ENGINE_PAR_VOLUME, 0, -1,-1)
set_engine_par($ENGINE_PAR_VOLUME, 0, 0, -1, -1)

else
set_engine_par($ENGINE_PAR_VOLUME, $volume1, 0, -1, -1)
end if

end on

on ui_control($samp2Knob)
set_engine_par($ENGINE_PAR_VOLUME, $samp2Knob, 1, -1, -1)
set_knob_label($samp2Knob, get_engine_par_disp($ENGINE_PAR_VOLUME, 1, -1,-1))
end on

on ui_control($samp2pitchKnob)
set_engine_par($ENGINE_PAR_TUNE, $samp2pitchKnob, 1, -1, -1)
set_knob_label($samp2pitchKnob, get_engine_par_disp($ENGINE_PAR_TUNE, 1, -1,-1))
end on

on ui_control($samp2mute)

if ($samp2mute = 1)
$volume2 := get_engine_par($ENGINE_PAR_VOLUME, 1, -1,-1)
set_engine_par($ENGINE_PAR_VOLUME, 0, 1, -1, -1)

else
set_engine_par($ENGINE_PAR_VOLUME, $volume2, 1, -1, -1)
end if

end on

on ui_control($samp3Knob)
set_engine_par($ENGINE_PAR_VOLUME, $samp3Knob, 2, -1, -1)
set_knob_label($samp3Knob, get_engine_par_disp($ENGINE_PAR_VOLUME, 2, -1,-1))
end on

on ui_control($samp3pitchKnob)
set_engine_par($ENGINE_PAR_TUNE, $samp3pitchKnob, 2, -1, -1)
set_knob_label($samp3pitchKnob, get_engine_par_disp($ENGINE_PAR_TUNE, 2, -1,-1))
end on

on ui_control($samp3mute)

if ($samp3mute = 1)
$volume3 := get_engine_par($ENGINE_PAR_VOLUME, 2, -1,-1)
set_engine_par($ENGINE_PAR_VOLUME, 0, 2, -1, -1)

else
set_engine_par($ENGINE_PAR_VOLUME, $volume3, 2, -1, -1)
end if

end on


----------



## Tod (Dec 12, 2018)

farjedi said:


> Tod, I hope this makes things a bit clearer!



Yes farjedi and thanks. I got it, but I didn't know about that and it makes sense now. 

I don't think you can select zones in the mapping editor with a script, although Mario will correct me if I'm wrong. I think you'll have to put all those individual samples in separate groups. I take it that kick has a single sample, is that right.

How many kicks do you have all together?


----------



## Tod (Dec 12, 2018)

Hey farjedi, it's best to put scripting in in CODE, then it retains it's format somewhat.

Like this:


```
on init

  make_perfview
  set_ui_height(4)
  set_ui_color(914526842h)
    
  declare ui_knob $samp1Knob (0,1000000,1)
    $samp1Knob:= 500000
    move_control($samp1Knob,1,1)
    set_text($samp1Knob, "El Tight")
    make_persistent($samp1Knob)
    read_persistent_var ($samp1Knob)
    set_engine_par($ENGINE_PAR_VOLUME, $samp1Knob, 0, -1, -1)
    set_knob_label($samp1Knob, get_engine_par_disp($ENGINE_PAR_VOLUME, 0, -1,-1))
 
  declare ui_knob $samp1pitchKnob (0,1000000,1)
    $samp1pitchKnob:= 500000
    move_control($samp1pitchKnob,1,3)
    set_text($samp1pitchKnob, "Pitch")
    make_persistent($samp1pitchKnob)
    read_persistent_var ($samp1pitchKnob)
    set_engine_par($ENGINE_PAR_TUNE, $samp1pitchKnob, 0, -1, -1)
    set_knob_label($samp1pitchKnob, get_engine_par_disp($ENGINE_PAR_TUNE, 0, -1,-1))
 
  declare $volume1
  declare ui_switch $samp1mute
    move_control($samp1mute,1,5)
    set_text ($samp1mute, "Mute")
 
  declare ui_knob $samp2Knob (0,1000000,1)
    $samp2Knob:= 500000
    move_control($samp2Knob,2,1)
    set_text($samp2Knob, "El Boom")
    make_persistent($samp2Knob)
    read_persistent_var ($samp2Knob)
    set_engine_par($ENGINE_PAR_VOLUME, $samp2Knob, 1, -1, -1)
    set_knob_label($samp2Knob, get_engine_par_disp($ENGINE_PAR_VOLUME, 1, -1,-1))
 
  declare ui_knob $samp2pitchKnob (0,1000000,1)
    $samp2pitchKnob:= 500000
    move_control($samp2pitchKnob,2,3)
    set_text($samp2pitchKnob, "Pitch")
    make_persistent($samp2pitchKnob)
    read_persistent_var ($samp2pitchKnob)
    set_engine_par($ENGINE_PAR_TUNE, $samp2pitchKnob, 1, -1, -1)
    set_knob_label($samp2pitchKnob, get_engine_par_disp($ENGINE_PAR_TUNE, 1, -1,-1))
 
  declare $volume2
  declare ui_switch $samp2mute
    move_control($samp2mute,2,5)
    set_text ($samp2mute, "Mute")
 
  declare ui_knob $samp3Knob (0,1000000,1)
    $samp3Knob:= 500000
    move_control($samp3Knob,3,1)
    set_text($samp3Knob, "El EX")
    make_persistent($samp3Knob)
    read_persistent_var ($samp3Knob)
    set_engine_par($ENGINE_PAR_VOLUME, $samp3Knob, 2, -1, -1)
    set_knob_label($samp3Knob, get_engine_par_disp($ENGINE_PAR_VOLUME, 2, -1,-1))
 
  declare ui_knob $samp3pitchKnob (0,1000000,1)
    $samp3pitchKnob:= 500000
    move_control($samp3pitchKnob,3,3)
    set_text($samp3pitchKnob, "Pitch")
    make_persistent($samp3pitchKnob)
    read_persistent_var ($samp3pitchKnob)
    set_engine_par($ENGINE_PAR_TUNE, $samp3pitchKnob, 2, -1, -1)
    set_knob_label($samp3pitchKnob, get_engine_par_disp($ENGINE_PAR_TUNE, 2, -1,-1))
 
  declare $volume3
  declare ui_switch $samp3mute
    move_control($samp3mute,3,5)
    set_text ($samp3mute, "Mute")
end on

on ui_control($samp1Knob)
  set_engine_par($ENGINE_PAR_VOLUME, $samp1Knob, 0, -1, -1)
  set_knob_label($samp1Knob, get_engine_par_disp($ENGINE_PAR_VOLUME, 0, -1,-1))
end on

on ui_control($samp1pitchKnob)
  set_engine_par($ENGINE_PAR_TUNE, $samp1pitchKnob, 0, -1, -1)
  set_knob_label($samp1pitchKnob, get_engine_par_disp($ENGINE_PAR_TUNE, 0, -1,-1))
end on

on ui_control($samp1mute)
  if ($samp1mute = 1)
    $volume1 := get_engine_par($ENGINE_PAR_VOLUME, 0, -1,-1)
    set_engine_par($ENGINE_PAR_VOLUME, 0, 0, -1, -1)
    
  else
    set_engine_par($ENGINE_PAR_VOLUME, $volume1, 0, -1, -1)
  end if
 
end on

on ui_control($samp2Knob)
  set_engine_par($ENGINE_PAR_VOLUME, $samp2Knob, 1, -1, -1)
  set_knob_label($samp2Knob, get_engine_par_disp($ENGINE_PAR_VOLUME, 1, -1,-1))
end on

on ui_control($samp2pitchKnob)
  set_engine_par($ENGINE_PAR_TUNE, $samp2pitchKnob, 1, -1, -1)
  set_knob_label($samp2pitchKnob, get_engine_par_disp($ENGINE_PAR_TUNE, 1, -1,-1))
end on

on ui_control($samp2mute)
  if ($samp2mute = 1)
    $volume2 := get_engine_par($ENGINE_PAR_VOLUME, 1, -1,-1)
    set_engine_par($ENGINE_PAR_VOLUME, 0, 1, -1, -1)
    
  else
    set_engine_par($ENGINE_PAR_VOLUME, $volume2, 1, -1, -1)
  end if
 
end on

on ui_control($samp3Knob)
  set_engine_par($ENGINE_PAR_VOLUME, $samp3Knob, 2, -1, -1)
  set_knob_label($samp3Knob, get_engine_par_disp($ENGINE_PAR_VOLUME, 2, -1,-1))
end on

on ui_control($samp3pitchKnob)
  set_engine_par($ENGINE_PAR_TUNE, $samp3pitchKnob, 2, -1, -1)
  set_knob_label($samp3pitchKnob, get_engine_par_disp($ENGINE_PAR_TUNE, 2, -1,-1))
end on

on ui_control($samp3mute)
  if ($samp3mute = 1)
    $volume3 := get_engine_par($ENGINE_PAR_VOLUME, 2, -1,-1)
    set_engine_par($ENGINE_PAR_VOLUME, 0, 2, -1, -1)
    
  else
    set_engine_par($ENGINE_PAR_VOLUME, $volume3, 2, -1, -1)
  end if
end on
```


----------



## farjedi (Dec 12, 2018)

Hi Tod, ah good, a picture paints a thousand words! 

I think you may be right about that. I've not seen anything that points to that in the KSP reference manual (although I probably need a manual for that also! Which reminds me to ask if you know of any KSP related literature out there which is a bit more explanatory?) 

Each group has one sample in, but they relate to different folders. And thus far I'm just using the sample navigation to change the sample in whatever group I wish to change..oh uh I feel it's getting confusing again! 

I know this method will have to change. Levitanus mentioned above, if I understood correctly, that I could stack my samples on one key, so that each sample took up one increment of velocity and use a switch to filter velocity information up and down to select the different samples. I would need to retain the velocity information for performance so I'm not sure the two can coexist. 

And then there is Mario's epic midi layout, which is certainly something very useful to learn about and may be better if the velocity idea means I lose performance velocity which is a must.


----------



## farjedi (Dec 12, 2018)

Ah ok got you, it's in the top right corner? Thanks for the heads up


----------



## Levitanus (Dec 12, 2018)

farjedi said:


> I would need to retain the velocity information


general, it would be something like:

```
{ Compiled on Thu Dec 13 02:26:04 2018 }
on init
  declare ui_value_edit $current_note(1, 127, 1)
  declare $event
end on

on note
  ignore_event($EVENT_ID)
  $event := play_note($EVENT_NOTE,$current_note,0,0)
  {1000000 is absolute volume scale (1000000 / 127 was instead of 7874), relative-bit has to be set to absolute (I don't remember which value is it)}
  change_vol($event,7874*$EVENT_VELOCITY,0)
end on
```


----------



## Tod (Dec 12, 2018)

farjedi said:


> I think you may be right about that. I've not seen anything that points to that in the KSP reference manual (although I probably need a manual for that also! Which reminds me to ask if you know of any KSP related literature out there which is a bit more explanatory?)



You can probably find the KSP manual where you have your Kontakt library, it would be in a folder called "Documentation".



> I know this method will have to change. Levitanus mentioned above, if I understood correctly, that I could stack my samples on one key, so that each sample took up one increment of velocity and use a switch to filter velocity information up and down to select the different samples. I would need to retain the velocity information for performance so I'm not sure the two can coexist.



Yes you can do this, however your "Velocity Sensitivity" will have to be set to 0%, and if that don't matter to you it will work quite well. Velocity Sensitivity is basically a volume control based on the velocity level. I'm working on a Steel Guitar instrument right now and it's totally based on single velocities.



> And then there is Mario's epic midi layout, which is certainly something very useful to learn about and may be better if the velocity idea means I lose performance velocity which is a must.



Aah, so does performance velocity mean velocity intensity?


----------



## farjedi (Dec 12, 2018)

Tod, I have the KSP manual!.. I was joking that I need a manual to interpret it's contents. It's not really set out for the layman imo. 

Yes, sorry for my confusing terminology, Tod and Levitanus. I need to retain velocity sensitivity in order to play in/program my beats. That is one of the things I can't live without. So I'm guessing this rules out Levitanus' idea of velocity filtering? I can't have my cake and eat it it looks like. Thanks anyway for your input, I will study your script idea regardless. 

It's a shame as that would have been the simplest solution. Mapping the samples out across the keyboard is probably quite easy to implement with a transpose of some form, but it leaves the difficulty of how I can still play with other sounds as a live kit. Which is another thing I must have. 

Guess I'll be digging into Evil Dragons script for ideas.

I'm imagining having to have some kind of Multi script with lots of midi filtering and transposing going on and the other sounds, claps, hats etc, on separate midi channels. Or I'll just save up for Battery which is probably basically what I'm recreating. But where's the fun in that!


----------



## Tod (Dec 12, 2018)

If you need this for playing live, then I think you're going to need presets. What midi controller do you have and how many CC controllers does it have?


----------



## EvilDragon (Dec 12, 2018)

farjedi said:


> Levitanus mentioned above, if I understood correctly, that I could stack my samples on one key, so that each sample took up one increment of velocity and use a switch to filter velocity information up and down to select the different samples.



That's a really bad idea. The script I posted works exactly the opposite, which is much better for this particular purpose - instead of stacking samples vertically, you're stacking them horizontally (chromatically, mapping one sample next to the other). Then velocity remains available - which is of course, a must. The "Sample" knob in my script basically just redirects which note is being played when you hit the actual trigger note (which is defined on the right side, close to the group output selector). Simples.


----------



## farjedi (Dec 12, 2018)

EvilDragon said:


> That's a really bad idea. The script I posted works exactly the opposite, which is much better for this particular purpose - instead of stacking samples vertically, you're stacking them horizontally (chromatically, mapping one sample next to the other). Then velocity remains available - which is of course, a must. The "Sample" knob in my script basically just redirects which note is being played when you hit the actual trigger note (which is defined on the right side, close to the group output selector). Simples.



Yeah that sounds like that's going to be the best, if not only way. Although it will mean having other sounds on different midi channels. As this is my first script it's going to take a while to digest your code but I'll get there.


----------



## farjedi (Dec 13, 2018)

Tod said:


> If you need this for playing live, then I think you're going to need presets. What midi controller do you have and how many CC controllers does it have?



Not for a live performance as such, I won't need to midi control the UI controls I don't think, although I have an axiom pro should I need to. I just like to be able to finger drum the entire kit so my beats come from that rather than layering in one sound at a time.


----------



## Tod (Dec 13, 2018)

Hi farjedi, what I was thinking is that as you test the kicks out and find good combinations, you could save then as a presets. Then using a CC controller you can access any of them when ever you want.


----------



## farjedi (Dec 13, 2018)

Tod said:


> Hi farjedi, what I was thinking is that as you test the kicks out and find good combinations, you could save then as a presets. Then using a CC controller you can access any of them when ever you want.



Hey Tod, interesting, how would I use the CC controller to access? Sounds like it might be fun.


----------



## Tod (Dec 13, 2018)

farjedi said:


> Hey Tod, interesting, how would I use the CC controller to access? Sounds like it might be fun.



Well the concept is pretty simple, for example in one of my current projects I have 8 effects for a total of 58 knobs. However, only the first 28 knobs pertain to my EQs. I also have another set 4 of presets for just the EQs that can also be saved by the user. So all total I've got 8 presets for the EQs which I've got tied to a CC controller, I'm using CC26 right now but that could change.

At any rate I've got it set up so I can call any of the 8 presets at any time while in play and it's working without a hiccup.

Since you're experimenting with different combinations of samples, keys, and volume levels along with whatever, I think presets would be essential for you.


----------



## farjedi (Dec 14, 2018)

I see what you mean now. Sounds good. What controller do you use?


----------



## Levitanus (Dec 14, 2018)

EvilDragon said:


> That's a really bad idea.


why? I think it's a pretty common technique.
Especially if you have over 9000 samples)
here are only two groups for personal key velocity and cutoff sensitivity with about 700 samples mapped (various RR amount etc)

P.S. Don't count cracks, something wrong with my interface on directsound


----------



## farjedi (Dec 14, 2018)

Levitanus said:


> why? I think it's a pretty common technique.
> Especially if you have over 9000 samples)
> here are only two groups for personal key velocity and cutoff sensitivity with about 700 samples mapped (various RR amount etc)
> 
> P.S. Don't count cracks, something wrong with my interface on directsound




I like the idea, but in filtering the velocity to select certain samples, I lose the ability to program midi dynamics into my drum beats. The only thing I can think of as a complete layman, is perhaps the velocity could be declared before the filtering and used to affect the volume of the group. I have no idea if that's possible just a thought. And I expect that's some complicated code to represent 127 possible velocity values even if it was (I expect not). 

There is no way I would want to program beats with just one possible volume per drum hit. So if there isn't a work around then I will have to go with the midi method. 

Your method is useful for other sounds that don't require velocity for sure.


----------



## Levitanus (Dec 14, 2018)

farjedi said:


> midi dynamics into my drum beats.


You said, You have only one dynamic layer (one sample) per drum. The actual volume by velocity is programmable very simple:

```
$event :=play_note($EVENT_NOTE, <your velocity>, 0, 0)
change_vol($event, <something about -40000> + (40000 / 127) *$EVENT_VELOCITY, 0)
```


----------



## farjedi (Dec 14, 2018)

Levitanus said:


> You said, You have only one dynamic layer (one sample) per drum. The actual volume by velocity is programmable very simple:
> 
> ```
> $event :=play_note($EVENT_NOTE, <your velocity>, 0, 0)
> ...



I think I am confusing with different terminology. Yes, I have one sample per drum, but I wish to dynamically control it's volume by velocity via midi. 

I'm not the best at reading code, but is the top line fixing the volume to trigger a particular sample, and the second giving the 'volume by velocity'? If so, then this is good!


----------



## Levitanus (Dec 14, 2018)

farjedi said:


> second giving the 'volume by velocity'


exactly
P.S. If look into OrangeTree instruments live becomes very interesting))


----------



## farjedi (Dec 14, 2018)

Levitanus said:


> exactly
> P.S. If look into OrangeTree instruments live becomes very interesting))



OK, I'm definitely going to try this out. Thanks for that Levitanus! If this works out for me I think this is the one for me, and easiest to implement.


----------



## EvilDragon (Dec 14, 2018)

Levitanus said:


> why? I think it's a pretty common technique.



Because you lose the ability to use velocity as a modulator for parameters other than volume, pan and tune (which can be sorted out via KSP, but only those three). You can't have vel > filter cutoff, for example, or vel > saturation amount. This is why I really dislike it.


----------



## Levitanus (Dec 14, 2018)

EvilDragon said:


> You can't have vel > filter cutoff, for example


yep. But from case to case. My TT now is to be able to modulate cutoff personally for any of ~400 different drums with the ability of extension. So, I've decided, that 20-30 groups with group_fx + 5-6 AHDSR as constant modulators saves more, than ~400 groups with personal group fx))
If you look video, the cutoff is still modulated via velocity.


----------



## EvilDragon (Dec 14, 2018)

Levitanus said:


> If you look video, the cutoff is still modulated via velocity.



It doesn't work well polyphonically (you play a new note and all still sounding voices from a particular group change to the new value you set via script - that's not how it's supposed to work). That's where it breaks and why that method of mapping shouldn't be used if you want to have modulatable filters (or any other group FX), and there are plenty of cases where you would want that.


----------



## Levitanus (Dec 15, 2018)




----------



## EvilDragon (Dec 15, 2018)

So what exactly are you doing here? Constant mod on envelope intensity? This still applies to all active voices if you change the constant modulator amount from the script, it's not a polyphonic modulation.

And here's the proof, attached. Play a note at high velocity and hold it, then while the filter sweeps play another note with low velocity. Notice how the sweep of previous note gets messed up.


By the way, 9000 samples is a piece of cake for Kontakt. So is 400-500 groups.


----------



## Levitanus (Dec 15, 2018)

EvilDragon said:


> And here's the proof, attached. Play a note at high velocity and hold it



Just demonstrated)
Not constant modulator, AHDSR, with setting sustain value on the note.


EvilDragon said:


> 400-500 groups.


*4-5 group fx. It's the point to research, but I doubt... I've lived with it in VIKINGS)


----------



## EvilDragon (Dec 15, 2018)

Levitanus said:


> Not constant modulator, AHDSR, with setting sustain value on the note.



Ah! OK so that will work because the envelope is pre-rendered on note on (which, ironically, screws up the release velocity modulator, it can only work on next note you play, but not the current one. Quite weird and unexpected). But that still doesn't make it usable for hybrid synth-based libraries, and many other cases which depend on envelopes to, you know, actually do their job. 



Levitanus said:


> *4-5 group fx. It's the point to research, but I doubt... I've lived with it in VIKINGS)



It heavily depends on which effects are loaded. Daft filter takes a lot of RAM because of oversampling - especially if max voices is set to a high value. So if the instrument was set to something crazy like 500+ max polyphony, of course there will be a higher RAM load (and consequently higher CPU load because more voices are allowed to ring out).

It's a matter of balancing things properly for each use case.


----------



## farjedi (Dec 18, 2018)

Thanks for all the suggestions..I should have some time this week to start applying some of your methods. 

One other thing I'd like to know about Kontakt. Using Nuance sampler I'm able to say load an analog sample of a single note doing some filter sweep and in legato mode play a passage and the sample plays through without resetting to the start on each note. I've tried the portamento script in Kontakt and it resets the note to the start each time so not the answer. Is this possible in Kontakt?


----------



## EvilDragon (Dec 18, 2018)

It's possible, but set the mono mode to Legato in that script


----------



## farjedi (Dec 18, 2018)

EvilDragon said:


> It's possible, but set the mono mode to Legato in that script



That's perfect, somehow I missed that!


----------



## farjedi (Dec 20, 2018)

Been trying to implement Levitanus' method. Whilst I thought I could read the basic outline and principle of the code, I find KSP too esoteric and vague to really get my head around what it all means in detail. At least with any speed.

I did try copying pasting the code at one stage and Kontakt just muted itself and wasn't having any of it. Perhaps because Ignore_Event is ignoring everything(volume, pan, tune) this is conflicting with the UI knobs I have already that are tied to volume and tune parameters. A guess as to why I got a weird result, but I really have no idea. 

I'll give it another try tomorrow before EvilDragons midi filter method. Not greatly hopeful without a better way of accessing the meaning of commands in KSP. I seem forever to be trying to find them and when I do it's often no clearer


----------



## farjedi (Mar 21, 2019)

I'm back after a hiatus, almost 2 months since I had a look at Kontakt scripting, unfortunately with all the other non musical studying I've had to do, I'm several steps backwards from where I was. 

I still haven't finished this thing, but at least now I have implemented mute and solo buttons. I even surprised myself in working out solo for myself. Although please can someone advise me if there is an easier method? 

Anyone wishing to peruse my code and give advice I will appreciate your feedback.


----------



## farjedi (Mar 21, 2019)

on init
make_perfview
set_ui_height(4)
set_ui_color(914526842h)

declare ui_knob $samp1Knob (0,1000000,1)
$samp1Knob:= 500000
move_control_px ($samp1Knob,65,05)
set_text($samp1Knob, "El Tight")
make_persistent($samp1Knob)
read_persistent_var ($samp1Knob)
set_engine_par($ENGINE_PAR_VOLUME, $samp1Knob, 0, -1, -1)
set_knob_label($samp1Knob, get_engine_par_disp($ENGINE_PAR_VOLUME, 0, -1,-1))

declare ui_knob $samp1pitchKnob (0,1000000,1)
$samp1pitchKnob:= 500000
move_control_px ($samp1pitchKnob,65,50)
set_text($samp1pitchKnob, "Pitch")
make_persistent($samp1pitchKnob)
read_persistent_var ($samp1pitchKnob)
set_engine_par($ENGINE_PAR_TUNE, $samp1pitchKnob, 0, -1, -1)
set_knob_label($samp1pitchKnob, get_engine_par_disp($ENGINE_PAR_TUNE, 0, -1,-1))

declare $solo1
declare ui_switch $samp1solo
move_control_px ($samp1solo, 77,100)
set_control_par (get_ui_id ($samp1solo) , $CONTROL_PAR_WIDTH, 35)
set_control_par (get_ui_id ($samp1solo), $CONTROL_PAR_HEIGHT, 20)
set_control_par (get_ui_id ($samp1solo),$CONTROL_PAR_TEXT_ALIGNMENT,1)
set_text ($samp1solo, "Solo")

declare $mute1
declare ui_switch $samp1mute
move_control_px ($samp1mute, 113,100)
set_control_par (get_ui_id ($samp1mute) , $CONTROL_PAR_WIDTH, 35)
set_control_par (get_ui_id ($samp1mute), $CONTROL_PAR_HEIGHT, 20)
set_control_par (get_ui_id ($samp1mute),$CONTROL_PAR_TEXT_ALIGNMENT,1)
set_text ($samp1mute, "Mute")

declare ui_switch $Prev1 
move_control_px ($Prev1, 77,125)
set_control_par (get_ui_id ($Prev1), $CONTROL_PAR_WIDTH, 35)
set_control_par (get_ui_id ($Prev1), $CONTROL_PAR_HEIGHT, 20)
set_control_par (get_ui_id ($Prev1),$CONTROL_PAR_TEXT_ALIGNMENT,1)
set_text ($Prev1, "Prev")

declare ui_switch $Next1
move_control_px ($Next1, 113,125)
set_control_par (get_ui_id ($Next1), $CONTROL_PAR_WIDTH, 35)
set_control_par (get_ui_id ($Next1), $CONTROL_PAR_HEIGHT, 20)
set_control_par (get_ui_id ($Next1),$CONTROL_PAR_TEXT_ALIGNMENT,1)
set_text ($Next1, "Next")

declare ui_knob $samp2Knob (0,1000000,1)
$samp2Knob:= 500000
move_control_px ($samp2Knob,160,05)
set_text($samp2Knob, "El Boom")
make_persistent($samp2Knob)
read_persistent_var ($samp2Knob)
set_engine_par($ENGINE_PAR_VOLUME, $samp2Knob, 1, -1, -1)
set_knob_label($samp2Knob, get_engine_par_disp($ENGINE_PAR_VOLUME, 1, -1,-1))

declare ui_knob $samp2pitchKnob (0,1000000,1)
$samp2pitchKnob:= 500000
move_control_px ($samp2pitchKnob,160,50)
set_text($samp2pitchKnob, "Pitch")
make_persistent($samp2pitchKnob)
read_persistent_var ($samp2pitchKnob)
set_engine_par($ENGINE_PAR_TUNE, $samp2pitchKnob, 1, -1, -1)
set_knob_label($samp2pitchKnob, get_engine_par_disp($ENGINE_PAR_TUNE, 1, -1,-1))

declare $solo2
declare ui_switch $samp2solo
move_control_px ($samp2solo, 172,100)
set_control_par (get_ui_id ($samp2solo) , $CONTROL_PAR_WIDTH, 35)
set_control_par (get_ui_id ($samp2solo), $CONTROL_PAR_HEIGHT, 20)
set_control_par (get_ui_id ($samp2solo),$CONTROL_PAR_TEXT_ALIGNMENT,1)
set_text ($samp2solo, "Solo")

declare $mute2
declare ui_switch $samp2mute
move_control_px ($samp2mute, 208,100)
set_control_par (get_ui_id ($samp2mute) , $CONTROL_PAR_WIDTH, 35)
set_control_par (get_ui_id ($samp2mute), $CONTROL_PAR_HEIGHT, 20)
set_control_par (get_ui_id ($samp2mute),$CONTROL_PAR_TEXT_ALIGNMENT,1)
set_text ($samp2mute, "Mute")

declare ui_switch $Prev2 
move_control_px ($Prev2, 172,125)
set_control_par (get_ui_id ($Prev2), $CONTROL_PAR_WIDTH, 35)
set_control_par (get_ui_id ($Prev2), $CONTROL_PAR_HEIGHT, 20)
set_control_par (get_ui_id ($Prev2),$CONTROL_PAR_TEXT_ALIGNMENT,1)
set_text ($Prev2, "Prev")

declare ui_switch $Next2
move_control_px ($Next2, 208,125)
set_control_par (get_ui_id ($Next2), $CONTROL_PAR_WIDTH, 35)
set_control_par (get_ui_id ($Next2), $CONTROL_PAR_HEIGHT, 20)
set_control_par (get_ui_id ($Next2),$CONTROL_PAR_TEXT_ALIGNMENT,1)
set_text ($Next2, "Next") 

declare ui_knob $samp3Knob (0,1000000,1)
$samp3Knob:= 500000
move_control_px ($samp3Knob,255,05)
set_text($samp3Knob, "El EX")
make_persistent($samp3Knob)
read_persistent_var ($samp3Knob)
set_engine_par($ENGINE_PAR_VOLUME, $samp3Knob, 2, -1, -1)
set_knob_label($samp3Knob, get_engine_par_disp($ENGINE_PAR_VOLUME, 2, -1,-1))

declare ui_knob $samp3pitchKnob (0,1000000,1)
$samp3pitchKnob:= 500000
move_control_px ($samp3pitchKnob,255,50)
set_text($samp3pitchKnob, "Pitch")
make_persistent($samp3pitchKnob)
read_persistent_var ($samp3pitchKnob)
set_engine_par($ENGINE_PAR_TUNE, $samp3pitchKnob, 2, -1, -1)
set_knob_label($samp3pitchKnob, get_engine_par_disp($ENGINE_PAR_TUNE, 2, -1,-1))

declare $solo3
declare ui_switch $samp3solo
move_control_px ($samp3solo, 267,100)
set_control_par (get_ui_id ($samp3solo) , $CONTROL_PAR_WIDTH, 35)
set_control_par (get_ui_id ($samp3solo), $CONTROL_PAR_HEIGHT, 20)
set_control_par (get_ui_id ($samp3solo),$CONTROL_PAR_TEXT_ALIGNMENT,1)
set_text ($samp3solo, "Solo")

declare $mute3
declare ui_switch $samp3mute
move_control_px ($samp3mute, 303,100)
set_control_par (get_ui_id ($samp3mute) , $CONTROL_PAR_WIDTH, 35)
set_control_par (get_ui_id ($samp3mute), $CONTROL_PAR_HEIGHT, 20)
set_control_par (get_ui_id ($samp3mute),$CONTROL_PAR_TEXT_ALIGNMENT,1)
set_text ($samp3mute, "Mute")

declare ui_switch $Prev3 
move_control_px ($Prev3, 267,125)
set_control_par (get_ui_id ($Prev3), $CONTROL_PAR_WIDTH, 35)
set_control_par (get_ui_id ($Prev3), $CONTROL_PAR_HEIGHT, 20)
set_control_par (get_ui_id ($Prev3),$CONTROL_PAR_TEXT_ALIGNMENT,1)
set_text ($Prev3, "Prev")

declare ui_switch $Next3
move_control_px ($Next3, 303,125)
set_control_par (get_ui_id ($Next3), $CONTROL_PAR_WIDTH, 35)
set_control_par (get_ui_id ($Next3), $CONTROL_PAR_HEIGHT, 20)
set_control_par (get_ui_id ($Next3),$CONTROL_PAR_TEXT_ALIGNMENT,1)
set_text ($Next3, "Next") 

end on

on ui_control($samp1Knob)
set_engine_par($ENGINE_PAR_VOLUME, $samp1Knob, 0, -1, -1)
set_knob_label($samp1Knob, get_engine_par_disp($ENGINE_PAR_VOLUME, 0, -1,-1))

end on

on ui_control($samp1pitchKnob)
set_engine_par($ENGINE_PAR_TUNE, $samp1pitchKnob, 0, -1, -1)
set_knob_label($samp1pitchKnob, get_engine_par_disp($ENGINE_PAR_TUNE, 0, -1,-1))


end on

on ui_control($samp1solo)

if ($samp1solo = 1)
$mute2 := get_engine_par($ENGINE_PAR_VOLUME, 1, -1,-1)
set_engine_par($ENGINE_PAR_VOLUME, 0, 1, -1, -1)
$mute3 := get_engine_par($ENGINE_PAR_VOLUME, 2, -1,-1)
set_engine_par($ENGINE_PAR_VOLUME, 0, 2, -1, -1)

else
set_engine_par($ENGINE_PAR_VOLUME, $mute2, 1, -1, -1)
set_engine_par($ENGINE_PAR_VOLUME, $mute3, 2, -1, -1) 
end if

end on

on ui_control($samp1mute)

if ($samp1mute = 1)
$mute1 := get_engine_par($ENGINE_PAR_VOLUME, 0, -1,-1)
set_engine_par($ENGINE_PAR_VOLUME, 0, 0, -1, -1)

else
set_engine_par($ENGINE_PAR_VOLUME, $mute1, 0, -1, -1)
end if


end on

on ui_control($samp2Knob)
set_engine_par($ENGINE_PAR_VOLUME, $samp2Knob, 1, -1, -1)
set_knob_label($samp2Knob, get_engine_par_disp($ENGINE_PAR_VOLUME, 1, -1,-1))

end on

on ui_control($samp2pitchKnob)
set_engine_par($ENGINE_PAR_TUNE, $samp2pitchKnob, 1, -1, -1)
set_knob_label($samp2pitchKnob, get_engine_par_disp($ENGINE_PAR_TUNE, 1, -1,-1))

end on

on ui_control($samp2solo)

if ($samp2solo = 1)
$mute1 := get_engine_par($ENGINE_PAR_VOLUME, 0, -1,-1)
set_engine_par($ENGINE_PAR_VOLUME, 0, 0, -1, -1)
$mute3 := get_engine_par($ENGINE_PAR_VOLUME, 2, -1,-1)
set_engine_par($ENGINE_PAR_VOLUME, 0, 2, -1, -1)

else
set_engine_par($ENGINE_PAR_VOLUME, $mute1, 0, -1, -1)
set_engine_par($ENGINE_PAR_VOLUME, $mute3, 2, -1, -1) 
end if

end on


on ui_control($samp2mute)

if ($samp2mute = 1)
$mute2 := get_engine_par($ENGINE_PAR_VOLUME, 1, -1,-1)
set_engine_par($ENGINE_PAR_VOLUME, 0, 1, -1, -1)

else
set_engine_par($ENGINE_PAR_VOLUME, $mute2, 1, -1, -1)
end if

end on

on ui_control($samp3mute)

if ($samp3mute = 1)
$mute3 := get_engine_par($ENGINE_PAR_VOLUME, 2, -1,-1)
set_engine_par($ENGINE_PAR_VOLUME, 0, 2, -1, -1)

else
set_engine_par($ENGINE_PAR_VOLUME, $mute3, 2, -1, -1)
end if

end on
on ui_control($samp3Knob)
set_engine_par($ENGINE_PAR_VOLUME, $samp3Knob, 2, -1, -1)
set_knob_label($samp3Knob, get_engine_par_disp($ENGINE_PAR_VOLUME, 2, -1,-1))

end on

on ui_control($samp3pitchKnob)
set_engine_par($ENGINE_PAR_TUNE, $samp3pitchKnob, 2, -1, -1)
set_knob_label($samp3pitchKnob, get_engine_par_disp($ENGINE_PAR_TUNE, 2, -1,-1))

end on

on ui_control($samp3solo)

if ($samp3solo = 1)
$mute1 := get_engine_par($ENGINE_PAR_VOLUME, 0, -1,-1)
set_engine_par($ENGINE_PAR_VOLUME, 0, 0, -1, -1)
$mute2 := get_engine_par($ENGINE_PAR_VOLUME, 1, -1,-1)
set_engine_par($ENGINE_PAR_VOLUME, 0, 1, -1, -1)

else
set_engine_par($ENGINE_PAR_VOLUME, $mute1, 0, -1, -1)
set_engine_par($ENGINE_PAR_VOLUME, $mute2, 1, -1, -1) 
end if

end on

on ui_control($samp3mute)

if ($samp3mute = 1)
$mute3 := get_engine_par($ENGINE_PAR_VOLUME, 2, -1,-1)
set_engine_par($ENGINE_PAR_VOLUME, 0, 2, -1, -1)

else
set_engine_par($ENGINE_PAR_VOLUME, $mute3, 2, -1, -1)
end if

end on


----------



## geronimo (Mar 21, 2019)

Tod said:


> Hey farjedi, it's best to put scripting in in CODE, then it retains it's format somewhat.


----------



## farjedi (Mar 21, 2019)

Yeah my bad thought I had used the BB Code editor..but clearly messed up or that is completely the wrong thing anyways...


----------

