Skip to content

Commit

Permalink
adds beat function
Browse files Browse the repository at this point in the history
  • Loading branch information
geikha committed Jan 20, 2025
1 parent 4a39773 commit f38b8a6
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Sound/Tidal/UI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1460,6 +1460,23 @@ _markovPat :: Int -> Int -> [[Double]] -> Pattern Int
_markovPat n xi tp = setTactus (toRational n) $ splitQueries $ pattern (\(State a@(Arc s _) _) ->
queryArc (listToPat $ runMarkov n tp xi (sam s)) a)

{-|
@beat@ structures a pattern by picking subdivisions of a cycle.
Takes in a pattern that tells it which parts to play (polyphony is recommeded here),
and the number of parts by which to subdivide the cycle (also pattern-able).
For example:
> d1 $ beat "[3,4.2,9,11,14]" 16 $ s "sd"
-}
beat :: Pattern Time -> Pattern Time -> Pattern a -> Pattern a
beat = patternify2 $ __beat innerJoin

__beat :: (Pattern (Pattern a) -> Pattern a) -> Time -> Time -> Pattern a -> Pattern a
__beat join t d p = join $ (compress (s,e) . pure) <$> p
where s = t' / d
e = (t'+1) / d
t' = t `mod'` d


{-|
@mask@ takes a boolean pattern and ‘masks’ another pattern with it. That is,
events are only carried over if they match within a ‘true’ event in the binary
Expand Down

0 comments on commit f38b8a6

Please sign in to comment.