First time here? Check out the FAQ!

What is the best way to create independent, random, white noise sources?

0 votes

The Noise Sound has an InitialState parameter which is effectively its seed.

Two Noise Sounds with the same InitialState create exactly the same output. If I want all my random noise generators to be different from each other (even in multiple instances of an encapsulated Sound) then I'll want different random values in the InitialState field of every Noise Sound. 

What's the best way of generating unique random seeds for every Noise Sound?

I thought it might be to put the following in the InitialState field:

Random new next

but that doesn't work. It seems to generate the same seed for each Noise Sound. Number nextUniqueNumber inverse didn't work either. And I can't use !Random in a compile-time field like InitialState. 
Random newForKymaWithSeed: just defers the issue of creating a unique seed. 

asked Jan 13 in Capytalk & Smalltalk by alan-jackson (Virtuoso) (15,680 points)
edited Jan 13 by alan-jackson

1 Answer

0 votes

The common subexpression eliminator is probably identifying all of your Random new next expressions as being the same expression. You could try making each unique, for example:

Random new next * ?VoiceNumber

answered Jan 13 by ssc (Savant) (117,100 points)
That worked. And here's a freaky thing, while trying this out I put just "Random new next" in two Noise Sounds, but one of the expressions had a trailing space. The trailing space was enough to make the two Noises different. When I deleted the space they became the same. I didn't think whitespace would make a difference.