# ***New and Improved*** Intelligent Round Robin Script V1.1



## Thonex (Apr 26, 2006)

Hi Guys,

Here is a little script that will make your round robin patches far more realistic when playing 2 notes (or more) at a time. Normally, with a stock RR patch, when you play a chord, each note of the chord cycles through the round RR.... so... if you had an Up/Down bow RR and played a 4 note chord, half the notes in the chord would be up bows and the rest down bows... not very realistic.

This script assigns all the notes in a chord played within a certain number of milliseconds (user definable) to play the same group (same articulation).

It also allows you to reset the RR based on either a Key Switch or a Controller (user definable). In the case of the controller, any Controller whose value is greater than 64 fill reset the RR.

*[EDIT] Since I originally posted this, Nils Liberg decided to contribute to the script making the GUI friendlier with a button and additional text (also some code to make it more bullet proof).... so I'm posting the new code in place of the old code and now the version number is v1.1. I would like to thank Nils for taking his time to make these changes... they are most welcome.*

[EDIT] I forgot to mention, to use this script, de-activate Round Robin on all the groups in the original patch. To do this, select the Group Editor tab and choose Edit All Groups (the red button) and then for Group Start options.. choose Always (or whatever the default is... I'm not at my rig :smile: ).

I'd like to thank Nils Liberg for his RR script that he posted as an example because I based my script on his. http://vi-control.net/forum/viewtopic.php?t=3382

I'd also like to thank Nils for his awesome KScript Editor!!!

Here is the code


```
{*******************************************************}
{*********** Intelligent Round Robin V1.1 **************}
{********* By Andrew Keesztes and Nils Liberg **********}
{*******************************************************}

on init   
   declare ui_value_edit $ResetKS(0,127,1)
   declare ui_value_edit $ResetCC(0,127,1)
   declare ui_value_edit $ms(0,1000,1)                                                 
   declare ui_label $labelKS(1,1)
   declare ui_label $labelCC(1,1)
   declare ui_label $labelms(1,1)   
   declare ui_button $Learn               
   declare $group
   declare $time
   declare $time_differential   
   $ms := 50
   set_text($labelKS, "Reset keyswitch")
   set_text($labelCC, "Reset MIDI CC")
   set_text($labelms, "Chord in millisecs")   
   move_control($Learn, 1, 3)
   move_control($ResetKS, 1, 2)
   move_control($ResetCC, 2, 2)
   move_control($ms, 3, 2)
   make_persistent($ms)
   make_persistent($ResetCC)
   make_persistent($ResetKS)   
   message("")
end on

on note   
   if ($Learn = 1)
      $ResetKS := $EVENT_NOTE
      $Learn := 0
      message("Reset keyswitch learned!")
      wait(1500000)
      message("")
      exit
   end if
   
   if ($EVENT_NOTE = $ResetKS)
      $group := -1     
      ignore_event($EVENT_ID)
      exit
   end if
   
   if (num_elements(%GROUPS_AFFECTED) > 0)
      disallow_group($ALL_GROUPS)     
      $time_differential := $ENGINE_UPTIME - $time
      if ($time_differential > $ms or $group = -1)
         $group := ($group + 1) mod num_elements(%GROUPS_AFFECTED)
      end if
      allow_group($group)
      $time := $ENGINE_UPTIME
   end if   
end on

on controller
   if ($ResetCC # 0 and %CC[$ResetCC]>= 64)
      $group :=-1
   end if   
end on

on ui_control($Learn)
   if ($Learn = 1)
      message("Press the note you want to use as keyswitch for reset...")
   else
      message("")
   end if
end on
```


Enjoy.


----------



## Scott Cairns (Apr 26, 2006)

*Re: Intelligent Round Robin Script*

Thanks Andrew, this looks great!

Cheers,

Scott.


----------



## kotori (Apr 27, 2006)

*Re: Intelligent Round Robin Script*

Great work Thonex!

Cheers,
Nils


----------



## Thonex (Apr 27, 2006)

*Re: Intelligent Round Robin Script*

HI guys,

Thanks fo the kind words.

Kotori (Nils) PMed me with a better version of the script (he added a couple of features) and I'll post it when I get back to my studio (yes yes.... my studio is at my house.... but I have kids you know :wink: ).

Anyway... I think it's great that I post a script and a few hours later an "new and improved" version is introduced  

Stay tuned.. I'll post it when I get a moment.

Cheers,

T


----------



## Big Bob (Apr 27, 2006)

*Re: Intelligent Round Robin Script*

Hi Andrew,

Great Job! You keep this up and pretty soon I'll be able to completely retire :wink: . 

Here's a suggestion that is sure to intrigue you and keep you busy for a while. As an option to RR, add something similar to 'Full-Cycle-Random ' as implemented in the Ultra TKT. The basic idea is that if you have say 4 groups, instead of just going through them 1, 2, 3, 4, 1, 2, 3, 4, instead you go through them in a random order but, always go through all 4 and never double up the same group twice in a row. For example:

1, 3, 2, 4, 1, 4, 2, 3, 4, 2, 3, 1, etc. 

Now isn't that a wild idea? :idea: But, seriously, keep 'em coming Andrew.

God Bless,

Bob


----------



## Thonex (Apr 27, 2006)

*Re: Intelligent Round Robin Script*



Big Bob @ Thu Apr 27 said:


> Hi Andrew,
> 
> Great Job! You keep this up and pretty soon I'll be able to completely retire :wink: .
> 
> ...



Heh heh... I already wrote that script :wink: but as a TKT script with the additional feature that you can choose between Random, RR, RR reset and Bypass.

Another cool additional feature I included was, in addition to not repeating the same random note twice, you could play (say) a C5 and then play for an hour never playing the C5 again... yet when you come back to C5 an hour later and play it.... it will be a different one!!! SO.. not only is it not repeating notes... but it also keeps track of the note's history and makes sure that no note is played the same even if there are a bunch of notes in between. Clear as mud?? :wink: 

Cheers,

T


----------



## Thonex (Apr 27, 2006)

*Re: Intelligent Round Robin Script*

Ok,

Nils' newer version of the script is posted in the original post above... along with a new link to the new .nkp file.

Enjoy.

T


----------



## Big Bob (Apr 27, 2006)

Hi Andrew,



> Heh heh... I already wrote that script but as a TKT script with the additional feature that you can choose between Random, RR, RR reset and Bypass.
> 
> Another cool additional feature I included was, in addition to not repeating the same random note twice, you could play (say) a C5 and then play for an hour never playing the C5 again... yet when you come back to C5 an hour later and play it.... it will be a different one!!! SO.. not only is it not repeating notes... but it also keeps track of the note's history and makes sure that no note is played the same even if there are a bunch of notes in between. Clear as mud??


How did you know this was going to be clear as mud :razz: ? When you say you wrote that script already but as a TKT, do you mean you wrote another TKT script? If so, why? The multiple random modes you describe were already in the UTKT. I was talking about adding them to your group cycling script. Maybe I'm not on the same page?

God Bless,

Bob


----------



## Thonex (Apr 27, 2006)

Big Bob @ Thu Apr 27 said:


> How did you know this was going to be clear as mud :razz: ? When you say you wrote that script already but as a TKT, do you mean you wrote another TKT script? If so, why? The multiple random modes you describe were already in the UTKT. I was talking about adding them to your group cycling script. Maybe I'm not on the same page?
> 
> God Bless,
> 
> Bob



I wrote it about 6 months ago as a learning experience for myself.

I could add the Group cycling to my TKT script pretty easily I think.

I'll check it out when I have more time.

Cheers,

T


----------



## Big Bob (Apr 28, 2006)

> I wrote it about 6 months ago as a learning experience for myself.
> 
> I could add the Group cycling to my TKT script pretty easily I think.
> 
> I'll check it out when I have more time.


I meant it the other way around, I was suggesting you add the Full-Cycle-Random mode (that's in the UTKT and that you said you incorporated in your TKT) to your new group sequencing script.

Besides, none of us can do anything like this now until we can all get and assess the big 2.1 update  , so far (according to Nils) it sounds pretty encouraging. So far, I haven't been lucky enough to get it . Have you got it yet?

God Bless,

Bob


----------



## Thonex (Apr 28, 2006)

Big Bob @ Fri Apr 28 said:


> > I wrote it about 6 months ago as a learning experience for myself.
> >
> > I could add the Group cycling to my TKT script pretty easily I think.
> >
> ...


I'll try the RR Rnadom group thing (with bells and whistles) when I get the next projects out of the way... probably in a month. From the look of it... it shouldn't be too hard. It's basically substituting the pitch tuning for groups.. we'll see.:smile: 

Have I downloaded K2.1 yet???...Nope.... I'm delivering a project today. I'll probably download it this weekend.

Cheers,

T :smile:


----------



## Alex W (Jun 15, 2006)

Great script fellas, but is there any way you guys could modify this script to allow for my situation?

Because I'm using 2 separate mic distances of the same sample concurrently, I've got 4 groups; 2 for down bow and 2 for up bow.

I don't want to combine the 2 mic distances into 1 group because that means I lose independant panning and volume control over each mic. (unless I do it by performing a "select all zones" and then changing the volume / panning that way - not good for this situation as each zone has been tweaked individually in terms of volume.)

So basically I'd like a modification to be made so that instead of the script playing 1 group at a time in the order of "1,2,3,4,1,2,3,4" etc, I need it to play 2 groups at a time so that the order is like "1+3,2+4,1+3,2+4" etc.


----------



## Thonex (Jun 15, 2006)

Alex W @ Thu Jun 15 said:


> So basically I'd like a modification to be made so that instead of the script playing 1 group at a time in the order of "1,2,3,4,1,2,3,4" etc, I need it to play 2 groups at a time so that the order is like "1+3,2+4,1+3,2+4" etc.



Hi Alex,

Yeah... that shouldn't be too hard... at least no to hard to customize it... it may be more difficult to have it set up automatically and figure it out.

I'm in the middle of a crunch deadline... but when I'm done.. after the 21st.. I take a look.

In the meantime... here is a more recent version of the script:
http://www.andrewkmusic.com/filearea/K2%20Scripts/AK%20RR%20V1.3.html (http://www.andrewkmusic.com/filearea/K2 ... 0V1.3.html)

Cheers,

T


----------



## Thonex (Jun 17, 2006)

Here Alex:

Since all I needed to do was change a line and add a line I decided it wouldn't cut into my deadline... so here are the changes:

$group := ($group + 1) mod (num_elements(%GROUPS_AFFECTED)/2) 

instead of

$group := ($group + 1) mod num_elements(%GROUPS_AFFECTED) 


and then I added the line

allow_group ($group+(num_elements(%GROUPS_AFFECTED)/2))

...after the original "allow_group($group)"

so here is the new code specifically for you... it shold work on any F+S RR patch for EW... provided the F and S have equal number of groups and are (for example) F=groups 1-4, S=groups 5-8.


```
{*******************************************************}
{*********** Intelligent Round Robin for Alex W  **************}
{********* By Andrew Keesztes and Nils Liberg **********}
{*******************************************************}

on init   
   declare ui_value_edit $ResetKS(0,127,1)
   declare ui_value_edit $ResetCC(0,127,1)
   declare ui_value_edit $ms(0,1000,1)                                                 
   declare ui_label $labelKS(1,1)
   declare ui_label $labelCC(1,1)
   declare ui_label $labelms(1,1)   
   declare ui_button $Learn               
   declare $group
   declare $time
   declare $time_differential   
   $ms := 50
   set_text($labelKS, "Reset keyswitch")
   set_text($labelCC, "Reset MIDI CC")
   set_text($labelms, "Chord in millisecs")   
   move_control($Learn, 1, 3)
   move_control($ResetKS, 1, 2)
   move_control($ResetCC, 2, 2)
   move_control($ms, 3, 2)
   make_persistent($ms)
   make_persistent($ResetCC)
   make_persistent($ResetKS)   
   message("")
end on

on note   
   if ($Learn = 1)
      $ResetKS := $EVENT_NOTE
      $Learn := 0
      message("Reset keyswitch learned!")
      wait(1500000)
      message("")
      exit
   end if
   
   if ($EVENT_NOTE = $ResetKS)
      $group := -1     
      ignore_event($EVENT_ID)
      exit
   end if
   
   if (num_elements(%GROUPS_AFFECTED) > 0)
      disallow_group($ALL_GROUPS)     
      $time_differential := $ENGINE_UPTIME - $time
      if ($time_differential > $ms or $group = -1)
         $group := ($group + 1) mod (num_elements(%GROUPS_AFFECTED)/2)
      end if
      allow_group($group)
      allow_group ($group+(num_elements(%GROUPS_AFFECTED)/2))
      $time := $ENGINE_UPTIME
   end if   
end on

on controller
   if ($ResetCC # 0 and %CC[$ResetCC]>= 64)
      $group :=-1
   end if   
end on

on ui_control($Learn)
   if ($Learn = 1)
      message("Press the note you want to use as keyswitch for reset...")
   else
      message("")
   end if
end on
```

cheers

T


----------



## Alex W (Jun 17, 2006)

Thanks a lot Thonex, I really appreciate that mate. I owe ya one.


----------



## Scott Cairns (Jun 18, 2006)

{*********** Intelligent Round Robin for Alex W **************} 

Now thats service Andrew! :wink: :smile:


----------



## Thonex (Jun 18, 2006)

Scott Cairns @ Sun Jun 18 said:


> {*********** Intelligent Round Robin for Alex W **************}
> 
> Now thats service Andrew! :wink: :smile:



heh heh... would you like fries with that??  ....as much I like to be of service to Alex, it's more for keeping tabs on what versions are floating around than anything else  

T


----------



## Alex W (Sep 19, 2006)

would it be possible for one of you scripting geniuses to add another function to this script allowing you to select a time value in ms before the round robin resets back to the front of the cue?

that way I could keep using a down bow if I wanted it to keep resetting after say 100-200ms or something.

cheers


----------



## Thonex (Sep 19, 2006)

Alex W @ Tue Sep 19 said:


> would it be possible for one of you scripting geniuses to add another function to this script allowing you to select a time value in ms before the round robin resets back to the front of the cue?
> 
> that way I could keep using a down bow if I wanted it to keep resetting after say 100-200ms or something.
> 
> cheers



Already done. You can specify between 1-60 seconds and there is also a "Auto Reset" button so you can have it active or not. If you want it to be shorter, then you can change the multiplier value to (say) 100 instead of 1000 and this will give you a 100ms to 6 second range. This is the line of code you need to change (it's on the 3rd line):


```
case 1 {===================Round Robin Script============================}
         $TimeDif := $ENGINE_UPTIME - $EngineClock
         if ($AutoReset_RR = 1 and TimeDif >= $Reset_T*1000)
            $group := -1   
            end if
```

cheers,

T


----------



## Alex W (Sep 19, 2006)

dead set Thonex, you're a champion. Works like a lil' beauty!

CRIKEY!


----------



## synergy543 (Sep 19, 2006)

Thanks for this custom programming tip Thonex. Just what I was looking for too!


----------



## Moonchilde (Dec 6, 2006)

Thonex, I was wondering if it was possible to have a custom groups button of some sorts.

For example, if you wanted crossfading round robing groups that have up/down martele bowing and want to have the modwheel cross fade between Group A (with group 1 up and group 2 down) and Group B (with group 3 up and group 4 down). So the patch itself would look like this:

Group Tab:

Group 1 up, Group 1 down, Group 2 up, Group 2 down

Group 1 up/down has marcato samples, and group 2 up/down has martele. You have it set to crossfade group 1 into group 2, and IRR will only round robin the up downs and not the group 1/2, so you still have crossfading available.

Possible?


----------



## Thonex (Dec 8, 2006)

Moonchilde @ Wed Dec 06 said:


> Thonex, I was wondering if it was possible to have a custom groups button of some sorts.
> 
> For example, if you wanted crossfading round robing groups that have up/down martele bowing and want to have the modwheel cross fade between Group A (with group 1 up and group 2 down) and Group B (with group 3 up and group 4 down). So the patch itself would look like this:
> 
> ...



Actually, I think the script I customized for Alex above would do that. Basically playing 2 samples at once and RR the pair of samples. He was using a surround samples combined with a Front stage sample.... but I think you could use the mod I made for him and just add your MW stuff to it.

Cheers,
T


----------



## Moonchilde (Dec 9, 2006)

Dude, that really worked really well. Awesome... I really love it. Thanks a bunch!


----------



## LATA (Apr 18, 2009)

Hi,

Thanks a lot! My situation is a bit more complex:
I have group 1 and group 2 having a group start condition of CC 127 = 1, and group 3 and group 4 having a group start condition of CC 127 = 2.
Now, depending on the value of CC 127, I want to RR between groups 1-2 OR between groups 3-4. The problem is, I don't think that the GROUPS_AFFECTED variable knows how to filter on group start options. Is that a correct statement?

Thanks!


----------

