packages feed

tidal 1.0.2 → 1.0.3

raw patch · 4 files changed

+168/−7 lines, 4 filesdep ~hosc

Dependency ranges changed: hosc

Files

src/Sound/Tidal/Utils.hs view
@@ -26,12 +26,12 @@ removeCommon as [] = (as,[]) removeCommon (a:as) bs | elem a bs = removeCommon as (delete a bs)                        | otherwise = (a:as',bs')-                           where (as',bs') = removeCommon as bs+                      where (as',bs') = removeCommon as bs -readMaybe        :: (Read a) => String -> Maybe a-readMaybe s      =  case [x | (x,t) <- reads s, ("","") <- lex t] of-                         [x] -> Just x-                         _   -> Nothing+readMaybe :: (Read a) => String -> Maybe a+readMaybe s = case [x | (x,t) <- reads s, ("","") <- lex t] of+                   [x] -> Just x+                   _   -> Nothing  {- | like `!!` selects @n@th element from xs, but wraps over at the end of @xs@ 
test/Sound/Tidal/PatternTest.hs view
@@ -13,6 +13,7 @@ import           Sound.Tidal.Control import           Sound.Tidal.Core import           Sound.Tidal.Pattern+import           Sound.Tidal.UI  import qualified Data.Map.Strict     as Map @@ -254,6 +255,22 @@       it "retrieve first element of a tuple, inside first element of a tuple, inside the first of another" $ do          property $ 1 === wholeStart (Event (Arc 1 2) (Arc 3 4) (5 :: Int)) +    describe "wholeStop" $ do+      it "retrieve the end time from the first Arc in an Event" $ do+        property $ 2 === wholeStop (Event (Arc 1 2) (Arc 3 4) (5 :: Int))++    describe "eventPartStart" $ do +      it "retrieve the start time of the second Arc in an Event" $ do +        property $ 3 === eventPartStart (Event (Arc 1 2) (Arc 3 4) (5 :: Int))++    describe "eventPartStop" $ do +      it "retrieve the end time of the second Arc in an Event" $ do +        property $ 4 === eventPartStop (Event (Arc 1 2) (Arc 3 4) (5 :: Int))+    +    describe "eventPart" $ do +      it "retrieve the second Arc in an Event" $ do +        property $ Arc 3 4 === eventPart (Event (Arc 1 2) (Arc 3 4) (5 :: Int))+         describe "eventValue" $ do       it "retrieve the second value from a tuple" $ do          property $ 5 === eventValue (Event (Arc 1 2) (Arc 3 4) (5 :: Int))@@ -420,6 +437,110 @@       it "compare lists of same length with same Events" $ do          let res = compareDefrag [Event (Arc 1 2) (Arc 3 4) (5 :: Int)] [Event (Arc 1 2) (Arc 3 4) (5 :: Int)]         property $ True === res ++    describe "sect" $ do +      it "take two Arcs and return - Arc (max of two starts) (min of two ends)" $ do+        let res = sect (Arc 2.2 3) (Arc 2 2.9)+        property $ Arc 2.2 2.9 == res++    describe "hull" $ do +      it "take two Arcs anre return - Arc (min of two starts) (max of two ends)" $ do+        let res = hull (Arc 2.2 3) (Arc 2 2.9) +        property $ Arc 2 3 == res++    describe "withResultArc" $ do +     it "apply given function to the Arcs" $ do+      let p = withResultArc (+5) (fast "1 2" "3 4" :: Pattern Int) +      let res = queryArc p (Arc 0 1)+      property $ res === fmap toEvent [(((5, 11%2), (5, 11%2)), 3), (((11%2, 23%4), (11%2, 23%4)), 3), (((23%4, 6), (23%4, 6)), 4)]++    describe "applyFIS" $ do +      it "apply Float function when value of type VF" $ do +        let res = applyFIS (+1) (+1) (++ "1") (VF 1)+        property $ (VF $ 2.0) === res+      it "apply Int function when value of type VI" $ do +        let res = applyFIS (+1) (+1) (++ "1") (VI 1)+        property $ (VI $ 2) === res+      it "apply String function when value of type VS" $ do+        let res = applyFIS (+1) (+1) (++ "1") (VS "1")+        property $ (VS $ "11") === res ++    describe "fNum2" $ do+      it "apply Int function for two Int values" $ do +        let res = fNum2 (+) (+) (VI 2) (VI 3)+        property $ (VI $ 5) === res +      it "apply float function when given two float values" $ do +        let res = fNum2 (+) (+) (VF 2) (VF 3)+        property $ (VF $ 5.0) === res +      it "apply float function when one float and one int value given" $ do+        let res = fNum2 (+) (+) (VF 2) (VI 3) +        property $ (VF $ 5.0) === res ++    describe "getI" $ do +      it "get Just value when Int value is supplied" $ do+        let res = getI (VI 3)+        property $ (Just 3) === res+      it "get Nothing if Int value is not supplied" $ do+        let res = getI (VF 3)+        property $ Nothing === res++    describe "getf" $ do +     it "get Just value when Float value is supplied" $ do+       let res = getF (VF 3)+       property $ (Just 3.0) === res+     it "get Nothing if Int value is not supplied" $ do+       let res = getF (VI 3)+       property $ Nothing === res++    describe "getS" $ do +     it "get Just value when String value is supplied" $ do+       let res = getS (VS "Tidal")+       property $ (Just "Tidal") === res+     it "get Nothing if Int value is not supplied" $ do+       let res = getS (VI 3) +       property $ Nothing === res++    describe "filterValues" $ do +     it "remove Events above given threshold" $ do +       let fil = filterValues (<2) $ fastCat [pure 1, pure 2, pure 3] :: Pattern Time +       let res = queryArc fil (Arc 0.5 1.5)+       property $ fmap toEvent [(((1, 4%3), (1, 4%3)), 1%1)] === res++     it "remove Events below given threshold" $ do +       let fil = filterValues (>2) $ fastCat [pure 1, pure 2, pure 3] :: Pattern Time +       let res = queryArc fil (Arc 0.5 1.5)+       property $ fmap toEvent [(((2%3, 1), (2%3, 1)), 3%1)] === res++    describe "filterWhen" $ do +      it "filter below given threshold" $ do +        let fil = filterWhen (<0.5) $ struct "t*4" $ (tri :: Pattern Double) + 1+        let res = queryArc fil (Arc 0.5 1.5)+        property $ [] === res++      it "filter above given threshold" $ do +        let fil = filterWhen (>0.5) $ struct "t*4" $ (tri :: Pattern Double) + 1+        let res = queryArc fil (Arc 0.5 1.5)+        property $ fmap toEvent [(((3%4, 1), (3%4, 1)), 1.5), (((1, 5%4), (1, 5%4)), 1.0), (((5%4, 3%2), (5%4, 3%2)), 1.5)] === res++    describe "compressArc" $ do+      it "return empty if start time is greater than end time" $ do +        let res = queryArc (compressArc (Arc 0.8 0.1) (fast "1 2" "3 4" :: Pattern Time) ) (Arc 1 2)+        property $ [] === res++      it "return empty if start time or end time are greater than 1" $ do +        let res = queryArc (compressArc (Arc 0.1 2) (fast "1 2" "3 4" :: Pattern Time)) (Arc 1 2)+        property $ [] === res++      it "return empty if start or end are less than zero" $ do+        let res = queryArc (compressArc (Arc (-0.8) 0.1) (fast "1 2" "3 4" :: Pattern Time)) (Arc 1 2)+        property $ [] === res+      +      it "otherwise compress difference between start and end values of Arc" $ do+        let p = fast "1 2" "3 4" :: Pattern Time+        let res = queryArc (compressArc (Arc 0.2 0.8) p) (Arc 0 1)+        let expected = fmap toEvent [(((1%5, 1%2), (1%5, 1%2)), 3%1), (((1%2, 13%20), (1%2, 13%20)), 3%1), (((13%20, 4%5), (13%20, 4%5)), 4%1)]+        property $ expected === res+              -- pending "Sound.Tidal.Pattern.eventL" $ do     --  it "succeeds if the first event 'whole' is shorter" $ do
test/Sound/Tidal/UtilsTest.hs view
@@ -14,3 +14,43 @@     describe "delta" $ do       it "subtracts the second element of a tuple from the first" $ do         property $ delta (3,10) === (7 :: Int)+   +    describe "applies function to both elements of tuple" $ do+       let res = mapBoth (+1) (2,5) +       property $ ((3,6) :: (Int, Int)) === res++    describe "apply function to first element of tuple" $ do+       let res = mapFst (+1) (2, 5) +       property $ ((3, 5) :: (Int, Int)) === res++    describe "apply function to second element of tuple" $ do+       let res = mapSnd (+1) (2, 5)+       property $ ((2, 6) :: (Int, Int)) === res+     +    describe "return midpoint between first and second tuple value" $ do+       let res = mid (2, 5)+       property $ (3.5 :: Double) === res++    describe "return of two lists, with unique values to each list" $ do+       let res = removeCommon [1,2,5,7,12,16] [2,3,4,5,15,16]+       property $ (([1,7,12],[3,4,15]) :: ([Int], [Int])) === res++    describe "wrap around indexing" $ do+       let res = (!!!) [1..5] 7+       property $ (3 :: Int) === res++    describe "safe list indexing" $ do +       let res = nth 2 ([] :: [Int])+       property $ Nothing === res++    describe "list accumulation with given list elements" $ do+       let res = accumulate ([1..5] :: [Int])+       property $ [1,3,6,10,15] === res ++    describe "index elements in list" $ do+       let res = enumerate ['a', 'b', 'c']+       property $ [(0,'a'),(1,'b'),(2,'c')] === res++    describe "split list by given pred" $ do +       let res = wordsBy (== ':') "bd:3"+       property $ ["bd", "3"] === res
tidal.cabal view
@@ -1,5 +1,5 @@ name:                tidal-version:             1.0.2+version:             1.0.3 synopsis:            Pattern language for improvised music -- description: homepage:            http://tidalcycles.org/@@ -52,7 +52,7 @@     , containers     , hashable     , colour-    , hosc >= 0.16+    , hosc == 0.16     , text     , random     , time