Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jwaldmann opened this issue Jan 21, 2024 · 0 comments

Comments

@jwaldmann
Copy link
Contributor

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})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant