Forum

One button and random sounds

More
#608 by ericleven
ericleven replied the topic: One button and random sounds
Ah yes. My brain has been spoiled by higher level programming and I never thought to organize 4 bit registers that way. Makes sense!

Things are up and running now, and I'm testing and trying to make sure the code works and is properly "random". I know that computers usually aren't "technically" random, and patterns that humans see are often coincidences, but I wanted to share some data to see if it means anything:

I have 63 sound files; I ran the program 165 times (hardly enough to get random sampling, to be sure).
That said: sound #51 was called 11 times (6%); not unreasonable.

However, after sound #51 was called, sound #62 was called 7 times; and sound #9 was called 4 times. That means there's 63% chance sound #51 is followed by #62, and a 36% chance #51 is followed by #9. That SEEMS not random, no? There might be other situations like this, but this was the one that jumped out at me. Coincidence?

As a professional electronics sound guy, do you prefer the purely random method I'm using? Or the predetermined "random" order you described earlier?

-eric

Please Log in or Create an account to join the conversation.

More
#609 by foxonix
foxonix replied the topic: One button and random sounds
Yeah, it's hard to say how "random" the random function really is. Honestly, we don't have much insight into how the chip generates the random number. If you had a small number of paths then using a pseudo-random sequence might be a good idea. For example, if you were only calling five different paths, then you could step through them in a pre-determined pattern. Like:

button:
  & M0=M0+1
  & M0:[path0 path4 path2 path1 path3 path4 path0 path2 path3 path1] M0=15 button

Stepping through the five paths two different ways helps to make the whole sequence longer. You could even do this a third time with a different order to make the sequence even longer still. The M0=15 after the array means that when M0 increments and falls outside the array M0 will be set to 15 and then button: will be called. Then when M0 increments it will roll over to zero and you'll start at the beginning of the array again. Clever!

Since you have such a large number of paths in your project, you're probably better off NOT setting up a pseudo-random sequence. It would be a fair amount of work, so you can probably stick with using a random variable. To increase the apparent randomness, you could try using a combination of a random variable and a stepped sequence, like so:

; use a random variable to randomly select one of nine arrays
button:
  & delay(.02)
  & rand0:[array0 array1 array2 array3 array4 array5 array6 array7 array8]

; then use a counter to step through and call one of seven paths
array0:
  & M0=M0+1
  & M0:[path0 path1 path2 path3 path4 path5 path6] M0=15 array0

array1:
  & M0=M0+1
  & M0:[path7 path8 path9 path10 path11 path12 path13] M0=15 array1

This way, even if the same random number is generated twice in a row, you're still guranteed that the same path will never play twice in a row. If you really wanted to go whole hog, you could assign each array its own counter, so array0 could use M0, array1 could use M1, and so on. I'm not sure how much better this is in the long run, but it would be worth trying.

Either way, it sounds like you're making awesome progress with your project!

Foxonix - make your ideas heard.
@foxonixdev
The following user(s) said Thank You: ericleven

Please Log in or Create an account to join the conversation.

Time to create page: 0.018 seconds