module Strategies where
import Pattern
import Time
import Dirt
import Data.Ratio
import Control.Applicative
import Utils
echo n p = stack [p, n ~> p]
double f p = stack [p, f p]
smash n xs p = slowcat $ map (\n -> slow n p') xs
where p' = striate n p
brak = every 2 (((1%4) <~) . (\x -> cat [x, silence]))
samples :: Applicative f => f String -> f Int -> f String
samples p p' = pick <$> p <*> p'
spread :: (a -> t -> Pattern b) -> [a] -> t -> Pattern b
spread f xs p = cat $ map (\x -> f x p) xs
slowspread :: (a -> t -> Pattern b) -> [a] -> t -> Pattern b
slowspread f xs p = slow (fromIntegral $ length $ xs) $ spread f xs p
spread' :: (a -> Pattern b -> Pattern c) -> Pattern a -> Pattern b -> Pattern c
spread' f timepat pat =
Pattern $ \r -> concatMap (\(r', x) -> (arc (f x pat) r')) (rs r)
where rs r = arc (filterOffsets timepat) r
scrumple :: Time -> Pattern a -> Pattern a -> Pattern a
scrumple o p p' = p''
where p'' = Pattern $ \a -> concatMap
(\((s,d), vs) -> map (\x -> ((s,d),
snd x
)
)
(arc p' (s,s))
) (arc p a)
whenmod a b = Pattern.when ((\t -> (t `mod` a) >= b ))