In particular, is there a patch associated with the July 5 YouTube by bimini road called "Creating a Self-Playing Patch in Audulus".

I searched and was not able to find a patch to go with the excellent tutorial.

Thank you very much for any help.]]>

Introduction:

A random non-repeating sequencer generates a fixed set of random numbers in a random order. It's useful for sequencing because it's possible for a random sequencer to a string of sequences that are the exact same notes in a row. This method on the other hand ensures motion on every single note and within the entire sequence.

This may seem an easy task at first, but when you examine it a little closer, it becomes a sticky problem, especially in Audulus, which doesn't have an obvious way to iterate through an array. It's a fascinating problem though, and one that gives you a deep insight into why computers are so incredible for tasks like this.

This is a much improved version of the random non-repeating sequencer I made a while back. It has fewer sample and holds and a much less convoluted method. Below is a CPU% comparison between the old (top) and new (bottom) versions.

How it works:

1. A random number is generated and multiplied by n-0.001, where n = number of samples. In this case, 4.

2. This number is used to control a multiplexer, which acts as the initial state of our unshuffled array. The number chosen is the first step in the sequence. In this case, one of the numbers [0, 1/3, 2/3, 1] is chosen.

3. The next stage checks the numbers in the array against the chosen number. If the number is chosen, it is turned into a null (a zero).

4. After that, the set of numbers are sorted using a bubble sort algorithm. This compares each number and determines which is higher and which is lower. This iterates a few times until all incoming sequences are perfectly sorted every time.

5. The null (0) value obtained by step 3 is discarded and the random number generated in step 1 is multiplied by n-1.001 and chooses one of the remaining 3 numbers.

6. Steps 3-5 are repeated until a final number remains unchosen, which is switched in position on a new Mux8 with the previous value, and chosen with the same n-2.001 value.

ArrayX = Chosen [Remaining]

Array0 = [0, 1/3, 2/3, 1]

Array1 = 1/3 [0, 2/3, 1] {2}

Array2 = 1/3, 1, [0, 2/3]

Array3 = 1/3, 1, 0 [2/3]

Array 4 = 1/3, 1, 0, 2/3

The seed of the Random node inside the sequencer must be changed if multiple sequencers are being used at the same tempo and reset rate. If the sequencers are not being played at the same time, or resetting at the same moment, then it's fine to leave the seed the same.

Keep in mind: when changing seeds, multiple seeds with values 0,1,2,3... will be just as random as 4810, 2795, 1972,... - so no need to go nuts with seed value changes.

The effect of *not* changing the seed will only become apparent when you open the patch after closing it (when the Random node resets from the seed value), so just be aware of that.

Randomness and the n! (n factorial):

The formula for determining the number of possible random combinations for a given number is n! (n factorial). This translates to n*n-1*n-2*n-3...n-n+1. In 4's case, that's 4*3*2*1, or 24. That means there are 24 different patterns you'll hear over the course of using the sequencer.

Now, of course, the *proper* way to do this random sequence generator in Audulus is to use a lookup table, or a Mux24 that contains all the possibilities of arrangements. I will actually make a version of that as well, but this is an important small proof-of-concept that explains the concept in a way that makes it easy to expand to more steps.

The reason we don't use multiplexer-based lookup tables for larger factorials is the number of possibilities explodes quickly.*

If we want an 8 step sequencer, that's 8! = 40,320

16 step sequencer: 16! ~ 2.1*10^13

32 step sequencer : 32! ~2.6*10^35

It would be possible to make a more efficient 8 step sequencer in Audulus 4 when we have the data node, which can treat a .wav file as a lookup table. 40,320 samples is less than 1 second of audio.

However, this method also *quickly* becomes useless. A 16 step sequencer would require nearly 126,000 HOURS (14 years!) of audio to cover all its possibilities! A 32 step sequencer would need 1.4^23 YEARS of audio - many times the AGE of the UNIVERSE!

How it sounds:

Assuming 4/4 time signature and BPM = 120;

1 bar of 120 BPM 4/4 time = 8 seconds;

A 4 step random non-repeating (RNR) sequencer randomized every 16 beats will take on average** 24 bars, or 192 seconds (3.2 minutes) to repeat an identical sequence. In reality, you'll hear sequences repeat more often than that, because the pure randomness only appears over large numbers.

An 8 step RNR sequencer randomized every 16 beats will take on average 40,320 bars, or 89.6 hours to repeat an identical sequence. At this level, you can be almost certain that given an average 3m30s song, you will not hear the same sequence twice.

A 16 step RNR sequencer randomized every 16 beats will take on average 2.1*10^13 bars, or ~5.3 million years to repeat an identical sequence.

A 32 step RNR sequencer randomized every 32 beats (assuming 32nd notes here) will take on average 2.6*10^35 bars, or ~6.6*10^28 years to repeat an identical sequence. To put that into perspective, this is 5 quintillion times the age of the universe, and interestingly, almost exactly as long as the lifespan of electrons as detailed in this article (spooky coincidence):

https://gizmodo.com/electron-lifespan-is-at-least-5-quintillion-times-the-1747606990

Thoughts on scaling:

"Non-repeating" is of course subjective here, as the 0-1 output of the sequencer can be translated into a range that plays only one, two, or three notes when quantized, rather than the maximal 4 notes.

The signal this 4 step sequencer creates must be at least 0-(3.99/12), or 0~1/3 wide to ensure that at least 4 semi tones are available to play. The formula for chromatic non-randomness is sequence*(n-0.001/12), when sequence<=12 steps.<br />

Ranges smaller than the one provided by the formula might still move, but will not be non-repeating.

This is of course an artistic choice for you - you can scale the width of the sequence down in one part, and expand it in another. You can use a Mapper node to bias the randomness exponentially, logarithmically, or in a U or n shape - all up to you.

This is just to point out the "min spec" for true non-repetition.

Conclusion:

So there you have it. Although computers aren't exactly perfect at creating randomness for cryptography purposes, they are more than adequate for musical randomness.

I will be creating a lookup table version of this 4 step RNR sequencer, as well as an 8 and 16 step version of the algorithmically generated one. I might wait until I'm snowed in to do the 32 step version ;)

Further Reading:

This is the shuffling algorithm I used - from what I understand it is the superior shuffle algorithm that creates provable true randomness.

https://en.wikipedia.org/wiki/Fisherâ€“Yates_shuffle

This is the sorting algorithm I used - it's not the most efficient, but it is the easiest to implement in Audulus

https://en.wikipedia.org/wiki/Bubble_sort

Looking more closely it might not be exactly a bubble sort, but it's a similar principle, with the sorts happening in parallel with one another. Perhaps there is a more correct name of this algorithm I used, if so, leave a comment below and I'll amend it.

Notes:

*- this could be techinically feasible using @jjthrash's methods of altering Audulus JSON code with an iterative algorithm, but it would be terribly CPU inefficient compared to the shuffling/sorting algorithmic method. You would need 5,040 Mux8 nodes, not to mention all of the logic in between to combine them!

** - You can think of the appearance of randomness here like flipping a coin - it's rare to flip HTHTHTHT...over and over. More likely you'll get HHHTTHTHHTHTTTHHTHTHHHHHTTTT...but over time the number of heads and tails approaches a 50-50 distribution. This means it's very rare to, on a first listen through, have a totally un-repeated set of sequences over the course of the given period.]]>