tidalcycles / Tidal

Pattern language
http://tidalcycles.org/
GNU General Public License v3.0
2.22k stars 254 forks source link

timeToRands produces constant sequence if seed is 0 => replace tidal's random mechanism with System.Random? #1067

Open jwaldmann opened 8 months ago

jwaldmann commented 8 months ago
ghci> import Sound.Tidal.UI
ghci> timeToRands 0 10
[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]

this function is used in randrun, which is used in shuffle, so we get (for query arc starting at 0)

ghci> shuffle 4 $ run 4
(0>¼)|0
(¼>½)|1
(½>¾)|2
(¾>1)|3

the reason is that the implementation iterates xorwise which maps 0 to 0 (as all xor/shift generators do).

perhaps xorwise can be replaced with something from System.Random. E.g., think of mkStdGen as timeToIntSeed, then the first value already is "random" (non-zero).

ghci> import System.Random
ghci> uniformR (0,10) (mkStdGen 0)
(8,StdGen {unStdGen = SMGen 16294208416658607535 16294208416658607535})