ISO: Router that can swap a random pair of in→outs?

Oh, you forced me to make a patch storage account, ha ha!

Uh, if you want any hints to “understand” it…the one interesting programmatic thing that occurred to me is that – we have 2 random voltages selecting the 2 channels to swap. One way to swap the voltages is just to get the absolute value of A-B, add that to A, subtract it from B, and voila. (Even though I don’t use an absolute value function – that’s the job PMM is doing).

And I was sure docB’s new TXVI module would be useful. I’m finding a way to use that every day the past week. Cheers!

It does look cool! But it’s randomizing the whole array, no? OP wants just 2 channels swapped and no more.

Ah now I see if he had 80 inputs after a trigger he only wants 2 of the 80 to swap and the rest to stay the same, that’s what he meant with a pair :blush:

WOW. This is incredible, thanks for devising this. I’m impressed.

I hate to say it… but this is a step short of what I was trying to describe.

Your patch swaps a random two channels, but on the next trigger, I want it to swap another random pair from that last state, rather than “resetting” to 1→1, 2→2, etc…

I’m thinking this patch could be modified to sorta “save its state” and randomize step by step, eventually producing an entirely mixed up routing, pair by pair.

Oh, ha, that is certainly harder. Probably just a matter of adding another 18 modules to the right of what I banged together. Sounds simple enough, ‘capture the last state, then make the next change from there’. But it reminds me of the very complicated things I made a few months ago to make random-based arpeggios where a note would not be repeated twice in succession.

We all want random, but juuuust enough random.

One thing I can rule out is just patching the result values from the right side back into the IN of the TXVI module. It doesn’t work like that (similar to how docB’s Faders module doesn’t capture the mod input for storage).

@cotterjk do you ever want an input swapped more than once?

1/a 2/b 3/c 4/d 5/e 6/f

1/c 2/b 3/a 4/d 5/e 6/f

1/f 2/b 3/a 4/d 5/e 6/c

Or do you want all the inputs guaranteed to be swapped after n/2 triggers which would require swapped inputs be excluded from future swapping?

No exclusion necessary. Every input is eligible for a swap, even if it was just moved on the last trigger.

1 Like

Oh yeah, that or docB’s Formula One. This is definitely the solution. With an array data type, it’s relatively straightforward.

1 Like

Yes…flexible solution

I’ve put this thread on my Watch list because it may give me some hints about how to make a pattern like change ringing or method ringing of church bells. Unlike a carillon where the bells remain still and relatively light-weight clappers strike them in any arbitrary order, the bells used in change ringing are swinging back and forth, and their inertia restricts how soon they may be rung again, typically shifting by no more than one place in the sequence (if at all).

See Change ringing - Wikipedia and Method ringing - Wikipedia

Here is a sample sequence, “plain hunt on eight bells”:

1 2 3 4 5 6 7 8- start in rounds (rounds is the descending sequence of bells)
2 1 4 3 6 5 8 7
2 4 1 6 3 8 5 7
4 2 6 1 8 3 7 5
4 6 2 8 1 7 3 5
6 4 8 2 7 1 5 3
6 8 4 7 2 5 1 3
8 6 7 4 5 2 3 1
8 7 6 5 4 3 2 1 – reverse rounds
7 8 5 6 3 4 1 2
7 5 8 3 6 1 4 2
5 7 3 8 1 6 2 4
5 3 7 1 8 2 6 4
3 5 1 7 2 8 4 6
3 1 5 2 7 4 8 6
1 3 2 5 4 7 6 8
1 2 3 4 5 6 7 8 – finish in rounds

Each note swaps places with one of its neighbours, so it’s like a braid pattern.

Here’s another pattern with 6 bells, with two of the strands highlighted:

I have a feeling it’s going to end up being a complicated arrangement of A/B switches, shift registers, S&H, flip-flops, etc. — Oh, I may have an idea. Something to do with two shift registers, one that keeps track of notes “travelling” to the right, another for notes travelling to the left, and they somehow get “interleaved” — Nope. It’s gone now.

Ok, so to get the language perfectly clear:

  • You want N inputs routed to N outputs.
  • The inputs could be both audio and CV.
  • Two different inputs must never be routed to the same output, and two different outputs must never be routed from the same input.
  • On a trigger you want to swap the routing of only two of the inputs to their respective outputs. So if In3 and In5 are selected for swapping this time, and they are routed as In3->Out4 and In5->Out2, then after the trigger the routing is now In3->Out2 and In5->Out4. The other routings are unchanged.
  • On each trigger two random inputs are selected for swapping.

Is that correctly understood?

What you also kind of need to specify is:

  • What are the minum and maximum values of N? Because modules are limited.
  • Since random is sometimes completely random, and sometimes repeats itself, is it acceptable that sometimes one or both of the inputs selected in the previous step is selected for swapping again? Because if the answer is “no” then we’re looking at something more advanced that needs to “remember” and not repeat until N swaps have gone by. Something more sequential but still non-deterministic rather than completely random. Because sometimes random won’t feel random.

