@Robin_Hase shared this cool idea they had in the Discord where you would be able to generate an euclidian pattern, but only keeping the first n
active beats while silencing the remaining ones. And maybe even offseting it such that you get the first n
active beats starting from the o
active beat.
It would be something like this:
euclid 5 8 -- |1 ~ 1 1 ~ 1 1 ~ |
euclidSub 5 8 3 0 -- |1 ~ 1 1 ~ ~ ~ ~ |
euclidSub 5 8 3 1 -- |~ ~ 1 1 ~ 1 ~ ~ |
They needed help with a solution that worked in Haskell so here's what I came up with:
import Sound.Tidal.Pattern
_maskList :: [Bool] -> [Bool] -> Int -> Int -> [Bool]
_maskList [] ys _ _ = ys
_maskList (False:xs) ys n o = _maskList xs (ys ++ [False]) n o
_maskList (True:xs) ys 0 0 = _maskList xs (ys ++ [False]) 0 0
_maskList (True:xs) ys n 0 = _maskList xs (ys ++ [True]) (n-1) 0
_maskList (True:xs) ys n o = _maskList xs (ys ++ [False]) n (o-1)
maskList :: [Bool] -> Int -> Int -> [Bool]
maskList xs n o = _maskList xs [] n o
bjorklundSub :: (Int, Int) -> Int -> Int -> [Bool]
bjorklundSub t = maskList (bjorklund t)
tParam4 f a b c d p = innerJoin $ (\x y z w -> f x y z w p) <$> a <*> b <*> c <*> d
_euclidSub :: Int -> Int -> Int -> Int -> Pattern a -> Pattern a
_euclidSub n k m o a | n >= 0 = fastcat $ fmap (bool silence a) $ bjorklundSub (n,k) m o
| otherwise = fastcat $ fmap (bool a silence) $ bjorklundSub (-n,k) m o
euclidSub = tParam4 _euclidSub
d1 $ euclidSub 7 16 "<4 3>" 1 "bd"
We thought this should be shared here