diff --git a/tidal-core/src/Sound/Tidal/UI.hs b/tidal-core/src/Sound/Tidal/UI.hs index 58b27f19..73cb1ffb 100644 --- a/tidal-core/src/Sound/Tidal/UI.hs +++ b/tidal-core/src/Sound/Tidal/UI.hs @@ -95,7 +95,9 @@ intSeedToRand :: (Fractional a) => Int -> a intSeedToRand = (/ 536870912) . realToFrac . (`mod` 536870912) timeToRand :: (RealFrac a, Fractional b) => a -> b -timeToRand = intSeedToRand . timeToIntSeed +-- Otherwise the value would be 0 at time 0.. Let's start in the middle. +timeToRand 0 = 0.5 +timeToRand t = intSeedToRand $ timeToIntSeed t timeToRands :: (RealFrac a, Fractional b) => a -> Int -> [b] timeToRands 0 n = timeToRands' (timeToIntSeed (9999999 :: Double)) n diff --git a/tidal-core/test/Sound/Tidal/UITest.hs b/tidal-core/test/Sound/Tidal/UITest.hs index dd9033af..7d9264b5 100644 --- a/tidal-core/test/Sound/Tidal/UITest.hs +++ b/tidal-core/test/Sound/Tidal/UITest.hs @@ -105,7 +105,7 @@ run = describe "rand" $ do it "it generates a (pseudo-)random number between 0 and 1 at the start of a cycle" $ - (queryArc rand (Arc 0 0)) `shouldBe` [Event (Context []) Nothing (Arc 0 0) (0 :: Float)] + (queryArc rand (Arc 0 0)) `shouldBe` [Event (Context []) Nothing (Arc 0 0) (0.5 :: Float)] it "it generates a (pseudo-)random number between 0 and 1 at 1/4 of a cycle" $ (queryArc rand (Arc 0.25 0.25)) `shouldBe` [Event (Context []) Nothing (Arc 0.25 0.25) (0.6295689214020967 :: Float)] @@ -116,19 +116,19 @@ run = describe "irand" $ do -- it "generates a (pseudo-random) integer between zero & i" $ do it "at the start of a cycle" $ - (queryArc (irand 10) (Arc 0 0)) `shouldBe` [Event (Context []) Nothing (Arc 0 0) (0 :: Int)] + (queryArc (irand 10) (Arc 0 0)) `shouldBe` [Event (Context []) Nothing (Arc 0 0) (5 :: Int)] it "at 1/4 of a cycle" $ (queryArc (irand 10) (Arc 0.25 0.25)) `shouldBe` [Event (Context []) Nothing (Arc 0.25 0.25) (6 :: Int)] it "is patternable" $ (queryArc (irand "10 2") (Arc 0 1)) - `shouldBe` [ Event (Context [((1, 1), (3, 1))]) Nothing (Arc 0 0.5) (0 :: Int), + `shouldBe` [ Event (Context [((1, 1), (3, 1))]) Nothing (Arc 0 0.5) (5 :: Int), Event (Context [((4, 1), (5, 1))]) Nothing (Arc 0.5 1) (0 :: Int) ] describe "normal" $ do it "produces values within [0,1] in a bell curve at different parts of a cycle" $ do queryArc normal (Arc 0 0.1) - `shouldBe` [Event (Context []) Nothing (Arc 0 0.1) (0.26202741871417984 :: Double)] + `shouldBe` [Event (Context []) Nothing (Arc 0 0.1) (0.42461738824387246 :: Double)] queryArc normal (Arc 0.25 0.25) `shouldBe` [Event (Context []) Nothing (Arc 0.25 0.25) (0.5 :: Double)] queryArc normal (Arc 0.75 0.75)