See what I mean?

Yes! Change ringing has been a wonderful source of inspiration in exploring permutations in composition. Really delightfully low-tech.

Yes! Thank you. Sorry to keep the language too vague—I’m looking for a general method, and didn’t want to get anyone bogged down in specific modules, routing triggers vs. CV, or exactly how many routings, but I see how that was unhelpful.

  • 4 < N ≤ 8 is plenty, but more is fine too.
  • “Truly” random is fine‚ swapped channels may immediately be reselected. As N increases, “repeated swaps” will get much less likely anyway.

Ok. I’m cooking on something but… sorry to disappoint but using existing modules there’s no way I can get around this being a problem of combinatorial explosion. Anything above N=4 gets rapidly completely out of hand. Would you still like a solution for N=always 4?

To avoid the combinatorial explosion this really needs to be made as a dedicated module, as I see it.

This looks promising, I’ll give it a shot. I think the generative mechanic I’m describing is much more easily programmed than patched :sweat_smile:

2 Likes

Don’t worry about sweating over something custom just for me, unless it’s an interesting dev problem for you! I’m pretty confident this:

– can solve my specific use case.

For other, less picky methods of randomizing inputs to outputs, I think the Roly Pouter method is sufficient.

Here’s the code for a solution in BASICally. Yes, it is ungainly and repetitive, due to some safeguards in the language, and it only goes up to six outputs, because BASICally only has six outputs. ON the other hand, just one module!

A trigger to IN9 will cause two of the assignments to switch.

WHEN start()
  for pos = 1 to 6
    grab[pos] = pos
  next
  ' Initialize the mapping.
  for pos = 1 to 6
    pull_pos = floor(random(1, 7 - pos))
    out_map[pos] = grab[pull_pos]
    ' Put last value from grab[] into the location
    ' we just selected from.
    grab[pull_pos] = grab[7 - pos]
  next
END WHEN

WHEN trigger(IN9)
  switch1 = floor(random(1, 7))
  for dummy = 1 to 2 STEP 0
    switch2 = floor(random(1, 7))
    if switch1 != switch2 THEN
      EXIT FOR
    END IF
  NEXT
  temp = out_map[switch1]
  out_map[switch1] = out_map[switch2]
  out_map[switch2] = temp
END WHEN

ALSO
  out_num = out_map[1]
  if out_num == 1 THEN
    out1 = in1
  elseif out_num == 2 THEN
    out2 = in1
  elseif out_num == 3 THEN
    out3 = in1
  elseif out_num == 4 THEN
    out4 = in1
  elseif out_num == 5 THEN
    out5 = in1
  elseif out_num == 6 THEN
    out6 = in1
  END IF

  out_num = out_map[2]
  if out_num == 1 THEN
    out1 = in2
  elseif out_num == 2 THEN
    out2 = in2
  elseif out_num == 3 THEN
    out3 = in2
  elseif out_num == 4 THEN
    out4 = in2
  elseif out_num == 5 THEN
    out5 = in2
  elseif out_num == 6 THEN
    out6 = in2
  END IF

  out_num = out_map[3]
  if out_num == 1 THEN
    out1 = in3
  elseif out_num == 2 THEN
    out2 = in3
  elseif out_num == 3 THEN
    out3 = in3
  elseif out_num == 4 THEN
    out4 = in3
  elseif out_num == 5 THEN
    out5 = in3
  elseif out_num == 6 THEN
    out6 = in3
  END IF

  out_num = out_map[4]
  if out_num == 1 THEN
    out1 = in4
  elseif out_num == 2 THEN
    out2 = in4
  elseif out_num == 3 THEN
    out3 = in4
  elseif out_num == 4 THEN
    out4 = in4
  elseif out_num == 5 THEN
    out5 = in4
  elseif out_num == 6 THEN
    out6 = in4
  END IF

  out_num = out_map[5]
  if out_num == 1 THEN
    out1 = in5
  elseif out_num == 2 THEN
    out2 = in5
  elseif out_num == 3 THEN
    out3 = in5
  elseif out_num == 4 THEN
    out4 = in5
  elseif out_num == 5 THEN
    out5 = in5
  elseif out_num == 6 THEN
    out6 = in5
  END IF

  out_num = out_map[6]
  if out_num == 1 THEN
    out1 = in6
  elseif out_num == 2 THEN
    out2 = in6
  elseif out_num == 3 THEN
    out3 = in6
  elseif out_num == 4 THEN
    out4 = in6
  elseif out_num == 5 THEN
    out5 = in6
  elseif out_num == 6 THEN
    out6 = in6
  END IF
END ALSO

Here’s a patch that demonstrates it in action.

SwitchTwo.vcv (1.9 KB)

3 Likes

*trig

It works!!! Wow, thanks so much for saving me from brushing up on my BASIC :sweat_smile:

3 Likes