# Ignore_controller until certain CC value is met?



## Rennaissance_manta_ray (Aug 30, 2018)

I've been trying to figure out a way to script this but I can't seem to find one. Hoping maybe someone here can help.

Is there any way that you can ignore CC values (in my case mod wheel cc1) until a certain value is reached, and then have the controller return back to normal function?

What I want to have happen is have a group where the default is, let's say CC1=55. I don't want the modwheel to jump around from 55 to wherever it is when the user touches it (like if it's at 0 it'd go 55-0 really quick, or if it's up at 127 it'd go quickly from 55 to 127 as soon as they move it). So I want the script to ignore the mod wheel until it gets to 55, but after that I want it to function normally.

I tried things like if (%CC[1]<55) ignore_controller, but I couldn't find any way to stop the "ignore_controller" so I could never get the CC1 to go below 55 afterwards.

Hopefully I'm just being a total noob and there's an easy elegant way to do this!

Thanks!


----------



## EvilDragon (Aug 30, 2018)

This works fine over here? Doesn't receive anything below 55 and then works normally from 55-127.


```
on controller
    if ($CC_NUM = 1 and %CC[$CC_NUM] < 55)
        ignore_controller
    end if
end on
```


----------



## Rennaissance_manta_ray (Aug 30, 2018)

Thanks EvilDragon!

I got that part to work, but what I'm really wondering is if there's a way to have the "ignore_controller" work until you reach 55, then be able to use the full 0-127 range of the mod wheel after that condition is met. Couldn't figure a way to make that work!

Hopefully there's a way!

Thanks!!!


----------



## EvilDragon (Aug 30, 2018)

Ah I get ya. Yeah you would need to use a bit of math to rescale the rest of the range.


```
on controller
   if ($CC_NUM = 1)
       ignore_controller
       if (%CC[$CC_NUM] >= 55)
           set_controller($CC_NUM, (%CC[$CC_NUM] - 55) * 44 / 25)
       end if
   end if
end on
```


Of course you will lose some resolution there, since you use the smaller range of CC to cover a larger one.


----------



## Rennaissance_manta_ray (Aug 30, 2018)

Totally awesome! Thanks Man. The only problem I have now, is that as soon as it rescales, it jumps to zero (on my modulator) instead of going smoothly up from 55-127. the way back down is perfect, but is there any way to get it to move up without having it jump down to the bottom of the rescaled range?

Thanks, I love how much help you can get on this forum, you guys are the best.


----------



## EvilDragon (Aug 30, 2018)

I don't think you can get that behavior. Not sure. If you only want it to respond from 55-127, but want the rest of the range to rescale to 0-127, this is what you get.


----------



## Rennaissance_manta_ray (Aug 30, 2018)

Gotcha. I'll play around. There's no way to "cancel" the "ignore_controller" with some kind of condition? 

Thanks!!!


----------



## polypx (Aug 30, 2018)

If you want it to behave normally once you pass 55, you'll need some kind of flag in the ignore_controller condition. Once 55 is passed, you can turn the flag off and ignore the ignore_controller...


----------



## EvilDragon (Aug 31, 2018)

But with rescaling above 55 that will be quite weird... So you would get these values: 0...54, then from 55 onwards it would use rescaling, so you would get 0...127 when CC1 is 55-127...


----------



## tonewill (Aug 31, 2018)

Sorry to butt it, but what I got from the original post is that the controller should work normally throughout its range 0-127 but only once it has hit (or moved through) 55 the very first time (from either direction) to stop whatever the mod wheel is set to do suddenly jumping from 55 to the current position of the mod wheel.


----------



## EvilDragon (Aug 31, 2018)

Oh. Well in that case, there's this thing called "soft takeover" in Kontakt.

When you MIDI learn a scripted knob, you have an option in Automation->MIDI Automation pane, when you select the relevant MIDI CC, on the bottom. Enable soft takeover. This should ensure that the value is changed only when controller's position matches the GUI control's.


----------



## Tod (Aug 31, 2018)

Why not just set up an array with 128 elements, %Ary[0 to 54]:=$Ignor, %Ary[55 to 127]:=EPValue.

$Ignor would be what ever value is desired when being ignored, EPValue would be what ever engine parameter values for each of the %Ary[55 to 127] that is desired.

Or just ignore up to 54, then use the %Ary[55 to 127] values.


----------



## EvilDragon (Sep 1, 2018)

I don't think that'd solve the issue. It's basically a more complicated way of doing what code I pasted does. 

This is a job for "soft takeover" feature.


----------



## Rennaissance_manta_ray (Sep 1, 2018)

polypx said:


> If you want it to behave normally once you pass 55, you'll need some kind of flag in the ignore_controller condition. Once 55 is passed, you can turn the flag off and ignore the ignore_controller...



Ah, that would be awesome. I was able to do something sort of like this with declaring a variable, and setting CC1 to 0 if it was <55 and the variable was =0, then having the variable go to =1 after the controller hit 55.

I think a flag would be more elegant, but I can't find the proper syntax in the KSP manual. And searching "flag" her seems like it doesn't bring up any good examples. Any chance you could point me in the right direction?

Thanks!!!!


----------



## Rennaissance_manta_ray (Sep 1, 2018)

EvilDragon said:


> Oh. Well in that case, there's this thing called "soft takeover" in Kontakt.
> 
> When you MIDI learn a scripted knob, you have an option in Automation->MIDI Automation pane, when you select the relevant MIDI CC, on the bottom. Enable soft takeover. This should ensure that the value is changed only when controller's position matches the GUI control's.




Ah, that's what that does! Though is there a way to script it? or would the user have to set it up themselves?


----------



## EvilDragon (Sep 1, 2018)

If you set it up in the patch, then save the patch, it is saved along with it. There's no need to script it - the caveat is that you need to apply it on a scripted control, you cannot apply it directly on a CC.


----------



## Rennaissance_manta_ray (Sep 1, 2018)

EvilDragon said:


> If you set it up in the patch, then save the patch, it is saved along with it. There's no need to script it - the caveat is that you need to apply it on a scripted control, you cannot apply it directly on a CC.


Ahhhh. Cool. Great to know! Thanks so much everyone for the help!


----------

