1. IMPORTANT:
    We launched a new online community and this space is now closed. This community will be available as a read-only resources until further notice.
    JOIN US HERE

Round Robin Script for Multiple Groups

Discussion in 'Scripting Workshop' started by ipopon, Nov 10, 2019.

  1. ipopon

    ipopon New Member

    Messages:
    7
    Hello! I've been looking for this script on the forums but could not find the exact thing I want.

    Lets say I have 2 sound groups with 5 round-robins (and 7 velocity layers if it matters):

    Snare rr1; Snare rr2; Snare rr3; Snare rr4; Snare rr5; Kick rr1; Kick rr2; Kick rr3; Kick rr4; Kick rr5

    I would like to trigger my round-robins randomly but never repeating the same one twice in my snare section (Gourps: Snare rr1; Snare rr2; Snare rr3; Snare rr4; Snare rr5) and do the same for the kick section (Like "Kick": Kick rr1; Kick rr2; Kick rr3; Kick rr4; Kick rr5). And the same for all other sounds in my drum kit.

    Please, help me!
     
  2. petemain

    petemain New Member

    Messages:
    8
    Hi ipopon that is quite a large question - and quite a large script to just find hanging around!

    In the first instance you will need: disallow_group($ALL_GROUPS)

    and then depending on how you choose to do the randomising : allow_group (*insertGroupnumberhere*)

    *remember that the groups are zero based!

    I would approach this by generating a random number and allowing that group(s), storing what that was and then draw another random number and make a comparison between that and the last group allowed. If it is the same then choose another random number until it is different from the group before and then continue like that round and round..
     
    • Like Like x 1
  3. medusa

    medusa NI Product Owner

    Messages:
    239
    Or just choose randomly from the remainder each time, wrapping around with mod.
    Kick_Group_0 and Snare_Group_0 are set to the first group of each set...


    Code:
    disallow_group(ALL_GROUPS)
    
    Kick_Robin := (Kick_Robin + random(1,4)) mod 5
    allow_group(Kick_Group_0 + Kick_Robin)
    
    Snare_Robin := (Snare_Robin + random(1,4)) mod 5
    allow_group(Snare_Group_0 + Snare_Robin)
     
    • Like Like x 1
  4. ipopon

    ipopon New Member

    Messages:
    7

    Thank you! I'll try it out tomorrow!
     
  5. ipopon

    ipopon New Member

    Messages:
    7
    I didn't manage to make it work. I thought there might be something like this script, but just for multiple groups:

    Code:
    on init
      declare %list[7]
      declare $at := num_elements(%list)
      { %list is the order the groups will play, $at is the current position in the list. }
      { for any number of round robin groups other than 7, change the %list size. }
    
     
      declare $x
      declare $last
    
      declare @debug { remove this and the debug section below after testing }
    end on
    
    on note
      disallow_group($ALL_GROUPS)
     
      inc($at)
     
      { if all groups in the list have been played, fill the list with all groups in random }
      { order, and make sure the last played group is not the first in the new list }
      if($at >= num_elements(%list))
     
        { remember last played group }
        $last := %list[num_elements(%list) - 1]
       
        { fill list with all groups in random order }
        %list[0] := 0
        $at := 1
        while($at # num_elements(%list))
          $x := random(0, $at)
          %list[$at] := %list[$x]
          %list[$x] := $at
          inc($at)
        end while
        $at := 0
       
        { if the last played group is first in the new list, swap first and last in the list }
        if(%list[0] = $last)
          %list[0] := %list[num_elements(%list) - 1]
          %list[num_elements(%list) - 1] := $last
        end if
       
        { debug: show list }
        $x := 0
        @debug := "list:"
        while($x # num_elements(%list))
          @debug := @debug & " " & %list[$x]
          inc($x)
        end while
        message(@debug)
        { debug end }
     
      end if
     
      { enable a group from the list }
      allow_group(%list[$at])
    end on
    
    Just to make it clear one more time... I have 10 groups in total (Snare rr1; Snare rr2; Snare rr3; Snare rr4; Snare rr5; Kick rr1; Kick rr2; Kick rr3; Kick rr4; Kick rr5).

    I also don't know how coding works and what all those commands and punctuation do. If there are some kontakt coding manuals for non-programmers, I'd like to have a look! Hoping that it'll help me to what I'm trying to do.
     
  6. medusa

    medusa NI Product Owner

    Messages:
    239
    This, the same as above but formatted for you:

    Code:
    on init
      declare const $Snare_Group_0 := 0
      declare const $Kick_Group_0 := 5
      declare $Kick_Robin
      declare $Snare_Robin
    end on
    
    on note
      disallow_group($ALL_GROUPS)
      $Kick_Robin := ($Kick_Robin+random(1,4)) mod 5
      allow_group($Kick_Group_0 + $Kick_Robin)
      $Snare_Robin := ($Snare_Robin+random(1,4)) mod 5
      allow_group($Snare_Group_0+$Snare_Robin)
    end on
    
     
    • Like Like x 2
  7. ipopon

    ipopon New Member

    Messages:
    7
    It did work!!! Thank you!
    I guess, it doesn't matter whether my groups are named "Kick rr1", "Kick rr2"... or "Kick1", "Kick2"... The script just finds the word "Kick" and that's it, right?

    For those, who gonna use this script: "group start" options should be turned off (set to "always")
     
  8. medusa

    medusa NI Product Owner

    Messages:
    239
    The name doesn't matter, it's just using the numbers. Kick's start from group 5 (Kick_Group_0) and Snares from group 0 (Snare_Group_0).
     
    • Like Like x 1
  9. ipopon

    ipopon New Member

    Messages:
    7
    Now it's clear! Thank you so much!
     
  10. Noise Native

    Noise Native New Member

    Messages:
    1
    This is a really great script medusa, thank you. Easy to edit and update for purpose.