packages feed

tidal 0.4.3 → 0.4.4

raw patch · 4 files changed

+31/−11 lines, 4 files

Files

Sound/Tidal/Parse.hs view
@@ -12,6 +12,8 @@ import GHC.Exts( IsString(..) ) import Data.Monoid import Control.Exception as E+import Control.Applicative ((<$>), (<*>))+import Data.Maybe  import Sound.Tidal.Pattern @@ -100,13 +102,13 @@                  return p  pSingle :: Parser (Pattern a) -> Parser (Pattern a)-pSingle f = do part <- f-               pMult part+pSingle f = f >>= pRand >>= pMult  pPart :: Parser (Pattern a) -> Parser ([Pattern a]) pPart f = do part <- parens (pSequence f) <|> pSingle f <|> pPolyIn f <|> pPolyOut f+             part' <- pRand part              spaces-             parts <- pReplicate part+             parts <- pReplicate part'              spaces              return $ parts @@ -165,13 +167,19 @@               <|>               return thing +++pRand :: Pattern a -> Parser (Pattern a)+pRand thing = do char '?'+                 spaces+                 return $ degrade thing+              <|> return thing+ pReplicate :: Pattern a -> Parser ([Pattern a])-pReplicate thing = do is <- many1 $ do char '!'-                                       spaces-                                       return 1-                      let i = sum is-                      return $ replicate (1 + fromIntegral i) thing-                   <|> return [thing]+pReplicate thing = do extras <- many $ do char '!'+                                          spaces+                                          pRand thing+                      return (thing:extras)  pRatio :: Parser (Rational) pRatio = do n <- natural <?> "numerator"
Sound/Tidal/Pattern.hs view
@@ -321,6 +321,9 @@ envL :: Pattern Double envL = sig $ \t -> max 0 $ min (fromRational t) 1 +filterValues :: (a -> Bool) -> Pattern a -> Pattern a+filterValues f (Pattern x) = Pattern $ (filter (f . thd')) . x+ -- Filter out events that have had their onsets cut off filterOnsets :: Pattern a -> Pattern a filterOnsets (Pattern f) = @@ -364,9 +367,18 @@ rand :: Pattern Double rand = Pattern $ \a -> [(a, a, fst $ randomDouble $ pureMT $ floor $ (*1000000) $ (midPoint a))] + irand :: Double -> Pattern Int irand i = (floor . (*i)) <$> rand +degradeBy :: Double -> Pattern a -> Pattern a+degradeBy x p = unMaybe $ (\a f -> toMaybe (f > x) a) <$> p <*> rand+    where toMaybe False _ = Nothing+          toMaybe True a  = Just a+          unMaybe = (fromJust <$>) . filterValues isJust++degrade :: Pattern a -> Pattern a+degrade = degradeBy 0.5  -- | @wedge t p p'@ combines patterns @p@ and @p'@ by squashing the -- @p@ into the portion of each cycle given by @t@, and @p'@ into the
Sound/Tidal/Stream.hs view
@@ -39,7 +39,7 @@  type OscPattern = Pattern OscMap -latency = 0.04+latency = 0.1  defaultDatum :: Param -> Maybe Datum defaultDatum (S _ (Just x)) = Just $ string x
tidal.cabal view
@@ -1,5 +1,5 @@ name:                tidal-version:             0.4.3+version:             0.4.4 synopsis:            Pattern language for improvised music -- description:          homepage:            http://yaxu.org/tidal/