Script for Random Round Robins position w/ two microphones
Infant scripting child here, so please be gentle. I'm trying to accomplish something fairly simple, which involves keeping my first five groups (1-5 (mic A)) , and my second set of five groups (6-10 (mic B)) together via their respective round robin position (ie RR position 1 is used for groups 1 & 6, RR position 2 is used for 2 & 7) but using code so that they cycle randomly while not repeating the last sample just played. David Hilowitz had posted a video on this subject, and I've read through some of the other threads, but I still can't find a method that works given the constraints.
on init
make_perfview
set_ui_height_px(255)
set_ui_width_px(633)
declare $mouse_resp := -900
set_control_par_str($INST_WALLPAPER_ID,$CONTROL_PAR_PICTURE,"instrumentbackground")
declare ui_slider $NEAR(0,1000000)
make_persistent($NEAR)
declare $k_NEAR
$k_NEAR := get_ui_id($NEAR)
set_control_par_str($k_NEAR,$CONTROL_PAR_PICTURE,"MK2-64")
set_control_par($k_NEAR,$CONTROL_PAR_POS_X,25)
set_control_par($k_NEAR,$CONTROL_PAR_POS_Y,80)
set_control_par($k_NEAR,$CONTROL_PAR_MOUSE_BEHAVIOUR,$mouse_resp)
declare ui_slider $Far(0,1000000)
make_persistent($Far)
declare $k_Far
$k_Far := get_ui_id($Far)
set_control_par_str($k_Far,$CONTROL_PAR_PICTURE,"MK2-64")
set_control_par($k_Far,$CONTROL_PAR_POS_X,110)
set_control_par($k_Far,$CONTROL_PAR_POS_Y,80)
set_control_par($k_Far,$CONTROL_PAR_MOUSE_BEHAVIOUR,$mouse_resp)
declare %rr_index[10] := (0,1,2,3,4,5,6,7,8,9) {not sure num is needed}
declare %rr_index_prev[10] := (0,1,2,3,4,5,6,7,8,9) {this may be incorrect}
end on
on ui_control($NEAR)
set_engine_par($ENGINE_PAR_VOLUME, $NEAR, -1, -1, $NI_BUS_OFFSET + 0)
end on
on ui_control($Far)
set_engine_par($ENGINE_PAR_VOLUME, $Far, -1, -1, $NI_BUS_OFFSET + 1)
end on
on note
if (rr_random = 0) {I get an error here saying ) expected}
%rr_index[$EVENT_NOTE] := %rr_index[$EVENT_NOTE] + 1
if %rr_index[$EVENT_NOTE] >= $MAX_RR
%rr_index[$EVENT_NOTE] := 0
end if
else
%rr_index_prev[$EVENT_NOTE] := %rr_index[$EVENT_NOTE]
while %rr_index[$EVENT_NOTE] = %rr_index_prev[$EVENT_NOTE]
%rr_index[$EVENT_NOTE] := random(0, $MAX_RR-1)
end while
end if
disallow_group($ALL_GROUPS)
allow_group(%rr_index[$EVENT_NOTE]) { Close? }
allow_group(%rr_index[$EVENT_NOTE] + 10) { Far? }
message("note -> " & $EVENT_NOTE & " / vel = " & $EVENT_VELOCITY & " / rr = " & rr_index[$EVENT_NOTE])
end on
Comments
-
Please read the sticky about how to post code around here. 😊
As to your question - you're going in the right direction, but you probably need to just do + 5 instead of + 10 in that second allow_group(), if you have 5 RR groups per mic.
0 -
Hey Babble - code noob here as well. I was adapting your code to fit my situation and I got the error in the same spot you pointed yours out. Did you ever solve the error in that line and if so could you share the solution with me? Thank you!
0 -
Not sure about this, but in the
on note
callback, where isrr_random
coming from? It doesn't look like it's been declared anywhere0 -
Good catch - I declared it but wasn't sure what value to give it. In my case I want 4 round robins so I put 4. The code didn't get any errors, but when I press a note it takes a good half second to crunch some huge array before outputting a note (and every output resulted in rr0). While it was processing the array I saw a message at the very bottom of the Kontakt window saying something about the array being out of bounds or something.
0 -
You probably need to assign it a random value if you want random RRs. So use this plus the range of RRs you have to give it a value. Maybe?
0 -
-
Thank you so much for jumping in to help Jared. This morning I managed to achieve my desired result by using a different code resource I had found and combining it with Babble's idea to add a second "allow group" line with "+4". Worked like a charm - it now randomizes groups 1-4 and triggers the respective group 5-8 alongside it. Beautiful.
I wanted to share how my code ended up looking, but every time I click "post comment" it does nothing (code is properly formatted too). If I can get it to work I'll share it here!
0 -
Trying again - here's what my code ended up looking like:
on init declare %list[4] declare $at := num_elements(%list) declare $x declare $last end on on note disallow_group($ALL_GROUPS) inc($at) if($at >= num_elements(%list)) $last := %list[num_elements(%list) - 1] %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(%list[0] = $last) %list[0] := %list[num_elements(%list) - 1] %list[num_elements(%list) - 1] := $last end if end if allow_group(%list[$at]) allow_group(%list[$at]+4) end on
0
Categories
- All Categories
- 19 Welcome
- 1.4K Hangout
- 60 NI News
- 735 Tech Talks
- 3.9K Native Access
- 15.9K Komplete
- 1.9K Komplete General
- 4.1K Komplete Kontrol
- 5.5K Kontakt
- 1.5K Reaktor
- 364 Battery 4
- 817 Guitar Rig & FX
- 416 Massive X & Synths
- 1.2K Other Software & Hardware
- 5.5K Maschine
- 7K Traktor
- 7K Traktor Software & Hardware
- Check out everything you can do
- Create an account
- See member benefits
- Answer questions
- Ask the community
- See product news
- Connect with creators