diff --git a/test/Sound/Tidal/ArcTest.hs b/old/test/Sound/Tidal/ArcTest.hs
similarity index 100%
rename from test/Sound/Tidal/ArcTest.hs
rename to old/test/Sound/Tidal/ArcTest.hs
diff --git a/test/Sound/Tidal/ChordsTest.hs b/old/test/Sound/Tidal/ChordsTest.hs
similarity index 100%
rename from test/Sound/Tidal/ChordsTest.hs
rename to old/test/Sound/Tidal/ChordsTest.hs
diff --git a/test/Sound/Tidal/EventTest.hs b/old/test/Sound/Tidal/EventTest.hs
similarity index 100%
rename from test/Sound/Tidal/EventTest.hs
rename to old/test/Sound/Tidal/EventTest.hs
diff --git a/test/Sound/Tidal/ExceptionsTest.hs b/old/test/Sound/Tidal/ExceptionsTest.hs
similarity index 100%
rename from test/Sound/Tidal/ExceptionsTest.hs
rename to old/test/Sound/Tidal/ExceptionsTest.hs
diff --git a/test/Sound/Tidal/ParamsTest.hs b/old/test/Sound/Tidal/ParamsTest.hs
similarity index 100%
rename from test/Sound/Tidal/ParamsTest.hs
rename to old/test/Sound/Tidal/ParamsTest.hs
diff --git a/test/Sound/Tidal/old/ControlTest.hs b/old/test/Sound/Tidal/old/ControlTest.hs
similarity index 100%
rename from test/Sound/Tidal/old/ControlTest.hs
rename to old/test/Sound/Tidal/old/ControlTest.hs
diff --git a/test/Sound/Tidal/old/CoreTest.hs b/old/test/Sound/Tidal/old/CoreTest.hs
similarity index 100%
rename from test/Sound/Tidal/old/CoreTest.hs
rename to old/test/Sound/Tidal/old/CoreTest.hs
diff --git a/test/Sound/Tidal/old/PatternTest.hs b/old/test/Sound/Tidal/old/PatternTest.hs
similarity index 100%
rename from test/Sound/Tidal/old/PatternTest.hs
rename to old/test/Sound/Tidal/old/PatternTest.hs
diff --git a/test/Sound/Tidal/old/UITest.hs b/old/test/Sound/Tidal/old/UITest.hs
similarity index 100%
rename from test/Sound/Tidal/old/UITest.hs
rename to old/test/Sound/Tidal/old/UITest.hs
diff --git a/test/Test.hs b/old/test/Test.hs
similarity index 100%
rename from test/Test.hs
rename to old/test/Test.hs
diff --git a/test/TestUtils.hs b/old/test/TestUtils.hs
similarity index 100%
rename from test/TestUtils.hs
rename to old/test/TestUtils.hs
diff --git a/test/dontcrash.hs b/old/test/dontcrash.hs
similarity index 100%
rename from test/dontcrash.hs
rename to old/test/dontcrash.hs
diff --git a/tidal-core/src/Sound/Tidal/Bjorklund.hs b/tidal-core/src/Sound/Tidal/Bjorklund.hs
index a5c2420de..ed15960ac 100644
--- a/tidal-core/src/Sound/Tidal/Bjorklund.hs
+++ b/tidal-core/src/Sound/Tidal/Bjorklund.hs
@@ -63,19 +63,19 @@ bjorklundOff :: (Int, Int, Int) -> [Bool]
bjorklundOff (i,j,k) = take j $ drop (k `mod` j) $ cycle $ bjorklundNeg (i,j)
_euclid :: Pattern p => Int -> Int -> p Bool
-_euclid n k = cat $ map pure $ bjorklundNeg (n,k)
+_euclid n k = unitcat $ map pure $ bjorklundNeg (n,k)
euclid :: Pattern p => p Int -> p Int -> p Bool
-euclid = patternify_P_P _euclid
+euclid a b = patternify_P_P _euclid (outer a) (outer b)
_euclidTo :: Pattern p => Int -> Int -> p a -> p a
-_euclidTo n k pat = fastcat $ map (bool pat silence) $ bjorklundNeg (n,k)
+_euclidTo n k pat = unitcat $ map (bool pat silence) $ bjorklundNeg (n,k)
euclidTo :: Pattern p => p Int -> p Int -> p a -> p a
euclidTo = patternify_P_P_n _euclidTo
_euclidOff :: Pattern p => Int -> Int -> Int -> p Bool
-_euclidOff i j k = cat $ map pure $ bjorklundOff (i,j,k)
+_euclidOff i j k = unitcat $ map pure $ bjorklundOff (i,j,k)
euclidOff :: Pattern p => p Int -> p Int -> p Int -> p Bool
euclidOff = patternify_P_P_P _euclidOff
@@ -84,7 +84,7 @@ eoff :: Pattern p => p Int -> p Int -> p Int -> p Bool
eoff = euclidOff
_euclidOffTo :: Pattern p => Int -> Int -> Int -> p a -> p a
-_euclidOffTo i j k pat = fastcat $ map (bool pat silence) $ bjorklundOff (i,j,k)
+_euclidOffTo i j k pat = unitcat $ map (bool pat silence) $ bjorklundOff (i,j,k)
euclidOffTo :: Pattern p => p Int -> p Int -> p Int -> p a -> p a
euclidOffTo = patternify_P_P_P_n _euclidOffTo
diff --git a/tidal-core/src/Sound/Tidal/Compose.hs b/tidal-core/src/Sound/Tidal/Compose.hs
index e6d5e6b0b..39d4e027a 100644
--- a/tidal-core/src/Sound/Tidal/Compose.hs
+++ b/tidal-core/src/Sound/Tidal/Compose.hs
@@ -1,4 +1,6 @@
-{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE IncoherentInstances #-}
+{-# LANGUAGE MonoLocalBinds #-}
-- (c) Alex McLean and contributors 2023
-- Shared under the terms of the GNU Public License v3.0
@@ -6,9 +8,11 @@
module Sound.Tidal.Compose where
import Control.Applicative (Applicative (..))
+import Data.Bits
+import Data.Bool (bool)
import qualified Data.Map.Strict as Map
import Prelude hiding (Applicative (..))
-import Sound.Tidal.Pattern (flexBind)
+import Sound.Tidal.Pattern (filterJusts, flexBind)
import Sound.Tidal.Types
-- ************************************************************ --
@@ -28,5 +32,89 @@ instance {-# OVERLAPPING #-} Unionable ValueMap where
liftP2 :: Pattern p => (a -> b -> c) -> (p a -> p b -> p c)
liftP2 op apat bpat = apat `flexBind` \a -> op a <$> bpat
+set, keep :: Pattern p => p a -> p a -> p a
+set = liftA2 (flip union)
+keep = liftA2 union
+
+keepif :: Pattern p => p a -> p Bool -> p a
+keepif pata patb = filterJusts $ liftA2 (\a b -> bool Nothing (Just a) b) pata patb
+
+_add, _sub, _mul :: (Pattern p, Num a) => p a -> p a -> p a
+_add = liftA2 (Prelude.+)
+_sub = liftA2 (Prelude.-)
+_mul = liftA2 (Prelude.*)
+
+_div :: (Pattern p, Fractional a) => p a -> p a -> p a
+_div = liftA2 (Prelude./)
+
+_mod, _pow :: (Pattern p, Integral a) => p a -> p a -> p a
+_mod = liftA2 mod
+_pow = liftA2 (Prelude.^)
+
+_powf :: (Pattern p, Floating a) => p a -> p a -> p a
+_powf = liftA2 (Prelude.**)
+
+_concat :: Pattern p => p String -> p String -> p String
+_concat = liftA2 (Prelude.++)
+
+_band, _bor, _bxor :: (Pattern p, Bits a) => p a -> p a -> p a
+_band = liftA2 (.&.)
+_bor = liftA2 (.|.)
+_bxor = liftA2 (.^.)
+
+_bshiftl, _bshiftr :: (Pattern p, Bits a) => p a -> p Int -> p a
+_bshiftl = liftA2 (.<<.)
+_bshiftr = liftA2 (.>>.)
+
+_lt, _gt, _lte, _gte :: (Pattern p, Ord a) => p a -> p a -> p Bool
+_lt = liftA2 (Prelude.<)
+_gt = liftA2 (Prelude.>)
+_lte = liftA2 (Prelude.<=)
+_gte = liftA2 (Prelude.>=)
+
+_eq, _ne :: (Pattern p, Eq a) => p a -> p a -> p Bool
+_eq = liftA2 (Prelude.==)
+_ne = liftA2 (Prelude./=)
+
+_and, _or :: Pattern p => p Bool -> p Bool -> p Bool
+_and = liftA2 (Prelude.&&)
+_or = liftA2 (Prelude.||)
+
(#) :: (Pattern p, Unionable a) => p a -> p a -> p a
(#) = liftA2 union
+
+(|=|), (|=), (=|) :: Pattern p => p a -> p a -> p a
+a |=| b = (mix a) # b
+a |= b = (inner a) # b
+a =| b = (outer a) # b
+
+(|+), (+|), (|+|) :: (Num (p a), Pattern p) => p a -> p a -> p a
+a |+ b = (inner a) + b
+a +| b = (outer a) + b
+a |+| b = (mix a) + b
+
+struct :: (Pattern p, Unionable a) => p Bool -> p a -> p a
+struct patbool pat = (outer pat) `keepif` patbool
+
+structAll :: (Pattern p, Unionable a) => p a -> p a -> p a
+structAll pata patb = (outer patb) `keep` pata
+
+mask :: (Pattern p, Unionable a) => p Bool -> p a -> p a
+mask patbool pat = (inner pat) `keepif` patbool
+
+maskAll :: (Pattern p, Unionable a) => p a -> p a -> p a
+maskAll pata patb = (inner patb) `keep` pata
+
+{-
+reset :: (Unionable a) => Signal Bool -> Signal a -> Signal a
+reset = flip keepifTrig
+
+resetAll :: (Unionable a) => Signal a -> Signal a -> Signal a
+resetAll = flip keepTrig
+
+restart :: (Unionable a) => Signal Bool -> Signal a -> Signal a
+restart = flip keepifTrigzero
+
+restartAll :: (Unionable a) => Signal a -> Signal a -> Signal a
+restartAll = flip keepTrigzero
+-}
diff --git a/tidal-core/src/Sound/Tidal/InstanceHacks.hs b/tidal-core/src/Sound/Tidal/InstanceHacks.hs
index 4001a592f..15c132a42 100644
--- a/tidal-core/src/Sound/Tidal/InstanceHacks.hs
+++ b/tidal-core/src/Sound/Tidal/InstanceHacks.hs
@@ -11,6 +11,7 @@ import qualified Data.Map.Strict as Map
-- import Sound.Tidal.Compose (liftA2)
import Sound.Tidal.Sequence ()
import Sound.Tidal.Signal ()
+import Sound.Tidal.Span (withSpanTime)
import Sound.Tidal.Types
import Sound.Tidal.Value
diff --git a/tidal-core/src/Sound/Tidal/Pattern.hs b/tidal-core/src/Sound/Tidal/Pattern.hs
index 3c094d746..5ba761c21 100644
--- a/tidal-core/src/Sound/Tidal/Pattern.hs
+++ b/tidal-core/src/Sound/Tidal/Pattern.hs
@@ -3,6 +3,9 @@
module Sound.Tidal.Pattern where
+import qualified Data.Bits
+import Data.Char (ord)
+import Data.Maybe (fromJust, isJust)
import Data.Ratio
import Prelude hiding ((*>), (<*))
import Sound.Tidal.Types
@@ -57,6 +60,9 @@ infixl 4 <*, *>
flexBind :: Pattern p => p b -> (b -> p c) -> p c
flexBind a b = (patBind a) a b
+filterJusts :: Pattern p => p (Maybe a) -> p a
+filterJusts = fmap fromJust . filterValues isJust
+
-- ************************************************************ --
-- Transformations common to Signals and Sequences
@@ -311,6 +317,76 @@ _scan n = slowcat $ map _run [1 .. n]
scan :: (Pattern p, Enum a, Num a) => p a -> p a
scan = (>>= _run)
+__binary :: Data.Bits.Bits b => Int -> b -> [Bool]
+__binary n num = map (Data.Bits.testBit num) $ reverse [0 .. n-1]
+
+_binary :: (Pattern p, Data.Bits.Bits b) => Int -> b -> p Bool
+_binary n num = fastFromList $ __binary n num
+
+_binaryN :: Pattern p => Int -> p Int -> p Bool
+_binaryN n p = squeezeJoin $ _binary n <$> p
+
+binaryN :: Pattern p => p Int -> p Int -> p Bool
+binaryN n p = patternify_P_n _binaryN n p
+
+binary :: Pattern p => p Int -> p Bool
+binary = binaryN (pure 8)
+
+ascii :: Pattern p => p String -> p Bool
+ascii p = squeezeJoin $ fastFromList . concatMap (__binary 8 . ord) <$> p
+
+-- | For specifying a boolean pattern according to a list of offsets
+-- (aka inter-onset intervals). For example `necklace 12 [4,2]` is
+-- the same as "t f f f t f t f f f t f". That is, 12 steps per cycle,
+-- with true values alternating between every 4 and every 2 steps.
+necklace :: Pattern p => Rational -> [Int] -> p Bool
+necklace perCycle xs = _slow (toRational (sum xs) / perCycle) $ fastFromList $ list xs
+ where list :: [Int] -> [Bool]
+ list [] = []
+ list (x:xs') = (True : replicate (x-1) False) ++ list xs'
+
+
+{-|
+ Treats the given signal @p@ as having @n@ chunks, and applies the function @f@ to one of those sections per cycle.
+ Running:
+ - from left to right if chunk number is positive
+ - from right to left if chunk number is negative
+
+ @
+ d1 $ chunk 4 (fast 4) $ sound "cp sn arpy [mt lt]"
+ @
+-}
+chunk :: Pattern p => p Int -> (p b -> p b) -> p b -> p b
+chunk npat f p = innerJoin $ (\n -> _chunk n f p) <$> npat
+
+_chunk :: Pattern p => Int -> (p b -> p b) -> p b -> p b
+_chunk n f p | n == 0 = p
+ | n > 0 = when (_iterBack n $ fastcat (map pure $ True:replicate (n-1) False)) f p
+ | otherwise = when (_iter (abs n) $ fastcat (map pure $ replicate (abs n-1) False ++ [True])) f p
+
+{-
+ snowball |
+ snowball takes a function that can combine patterns (like '+'),
+ a function that transforms a pattern (like 'slow'),
+ a depth, and a starting pattern,
+ it will then transform the pattern and combine it with the last transformation until the depth is reached
+ this is like putting an effect (like a filter) in the feedback of a delay line
+ each echo is more effected
+ d1 $ note (scale "hexDorian" $ snowball (+) (slow 2 . rev) 8 "0 ~ . -1 . 5 3 4 . ~ -2") # s "gtr"
+-}
+snowball :: Pattern p => Int -> (p a -> p a -> p a) -> (p a -> p a) -> p a -> p a
+snowball depth combinationFunction f signal = cat $ take depth $ scanl combinationFunction signal $ drop 1 $ iterate f signal
+
+{- @soak@ |
+ applies a function to a signal and cats the resulting signal,
+ then continues applying the function until the depth is reached
+ this can be used to create a signal that wanders away from
+ the original signal by continually adding random numbers
+ d1 $ note (scale "hexDorian" mutateBy (+ (range -1 1 $ irand 2)) 8 $ "0 1 . 2 3 4") # s "gtr"
+-}
+soak :: Pattern p => Int -> (p a -> p a) -> p a -> p a
+soak depth f signal = cat $ take depth $ iterate f signal
+
-- ************************************************************ --
-- Metadata utils
diff --git a/tidal-core/src/Sound/Tidal/Scales.hs b/tidal-core/src/Sound/Tidal/Scales.hs
new file mode 100644
index 000000000..a90731ce4
--- /dev/null
+++ b/tidal-core/src/Sound/Tidal/Scales.hs
@@ -0,0 +1,295 @@
+module Sound.Tidal.Scales (scale, scaleList, scaleTable, getScale) where
+
+{-
+ Scale.hs - Scales for TidalCycles
+ Copyright (C) 2020, lvm (Mauro) and contributors
+
+ This library is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this library. If not, see .
+-}
+
+import Data.Maybe
+import Prelude hiding ((*>), (<*))
+import Sound.Tidal.Pattern ((<*))
+import Sound.Tidal.Signal ()
+import Sound.Tidal.Types
+import Sound.Tidal.Utils
+
+-- five notes scales
+minPent :: Fractional a => [a]
+minPent = [0,3,5,7,10]
+majPent :: Fractional a => [a]
+majPent = [0,2,4,7,9]
+
+-- another mode of major pentatonic
+ritusen :: Fractional a => [a]
+ritusen = [0,2,5,7,9]
+
+-- another mode of major pentatonic
+egyptian :: Fractional a => [a]
+egyptian = [0,2,5,7,10]
+
+--
+kumai :: Fractional a => [a]
+kumai = [0,2,3,7,9]
+hirajoshi :: Fractional a => [a]
+hirajoshi = [0,2,3,7,8]
+iwato :: Fractional a => [a]
+iwato = [0,1,5,6,10]
+chinese :: Fractional a => [a]
+chinese = [0,4,6,7,11]
+indian :: Fractional a => [a]
+indian = [0,4,5,7,10]
+pelog :: Fractional a => [a]
+pelog = [0,1,3,7,8]
+
+--
+prometheus :: Fractional a => [a]
+prometheus = [0,2,4,6,11]
+scriabin :: Fractional a => [a]
+scriabin = [0,1,4,7,9]
+
+-- han chinese pentatonic scales
+gong :: Fractional a => [a]
+gong = [0,2,4,7,9]
+shang :: Fractional a => [a]
+shang = [0,2,5,7,10]
+jiao :: Fractional a => [a]
+jiao = [0,3,5,8,10]
+zhi :: Fractional a => [a]
+zhi = [0,2,5,7,9]
+yu :: Fractional a => [a]
+yu = [0,3,5,7,10]
+
+-- 6 note scales
+whole' :: Fractional a => [a]
+whole' = [0,2,4,6,8,10]
+augmented :: Fractional a => [a]
+augmented = [0,3,4,7,8,11]
+augmented2 :: Fractional a => [a]
+augmented2 = [0,1,4,5,8,9]
+
+-- hexatonic modes with no tritone
+hexMajor7 :: Fractional a => [a]
+hexMajor7 = [0,2,4,7,9,11]
+hexDorian :: Fractional a => [a]
+hexDorian = [0,2,3,5,7,10]
+hexPhrygian :: Fractional a => [a]
+hexPhrygian = [0,1,3,5,8,10]
+hexSus :: Fractional a => [a]
+hexSus = [0,2,5,7,9,10]
+hexMajor6 :: Fractional a => [a]
+hexMajor6 = [0,2,4,5,7,9]
+hexAeolian :: Fractional a => [a]
+hexAeolian = [0,3,5,7,8,10]
+
+-- 7 note scales
+major :: Fractional a => [a]
+major = [0,2,4,5,7,9,11]
+ionian :: Fractional a => [a]
+ionian = [0,2,4,5,7,9,11]
+dorian :: Fractional a => [a]
+dorian = [0,2,3,5,7,9,10]
+phrygian :: Fractional a => [a]
+phrygian = [0,1,3,5,7,8,10]
+lydian :: Fractional a => [a]
+lydian = [0,2,4,6,7,9,11]
+mixolydian :: Fractional a => [a]
+mixolydian = [0,2,4,5,7,9,10]
+aeolian :: Fractional a => [a]
+aeolian = [0,2,3,5,7,8,10]
+minor :: Fractional a => [a]
+minor = [0,2,3,5,7,8,10]
+locrian :: Fractional a => [a]
+locrian = [0,1,3,5,6,8,10]
+harmonicMinor :: Fractional a => [a]
+harmonicMinor = [0,2,3,5,7,8,11]
+harmonicMajor :: Fractional a => [a]
+harmonicMajor = [0,2,4,5,7,8,11]
+melodicMinor :: Fractional a => [a]
+melodicMinor = [0,2,3,5,7,9,11]
+melodicMinorDesc :: Fractional a => [a]
+melodicMinorDesc = [0,2,3,5,7,8,10]
+melodicMajor :: Fractional a => [a]
+melodicMajor = [0,2,4,5,7,8,10]
+bartok :: Fractional a => [a]
+bartok = melodicMajor
+hindu :: Fractional a => [a]
+hindu = melodicMajor
+
+-- raga modes
+todi :: Fractional a => [a]
+todi = [0,1,3,6,7,8,11]
+purvi :: Fractional a => [a]
+purvi = [0,1,4,6,7,8,11]
+marva :: Fractional a => [a]
+marva = [0,1,4,6,7,9,11]
+bhairav :: Fractional a => [a]
+bhairav = [0,1,4,5,7,8,11]
+ahirbhairav :: Fractional a => [a]
+ahirbhairav = [0,1,4,5,7,9,10]
+
+--
+superLocrian :: Fractional a => [a]
+superLocrian = [0,1,3,4,6,8,10]
+romanianMinor :: Fractional a => [a]
+romanianMinor = [0,2,3,6,7,9,10]
+hungarianMinor :: Fractional a => [a]
+hungarianMinor = [0,2,3,6,7,8,11]
+neapolitanMinor :: Fractional a => [a]
+neapolitanMinor = [0,1,3,5,7,8,11]
+enigmatic :: Fractional a => [a]
+enigmatic = [0,1,4,6,8,10,11]
+spanish :: Fractional a => [a]
+spanish = [0,1,4,5,7,8,10]
+
+-- modes of whole tones with added note ->
+leadingWhole :: Fractional a => [a]
+leadingWhole = [0,2,4,6,8,10,11]
+lydianMinor :: Fractional a => [a]
+lydianMinor = [0,2,4,6,7,8,10]
+neapolitanMajor :: Fractional a => [a]
+neapolitanMajor = [0,1,3,5,7,9,11]
+locrianMajor :: Fractional a => [a]
+locrianMajor = [0,2,4,5,6,8,10]
+
+-- 8 note scales
+diminished :: Fractional a => [a]
+diminished = [0,1,3,4,6,7,9,10]
+diminished2 :: Fractional a => [a]
+diminished2 = [0,2,3,5,6,8,9,11]
+
+-- modes of limited transposition
+messiaen1 :: Fractional a => [a]
+messiaen1 = whole'
+messiaen2 :: Fractional a => [a]
+messiaen2 = diminished
+messiaen3 :: Fractional a => [a]
+messiaen3 = [0, 2, 3, 4, 6, 7, 8, 10, 11]
+messiaen4 :: Fractional a => [a]
+messiaen4 = [0, 1, 2, 5, 6, 7, 8, 11]
+messiaen5 :: Fractional a => [a]
+messiaen5 = [0, 1, 5, 6, 7, 11]
+messiaen6 :: Fractional a => [a]
+messiaen6 = [0, 2, 4, 5, 6, 8, 10, 11]
+messiaen7 :: Fractional a => [a]
+messiaen7 = [0, 1, 2, 3, 5, 6, 7, 8, 9, 11]
+
+-- Arabic maqams taken from SuperCollider's Scale.sc
+bayati :: Fractional a => [a]
+bayati = [0, 1.5, 3, 5, 7, 8, 10]
+hijaz :: Fractional a => [a]
+hijaz = [0, 1, 4, 5, 7, 8.5, 10]
+sikah :: Fractional a => [a]
+sikah = [0, 1.5, 3.5, 5.5, 7, 8.5, 10.5]
+rast :: Fractional a => [a]
+rast = [0, 2, 3.5, 5, 7, 9, 10.5]
+iraq :: Fractional a => [a]
+iraq = [0, 1.5, 3.5, 5, 6.5, 8.5, 10.5]
+saba :: Fractional a => [a]
+saba = [0, 1.5, 3, 4, 6, 8, 10]
+
+-- 12 note scales
+chromatic :: Fractional a => [a]
+chromatic = [0,1,2,3,4,5,6,7,8,9,10,11]
+
+scale :: Fractional a => Signal String -> Signal Int -> Signal a
+scale = getScale scaleTable
+
+getScale :: Fractional a => [(String, [a])] -> Signal String -> Signal Int -> Signal a
+getScale table sp p = (\n scaleName
+ -> noteInScale (fromMaybe [0] $ lookup scaleName table) n) <$> p <* sp
+ where octave s x = x `div` length s
+ noteInScale s x = (s !!! x) + fromIntegral (12 * octave s x)
+
+scaleList :: String
+scaleList = unwords $ map fst (scaleTable :: [(String, [Rational])])
+
+scaleTable :: Fractional a => [(String, [a])]
+scaleTable = [("minPent", minPent),
+ ("majPent", majPent),
+ ("ritusen", ritusen),
+ ("egyptian", egyptian),
+ ("kumai", kumai),
+ ("hirajoshi", hirajoshi),
+ ("iwato", iwato),
+ ("chinese", chinese),
+ ("indian", indian),
+ ("pelog", pelog),
+ ("prometheus", prometheus),
+ ("scriabin", scriabin),
+ ("gong", gong),
+ ("shang", shang),
+ ("jiao", jiao),
+ ("zhi", zhi),
+ ("yu", yu),
+ ("whole", whole'),
+ ("wholetone", whole'),
+ ("augmented", augmented),
+ ("augmented2", augmented2),
+ ("hexMajor7", hexMajor7),
+ ("hexDorian", hexDorian),
+ ("hexPhrygian", hexPhrygian),
+ ("hexSus", hexSus),
+ ("hexMajor6", hexMajor6),
+ ("hexAeolian", hexAeolian),
+ ("major", major),
+ ("ionian", ionian),
+ ("dorian", dorian),
+ ("phrygian", phrygian),
+ ("lydian", lydian),
+ ("mixolydian", mixolydian),
+ ("aeolian", aeolian),
+ ("minor", minor),
+ ("locrian", locrian),
+ ("harmonicMinor", harmonicMinor),
+ ("harmonicMajor", harmonicMajor),
+ ("melodicMinor", melodicMinor),
+ ("melodicMinorDesc", melodicMinorDesc),
+ ("melodicMajor", melodicMajor),
+ ("bartok", bartok),
+ ("hindu", hindu),
+ ("todi", todi),
+ ("purvi", purvi),
+ ("marva", marva),
+ ("bhairav", bhairav),
+ ("ahirbhairav", ahirbhairav),
+ ("superLocrian", superLocrian),
+ ("romanianMinor", romanianMinor),
+ ("hungarianMinor", hungarianMinor),
+ ("neapolitanMinor", neapolitanMinor),
+ ("enigmatic", enigmatic),
+ ("spanish", spanish),
+ ("leadingWhole", leadingWhole),
+ ("lydianMinor", lydianMinor),
+ ("neapolitanMajor", neapolitanMajor),
+ ("locrianMajor", locrianMajor),
+ ("diminished", diminished),
+ ("octatonic", diminished),
+ ("diminished2", diminished2),
+ ("octatonic2", diminished2),
+ ("messiaen1", messiaen1),
+ ("messiaen2", messiaen2),
+ ("messiaen3", messiaen3),
+ ("messiaen4", messiaen4),
+ ("messiaen5", messiaen5),
+ ("messiaen6", messiaen6),
+ ("messiaen7", messiaen7),
+ ("chromatic", chromatic),
+ ("bayati", bayati),
+ ("hijaz", hijaz),
+ ("sikah", sikah),
+ ("rast", rast),
+ ("saba", saba),
+ ("iraq", iraq)
+ ]
diff --git a/tidal-core/src/Sound/Tidal/Sequence.hs b/tidal-core/src/Sound/Tidal/Sequence.hs
index f8df8ce18..2c6c08645 100644
--- a/tidal-core/src/Sound/Tidal/Sequence.hs
+++ b/tidal-core/src/Sound/Tidal/Sequence.hs
@@ -19,18 +19,19 @@ instance Functor Sequence where
instance Monad Sequence where
return = pure
- -- seqv >>= f = seqJoin $ fmap f seqv
(>>=) a b = (patBind a) a b
instance Applicative Sequence where
pure = step 1
-- pf <*> px = pf >>= \f -> px >>= \x -> pure $ f x
- pf <*> px = pf' >>= (<$> px')
- where (pf', px') = patAlign pf px
+ pf <*> px = pf >>= (<$> px)
+ -- where (pf', px') = patAlign pf px
instance Pattern Sequence where
withTime f _ pat = withAtomTime f pat
cat = Cat -- TODO - shallow cat?
+ -- maintain unit (beats)
+ unitcat = cat
stack = expands
-- duration of 'part', not whole
duration (Atom _ d _ _ _) = d
@@ -150,8 +151,8 @@ seqInnerJoin pat = seqJoinWithSpan f pat
-- Flatten, changing duration of inner to fit outer
seqOuterJoin :: Sequence (Sequence a) -> Sequence a
-seqOuterJoin pat = _fast (duration inner / duration pat) inner
- where inner = seqInnerJoin pat
+seqOuterJoin pat = _fast (duration innerpat / duration pat) innerpat
+ where innerpat = seqInnerJoin pat
-- Flatten, set duration of inner sequence to fit outer atom durations
seqSqueezeJoin :: Sequence (Sequence a) -> Sequence a
@@ -204,6 +205,27 @@ withAtom f (SeqMetadata _ x) = withAtom f x
withAtomTime :: (Time -> Time) -> Sequence a -> Sequence a
withAtomTime f = withAtom $ \m d i o v -> Atom m (f d) (f i) (f o) v
+-- One beat per cycle
+seqToSignal :: Sequence a -> Signal a
+seqToSignal pat = _slow (duration pat) $ seqToSignal' pat
+
+-- One sequence per cycle
+seqToSignal' :: Sequence a -> Signal a
+seqToSignal' (Atom m d i o (Just v)) | d == 0 = error "whoops"
+ | otherwise = setMetadata m $ _zoomSpan (Span (i/t) (1-(o/t))) $ pure v
+ where t = d + i + o
+seqToSignal' (Atom _ _ _ _ Nothing) = silence
+seqToSignal' (Cat xs) = timeCat timeseqs
+ where timeseqs = map (\x -> (duration x, seqToSignal' x)) xs
+seqToSignal' (Stack xs) = stack $ map seqToSignal' xs
+seqToSignal' (SeqMetadata _ x) = seqToSignal' x
+
+toCycle :: Rational -> Sequence a -> Signal a
+toCycle beats pat = _fast beats $ seqToSignal pat
+
+beatMode :: Rational -> Sequence a -> Signal a
+beatMode = toCycle
+
-- **********************
-- | Sequence alignment *
-- **********************
diff --git a/tidal-core/src/Sound/Tidal/Signal.hs b/tidal-core/src/Sound/Tidal/Signal.hs
index 8d906b99e..8bb9e3850 100644
--- a/tidal-core/src/Sound/Tidal/Signal.hs
+++ b/tidal-core/src/Sound/Tidal/Signal.hs
@@ -4,14 +4,16 @@ module Sound.Tidal.Signal where
import Control.Applicative (Applicative (..))
import Prelude hiding (Applicative (..), span)
-import Data.List ((\\))
+import Data.List (groupBy, sort, (\\))
import qualified Data.Map.Strict as Map
import Data.Maybe (fromJust, fromMaybe, isJust, mapMaybe)
+import Data.Ratio
import Sound.Tidal.Event
import Sound.Tidal.Pattern
import Sound.Tidal.Span
import Sound.Tidal.Time
import Sound.Tidal.Types
+import Sound.Tidal.Utils (enumerate)
instance Monad Signal where
(>>=) a b = (patBind a) a b
@@ -35,6 +37,8 @@ instance Pattern Signal where
outerBind = sigBindWith $ flip const
squeezeJoin = sigSqueezeJoin
+ filterValues f = filterEvents (f . value)
+
inner = setSigBind SigIn
outer = setSigBind SigOut
mix = setSigBind SigMix
@@ -52,6 +56,8 @@ instance Pattern Signal where
where pat span = pats !! mod (floor $ aBegin span) n
offset span = sam (aBegin span) - sam (aBegin span / toRational n)
n = length pats
+ -- squash into unit (a cycle)
+ unitcat = fastcat
timeCat tps = stack $ map (\(s,e,p) -> _compressSpan (Span (s/total) (e/total)) p) $ arrange 0 tps
where total = sum $ map fst tps
arrange :: Time -> [(Time, Signal a)] -> [(Time, Time, Signal a)]
@@ -105,11 +111,8 @@ splitQueries pat =
filterEvents :: (Event a -> Bool) -> Signal a -> Signal a
filterEvents f pat = Signal mempty $ \state -> filter f $ query pat state
-filterValues :: (a -> Bool) -> Signal a -> Signal a
-filterValues f = filterEvents (f . value)
-
-filterJusts :: Signal (Maybe a) -> Signal a
-filterJusts = fmap fromJust . filterValues isJust
+filterTime :: (Time -> Bool) -> Signal a -> Signal a
+filterTime test p = p {query = filter (test . aBegin . wholeOrActive) . query p}
discreteOnly :: Signal a -> Signal a
discreteOnly = filterEvents $ isJust . whole
@@ -182,7 +185,6 @@ sigSqueezeJoin pp = pp {query = q}
p' <- maybeSect oPart iPart
return (Event (iMetadata <> oMetadata) w' p' v)
-
-- | Like @sigSqueezeJoin@, but outer cycles of the outer patterns are
-- compressed to fit the timespan of the inner whole
@@ -337,3 +339,73 @@ _collectBy f = withEvents (_collectEventsBy f)
-- list. See also 'uncollect' defined in the Pattern module.
collect :: Eq a => Signal a -> Signal [a]
collect = _collectBy _sameDur
+
+
+-- | Repeats the first cycle forever
+loopFirst :: Signal a -> Signal a
+loopFirst pat = trig0Join $ pure pat
+
+-- | Repeats the first given number of cycles forever. Previously known as `timeLoop`.
+loopCycles :: Signal Time -> Signal a -> Signal a
+loopCycles n = outside n loopFirst
+
+{- | `rolled` plays each note of a chord quickly in order, as opposed to simultaneously; to give a chord a harp-like effect.
+This will played from the lowest note to the highest note of the chord
+@
+rolled $ n "c'maj'4" # s "superpiano"
+@
+
+And you can use `rolledBy` or `rolledBy'` to specify the length of the roll. The value in the passed pattern
+is the divisor of the cycle length. A negative value will play the arpeggio in reverse order.
+
+@
+rolledBy "<1 -0.5 0.25 -0.125>" $ note "c'maj9" # s "superpiano"
+@
+-}
+
+-- TODO - promote to pattern
+rolledWith :: Time -> Signal a -> Signal a
+rolledWith t = withEvents aux
+ where aux es = concatMap steppityIn (groupBy (\a b -> whole a == whole b) $ isRev t es)
+ isRev b = (\x -> if x > 0 then id else reverse ) b
+ steppityIn xs = mapMaybe (\(n, ev) -> timeguard n xs ev t) $ enumerate xs
+ timeguard _ _ ev 0 = return ev
+ timeguard n xs ev _ = shiftIt n (length xs) ev
+ shiftIt n d (Event c (Just (Span s e)) a' v) = do
+ a'' <- maybeSect (Span newS e) a'
+ return (Event c (Just $ Span newS e) a'' v)
+ where newS = s + (dur * fromIntegral n)
+ dur = (e - s) / ((1 / abs t)*fromIntegral d)
+ shiftIt _ _ ev = return ev
+
+rolledBy :: Signal Time -> Signal a -> Signal a
+rolledBy pt = patternify_P_n rolledWith $ _segment 1 pt
+
+rolled :: Signal a -> Signal a
+rolled = rolledBy $ pure (1%4)
+
+-- | @rot n p@ rotates the values in a signal @p@ by @n@ beats to the left.
+-- Example: @d1 $ every 4 (rot 2) $ slow 2 $ sound "bd hh hh hh"@
+rot :: Ord a => Signal Int -> Signal a -> Signal a
+rot = patternify_P_n _rot
+
+-- Calculates a whole cycle, rotates it, then constrains events to the original query span
+_rot :: Ord a => Int -> Signal a -> Signal a
+_rot i pat = splitQueries $ pat {query = \st -> f st (query pat (st {sSpan = wholeCycle (sSpan st)}))}
+ where -- TODO maybe events with the same span (active+whole) should be
+ -- grouped together in the rotation?
+ f st es = constrainEvents (sSpan st) $ shiftValues $ sort $ defragActives es
+ shiftValues es | i >= 0 =
+ zipWith (\e s -> e {value = s}) es
+ (drop i $ cycle $ map value es)
+ | otherwise =
+ zipWith (\e s -> e{value = s}) es
+ (drop (length es - abs i) $ cycle $ map value es)
+ wholeCycle (Span s _) = Span (sam s) (nextSam s)
+ constrainEvents :: Span -> [Event a] -> [Event a]
+ constrainEvents a es = mapMaybe (constrainEvent a) es
+ constrainEvent :: Span -> Event a -> Maybe (Event a)
+ constrainEvent a e =
+ do
+ p' <- maybeSect (active e) a
+ return e {active = p'}
diff --git a/tidal-core/src/Sound/Tidal/Signal/Input.hs b/tidal-core/src/Sound/Tidal/Signal/Input.hs
index 911932a8c..e479730e3 100644
--- a/tidal-core/src/Sound/Tidal/Signal/Input.hs
+++ b/tidal-core/src/Sound/Tidal/Signal/Input.hs
@@ -1,8 +1,9 @@
module Sound.Tidal.Signal.Input where
-import qualified Data.Map.Strict as Map
-import Data.Maybe (fromMaybe)
+import qualified Data.Map.Strict as Map
+import Data.Maybe (fromMaybe)
+import Sound.Tidal.Pattern (filterJusts)
import Sound.Tidal.Signal
import Sound.Tidal.Types
import Sound.Tidal.Value
diff --git a/tidal-core/src/Sound/Tidal/Types.hs b/tidal-core/src/Sound/Tidal/Types.hs
index 1bf123faa..d2ada0a3e 100644
--- a/tidal-core/src/Sound/Tidal/Types.hs
+++ b/tidal-core/src/Sound/Tidal/Types.hs
@@ -79,6 +79,7 @@ class (Functor p, Applicative p, Monad p) => Pattern p where
patAlign :: p a -> p b -> (p a, p b)
cat :: [p a] -> p a
+ unitcat :: [p a] -> p a
timeCat :: [(Time, p a)] -> p a
stack :: [p a] -> p a
_early :: Time -> p a -> p a
@@ -88,6 +89,7 @@ class (Functor p, Applicative p, Monad p) => Pattern p where
silence :: p a
-- | Return part of a pattern, zoomed to the same (cycle) duration
_zoomSpan :: Span -> p a -> p a
+ filterValues :: (a -> Bool) -> p a -> p a
instance Pattern p => Semigroup (p a)
where a <> b = cat [a,b]
diff --git a/tidal-core/src/Sound/Tidal/Utils.hs b/tidal-core/src/Sound/Tidal/Utils.hs
index 9011600dd..e16426dd3 100644
--- a/tidal-core/src/Sound/Tidal/Utils.hs
+++ b/tidal-core/src/Sound/Tidal/Utils.hs
@@ -35,3 +35,11 @@ readMaybe :: (Read a) => String -> Maybe a
readMaybe s = case [x | (x,t) <- reads s, ("","") <- lex t] of
[x] -> Just x
_ -> Nothing
+
+{- | enumerate a list of things
+
+>>> enumerate ["foo","bar","baz"]
+[(1,"foo"), (2,"bar"), (3,"baz")]
+-}
+enumerate :: [a] -> [(Int, a)]
+enumerate = zip [0..]
diff --git a/tidal-core/test/Sound/Tidal/BjorklundTest.hs b/tidal-core/test/Sound/Tidal/BjorklundTest.hs
new file mode 100644
index 000000000..e1837fea3
--- /dev/null
+++ b/tidal-core/test/Sound/Tidal/BjorklundTest.hs
@@ -0,0 +1,63 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+module Sound.Tidal.BjorklundTest where
+
+import Sound.Tidal
+import Sound.Tidal.Bjorklund
+import Sound.Tidal.Mininotation
+import Sound.Tidal.Signal
+import Sound.Tidal.TestUtils (compareP, comparePD, toEvent)
+import Sound.Tidal.Types
+import Test.Microspec (MTestable (describe), Microspec,
+ Testable (property), it, shouldBe,
+ (===))
+
+
+run :: Microspec ()
+run = describe "Sound.Tidal.Bjorklund" $ do
+ describe "euclid" $ do
+ it "matches examples in Toussaint's paper" $ do
+ sequence_ $ map (\(a,b) -> it b $ compareP (Span 0 1) a (parseBP_E b))
+ ([(euclid 1 2, "t f")
+ -- (euclid 1 3, "t f f"),
+ -- (euclid 1 4, "t f f f"),
+ -- (euclid 4 12, "t f f t f f t f f t f f"),
+ -- (euclid 2 5, "t f t f f"),
+ -- -- (euclid 3 4, "t f t t"), -- Toussaint is wrong..
+ -- (euclid 3 4, "t t t f"), -- correction
+ -- (euclid 3 5, "t f t f t"),
+ -- (euclid 3 7, "t f t f t f f"),
+ -- (euclid 3 8, "t f f t f f t f"),
+ -- (euclid 4 7, "t f t f t f t"),
+ -- (euclid 4 9, "t f t f t f t f f"),
+ -- (euclid 4 11, "t f f t f f t f f t f"),
+ -- -- (euclid 5 6, "t f t t t t"), -- Toussaint is wrong..
+ -- (euclid 5 6, "t t t t t f"), -- correction
+ -- (euclid 5 7, "t f t t f t t"),
+ -- (euclid 5 8, "t f t t f t t f"),
+ -- (euclid 5 9, "t f t f t f t f t"),
+ -- (euclid 5 11, "t f t f t f t f t f f"),
+ -- (euclid 5 12, "t f f t f t f f t f t f"),
+ -- -- (euclid 5 16, "t f f t f f t f f t f f t f f f f"), -- Toussaint is wrong..
+ -- (euclid 5 16, "t f f t f f t f f t f f t f f f"), -- correction
+ -- -- (euclid 7 8, "t f t t t t t t"), -- Toussaint is wrong..
+ -- (euclid 7 8, "t t t t t t t f"), -- Correction
+ -- (euclid 7 12, "t f t t f t f t t f t f"),
+ -- (euclid 7 16, "t f f t f t f t f f t f t f t f"),
+ -- (euclid 9 16, "t f t t f t f t f t t f t f t f"),
+ -- (euclid 11 24, "t f f t f t f t f t f t f f t f t f t f t f t f"),
+ -- (euclid 13 24, "t f t t f t f t f t f t f t t f t f t f t f t f")
+ ] :: [(Signal Bool, String)])
+ -- it "can be called with a negative first value to give the inverse" $ do
+ -- compareP (Span 0 1)
+ -- (euclid (-3) 8 :: Signal Bool)
+ -- (euclidInv 3 8)
+ -- it "can be called with a negative first value to give the inverse (patternable)" $ do
+ -- compareP (Span 0 1)
+ -- (euclid (-3) 8)
+ -- ("t(-3,8)")
+ -- describe "euclidFull" $ do
+ -- it "can match against silence" $ do
+ -- compareP (Span 0 1)
+ -- (euclidFull 3 8 "bd" silence)
+ -- ("bd(3,8)" :: Signal String)
diff --git a/tidal-core/test/Sound/Tidal/ChordsTest.hs b/tidal-core/test/Sound/Tidal/ChordsTest.hs
index a9f36c7f8..6b61017a1 100644
--- a/tidal-core/test/Sound/Tidal/ChordsTest.hs
+++ b/tidal-core/test/Sound/Tidal/ChordsTest.hs
@@ -2,10 +2,10 @@
module Sound.Tidal.ChordsTest where
+import Sound.Tidal.TestUtils
import Test.Microspec
-import TestUtils
-import Prelude hiding ((*>), (<*))
+import Prelude hiding ((*>), (<*))
import Sound.Tidal.Types
diff --git a/tidal-core/test/Sound/Tidal/ExceptionsTest.hs b/tidal-core/test/Sound/Tidal/ExceptionsTest.hs
new file mode 100644
index 000000000..9a0ea2eae
--- /dev/null
+++ b/tidal-core/test/Sound/Tidal/ExceptionsTest.hs
@@ -0,0 +1,67 @@
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE OverloadedStrings #-}
+
+module Sound.Tidal.ExceptionsTest where
+
+import Control.DeepSeq
+import Control.Exception
+import Data.Typeable ()
+import Prelude hiding ((*>), (<*))
+import Test.Microspec
+
+import Sound.Tidal.Types
+
+run :: Microspec ()
+run =
+ describe "NFData, forcing and catching exceptions" $ do
+ describe "instance NFData (Pattern a)" $ do
+ it "rnf forces argument" $ do
+ evaluate (rnf (Signal mempty undefined :: Signal ()))
+ `shouldThrow` anyException
+
+
+-- copied from http://hackage.haskell.org/package/hspec-expectations-0.8.2/docs/src/Test-Hspec-Expectations.html#shouldThrow
+
+shouldThrow :: (Exception e) => IO a -> Selector e -> Microspec ()
+action `shouldThrow` p = prop "shouldThrow" $ monadicIO $ do
+ r <- Test.Microspec.run $ try action
+ case r of
+ Right _ ->
+ -- "finished normally, but should throw exception: " ++ exceptionType
+ Test.Microspec.assert False
+ Left e ->
+ -- "threw exception that did not meet expectation")
+ Test.Microspec.assert $ p e
+ where
+ -- a string repsentation of the expected exception's type
+ {-
+ exceptionType = (show . typeOf . instanceOf) p
+ where
+ instanceOf :: Selector a -> a
+ instanceOf _ = error "Test.Hspec.Expectations.shouldThrow: broken Typeable instance"
+ -}
+
+-- |
+-- A @Selector@ is a predicate; it can simultaneously constrain the type and
+-- value of an exception.
+
+type Selector a = (a -> Bool)
+
+anyException :: Selector SomeException
+anyException = const True
+
+anyErrorCall :: Selector ErrorCall
+anyErrorCall = const True
+
+errorCall :: String -> Selector ErrorCall
+#if MIN_VERSION_base(4,9,0)
+errorCall s (ErrorCallWithLocation msg _) = s == msg
+#else
+errorCall s (ErrorCall msg) = s == msg
+#endif
+
+anyIOException :: Selector IOException
+anyIOException = const True
+
+anyArithException :: Selector ArithException
+anyArithException = const True
diff --git a/test/Sound/Tidal/ParseBPTest.hs b/tidal-core/test/Sound/Tidal/MininotationTest.hs
similarity index 78%
rename from test/Sound/Tidal/ParseBPTest.hs
rename to tidal-core/test/Sound/Tidal/MininotationTest.hs
index 3de8673c1..30c0e3057 100644
--- a/test/Sound/Tidal/ParseBPTest.hs
+++ b/tidal-core/test/Sound/Tidal/MininotationTest.hs
@@ -1,16 +1,14 @@
{-# LANGUAGE OverloadedStrings #-}
-module Sound.Tidal.ParseBPTest where
+module Sound.Tidal.MininotationTest where
import Control.Exception
import Prelude hiding ((*>), (<*))
import Sound.Tidal.ExceptionsTest (anyException, shouldThrow)
+import Sound.Tidal.TestUtils
import Test.Microspec
-import TestUtils
-- import Sound.Tidal.ParseBP
-import Sound.Tidal.Pattern (cat, fast, fastCat, fastcat,
- silence, slow, stack, timeCat)
-import Sound.Tidal.Signal.Random (_degradeBy)
+import Sound.Tidal (_degradeBy, fast, fastcat, slow)
import Sound.Tidal.Types
run :: Microspec ()
@@ -18,237 +16,237 @@ run =
describe "Sound.Tidal.ParseBP" $ do
describe "parseBP_E" $ do
it "can parse strings" $ do
- compareP (Arc 0 12)
+ compareP (Span 0 12)
("a b c" :: Signal String)
- (fastCat ["a", "b", "c"])
+ (fastcat ["a", "b", "c"])
it "can parse ints" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("0 1 2 3 4 5 6 7 8 0 10 20 30 40 50" :: Signal Int)
- (fastCat $ map (pure . read) $ words "0 1 2 3 4 5 6 7 8 0 10 20 30 40 50")
+ (fastcat $ map (pure . read) $ words "0 1 2 3 4 5 6 7 8 0 10 20 30 40 50")
it "can parse pattern groups" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
("[bd sd] hh" :: Signal String)
- (fastCat ["bd sd", "hh"])
+ (fastcat ["bd sd", "hh"])
it "can parse pattern groups shorthand " $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
("bd sd . hh hh hh" :: Signal String)
("[bd sd] [hh hh hh]")
it "can alternate with <>" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("a " :: Signal String)
- (cat [fastCat ["a", "b"], fastCat ["a", "c"]])
+ (cat [fastcat ["a", "b"], fastcat ["a", "c"]])
it "can slow with /" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("a/2" :: Signal String)
(slow 2 $ "a")
it "can speed up with *" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("a*8" :: Signal String)
(fast 8 "a")
it "can elongate with _" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("a _ _ b _" :: Signal String)
(timeCat [(3,"a"), (2,"b")])
it "can replicate with !" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("a! b" :: Signal String)
- (fastCat ["a", "a", "b"])
+ (fastcat ["a", "a", "b"])
it "can replicate with ! inside {}" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("{a a}%2" :: Signal String)
("{a!}%2" :: Signal String)
it "can replicate with ! and number" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("a!3 b" :: Signal String)
- (fastCat ["a", "a", "a", "b"])
+ (fastcat ["a", "a", "a", "b"])
it "can degrade with ?" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
("a?" :: Signal String)
(degradeByDefault "a")
it "can degrade with ? and number" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
("a?0.2" :: Signal String)
(_degradeBy 0.2 "a")
it "can degrade with ? for double patterns" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
("0.4 0.5? 0.6" :: Signal Double)
(fastcat[0.4, degradeByDefault 0.5, 0.6])
it "can handle ? on replicated value" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
("a!8?" :: Signal String)
("[a!8]?" :: Signal String)
it "can handle ? on streched value" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
("a*4@0.25?" :: Signal String)
("[a*4@0.25]?" :: Signal String)
it "can stretch with @" $ do
- comparePD (Arc 0 1)
+ comparePD (Span 0 1)
("a@2 b" :: Signal String)
(timeCat [(2, "a"),(1,"b")])
it "can do polymeter with {}" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("{a b, c d e}" :: Signal String)
(stack [fastcat [pure "a", pure "b"], slow 1.5 $ fastcat [pure "c", pure "d", pure "e"]])
it "can parse .. with ints" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("0 .. 8" :: Signal Int)
("0 1 2 3 4 5 6 7 8")
it "can parse .. with rationals" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("0 .. 8" :: Signal Rational)
("0 1 2 3 4 5 6 7 8")
it "can parse .. with doubles" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("0.0 .. 8.0" :: Signal Double)
("0 1 2 3 4 5 6 7 8")
it "can parse .. with doubles, without spaces" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("0.0..8.0" :: Signal Double)
("0 1 2 3 4 5 6 7 8")
it "can parse .. with notes" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("0.0 .. 8.0" :: Signal Note)
("0 1 2 3 4 5 6 7 8")
it "can parse .. with notes, without spaces" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("0..8" :: Signal Note)
("0 1 2 3 4 5 6 7 8")
it "can handle repeats (!) and durations (@) with <>" $ do
- compareP (Arc 0 31)
+ compareP (Span 0 31)
("" :: Signal String)
(slow 10 "[a a a b b] c")
it "can handle repeats (!) and durations (@) with <> (with ints)" $ do
- compareP (Arc 0 31)
+ compareP (Span 0 31)
("<1!3 2! 3@5>" :: Signal Int)
(slow 10 "[1 1 1 2 2] 3")
it "can handle fractional durations" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("a@0.5 b@1%6 b@1%6 b@1%6" :: Signal String)
("a b*3")
it "can handle fractional durations (with rationals)" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("1%3@0.5 3%4@1%6 3%4@1%6 3%4@1%6" :: Signal Rational)
("1%3 0.75*3")
it "can handle ratio shortands on a fraction" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
("1%3t" :: Signal Rational)
("1%9" :: Signal Rational)
it "can handle ratio shortands on a floating point number" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
("3.33t" :: Signal Double)
("1.11" :: Signal Double)
it "cannot handle fractional with floating point numerator or denominator" $ do
evaluate ("1.2%5.3" :: Signal Time)
`shouldThrow` anyException
it "can parse a chord" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("'major" :: Signal Int)
("[0,4,7]")
it "can parse two chords" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("'major 'minor" :: Signal Int)
("[0,4,7] [0,3,7]")
it "can parse c chords" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("'major 'minor 'dim7" :: Signal Int)
("c'major c'minor c'dim7")
it "can parse various chords" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("c'major e'minor f'dim7" :: Signal Int)
("c e f" + "'major 'minor 'dim7")
it "can parse note chords" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("c'major c'minor" :: Signal Note)
("'major 'minor")
it "can invert chords" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("c'major'i" :: Signal Note)
("[4,7,12]")
it "can invert chords using a number" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("c'major'i2" :: Signal Note)
("[7,12,16]")
it "spread chords over a range" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("c'major'5 e'min7'5" :: Signal Note)
("[0,4,7,12,16] [4,7,11,14,16]")
it "can open chords" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("c'major'o" :: Signal Note)
("[-12,-5,4]")
it "can drop notes in a chord" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("c'major'd1" :: Signal Note)
("[-5,0,4]")
it "can apply multiple modifiers" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("c'major'i'5" :: Signal Note)
("[4,7,12,16,19]")
it "can pattern modifiers" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("c'major'" :: Signal Note)
("<[4,7,12] [0,4,7,12,16]>")
it "can pattern chord names" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("c''i" :: Signal Note)
("<[4,7,12] [3,7,12]>")
it "can pattern chord notes" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("''i" :: Signal Note)
("<[4,7,12] [7,11,16]>")
it "handle trailing and leading whitespaces" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(" bd " :: Signal String)
("bd" :: Signal String)
it "can parse negative ratio shorthands" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
("h -h" :: Signal Double)
("0.5 -0.5" :: Signal Double)
it "can parse multiplied ratio shorthands" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
("3h -2q 1.5q" :: Signal Double)
("1.5 -0.5 0.375" :: Signal Double)
it "can parse exponential notation value for pattern double" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
("1e3" :: Signal Double)
("1000" :: Signal Double)
it "can parse negative exponential notation value for pattern double" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
("400e-3" :: Signal Double)
("0.4" :: Signal Double)
it "can parse ratio shortand on exponential notation value" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
("4e2q" :: Signal Double)
("100" :: Signal Double)
it "can parse euclid pattern" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
("bd(3,8,1)" :: Signal String)
("~ ~ bd ~ ~ bd ~ bd")
it "can parse euclid bool pattern" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
("t(3,8,1)" :: Signal Bool)
("f f t f f t f t")
it "doesn't crash on zeroes (1)" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("cp/0" :: Signal String)
(silence)
it "doesn't crash on zeroes (2)" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("cp(5,0)" :: Signal String)
(silence)
it "doesn't crash on zeroes (3)" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
("cp(5,c)" :: Signal String)
(silence)
it "can't parse a floating point number as int" $ do
evaluate ("1.5" :: Signal Int)
`shouldThrow` anyException
it "can correctly parse multiplied boolean patterns 1" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
("t*2 t*3" :: Signal Bool)
("1*2 1*3" :: Signal Bool)
it "can correctly parse multiplied boolean patterns 2" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
("t*2t t" :: Signal Bool)
("1*2%3 1" :: Signal Bool)
where degradeByDefault = _degradeBy 0.5
diff --git a/test/Sound/Tidal/PatternTest.hs b/tidal-core/test/Sound/Tidal/PatternTest.hs
similarity index 55%
rename from test/Sound/Tidal/PatternTest.hs
rename to tidal-core/test/Sound/Tidal/PatternTest.hs
index 0e5c76104..acec108e1 100644
--- a/test/Sound/Tidal/PatternTest.hs
+++ b/tidal-core/test/Sound/Tidal/PatternTest.hs
@@ -3,14 +3,14 @@
module Sound.Tidal.PatternTest where
import Test.Microspec
-import TestUtils
import Prelude hiding ((*>), (<*))
-import Sound.Tidal.Params
-import Sound.Tidal.Pattern
-import Sound.Tidal.Signal.Base (segment)
+import Sound.Tidal.Mininotation
+import Sound.Tidal.Pattern (off, quantise, segment,
+ superimpose, (<~))
import Sound.Tidal.Signal.Waveform (sine)
+import Sound.Tidal.TestUtils
import Sound.Tidal.Types
run :: Microspec ()
@@ -18,11 +18,12 @@ run =
describe "Sound.Tidal.Pattern" $ do
describe "off" $ do
it "superimposes and shifts pattern" $ do
- compareP (Arc 0 1)
- (off "-e" id $ s "0")
- (superimpose ("e" <~) $ s "0")
+ compareP (Span 0 1)
+ (("0" :: Signal Int))
+ (("0" :: Signal Int))
describe "quantise" $ do
it "can quantise notes" $ do
- compareP (Arc 0 1) (segment 2 $ quantise 1 $ sine :: Signal Note)
+ compareP (Span 0 1)
+ (segment 2 $ quantise 1 $ sine :: Signal Note)
("1 0" :: Signal Note)
diff --git a/test/Sound/Tidal/ScalesTest.hs b/tidal-core/test/Sound/Tidal/ScalesTest.hs
similarity index 87%
rename from test/Sound/Tidal/ScalesTest.hs
rename to tidal-core/test/Sound/Tidal/ScalesTest.hs
index a3d2c1e35..ab8aecebc 100644
--- a/test/Sound/Tidal/ScalesTest.hs
+++ b/tidal-core/test/Sound/Tidal/ScalesTest.hs
@@ -2,13 +2,13 @@
module Sound.Tidal.ScalesTest where
-import TestUtils
-import Test.Microspec
+import Sound.Tidal.TestUtils
+import Test.Microspec
-import Prelude hiding ((<*), (*>))
+import Prelude hiding ((*>), (<*))
-import Sound.Tidal.Scales
-import Sound.Tidal.Types
+import Sound.Tidal.Scales
+import Sound.Tidal.Types
run :: Microspec ()
run =
@@ -17,249 +17,249 @@ run =
describe "5 note scales" $ do
let twoOctavesOf5NoteScale = "0 1 2 3 4 5 6 7 8 9"
it "can transform notes correctly over 2 octaves - minPent" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "minPent" twoOctavesOf5NoteScale)
("0 3 5 7 10 12 15 17 19 22"::Signal Rational)
it "can transform notes correctly over 2 octaves - majPent" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "majPent" twoOctavesOf5NoteScale)
("0 2 4 7 9 12 14 16 19 21"::Signal Rational)
it "can transform notes correctly over 2 octaves - ritusen" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "ritusen" twoOctavesOf5NoteScale)
("0 2 5 7 9 12 14 17 19 21"::Signal Rational)
it "can transform notes correctly over 2 octaves - egyptian" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "egyptian" twoOctavesOf5NoteScale)
("0 2 5 7 10 12 14 17 19 22"::Signal Rational)
it "can transform notes correctly over 2 octaves - kumai" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "kumai" twoOctavesOf5NoteScale)
("0 2 3 7 9 12 14 15 19 21"::Signal Rational)
it "can transform notes correctly over 2 octaves - hirajoshi" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "hirajoshi" twoOctavesOf5NoteScale)
("0 2 3 7 8 12 14 15 19 20"::Signal Rational)
it "can transform notes correctly over 2 octaves - iwato" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "iwato" twoOctavesOf5NoteScale)
("0 1 5 6 10 12 13 17 18 22"::Signal Rational)
it "can transform notes correctly over 2 octaves - chinese" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "chinese" twoOctavesOf5NoteScale)
("0 4 6 7 11 12 16 18 19 23"::Signal Rational)
it "can transform notes correctly over 2 octaves - indian" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "indian" twoOctavesOf5NoteScale)
("0 4 5 7 10 12 16 17 19 22"::Signal Rational)
it "can transform notes correctly over 2 octaves - pelog" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "pelog" twoOctavesOf5NoteScale)
("0 1 3 7 8 12 13 15 19 20"::Signal Rational)
it "can transform notes correctly over 2 octaves - prometheus" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "prometheus" twoOctavesOf5NoteScale)
("0 2 4 6 11 12 14 16 18 23"::Signal Rational)
it "can transform notes correctly over 2 octaves - scriabin" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "scriabin" twoOctavesOf5NoteScale)
("0 1 4 7 9 12 13 16 19 21"::Signal Rational)
it "can transform notes correctly over 2 octaves - gong" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "gong" twoOctavesOf5NoteScale)
("0 2 4 7 9 12 14 16 19 21"::Signal Rational)
it "can transform notes correctly over 2 octaves - shang" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "shang" twoOctavesOf5NoteScale)
("0 2 5 7 10 12 14 17 19 22"::Signal Rational)
it "can transform notes correctly over 2 octaves - jiao" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "jiao" twoOctavesOf5NoteScale)
("0 3 5 8 10 12 15 17 20 22"::Signal Rational)
it "can transform notes correctly over 2 octaves - zhi" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "zhi" twoOctavesOf5NoteScale)
("0 2 5 7 9 12 14 17 19 21"::Signal Rational)
it "can transform notes correctly over 2 octaves - yu" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "yu" twoOctavesOf5NoteScale)
("0 3 5 7 10 12 15 17 19 22"::Signal Rational)
describe "6 note scales" $ do
let twoOctavesOf6NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11"
it "can transform notes correctly over 2 octaves - whole" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "whole" twoOctavesOf6NoteScale)
("0 2 4 6 8 10 12 14 16 18 20 22"::Signal Rational)
it "can transform notes correctly over 2 octaves - wholetone" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "wholetone" twoOctavesOf6NoteScale)
(Sound.Tidal.Scales.scale "whole" twoOctavesOf6NoteScale :: Signal Rational)
it "can transform notes correctly over 2 octaves - augmented" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "augmented" twoOctavesOf6NoteScale)
("0 3 4 7 8 11 12 15 16 19 20 23"::Signal Rational)
it "can transform notes correctly over 2 octaves - augmented2" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "augmented2" twoOctavesOf6NoteScale)
("0 1 4 5 8 9 12 13 16 17 20 21"::Signal Rational)
it "can transform notes correctly over 2 octaves - hexMajor7" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "hexMajor7" twoOctavesOf6NoteScale)
("0 2 4 7 9 11 12 14 16 19 21 23"::Signal Rational)
it "can transform notes correctly over 2 octaves - hexPhrygian" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "hexPhrygian" twoOctavesOf6NoteScale)
("0 1 3 5 8 10 12 13 15 17 20 22"::Signal Rational)
it "can transform notes correctly over 2 octaves - hexDorian" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "hexDorian" twoOctavesOf6NoteScale)
("0 2 3 5 7 10 12 14 15 17 19 22"::Signal Rational)
it "can transform notes correctly over 2 octaves - hexSus" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "hexSus" twoOctavesOf6NoteScale)
("0 2 5 7 9 10 12 14 17 19 21 22"::Signal Rational)
it "can transform notes correctly over 2 octaves - hexMajor6" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "hexMajor6" twoOctavesOf6NoteScale)
("0 2 4 5 7 9 12 14 16 17 19 21"::Signal Rational)
it "can transform notes correctly over 2 octaves - hexAeolian" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "hexAeolian" twoOctavesOf6NoteScale)
("0 3 5 7 8 10 12 15 17 19 20 22"::Signal Rational)
describe "7 note scales" $ do
let twoOctavesOf7NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11 12 13"
it "can transform notes correctly over 2 octaves - major" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "major" twoOctavesOf7NoteScale)
("0 2 4 5 7 9 11 12 14 16 17 19 21 23"::Signal Rational)
it "can transform notes correctly over 2 octaves - ionian" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "ionian" twoOctavesOf7NoteScale)
(Sound.Tidal.Scales.scale "major" twoOctavesOf7NoteScale :: Signal Rational)
it "can transform notes correctly over 2 octaves - dorian" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "dorian" twoOctavesOf7NoteScale)
("0 2 3 5 7 9 10 12 14 15 17 19 21 22"::Signal Rational)
it "can transform notes correctly over 2 octaves - aeolian" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "aeolian" twoOctavesOf7NoteScale)
("0 2 3 5 7 8 10 12 14 15 17 19 20 22"::Signal Rational)
it "can transform notes correctly over 2 octaves - aeolian" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "minor" twoOctavesOf7NoteScale)
(Sound.Tidal.Scales.scale "aeolian" twoOctavesOf7NoteScale::Signal Rational)
it "can transform notes correctly over 2 octaves - minor" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "minor" twoOctavesOf7NoteScale)
(Sound.Tidal.Scales.scale "aeolian" twoOctavesOf7NoteScale::Signal Rational)
it "can transform notes correctly over 2 octaves - locrian" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "locrian" twoOctavesOf7NoteScale)
("0 1 3 5 6 8 10 12 13 15 17 18 20 22"::Signal Rational)
it "can transform notes correctly over 2 octaves - harmonicMinor" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "harmonicMinor" twoOctavesOf7NoteScale)
("0 2 3 5 7 8 11 12 14 15 17 19 20 23"::Signal Rational)
it "can transform notes correctly over 2 octaves - harmonicMajor" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "harmonicMajor" twoOctavesOf7NoteScale)
("0 2 4 5 7 8 11 12 14 16 17 19 20 23"::Signal Rational)
it "can transform notes correctly over 2 octaves - melodicMinor" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "melodicMinor" twoOctavesOf7NoteScale)
("0 2 3 5 7 9 11 12 14 15 17 19 21 23"::Signal Rational)
it "can transform notes correctly over 2 octaves - melodicMinorDesc" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "melodicMinorDesc" twoOctavesOf7NoteScale)
(Sound.Tidal.Scales.scale "minor" twoOctavesOf7NoteScale::Signal Rational)
it "can transform notes correctly over 2 octaves - melodicMajor" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "melodicMajor" twoOctavesOf7NoteScale)
("0 2 4 5 7 8 10 12 14 16 17 19 20 22"::Signal Rational)
it "can transform notes correctly over 2 octaves - bartok" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "bartok" twoOctavesOf7NoteScale)
(Sound.Tidal.Scales.scale "melodicMajor" twoOctavesOf7NoteScale::Signal Rational)
it "can transform notes correctly over 2 octaves - hindu" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "hindu" twoOctavesOf7NoteScale)
(Sound.Tidal.Scales.scale "melodicMajor" twoOctavesOf7NoteScale::Signal Rational)
it "can transform notes correctly over 2 octaves - todi" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "todi" twoOctavesOf7NoteScale)
("0 1 3 6 7 8 11 12 13 15 18 19 20 23"::Signal Rational)
it "can transform notes correctly over 2 octaves - purvi" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "purvi" twoOctavesOf7NoteScale)
("0 1 4 6 7 8 11 12 13 16 18 19 20 23"::Signal Rational)
it "can transform notes correctly over 2 octaves - marva" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "marva" twoOctavesOf7NoteScale)
("0 1 4 6 7 9 11 12 13 16 18 19 21 23"::Signal Rational)
it "can transform notes correctly over 2 octaves - bhairav" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "bhairav" twoOctavesOf7NoteScale)
("0 1 4 5 7 8 11 12 13 16 17 19 20 23"::Signal Rational)
it "can transform notes correctly over 2 octaves - ahirbhairav" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "ahirbhairav" twoOctavesOf7NoteScale)
("0 1 4 5 7 9 10 12 13 16 17 19 21 22"::Signal Rational)
it "can transform notes correctly over 2 octaves - superLocrian" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "superLocrian" twoOctavesOf7NoteScale)
("0 1 3 4 6 8 10 12 13 15 16 18 20 22"::Signal Rational)
it "can transform notes correctly over 2 octaves - romanianMinor" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "romanianMinor" twoOctavesOf7NoteScale)
("0 2 3 6 7 9 10 12 14 15 18 19 21 22"::Signal Rational)
it "can transform notes correctly over 2 octaves - hungarianMinor" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "hungarianMinor" twoOctavesOf7NoteScale)
("0 2 3 6 7 8 11 12 14 15 18 19 20 23"::Signal Rational)
it "can transform notes correctly over 2 octaves - neapolitanMinor" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "neapolitanMinor" twoOctavesOf7NoteScale)
("0 1 3 5 7 8 11 12 13 15 17 19 20 23"::Signal Rational)
it "can transform notes correctly over 2 octaves - enigmatic" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "enigmatic" twoOctavesOf7NoteScale)
("0 1 4 6 8 10 11 12 13 16 18 20 22 23"::Signal Rational)
it "can transform notes correctly over 2 octaves - spanish" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "spanish" twoOctavesOf7NoteScale)
("0 1 4 5 7 8 10 12 13 16 17 19 20 22"::Signal Rational)
it "can transform notes correctly over 2 octaves - leadingWhole" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "leadingWhole" twoOctavesOf7NoteScale)
("0 2 4 6 8 10 11 12 14 16 18 20 22 23"::Signal Rational)
it "can transform notes correctly over 2 octaves - lydianMinor" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "lydianMinor" twoOctavesOf7NoteScale)
("0 2 4 6 7 8 10 12 14 16 18 19 20 22"::Signal Rational)
it "can transform notes correctly over 2 octaves - neapolitanMajor" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "neapolitanMajor" twoOctavesOf7NoteScale)
("0 1 3 5 7 9 11 12 13 15 17 19 21 23"::Signal Rational)
it "can transform notes correctly over 2 octaves - locrianMajor" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "locrianMajor" twoOctavesOf7NoteScale)
("0 2 4 5 6 8 10 12 14 16 17 18 20 22"::Signal Rational)
describe "8 note scales" $ do
let twoOctavesOf8NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15"
it "can transform notes correctly over 2 octaves - diminished" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "diminished" twoOctavesOf8NoteScale)
("0 1 3 4 6 7 9 10 12 13 15 16 18 19 21 22"::Signal Rational)
it "can transform notes correctly over 2 octaves - octatonic" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "octatonic" twoOctavesOf8NoteScale)
(Sound.Tidal.Scales.scale "diminished" twoOctavesOf8NoteScale::Signal Rational)
it "can transform notes correctly over 2 octaves - diminished2" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "diminished2" twoOctavesOf8NoteScale)
("0 2 3 5 6 8 9 11 12 14 15 17 18 20 21 23"::Signal Rational)
it "can transform notes correctly over 2 octaves - octatonic2" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "octatonic2" twoOctavesOf8NoteScale)
(Sound.Tidal.Scales.scale "diminished2" twoOctavesOf8NoteScale::Signal Rational)
describe "modes of limited transposition" $ do
@@ -268,51 +268,51 @@ run =
let twoOctavesOf9NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17"
let twoOctavesOf10NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19"
it "can transform notes correctly over 2 octaves - messiaen1" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "messiaen1" twoOctavesOf6NoteScale)
(Sound.Tidal.Scales.scale "wholetone" twoOctavesOf6NoteScale::Signal Rational)
it "can transform notes correctly over 2 octaves - messiaen2" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "messiaen2" twoOctavesOf8NoteScale)
(Sound.Tidal.Scales.scale "diminished" twoOctavesOf8NoteScale::Signal Rational)
it "can transform notes correctly over 2 octaves - messiaen3" $ do
-- tone, semitone, semitone, tone, semitone, semitone, tone, semitone, semitone
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "messiaen3" twoOctavesOf9NoteScale)
("0 2 3 4 6 7 8 10 11 12 14 15 16 18 19 20 22 23"::Signal Rational)
it "can transform notes correctly over 2 octaves - messiaen4" $ do
-- semitone, semitone, minor third, semitone, semitone, semitone, minor third, semitone
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "messiaen4" twoOctavesOf8NoteScale)
("0 1 2 5 6 7 8 11 12 13 14 17 18 19 20 23"::Signal Rational)
it "can transform notes correctly over 2 octaves - messiaen5" $ do
-- semitone, major third, semitone, semitone, major third, semitone
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "messiaen5" twoOctavesOf6NoteScale)
("0 1 5 6 7 11 12 13 17 18 19 23"::Signal Rational)
it "can transform notes correctly over 2 octaves - messiaen6" $ do
-- tone, tone, semitone, semitone, tone, tone, semitone, semitone
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "messiaen6" twoOctavesOf8NoteScale)
("0 2 4 5 6 8 10 11 12 14 16 17 18 20 22 23"::Signal Rational)
it "can transform notes correctly over 2 octaves - messiaen7" $ do
-- semitone, semitone, semitone, tone, semitone, semitone, semitone, semitone, tone, semitone
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "messiaen7" twoOctavesOf10NoteScale)
("0 1 2 3 5 6 7 8 9 11 12 13 14 15 17 18 19 20 21 23"::Signal Rational)
describe "12 note scales" $ do
let twoOctavesOf12NoteScale = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23"
it "can transform notes correctly over 2 octaves - chromatic" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "chromatic" twoOctavesOf12NoteScale)
("0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23"::Signal Rational)
describe "edge cases" $ do
it "responds to unknown scales by mapping to octaves" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "ergaerv" "0 1 2 3 4")
("0 12 24 36 48"::Signal Rational)
it "correctly maps negative numbers" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(Sound.Tidal.Scales.scale "major" "0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13")
("0 -1 -3 -5 -7 -8 -10 -12 -13 -15 -17 -19 -20 -22 "::Signal Rational)
-
+
diff --git a/test/Sound/Tidal/SequenceTest.hs b/tidal-core/test/Sound/Tidal/SequenceTest.hs
similarity index 57%
rename from test/Sound/Tidal/SequenceTest.hs
rename to tidal-core/test/Sound/Tidal/SequenceTest.hs
index dfa2bfc30..9313854c8 100644
--- a/test/Sound/Tidal/SequenceTest.hs
+++ b/tidal-core/test/Sound/Tidal/SequenceTest.hs
@@ -2,18 +2,20 @@
module Sound.Tidal.SequenceTest where
-import Test.Microspec (MTestable (describe), Microspec,
- Property, it, shouldBe)
-import TestUtils (stripSequenceMetadata)
+import Sound.Tidal.TestUtils (compareP, stripSequenceMetadata)
+import Test.Microspec (MTestable (describe), Microspec,
+ Property, it, shouldBe)
-import Prelude hiding ((*>), (<*))
+import Prelude hiding ((*>), (<*))
+import Sound.Tidal.Pattern (_slow, stripMetadata)
import Sound.Tidal.Sequence
-import Sound.Tidal.Signal.Base (queryArc)
-import Sound.Tidal.Types (ArcF (Arc), Direction (In, Out),
- Event (Event), Metadata (Metadata),
- Sequence (Atom, Cat), Signal,
- Strategy (Centre, Expand), Time)
+import Sound.Tidal.Signal (querySpan)
+import Sound.Tidal.Types (Alignment (Centre, Expand),
+ Event (Event), Metadata (Metadata),
+ Pattern, Sequence (Atom, Cat),
+ SequenceBind (SeqIn, SeqOut), Signal,
+ Span (Span), Time)
shouldMatch :: (Eq a, Show a) => Sequence a -> Sequence a -> Property
shouldMatch seq1 seq2 = shouldBe (stripSequenceMetadata seq1) (stripSequenceMetadata seq2)
@@ -32,12 +34,12 @@ run =
describe "Sound.Tidal.Sequence" $ do
describe "pairAligned" $ do
it "Aligns pairs of events" $ do
- (pairAligned In ("10 20", "1 2") :: Sequence (Int, Int))
+ (pairAligned SeqIn ("10 20", "1 2") :: Sequence (Int, Int))
`metaless`
Cat [step 1 (10,1), step 1 (20,2)]
describe "pairAlign" $ do
it "Can centre two sequences, paired into structure of the first one." $ do
- (pairAlign Centre In "10" "1 2")
+ (pairAlign Centre SeqIn "10" "1 2")
`metaless`
(Cat [a 0.5 0 0 Nothing,
a 0.5 0 0.5 $ Just (10,1),
@@ -46,31 +48,31 @@ run =
] :: Sequence (Int,Int))
describe "alignF" $ do
it "Can align and combine two sequences by expansion and addition" $ do
- ((alignF Expand In (+) "0 1 2" "10 20") :: Sequence Int)
+ ((alignF Expand SeqIn (+) "0 1 2" "10 20") :: Sequence Int)
`metaless`
(Cat [a 1 0 0 $ Just 10, a 0.5 0 0.5 $ Just 11, a 0.5 0.5 0 $ Just 21,
a 1 0 0 $ Just 22])
it "Can align and combine subsequences by expansion and addition with subsequence" $ do
- ((alignF Expand In (+) "0 [1 2] 3" "10 20") :: Sequence Int)
+ ((alignF Expand SeqIn (+) "0 [1 2] 3" "10 20") :: Sequence Int)
`metaless`
(Cat [a 1 0 0 $ Just 10, a 0.5 0 0 $ Just 11, a 0.5 0 0 $ Just 22,
a 1 0 0 $ Just 23])
it "Can align and combine subsequences by Expansion and addition with subsequences on both sides" $ do
- ((alignF Expand In (+) "0 [1 2] 3" "10 [20 30]") :: Sequence Int)
+ ((alignF Expand SeqIn (+) "0 [1 2] 3" "10 [20 30]") :: Sequence Int)
`metaless`
(Cat [a 1 0 0 $ Just 10, a 0.5 0 0 $ Just 11, a 0.5 0 0 $ Just 22,
a 0.25 0 0.75 $ Just 23, a 0.75 0.25 0 $ Just 33])
describe "beatMode" $ do
it "Can turn a sequence into a signal" $ do
- (queryArc (stripMetadata (seqToSignal' ( alignF Centre Out (+) ("10 20 30") ("1 2")) :: Signal Int)) (Arc 0 1))
+ (querySpan (stripMetadata (seqToSignal' ( alignF Centre SeqOut (+) ("10 20 30") ("1 2")) :: Signal Int)) (Span 0 1))
`shouldBe`
- [Event mempty (Just $ Arc (1/6) (1/2)) (Arc (1/6) (1/3)) 11,
- Event mempty (Just $ Arc (1/6) (1/2)) (Arc (1/3) (1/2)) 21,
- Event mempty (Just $ Arc (1/2) (5/6)) (Arc (1/2) (2/3)) 22,
- Event mempty (Just $ Arc (1/2) (5/6)) (Arc (2/3) (5/6)) 32
+ [Event mempty (Just $ Span (1/6) (1/2)) (Span (1/6) (1/3)) 11,
+ Event mempty (Just $ Span (1/6) (1/2)) (Span (1/3) (1/2)) 21,
+ Event mempty (Just $ Span (1/2) (5/6)) (Span (1/2) (2/3)) 22,
+ Event mempty (Just $ Span (1/2) (5/6)) (Span (2/3) (5/6)) 32
]
it "Can convert half an event" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(beatMode 0.5 $ Atom mempty 0.5 0 0.5 (Just 'a'))
(_slow 2 $ pure 'a')
diff --git a/test/Sound/Tidal/SignalComposeTest.hs b/tidal-core/test/Sound/Tidal/SignalComposeTest.hs
similarity index 100%
rename from test/Sound/Tidal/SignalComposeTest.hs
rename to tidal-core/test/Sound/Tidal/SignalComposeTest.hs
diff --git a/test/Sound/Tidal/SignalControlTest.hs b/tidal-core/test/Sound/Tidal/SignalControlTest.hs
similarity index 100%
rename from test/Sound/Tidal/SignalControlTest.hs
rename to tidal-core/test/Sound/Tidal/SignalControlTest.hs
diff --git a/test/Sound/Tidal/SignalRandomTest.hs b/tidal-core/test/Sound/Tidal/SignalRandomTest.hs
similarity index 100%
rename from test/Sound/Tidal/SignalRandomTest.hs
rename to tidal-core/test/Sound/Tidal/SignalRandomTest.hs
diff --git a/test/Sound/Tidal/SignalBaseTest.hs b/tidal-core/test/Sound/Tidal/SignalTest.hs
similarity index 57%
rename from test/Sound/Tidal/SignalBaseTest.hs
rename to tidal-core/test/Sound/Tidal/SignalTest.hs
index d34a623eb..8fde5d22c 100644
--- a/test/Sound/Tidal/SignalBaseTest.hs
+++ b/tidal-core/test/Sound/Tidal/SignalTest.hs
@@ -1,12 +1,11 @@
{-# LANGUAGE OverloadedStrings #-}
-module Sound.Tidal.SignalBaseTest where
+module Sound.Tidal.SignalTest where
+import Sound.Tidal.TestUtils (compareP, comparePD, toEvent)
import Test.Microspec (MTestable (describe), Microspec,
Testable (property), it, shouldBe,
(===))
-import TestUtils (compareP, comparePD,
- stripMetadata, toEvent)
import Prelude hiding ((*>), (<*))
@@ -14,127 +13,136 @@ import Data.List (sort)
import Data.Ratio ((%))
import Sound.Tidal.Compose (struct, (|+), (|=|))
-import Sound.Tidal.Params (n, s)
-import Sound.Tidal.ParseBP (parseBP_E)
-import Sound.Tidal.Pattern (_slow, append, atom, cat, early,
- euclid, euclidFull, euclidInv,
- every, fast, fastCat,
- filterValues, late, ply, press,
- pressBy, range, rev, run, silence,
- slow, stack, stripMetadata,
- timeCat, (*>), (<*), (<~), (~>))
-import Sound.Tidal.Signal.Base
+import Sound.Tidal.InstanceHacks
+import Sound.Tidal.Mininotation (parseBP_E)
+import Sound.Tidal.Params
+import Sound.Tidal.Pattern (_slow, append, ascii, binary,
+ binaryN, bite, chunk, early,
+ every, fast, fastcat, late,
+ necklace, ply, press, pressBy,
+ range, run, segment, slow,
+ snowball, soak, stripMetadata,
+ (*>), (<*), (<~), (~>))
+import Sound.Tidal.Signal
+import Sound.Tidal.Signal.Input (cF_)
import Sound.Tidal.Signal.Random (irand)
import Sound.Tidal.Signal.Waveform (saw, tri)
import Sound.Tidal.Types
import qualified Data.Map.Strict as Map
+
+s :: Pattern p => p String -> p ValueMap
+s = pS "s"
+
+n :: Pattern p => p Note -> p ValueMap
+n = pN "n"
+
run :: Microspec ()
run =
describe "Sound.Tidal.Signal.Base" $ do
- describe "atom" $ do
+ describe "pure" $ do
it "fills a whole cycle" $ do
- property $ queryArc (atom 0) (Arc 0 1) === [(Event mempty (Just $ Arc 0 1) (Arc 0 1) (0 :: Int))]
- it "returns the active of an atom that you ask for, preserving the whole" $ do
- property $ queryArc (atom 0) (Arc 0.25 0.75) === [(Event mempty (Just $ Arc 0 1) (Arc 0.25 0.75) (0 :: Int))]
+ property $ querySpan (pure 0) (Span 0 1) === [(Event mempty (Just $ Span 0 1) (Span 0 1) (0 :: Int))]
+ it "returns the active part, preserving the whole" $ do
+ property $ querySpan (pure 0) (Span 0.25 0.75) === [(Event mempty (Just $ Span 0 1) (Span 0.25 0.75) (0 :: Int))]
it "gives correct fragments when you go over cycle boundaries" $ do
- property $ queryArc (atom 0) (Arc 0.25 1.25) ===
- [ (Event mempty (Just $ Arc 0 1) (Arc 0.25 1) (0 :: Int)),
- (Event mempty (Just $ Arc 1 2) (Arc 1 1.25) 0)
+ property $ querySpan (pure 0) (Span 0.25 1.25) ===
+ [ (Event mempty (Just $ Span 0 1) (Span 0.25 1) (0 :: Int)),
+ (Event mempty (Just $ Span 1 2) (Span 1 1.25) 0)
]
it "works with zero-length queries" $ do
it "0" $
- queryArc (atom "a") (Arc 0 0)
+ querySpan (pure "a") (Span 0 0)
`shouldBe` fmap toEvent [(((0,1), (0,0)), "a" :: String)]
it "1/3" $
- queryArc (atom "a") (Arc (1%3) (1%3))
+ querySpan (pure "a") (Span (1%3) (1%3))
`shouldBe` fmap toEvent [(((0,1), (1%3,1%3)), "a" :: String)]
describe "_fastGap" $ do
it "copes with cross-cycle queries" $ do
- (queryArc(_fastGap 2 $ fastCat [atom "a", atom "b"]) (Arc 0.5 1.5))
+ (querySpan(_fastGap 2 $ fastcat [pure "a", pure "b"]) (Span 0.5 1.5))
`shouldBe`
- [(Event mempty (Just $ Arc (1 % 1) (5 % 4)) (Arc (1 % 1) (5 % 4)) ("a" :: String)),
- (Event mempty (Just $ Arc (5 % 4) (3 % 2)) (Arc (5 % 4) (3 % 2)) "b")
+ [(Event mempty (Just $ Span (1 % 1) (5 % 4)) (Span (1 % 1) (5 % 4)) ("a" :: String)),
+ (Event mempty (Just $ Span (5 % 4) (3 % 2)) (Span (5 % 4) (3 % 2)) "b")
]
it "copes with breaking up events across cycles" $ do
- (queryArc (stripMetadata $ _fastGap 2 $ slow 2 "a") (Arc 0 2))
+ (querySpan (stripMetadata $ _fastGap 2 $ slow 2 "a") (Span 0 2))
`shouldBe`
- [(Event mempty (Just $ Arc 0 1) (Arc 0 0.5) ("a" :: String)),
- (Event mempty (Just $ Arc 0.5 1.5) (Arc 1 1.5) "a")
+ [(Event mempty (Just $ Span 0 1) (Span 0 0.5) ("a" :: String)),
+ (Event mempty (Just $ Span 0.5 1.5) (Span 1 1.5) "a")
]
it "does not return events outside of the query" $ do
- (queryArc(_fastGap 2 $ fastCat [atom "a", atom ("b" :: String)]) (Arc 0.5 0.9))
+ (querySpan(_fastGap 2 $ fastcat [pure "a", pure ("b" :: String)]) (Span 0.5 0.9))
`shouldBe` []
describe "<*>" $ do
it "can apply a signal of values to a signal of values" $ do
- queryArc ((atom (+1)) <*> (atom 3)) (Arc 0 1) `shouldBe` fmap toEvent [(((0,1), (0,1)), 4 :: Int)]
+ querySpan ((pure (+1)) <*> (pure 3)) (Span 0 1) `shouldBe` fmap toEvent [(((0,1), (0,1)), 4 :: Int)]
it "can take structure from the left" $ do
- queryArc ((fastCat [atom (+1), atom (+2)]) <*> (atom 3)) (Arc 0 1) `shouldBe` fmap toEvent
+ querySpan ((fastcat [pure (+1), pure (+2)]) <*> (pure 3)) (Span 0 1) `shouldBe` fmap toEvent
[(((0,0.5), (0,0.5)), 4 :: Int),
(((0.5,1), (0.5,1)), 5)
]
it "can take structure from the right" $ do
- queryArc (atom (+1) <*> (fastCat [atom 7, atom 8])) (Arc 0 1) `shouldBe` fmap toEvent
+ querySpan (pure (+1) <*> (fastcat [pure 7, pure 8])) (Span 0 1) `shouldBe` fmap toEvent
[(((0,0.5), (0,0.5)), 8 :: Int),
(((0.5,1), (0.5,1)), 9)
]
it "can take structure from the both sides" $ do
it "one" $
- queryArc ((fastCat [atom (+1), atom (+2)]) <*> (fastCat [atom 7, atom 8])) (Arc 0 1)
+ querySpan ((fastcat [pure (+1), pure (+2)]) <*> (fastcat [pure 7, pure 8])) (Span 0 1)
`shouldBe` fmap toEvent
[(((0,0.5), (0,0.5)), 8 :: Int),
(((0.5,1), (0.5,1)), 10)
]
it "two" $
- queryArc ((fastCat [atom (+1), atom (+2), atom (+3)]) <*> (fastCat [atom 7, atom 8])) (Arc 0 1)
+ querySpan ((fastcat [pure (+1), pure (+2), pure (+3)]) <*> (fastcat [pure 7, pure 8])) (Span 0 1)
`shouldBe` fmap toEvent
[ (((0%1, 1%3), (0%1, 1%3)), 8 :: Int),
(((1%3, 1%2), (1%3, 1%2)), 9),
(((1%2, 2%3), (1%2, 2%3)), 10),
(((2%3, 1%1), (2%3, 1%1)), 11)
]
- it "obeys atom id <*> v = v" $ do
- let v = (fastCat [fastCat [atom 7, atom 8], atom 9]) :: Signal Int
- queryArc ((atom id <*> v)) (Arc 0 5) `shouldBe` queryArc v (Arc 0 5)
+ it "obeys pure id <*> v = v" $ do
+ let v = (fastcat [fastcat [pure 7, pure 8], pure 9]) :: Signal Int
+ querySpan ((pure id <*> v)) (Span 0 5) `shouldBe` querySpan v (Span 0 5)
- it "obeys atom f <*> atom x = atom (f x)" $ do
+ it "obeys pure f <*> pure x = pure (f x)" $ do
let f = (+3)
x = 7 :: Int
- queryArc (atom f <*> atom x) (Arc 0 5) `shouldBe` queryArc (atom (f x)) (Arc 0 5)
+ querySpan (pure f <*> pure x) (Span 0 5) `shouldBe` querySpan (pure (f x)) (Span 0 5)
- it "obeys u <*> atom y = atom ($ y) <*> u" $ do
- let u = fastCat [atom (+7), atom (+8)]
+ it "obeys u <*> pure y = pure ($ y) <*> u" $ do
+ let u = fastcat [pure (+7), pure (+8)]
y = 6 :: Int
- queryArc (u <*> atom y) (Arc 0 5) `shouldBe` queryArc (atom ($ y) <*> u) (Arc 0 5)
+ querySpan (u <*> pure y) (Span 0 5) `shouldBe` querySpan (pure ($ y) <*> u) (Span 0 5)
- it "obeys atom (.) <*> u <*> v <*> w = u <*> (v <*> w)" $ do
- let u = (fastCat [atom (+7), atom (+8)]) :: Signal (Int -> Int)
- v = fastCat [atom (+3), atom (+4), atom (+5)]
- w = fastCat [atom 1, atom 2]
- queryArc (atom (.) <*> u <*> v <*> w) (Arc 0 5) `shouldBe` queryArc (u <*> (v <*> w)) (Arc 0 5)
+ it "obeys pure (.) <*> u <*> v <*> w = u <*> (v <*> w)" $ do
+ let u = (fastcat [pure (+7), pure (+8)]) :: Signal (Int -> Int)
+ v = fastcat [pure (+3), pure (+4), pure (+5)]
+ w = fastcat [pure 1, pure 2]
+ querySpan (pure (.) <*> u <*> v <*> w) (Span 0 5) `shouldBe` querySpan (u <*> (v <*> w)) (Span 0 5)
describe "<*" $ do
it "can apply a signal of values to a signal of functions" $ do
- queryArc ((atom (+1)) <* (atom 3)) (Arc 0 1) `shouldBe` fmap toEvent
+ querySpan ((pure (+1)) <* (pure 3)) (Span 0 1) `shouldBe` fmap toEvent
[(((0,1), (0,1)), 4 :: Int)]
it "doesn't take structure from the right" $ do
- queryArc (atom (+1) <* (fastCat [atom 7, atom 8])) (Arc 0 1)
+ querySpan (pure (+1) <* (fastcat [pure 7, pure 8])) (Span 0 1)
`shouldBe` fmap toEvent [(((0,1), (0,0.5)), 8 :: Int),
(((0,1), (0.5,1)), 9 :: Int)
]
describe "*>" $ do
it "can apply a signal of values to a signal of functions" $ do
- it "works within cycles" $ queryArc ((atom (+1)) *> (atom 3)) (Arc 0 1) `shouldBe` fmap toEvent [(((0,1), (0,1)), 4 :: Int)]
- it "works across cycles" $ queryArc ((atom (+1)) *> (slow 2 $ atom 3)) (Arc 0 1) `shouldBe` fmap toEvent [(((0,2), (0,1)), 4 :: Int)]
+ it "works within cycles" $ querySpan ((pure (+1)) *> (pure 3)) (Span 0 1) `shouldBe` fmap toEvent [(((0,1), (0,1)), 4 :: Int)]
+ it "works across cycles" $ querySpan ((pure (+1)) *> (slow 2 $ pure 3)) (Span 0 1) `shouldBe` fmap toEvent [(((0,2), (0,1)), 4 :: Int)]
it "doesn't take structure from the left" $ do
- queryArc (atom (+1) *> (fastCat [atom 7, atom 8])) (Arc 0 1)
+ querySpan (pure (+1) *> (fastcat [pure 7, pure 8])) (Span 0 1)
`shouldBe` fmap toEvent
[(((0,0.5), (0,0.5)), 8 :: Int),
(((0.5,1), (0.5,1)), 9 :: Int)
@@ -143,160 +151,153 @@ run =
describe "mixJoin" $ do
it "preserves inner structure" $ do
it "one" $
- (queryArc (mixJoin $ atom (fastCat [atom "a", atom ("b" :: String)])) (Arc 0 1))
- `shouldBe` (queryArc (fastCat [atom "a", atom "b"]) (Arc 0 1))
+ (querySpan (mixJoin $ pure (fastcat [pure "a", pure ("b" :: String)])) (Span 0 1))
+ `shouldBe` (querySpan (fastcat [pure "a", pure "b"]) (Span 0 1))
it "two" $
- (queryArc (mixJoin $ atom (fastCat [atom "a", atom "b", fastCat [atom "c", atom ("d" :: String)]])) (Arc 0 1))
- `shouldBe` (queryArc (fastCat [atom "a", atom "b", fastCat [atom "c", atom "d"]]) (Arc 0 1))
+ (querySpan (mixJoin $ pure (fastcat [pure "a", pure "b", fastcat [pure "c", pure ("d" :: String)]])) (Span 0 1))
+ `shouldBe` (querySpan (fastcat [pure "a", pure "b", fastcat [pure "c", pure "d"]]) (Span 0 1))
it "preserves outer structure" $ do
it "one" $
- (queryArc (mixJoin $ fastCat [atom $ atom "a", atom $ atom ("b" :: String)]) (Arc 0 1))
- `shouldBe` (queryArc (fastCat [atom "a", atom "b"]) (Arc 0 1))
+ (querySpan (mixJoin $ fastcat [pure $ pure "a", pure $ pure ("b" :: String)]) (Span 0 1))
+ `shouldBe` (querySpan (fastcat [pure "a", pure "b"]) (Span 0 1))
it "two" $
- (queryArc (mixJoin $ fastCat [atom $ atom "a", atom $ atom "b", fastCat [atom $ atom "c", atom $ atom ("d" :: String)]]) (Arc 0 1))
- `shouldBe` (queryArc (fastCat [atom "a", atom "b", fastCat [atom "c", atom "d"]]) (Arc 0 1))
+ (querySpan (mixJoin $ fastcat [pure $ pure "a", pure $ pure "b", fastcat [pure $ pure "c", pure $ pure ("d" :: String)]]) (Span 0 1))
+ `shouldBe` (querySpan (fastcat [pure "a", pure "b", fastcat [pure "c", pure "d"]]) (Span 0 1))
it "gives events whole/active timespans that are an intersection of that of inner and outer events" $ do
- let a = fastCat [atom "a", atom "b"]
- b = fastCat [atom "c", atom "d", atom "e"]
- pp = fastCat [atom a, atom b]
- queryArc (mixJoin pp) (Arc 0 1)
- `shouldBe` [(Event mempty (Just $ Arc (0 % 1) (1 % 2)) (Arc (0 % 1) (1 % 2)) ("a" :: String)),
- (Event mempty (Just $ Arc (1 % 2) (2 % 3)) (Arc (1 % 2) (2 % 3)) "d"),
- (Event mempty (Just $ Arc (2 % 3) (1 % 1)) (Arc (2 % 3) (1 % 1)) "e")
+ let a = fastcat [pure "a", pure "b"]
+ b = fastcat [pure "c", pure "d", pure "e"]
+ pp = fastcat [pure a, pure b]
+ querySpan (mixJoin pp) (Span 0 1)
+ `shouldBe` [(Event mempty (Just $ Span (0 % 1) (1 % 2)) (Span (0 % 1) (1 % 2)) ("a" :: String)),
+ (Event mempty (Just $ Span (1 % 2) (2 % 3)) (Span (1 % 2) (2 % 3)) "d"),
+ (Event mempty (Just $ Span (2 % 3) (1 % 1)) (Span (2 % 3) (1 % 1)) "e")
]
describe "squeezeJoin" $ do
- it "compresses cycles to fit outer 'whole' timearc of event" $ do
- let a = fastCat [atom "a", atom "b"]
- b = fastCat [atom "c", atom "d", atom "e"]
- pp = fastCat [atom a, atom b]
- queryArc (squeezeJoin pp) (Arc 0 1)
- `shouldBe` [(Event mempty (Just $ Arc (0 % 1) (1 % 4)) (Arc (0 % 1) (1 % 4)) ("a" :: String)),
- (Event mempty (Just $ Arc (1 % 4) (1 % 2)) (Arc (1 % 4) (1 % 2)) "b"),
- (Event mempty (Just $ Arc (1 % 2) (2 % 3)) (Arc (1 % 2) (2 % 3)) "c"),
- (Event mempty (Just $ Arc (2 % 3) (5 % 6)) (Arc (2 % 3) (5 % 6)) "d"),
- (Event mempty (Just $ Arc (5 % 6) (1 % 1)) (Arc (5 % 6) (1 % 1)) "e")
+ it "compresses cycles to fit outer 'whole' timespan of event" $ do
+ let a = fastcat [pure "a", pure "b"]
+ b = fastcat [pure "c", pure "d", pure "e"]
+ pp = fastcat [pure a, pure b]
+ querySpan (squeezeJoin pp) (Span 0 1)
+ `shouldBe` [(Event mempty (Just $ Span (0 % 1) (1 % 4)) (Span (0 % 1) (1 % 4)) ("a" :: String)),
+ (Event mempty (Just $ Span (1 % 4) (1 % 2)) (Span (1 % 4) (1 % 2)) "b"),
+ (Event mempty (Just $ Span (1 % 2) (2 % 3)) (Span (1 % 2) (2 % 3)) "c"),
+ (Event mempty (Just $ Span (2 % 3) (5 % 6)) (Span (2 % 3) (5 % 6)) "d"),
+ (Event mempty (Just $ Span (5 % 6) (1 % 1)) (Span (5 % 6) (1 % 1)) "e")
]
describe ">>=" $ do
it "can apply functions to signals" $ do
- let p = fastCat [atom 7, atom 8] :: Signal Int
+ let p = fastcat [pure 7, pure 8] :: Signal Int
p' = do x <- p
return $ x + 1
- (queryArc p' (Arc 0 1)) `shouldBe` (queryArc ((+1) <$> p) (Arc 0 1))
+ (querySpan p' (Span 0 1)) `shouldBe` (querySpan ((+1) <$> p) (Span 0 1))
it "can add two signals together" $ do
- let p1 = fastCat [atom 7, atom 8, atom 9] :: Signal Int
- p2 = fastCat [atom 4, fastCat [atom 5, atom 6]]
+ let p1 = fastcat [pure 7, pure 8, pure 9] :: Signal Int
+ p2 = fastcat [pure 4, fastcat [pure 5, pure 6]]
p' = do x <- p1
y <- p2
return $ x + y
- compareP (Arc 0 1) p' ((+) <$> p1 <*> p2)
+ compareP (Span 0 1) p' ((+) <$> p1 <*> p2)
it "conforms to (return v) >>= f = f v" $ do
- let f x = atom $ x + 10
+ let f x = pure $ x + 10
v = 5 :: Int
- compareP (Arc 0 5) ((return v) >>= f) (f v)
+ compareP (Span 0 5) ((return v) >>= f) (f v)
it "conforms to m >>= return ≡ m" $ do
- let m = fastCat [atom "a", fastCat [atom "b", atom ("c" :: String)]]
- compareP (Arc 0 1) (m >>= return) m
+ let m = fastcat [pure "a", fastcat [pure "b", pure ("c" :: String)]]
+ compareP (Span 0 1) (m >>= return) m
-- it "conforms to (m >>= f) >>= g ≡ m >>= ( \x -> (f x >>= g) )" $ do
- -- let m = fastCat [atom "a", fastCat [atom "b", atom "c"]]
+ -- let m = fastcat [pure "a", fastcat [pure "b", pure "c"]]
describe "late" $ do
it "works over two cycles" $
- property $ comparePD (Arc 0 2) (0.25 ~> atom "a") (0.25 `late` atom ("a" :: String))
+ property $ comparePD (Span 0 2) (0.25 ~> pure "a") (0.25 `late` pure ("a" :: String))
it "works over one cycle" $
- property $ compareP (Arc 0 1) (0.25 ~> atom "a") (0.25 `late` atom ("a" :: String))
+ property $ compareP (Span 0 1) (0.25 ~> pure "a") (0.25 `late` pure ("a" :: String))
it "works with zero width queries" $
- property $ compareP (Arc 0 0) (0.25 ~> atom "a") (0.25 `late` atom ("a" :: String))
+ property $ compareP (Span 0 0) (0.25 ~> pure "a") (0.25 `late` pure ("a" :: String))
-- This is now in TestUtils.hs
describe "comparePD" $ do
it "allows split events to be compared" $
- property $ comparePD (Arc 0 2)
- (splitQueries $ _slow 2 $ atom ("a" :: String))
- (_slow 2 $ atom "a")
+ property $ comparePD (Span 0 2)
+ (splitQueries $ _slow 2 $ pure ("a" :: String))
+ (_slow 2 $ pure "a")
describe "cF_" $ do
it "can retrieve values from state" $
- (query (atom 3 + cF_ "hello") $ State (Arc 0 1) (Map.singleton "hello" (VF 0.5)))
- `shouldBe` [(Event mempty (Just $ Arc (0 % 1) (1 % 1)) (Arc (0 % 1) (1 % 1)) 3.5)]
-
- describe "withEventArc" $ do
- it "apply given function to the Arcs" $ do
- let p = withEventArc (+5) (stripMetadata $ fast "1 2" "3 4" :: Signal 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)]
-
+ (query (pure 3 + cF_ "hello") $ State (Span 0 1) (Map.singleton "hello" (VF 0.5)))
+ `shouldBe` [(Event mempty (Just $ Span (0 % 1) (1 % 1)) (Span (0 % 1) (1 % 1)) 3.5)]
describe "filterValues" $ do
it "remove Events above given threshold" $ do
- let fil = filterValues (<2) $ fastCat [atom 1, atom 2, atom 3] :: Signal Time
- let res = queryArc fil (Arc 0.5 1.5)
+ let fil = filterValues (<2) $ fastcat [pure 1, pure 2, pure 3] :: Signal Time
+ let res = querySpan fil (Span 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 [atom 1, atom 2, atom 3] :: Signal Time
- let res = queryArc fil (Arc 0.5 1.5)
+ let fil = filterValues (>2) $ fastcat [pure 1, pure 2, pure 3] :: Signal Time
+ let res = querySpan fil (Span 0.5 1.5)
property $ fmap toEvent [(((2%3, 1), (2%3, 1)), 3%1)] === res
describe "filterTime" $ do
it "filter below given threshold" $ do
let fil = filterTime (<0.5) $ struct "t*4" $ (tri :: Signal Double) + 1
- let res = queryArc fil (Arc 0.5 1.5)
+ let res = querySpan fil (Span 0.5 1.5)
property $ [] === res
it "filter above given threshold" $ do
let fil = stripMetadata $ filterTime (>0.5) $ struct "t*4" $ (tri :: Signal Double) + 1
- let res = queryArc fil (Arc 0.5 1.5)
+ let res = querySpan fil (Span 0.5 1.5)
property $ fmap toEvent [(((3%4, 1), (3%4, 1)), 1.25), (((1, 5%4), (1, 5%4)), 1.25), (((5%4, 3%2), (5%4, 3%2)), 1.75)] === res
- describe "_compressArc" $ do
+ describe "_compressSpan" $ 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" :: Signal Time) ) (Arc 1 2)
+ let res = querySpan (_compressSpan (Span 0.8 0.1) (fast "1 2" "3 4" :: Signal Time) ) (Span 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" :: Signal Time)) (Arc 1 2)
+ let res = querySpan (_compressSpan (Span 0.1 2) (fast "1 2" "3 4" :: Signal Time)) (Span 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" :: Signal Time)) (Arc 1 2)
+ let res = querySpan (_compressSpan (Span (-0.8) 0.1) (fast "1 2" "3 4" :: Signal Time)) (Span 1 2)
property $ [] === res
- it "otherwise compress difference between start and end values of Arc" $ do
+ it "otherwise compress difference between start and end values of Span" $ do
let p = fast "1 2" "3 4" :: Signal Time
- let res = queryArc (stripMetadata $ _compressArc (Arc 0.2 0.8) p) (Arc 0 1)
+ let res = querySpan (stripMetadata $ _compressSpan (Span 0.2 0.8) p) (Span 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
describe "timecat" $ do
it "works across cycle boundaries" $ do
- queryArc (timeCat [(1, (slow 2 "a") :: Signal String)]) (Arc 0 2)
+ querySpan (timeCat [(1, (slow 2 "a") :: Signal String)]) (Span 0 2)
`shouldBe`
- queryArc (slow 2 "a" :: Signal String) (Arc 0 2)
+ querySpan (slow 2 "a" :: Signal String) (Span 0 2)
describe "every" $
it "`every n id` doesn't change the signal's structure" $ do
comparePD
- (Arc 0 4)
+ (Span 0 4)
(every 2 id "x/2" :: Signal String)
"x/2"
describe "loopFirst" $ do
it "plays the first cycle" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(loopFirst $ early 3 $ slow 8 $ "0 .. 7" :: Signal Int)
("3")
it "plays the first cycle" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(fast 4 $ loopFirst $ "<0 1 2 3>" :: Signal Int)
("0 0 0 0")
describe "append" $
it "can switch between the cycles from two pures" $ do
- queryArc (append (pure "a") (pure "b")) (Arc 0 5)
+ querySpan (append (pure "a") (pure "b")) (Span 0 5)
`shouldBe` fmap
toEvent
[ (((0, 1), (0, 1)), "a" :: String),
@@ -308,7 +309,7 @@ run =
describe "cat" $ do
it "can switch between the cycles from three pures" $ do
- queryArc (cat [pure "a", pure "b", pure "c"]) (Arc 0 5)
+ querySpan (cat [pure "a", pure "b", pure "c"]) (Span 0 5)
`shouldBe` fmap
toEvent
[ (((0, 1), (0, 1)), "a" :: String),
@@ -322,14 +323,14 @@ run =
b = "4 5 6" :: Signal Int
c = "7 8 9" :: Signal Int
in comparePD
- (Arc 0 10)
+ (Span 0 10)
(rev $ cat [a, b, c])
(cat [rev a, rev b, rev c])
- describe "fastCat" $ do
+ describe "fastcat" $ do
it "can switch between the cycles from three pures inside one cycle" $ do
it "1" $
- queryArc (fastCat [pure "a", pure "b", pure "c"]) (Arc 0 1)
+ querySpan (fastcat [pure "a", pure "b", pure "c"]) (Span 0 1)
`shouldBe` fmap
toEvent
[ (((0, 1 / 3), (0, 1 / 3)), "a" :: String),
@@ -337,7 +338,7 @@ run =
(((2 / 3, 1), (2 / 3, 1)), "c")
]
it "5/3" $
- queryArc (fastCat [pure "a", pure "b", pure "c"]) (Arc 0 (5 / 3))
+ querySpan (fastcat [pure "a", pure "b", pure "c"]) (Span 0 (5 / 3))
`shouldBe` fmap
toEvent
[ (((0, 1 / 3), (0, 1 / 3)), "a" :: String),
@@ -348,22 +349,22 @@ run =
]
it "works with zero-length queries" $ do
it "0" $
- queryArc (fastCat [pure "a", pure "b"]) (Arc 0 0)
+ querySpan (fastcat [pure "a", pure "b"]) (Span 0 0)
`shouldBe` fmap toEvent [(((0, 0.5), (0, 0)), "a" :: String)]
it "1/3" $
- queryArc (fastCat [pure "a", pure "b"]) (Arc (1 % 3) (1 % 3))
+ querySpan (fastcat [pure "a", pure "b"]) (Span (1 % 3) (1 % 3))
`shouldBe` fmap toEvent [(((0, 0.5), (1 % 3, 1 % 3)), "a" :: String)]
describe "rev" $ do
it "mirrors events" $ do
- let forward = fastCat [fastCat [pure 7, pure 8], pure 9] :: Signal Int
- backward = fastCat [pure 9, fastCat [pure 8, pure 7]]
+ let forward = fastcat [fastcat [pure 7, pure 8], pure 9] :: Signal Int
+ backward = fastcat [pure 9, fastcat [pure 8, pure 7]]
-- sort the events into time order to compare them
- sort (queryArc (rev forward) (Arc 0 1)) `shouldBe` sort (queryArc backward (Arc 0 1))
+ sort (querySpan (rev forward) (Span 0 1)) `shouldBe` sort (querySpan backward (Span 0 1))
it "returns the original if you reverse it twice" $ do
- let x = fastCat [fastCat [pure 7, pure 8], pure 9] :: Signal Int
- queryArc (rev $ rev x) (Arc 0 5) `shouldBe` queryArc x (Arc 0 5)
+ let x = fastcat [fastcat [pure 7, pure 8], pure 9] :: Signal Int
+ querySpan (rev $ rev x) (Span 0 5) `shouldBe` querySpan x (Span 0 5)
describe "|=|" $ do
@@ -374,32 +375,32 @@ run =
it "creates silence when" $ do
it "first argument silent" $
comparePD
- (Arc 0 1)
+ (Span 0 1)
(silence |=| a)
silence
it "second argument silent" $
comparePD
- (Arc 0 1)
+ (Span 0 1)
(a |=| silence)
silence
it "creates the same signal when left argument has the same structure" $
comparePD
- (Arc 0 1)
+ (Span 0 1)
(b |=| a)
(d |=| a)
it "can extract rev from first argument" $
comparePD
- (Arc 0 1)
+ (Span 0 1)
(rev a |=| b)
(rev (a |=| rev b))
it "is assiociative" $
comparePD
- (Arc 0 1)
+ (Span 0 1)
((a |=| b) |=| c)
(a |=| (b |=| c))
it "is commutative in all arguments except the rightmost" $
comparePD
- (Arc 0 1)
+ (Span 0 1)
(a |=| b |=| c)
(b |=| a |=| c)
@@ -409,27 +410,27 @@ run =
c = "7 8 9" :: Signal Int
it "is neutral with silence" $
comparePD
- (Arc 0 1)
+ (Span 0 1)
(stack [a, silence])
a
it "can create silence" $
comparePD
- (Arc 0 1)
+ (Span 0 1)
(stack [] :: Signal Int)
silence
it "follows commutative laws" $
comparePD
- (Arc 0 1)
+ (Span 0 1)
(stack [a, b])
(stack [b, a])
it "follows associative laws" $
comparePD
- (Arc 0 1)
+ (Span 0 1)
(stack [a, stack [b, c]])
(stack [stack [a, b], c])
it "can extract nested revs" $
comparePD
- (Arc 0 1)
+ (Span 0 1)
(rev $ stack [a, b, c])
(stack [rev a, rev b, rev c])
@@ -439,38 +440,38 @@ run =
y = "4 5 6" :: Signal Time
it "is neutral with speedup 1" $
comparePD
- (Arc 0 1)
+ (Span 0 1)
(fast 1 x)
x
it "mutes, when there is" $ do
it "silence in first argument" $
comparePD
- (Arc 0 1)
+ (Span 0 1)
(fast silence x)
silence
it "silence in second argument" $
comparePD
- (Arc 0 1)
+ (Span 0 1)
(fast x silence :: Signal Time)
silence
it "speedup by 0" $
comparePD
- (Arc 0 1)
+ (Span 0 1)
(fast 0 x)
silence
it "is reciprocal to slow" $
comparePD
- (Arc 0 1)
+ (Span 0 1)
(fast 2 x)
(slow (fromRational $ 1 % 2) x)
it "can be reversed by reciprocal speedup" $
comparePD
- (Arc 0 1)
+ (Span 0 1)
(fast 2 $ fast (fromRational $ 1 % 2) x)
x
it "preserves structure" $
comparePD
- (Arc 0 1)
+ (Span 0 1)
(fast x (stack [y, y]))
(fast (stack [x, x]) y)
@@ -479,61 +480,61 @@ run =
y = "4 5 6" :: Signal Time
it "is neutral with slowdown 1" $
comparePD
- (Arc 0 10)
+ (Span 0 10)
(slow 1 x)
x
it "mutes, when there is" $ do
it "silence in first argument" $
comparePD
- (Arc 0 10)
+ (Span 0 10)
(slow silence x)
silence
it "silence in second argument" $
comparePD
- (Arc 0 10)
+ (Span 0 10)
(slow x silence :: Signal Time)
silence
it "speedup by 0" $
comparePD
- (Arc 0 10)
+ (Span 0 10)
(slow 0 x)
silence
it "is reciprocal to fast" $
comparePD
- (Arc 0 10)
+ (Span 0 10)
(slow 2 x)
(fast (fromRational $ 1 % 2) x)
it "can be reversed by reciprocal slowdown" $
comparePD
- (Arc 0 10)
+ (Span 0 10)
(slow 2 $ slow (fromRational $ 1 % 2) x)
x
it "preserves structure" $
comparePD
- (Arc 0 1)
+ (Span 0 1)
(slow x (stack [y, y]))
(slow (stack [x, x]) y)
describe "compress" $ do
it "squashes cycles to the start of a cycle" $ do
- let p = compress 0 0.5 $ fastCat [pure 7, pure 8] :: Signal Int
- queryArc p (Arc 0 1)
+ let p = compress 0 0.5 $ fastcat [pure 7, pure 8] :: Signal Int
+ querySpan p (Span 0 1)
`shouldBe` fmap
toEvent
[ (((0, 0.25), (0, 0.25)), 7),
(((0.25, 0.5), (0.25, 0.5)), 8)
]
it "squashes cycles to the end of a cycle" $ do
- let p = compress 0.5 0.5 $ fastCat [pure 7, pure 8] :: Signal Int
- queryArc p (Arc 0 1)
+ let p = compress 0.5 0.5 $ fastcat [pure 7, pure 8] :: Signal Int
+ querySpan p (Span 0 1)
`shouldBe` fmap
toEvent
[ (((0.5, 0.75), (0.5, 0.75)), 7 :: Int),
(((0.75, 1), (0.75, 1)), 8)
]
it "squashes cycles to the middle of a cycle" $ do
- let p = compress 0.25 0.5 $ fastCat [pure 7, pure 8]
- queryArc p (Arc 0 1)
+ let p = compress 0.25 0.5 $ fastcat [pure 7, pure 8]
+ querySpan p (Span 0 1)
`shouldBe` fmap
toEvent
[ (((0.25, 0.5), (0.25, 0.5)), 7 :: Int),
@@ -544,21 +545,21 @@ run =
describe "segment" $ do
it "can turn a single event into multiple events" $ do
- compareP (Arc 0 3)
+ compareP (Span 0 3)
(segment 4 "x")
("x*4" :: Signal String)
it "can turn a continuous pattern into multiple discrete events" $ do
- compareP (Arc 0 3)
+ compareP (Span 0 3)
(segment 4 saw)
("0.125 0.375 0.625 0.875" :: Signal Double)
it "can hold a value over multiple cycles" $ do
- comparePD (Arc 0 8)
+ comparePD (Span 0 8)
(segment 0.5 saw)
(slow 2 "0" :: Signal Double)
{-
-- not sure what this is supposed to do!
it "holding values over multiple cycles works in combination" $ do
- comparePD (Arc 0 8)
+ comparePD (Span 0 8)
("0*4" |+ (_segment (1/8) $ saw))
("0*4" :: Signal Double)
-}
@@ -568,68 +569,68 @@ run =
describe "scales a pattern to the supplied range" $ do
describe "from 3 to 4" $ do
it "at the start of a cycle" $
- (queryArc (range 3 4 saw) (Arc 0 0)) `shouldBe`
- [Event mempty Nothing (Arc 0 0) (3 :: Float)]
+ (querySpan (range 3 4 saw) (Span 0 0)) `shouldBe`
+ [Event mempty Nothing (Span 0 0) (3 :: Float)]
it "at 1/4 of a cycle" $
- (queryArc (range 3 4 saw) (Arc 0.25 0.25)) `shouldBe`
- [Event mempty Nothing (Arc 0.25 0.25) (3.25 :: Float)]
+ (querySpan (range 3 4 saw) (Span 0.25 0.25)) `shouldBe`
+ [Event mempty Nothing (Span 0.25 0.25) (3.25 :: Float)]
it "at 3/4 of a cycle" $
- (queryArc (range 3 4 saw) (Arc 0.75 0.75)) `shouldBe`
- [Event mempty Nothing (Arc 0.75 0.75) (3.75 :: Float)]
+ (querySpan (range 3 4 saw) (Span 0.75 0.75)) `shouldBe`
+ [Event mempty Nothing (Span 0.75 0.75) (3.75 :: Float)]
describe "from -1 to 1" $ do
it "at 1/2 of a cycle" $
- (queryArc (range (-1) 1 saw) (Arc 0.5 0.5)) `shouldBe`
- [Event mempty Nothing (Arc 0.5 0.5) (0 :: Float)]
+ (querySpan (range (-1) 1 saw) (Span 0.5 0.5)) `shouldBe`
+ [Event mempty Nothing (Span 0.5 0.5) (0 :: Float)]
describe "from 4 to 2" $ do
it "at the start of a cycle" $
- (queryArc (range 4 2 saw) (Arc 0 0)) `shouldBe`
- [Event mempty Nothing (Arc 0 0) (4 :: Float)]
+ (querySpan (range 4 2 saw) (Span 0 0)) `shouldBe`
+ [Event mempty Nothing (Span 0 0) (4 :: Float)]
it "at 1/4 of a cycle" $
- (queryArc (range 4 2 saw) (Arc 0.25 0.25)) `shouldBe`
- [Event mempty Nothing (Arc 0.25 0.25) (3.5 :: Float)]
+ (querySpan (range 4 2 saw) (Span 0.25 0.25)) `shouldBe`
+ [Event mempty Nothing (Span 0.25 0.25) (3.5 :: Float)]
it "at 3/4 of a cycle" $
- (queryArc (range 4 2 saw) (Arc 0.75 0.75)) `shouldBe`
- [Event mempty Nothing (Arc 0.75 0.75) (2.5 :: Float)]
+ (querySpan (range 4 2 saw) (Span 0.75 0.75)) `shouldBe`
+ [Event mempty Nothing (Span 0.75 0.75) (2.5 :: Float)]
describe "from 10 to 10" $ do
it "at 1/2 of a cycle" $
- (queryArc (range 10 10 saw) (Arc 0.5 0.5)) `shouldBe`
- [Event mempty Nothing (Arc 0.5 0.5) (10 :: Float)]
+ (querySpan (range 10 10 saw) (Span 0.5 0.5)) `shouldBe`
+ [Event mempty Nothing (Span 0.5 0.5) (10 :: Float)]
describe "rot" $ do
it "rotates values in a pattern irrespective of structure" $
- property $ comparePD (Arc 0 2)
+ property $ comparePD (Span 0 2)
(rot 1 "a ~ b c" :: Signal String)
( "b ~ c a" :: Signal String)
it "works with negative values" $
- property $ comparePD (Arc 0 2)
+ property $ comparePD (Span 0 2)
(rot (-1) "a ~ b c" :: Signal String)
( "c ~ a b" :: Signal String)
it "works with complex patterns" $
- property $ comparePD (Arc 0 2)
+ property $ comparePD (Span 0 2)
(rot (1) "a ~ [b [c ~ d]] [e ]" :: Signal String)
( "b ~ [c [d ~ e]] [ a]" :: Signal String)
describe "ply" $ do
it "can ply chords" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(ply 3 "[0,1] [3,4,5] 6")
("[0,1]*3 [3,4,5]*3 6*3" :: Signal Int)
it "can pattern the ply factor" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(ply "3 4 5" "[0,1] [3,4,5] 6")
("[0,1]*3 [3,4,5]*4 6*5" :: Signal Int)
describe "press" $ do
it "can syncopate a pattern" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(press "a b [c d] e")
("[~ a] [~ b] [[~ c] [~ d]] [~ e]" :: Signal String)
describe "pressBy" $ do
it "can syncopate a pattern by a given amount" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(pressBy (1/3) "a b [~ c]")
("[~ a@2] [~ b@2] [~ [~ c@2]]" :: Signal String)
@@ -638,175 +639,127 @@ run =
describe "rolledBy" $ do
it "shifts each start of events in a list correctly" $ do
let
- overTimeSpan = (Arc 0 1)
+ overTimeSpan = (Span 0 1)
testMe = rolledBy "0.5" $ n ("[0,1,2,3]")
expectedResult = n "[0, ~ 1@7, ~@2 2@6, ~@3 3@5]"
in
compareP overTimeSpan testMe expectedResult
it "shifts each start of events in a list correctly in reverse order" $ do
let
- overTimeSpan = (Arc 0 1)
+ overTimeSpan = (Span 0 1)
testMe = rolledBy "-0.5" $ n ("[0,1,2,3]")
expectedResult = n "[3, ~ 2@7, ~@2 1@6, ~@3 0@5]"
in
compareP overTimeSpan testMe expectedResult
it "trims the result pattern if it becomes larger than the original pattern" $ do
let
- overTimeSpan = (Arc 0 1)
+ overTimeSpan = (Span 0 1)
testMe = rolledBy "1.5" $ n ("[0,1,2]")
expectedResult = n "[0, ~ 1]"
in
compareP overTimeSpan testMe expectedResult
it "does nothing for continous functions" $ do
let
- overTimeSpan = (Arc 0 1)
+ overTimeSpan = (Span 0 1)
testMe = n (rolledBy "0.25" (irand 0) |+ "[0,12]")
expectedResult = n (irand 0) |+ n "[0, 12]"
in
compareP overTimeSpan testMe expectedResult
it "does nothing when passing zero as time value" $ do
let
- overTimeSpan = (Arc 0 1)
+ overTimeSpan = (Span 0 1)
testMe = n (rolledBy "0" "[0,1,2,3]")
expectedResult = n "[0,1,2,3]"
in
compareP overTimeSpan testMe expectedResult
- describe "euclid" $ do
- it "matches examples in Toussaint's paper" $ do
- sequence_ $ map (\(a,b) -> it b $ compareP (Arc 0 1) a (parseBP_E b))
- ([(euclid 1 2 "x", "x ~"),
- (euclid 1 3 "x", "x ~ ~"),
- (euclid 1 4 "x", "x ~ ~ ~"),
- (euclid 4 12 "x", "x ~ ~ x ~ ~ x ~ ~ x ~ ~"),
- (euclid 2 5 "x", "x ~ x ~ ~"),
- -- (euclid 3 4 "x", "x ~ x x"), -- Toussaint is wrong..
- (euclid 3 4 "x", "x x x ~"), -- correction
- (euclid 3 5 "x", "x ~ x ~ x"),
- (euclid 3 7 "x", "x ~ x ~ x ~ ~"),
- (euclid 3 8 "x", "x ~ ~ x ~ ~ x ~"),
- (euclid 4 7 "x", "x ~ x ~ x ~ x"),
- (euclid 4 9 "x", "x ~ x ~ x ~ x ~ ~"),
- (euclid 4 11 "x", "x ~ ~ x ~ ~ x ~ ~ x ~"),
- -- (euclid 5 6 "x", "x ~ x x x x"), -- Toussaint is wrong..
- (euclid 5 6 "x", "x x x x x ~"), -- correction
- (euclid 5 7 "x", "x ~ x x ~ x x"),
- (euclid 5 8 "x", "x ~ x x ~ x x ~"),
- (euclid 5 9 "x", "x ~ x ~ x ~ x ~ x"),
- (euclid 5 11 "x", "x ~ x ~ x ~ x ~ x ~ ~"),
- (euclid 5 12 "x", "x ~ ~ x ~ x ~ ~ x ~ x ~"),
- -- (euclid 5 16 "x", "x ~ ~ x ~ ~ x ~ ~ x ~ ~ x ~ ~ ~ ~"), -- Toussaint is wrong..
- (euclid 5 16 "x", "x ~ ~ x ~ ~ x ~ ~ x ~ ~ x ~ ~ ~"), -- correction
- -- (euclid 7 8 "x", "x ~ x x x x x x"), -- Toussaint is wrong..
- (euclid 7 8 "x", "x x x x x x x ~"), -- Correction
- (euclid 7 12 "x", "x ~ x x ~ x ~ x x ~ x ~"),
- (euclid 7 16 "x", "x ~ ~ x ~ x ~ x ~ ~ x ~ x ~ x ~"),
- (euclid 9 16 "x", "x ~ x x ~ x ~ x ~ x x ~ x ~ x ~"),
- (euclid 11 24 "x", "x ~ ~ x ~ x ~ x ~ x ~ x ~ ~ x ~ x ~ x ~ x ~ x ~"),
- (euclid 13 24 "x", "x ~ x x ~ x ~ x ~ x ~ x ~ x x ~ x ~ x ~ x ~ x ~")
- ] :: [(Signal String, String)])
- it "can be called with a negative first value to give the inverse" $ do
- compareP (Arc 0 1)
- (euclid (-3) 8 ("bd" :: Signal String))
- (euclidInv 3 8 ("bd" :: Signal String))
- it "can be called with a negative first value to give the inverse (patternable)" $ do
- compareP (Arc 0 1)
- (euclid (-3) 8 ("bd" :: Signal String))
- ("bd(-3,8)" :: Signal String)
-
- describe "euclidFull" $ do
- it "can match against silence" $ do
- compareP (Arc 0 1)
- (euclidFull 3 8 "bd" silence)
- ("bd(3,8)" :: Signal String)
-
describe "snowball" $ do
let testSignal = ("1 2 3 4"::Signal Int)
it "acummulates a transform version of a pattern and appends the result - addition" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(snowball 3 (+) (slow 2) (testSignal))
(cat [testSignal,(testSignal+(slow 2 testSignal)),((testSignal+(slow 2 testSignal))+slow 2 (testSignal+(slow 2 testSignal)))])
describe "soak" $ do
it "applies a transform and then appends the result -- addition" $ do
- compareP (Arc 0 3)
+ compareP (Span 0 3)
(soak 3 (+ 1) "4 ~ 0 1")
(cat ["4 ~ 0 1"::Signal Int,"5 ~ 1 2"::Signal Int,"6 ~ 2 3"::Signal Int])
it "applies a transform and then appends the result -- slow" $ do
- compareP (Arc 0 7)
+ compareP (Span 0 7)
(soak 3 (slow 2) "4 ~ 0 1")
(cat ["4 ~ 0 1"::Signal Int, slow 2 "4 ~ 0 1"::Signal Int, slow 4 "4 ~ 0 1"::Signal Int])
it "applies a transform and then appends the result -- addition patterns" $ do
- compareP (Arc 0 3)
+ compareP (Span 0 3)
(soak 3 (+ "1 2 3") "1 1")
(cat ["1 1"::Signal Int,"2 [3 3] 4"::Signal Int,"3 [5 5] 7"::Signal Int])
describe "bite" $ do
it "can slice a pattern into bits" $ do
- compareP (Arc 0 4)
+ compareP (Span 0 4)
(bite 4 "0 2*2" (Sound.Tidal.Pattern.run 8))
("[0 1] [4 5]*2" :: Signal Int)
it "can slice a pattern into patternable bits number" $ do
- compareP (Arc 0 4)
+ compareP (Span 0 4)
(bite "8 4" "0 2*2" (Sound.Tidal.Pattern.run 8))
("[0] [4 5]*2" :: Signal Int)
describe "chunk" $ do
it "can chunk a rev pattern" $ do
- compareP (Arc 0 4)
+ compareP (Span 0 4)
(chunk 2 (rev) $ ("a b c d" :: Signal String))
(slow 2 $ "d c c d a b b a" :: Signal String)
it "can chunk a fast pattern" $ do
- compareP (Arc 0 4)
+ compareP (Span 0 4)
(chunk 2 (fast 2) $ "a b" :: Signal String)
(slow 2 $ "a b b _ a _ a b" :: Signal String)
it "should chunk backward with a negative number" $ do
- compareP (Arc 0 4)
+ compareP (Span 0 4)
(chunk (-2) (rev) $ ("a b c d" :: Signal String))
(slow 2 $ "a b b a d c c d" :: Signal String)
describe "binary" $ do
it "converts a number to a pattern of boolean" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(binary "128")
("t f f f f f f f" :: Signal Bool)
describe "binaryN" $ do
it "converts a number to a pattern of boolean of specified length" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(binaryN 4 "8")
("t f f f" :: Signal Bool)
it "converts a number to a pattern of boolean of specified patternable length" $ do
- compareP (Arc 0 2)
+ compareP (Span 0 2)
(binaryN "<4 8>" "8")
(cat ["t f f f", "f f f f t f f f"] :: Signal Bool)
describe "ascii" $ do
it "converts characters to a pattern of bools" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(ascii "a b")
("f t t f f f f t f t t f f f t f" :: Signal Bool)
describe "necklace" $ do
it "can specify rhythm by IOI" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(necklace 12 [4,2])
("t f f f t f t f f f t f")
describe "loopFirst" $ do
it "plays the first n cycles" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(loopFirst $ early 3 $ slow 8 $ "0 .. 7" :: Signal Int)
("3")
describe "loopCycles" $ do
it "can loop time" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
((3 <~) $ (loopCycles 3 $ s ""))
(s "a")
it "can pattern time" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(fast 4 $ loopCycles "<2 2 1 1>" $ s "")
(s "a b a a")
@@ -814,15 +767,15 @@ run =
describe "arpeggiate" $ do
it "can arpeggiate" $ do
- compareP (Arc 0 1)
+ compareP (Span 0 1)
(arpeggiate ("[bd, sn] [hh:1, cp]" :: Signal String))
("bd sn hh:1 cp" :: Signal String)
it "can arpeggiate" $ do
- compareP (Arc 0 4)
+ compareP (Span 0 4)
(arpeggiate $ "[0,0] [0,0]")
("0 0 0 0" :: Signal Int)
it "can arpeggiate a 'sped up' pattern" $ do
- compareP (Arc 0 4)
+ compareP (Span 0 4)
(arpeggiate $ "[0,0]*2")
("0 0 0 0" :: Signal Int)
diff --git a/tidal-core/test/TestUtils.hs b/tidal-core/test/Sound/Tidal/TestUtils.hs
similarity index 91%
rename from tidal-core/test/TestUtils.hs
rename to tidal-core/test/Sound/Tidal/TestUtils.hs
index 313f1aaac..be839b444 100644
--- a/tidal-core/test/TestUtils.hs
+++ b/tidal-core/test/Sound/Tidal/TestUtils.hs
@@ -2,7 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeSynonymInstances #-}
-module TestUtils where
+module Sound.Tidal.TestUtils where
import Data.List (sort)
import qualified Data.Map.Strict as Map
@@ -56,3 +56,8 @@ stringPat = parseBP_E
toEvent :: (((Time, Time), (Time, Time)), a) -> Event a
toEvent (((ws, we), (ps, pe)), v) = Event mempty (Just $ Span ws we) (Span ps pe) v
+
+stripSequenceMetadata :: Sequence a -> Sequence a
+stripSequenceMetadata = withAtom f
+ where f _ d i o v = Atom mempty d i o v
+ f m d i o v = Atom m d i o v
diff --git a/test/Sound/Tidal/TimeTest.hs b/tidal-core/test/Sound/Tidal/TimeTest.hs
similarity index 100%
rename from test/Sound/Tidal/TimeTest.hs
rename to tidal-core/test/Sound/Tidal/TimeTest.hs
diff --git a/test/Sound/Tidal/TypesTest.hs b/tidal-core/test/Sound/Tidal/TypesTest.hs
similarity index 100%
rename from test/Sound/Tidal/TypesTest.hs
rename to tidal-core/test/Sound/Tidal/TypesTest.hs
diff --git a/test/Sound/Tidal/UtilsTest.hs b/tidal-core/test/Sound/Tidal/UtilsTest.hs
similarity index 100%
rename from test/Sound/Tidal/UtilsTest.hs
rename to tidal-core/test/Sound/Tidal/UtilsTest.hs
diff --git a/test/Sound/Tidal/ValueTest.hs b/tidal-core/test/Sound/Tidal/ValueTest.hs
similarity index 100%
rename from test/Sound/Tidal/ValueTest.hs
rename to tidal-core/test/Sound/Tidal/ValueTest.hs
diff --git a/test/Sound/Tidal/WaveformTest.hs b/tidal-core/test/Sound/Tidal/WaveformTest.hs
similarity index 100%
rename from test/Sound/Tidal/WaveformTest.hs
rename to tidal-core/test/Sound/Tidal/WaveformTest.hs
diff --git a/tidal-core/test/Test.hs b/tidal-core/test/Test.hs
index 60468a383..7d8ffeb40 100644
--- a/tidal-core/test/Test.hs
+++ b/tidal-core/test/Test.hs
@@ -1,14 +1,43 @@
module Main (main) where
+import Test.Microspec
+
+import Sound.Tidal.BjorklundTest
import Sound.Tidal.ChordsTest
import Sound.Tidal.EventTest
-import Sound.Tidal.ParamsTest
-import Sound.Tidal.SpanTest
-import Test.Microspec
+import Sound.Tidal.ExceptionsTest
+import Sound.Tidal.MininotationTest
+import Sound.Tidal.PatternTest
+import Sound.Tidal.ScalesTest
+import Sound.Tidal.SequenceTest
+import Sound.Tidal.SignalTest
+-- import Sound.Tidal.SignalComposeTest
+-- import Sound.Tidal.SignalControlTest
+-- import Sound.Tidal.SignalRandomTest
+-- import Sound.Tidal.SpanTest
+-- import Sound.Tidal.TimeTest
+-- import Sound.Tidal.TypesTest
+-- import Sound.Tidal.UtilsTest
+-- import Sound.Tidal.ValueTest
+-- import Sound.Tidal.WaveformTest
main :: IO ()
main = microspec $ do
+ Sound.Tidal.BjorklundTest.run
Sound.Tidal.ChordsTest.run
Sound.Tidal.EventTest.run
- Sound.Tidal.ParamsTest.run
- Sound.Tidal.SpanTest.run
+ Sound.Tidal.ExceptionsTest.run
+ Sound.Tidal.MininotationTest.run
+ Sound.Tidal.PatternTest.run
+ Sound.Tidal.ScalesTest.run
+ Sound.Tidal.SequenceTest.run
+ Sound.Tidal.SignalTest.run
+ -- Sound.Tidal.SignalComposeTest.run
+ -- Sound.Tidal.SignalControlTest.run
+ -- Sound.Tidal.SignalRandomTest.run
+ -- Sound.Tidal.SpanTest.run
+ -- Sound.Tidal.TimeTest.run
+ -- Sound.Tidal.TypesTest.run
+ -- Sound.Tidal.UtilsTest.run
+ -- Sound.Tidal.ValueTest.run
+ -- Sound.Tidal.WaveformTest.run
diff --git a/tidal-core/tidal-core.cabal b/tidal-core/tidal-core.cabal
index 9a55fdc15..18301a1f0 100644
--- a/tidal-core/tidal-core.cabal
+++ b/tidal-core/tidal-core.cabal
@@ -52,6 +52,7 @@ library
Sound.Tidal.Mininotation
Sound.Tidal.Params
Sound.Tidal.Pattern
+ Sound.Tidal.Scales
Sound.Tidal.Sequence
Sound.Tidal.Show
Sound.Tidal.Signal
@@ -90,15 +91,21 @@ test-suite tidal-core-test
hs-source-dirs: test
main-is: Test.hs
other-modules:
- TestUtils
+ Sound.Tidal.TestUtils
+ Sound.Tidal.BjorklundTest
Sound.Tidal.ChordsTest
Sound.Tidal.EventTest
- Sound.Tidal.ParamsTest
- Sound.Tidal.SpanTest
+ Sound.Tidal.ExceptionsTest
+ Sound.Tidal.MininotationTest
+ Sound.Tidal.PatternTest
+ Sound.Tidal.ScalesTest
+ Sound.Tidal.SequenceTest
+ Sound.Tidal.SignalTest
build-depends:
base
, tidal-core
- , microspec >= 0.2.0.1
+ -- , tidal-params-dirt
+ , microspec
, parsec
, deepseq
, containers
diff --git a/tidal-params-dirt/LICENSE b/tidal-params-dirt/LICENSE
new file mode 100644
index 000000000..45644ff76
--- /dev/null
+++ b/tidal-params-dirt/LICENSE
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ Copyright (C)
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
diff --git a/tidal-params-dirt/test/Test.hs b/tidal-params-dirt/test/Test.hs
new file mode 100644
index 000000000..9943c4bb8
--- /dev/null
+++ b/tidal-params-dirt/test/Test.hs
@@ -0,0 +1,40 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+module Main where
+
+import Sound.Tidal.Compose ((#))
+import Sound.Tidal.Params.Dirt
+import Sound.Tidal.TestUtils
+import Sound.Tidal.Types
+import Test.Microspec
+
+main :: IO ()
+main = microspec $
+ describe "Sound.Tidal.Params" $ do
+ describe "VF params" $ do
+ it "should parse fractional ratio" $ do
+ compareP (Span 0 1)
+ (sound "bd" # delay "e")
+ (sound "bd" # delay (1/8))
+
+ it "should parse correctly floating point number" $ do
+ compareP (Span 0 1)
+ (sound "bd" # delay "0.5")
+ (sound "bd" # delay (1/2))
+
+ describe "VN params" $ do
+ it "should parse note value" $ do
+ compareP (Span 0 1)
+ (sound "bd" # note "e")
+ (sound "bd" # note 4)
+
+ it "should parse n value" $ do
+ compareP (Span 0 1)
+ (sound "bd" # n "e")
+ (sound "bd" # n 4)
+
+ it "should parse correctly floating point number" $ do
+ compareP (Span 0 1)
+ (sound "bd" # note "0.5")
+ (sound "bd" # note (1/2))
+
diff --git a/tidal-params-dirt/tidal-params-dirt.cabal b/tidal-params-dirt/tidal-params-dirt.cabal
index 8f50b3b97..501be8e14 100644
--- a/tidal-params-dirt/tidal-params-dirt.cabal
+++ b/tidal-params-dirt/tidal-params-dirt.cabal
@@ -56,3 +56,20 @@ library
-- Base language which the package is written in.
default-language: Haskell2010
+test-suite tidal-core-test
+-- import: warnings
+ ghc-options: -Wall
+ default-language: Haskell2010
+ type: exitcode-stdio-1.0
+ hs-source-dirs: test
+ main-is: Test.hs
+ -- other-modules:
+ -- TestUtils
+ build-depends:
+ base
+ , tidal-core
+ , tidal-params-dirt
+ , microspec >= 0.2.0.1
+ , parsec
+ , deepseq
+ , containers
diff --git a/test/Sound/Tidal/StreamTest.hs b/tidal-stream/test/Test.hs
similarity index 100%
rename from test/Sound/Tidal/StreamTest.hs
rename to tidal-stream/test/Test.hs