From 4f344b457a4951a4412bf8cae3b8563d20ff0445 Mon Sep 17 00:00:00 2001 From: Alex McLean Date: Thu, 18 Apr 2024 10:26:06 +0100 Subject: [PATCH] calculate tactus from the first cycle --- src/Sound/Tidal/Stepwise.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Sound/Tidal/Stepwise.hs b/src/Sound/Tidal/Stepwise.hs index 8164d007..be568c29 100644 --- a/src/Sound/Tidal/Stepwise.hs +++ b/src/Sound/Tidal/Stepwise.hs @@ -118,11 +118,13 @@ s_contract = s_patternify _s_contract s_patternify :: (a -> Pattern b -> Pattern c) -> (Pattern a -> Pattern b -> Pattern c) s_patternify f (Pattern _ _ (Just a)) b = f a b -s_patternify f pa p = keepTactus p $ stepJoin $ (`f` p) <$> pa +s_patternify f pa p = stepJoin $ (`f` p) <$> pa stepJoin :: Pattern (Pattern a) -> Pattern a -stepJoin pp = Pattern q Nothing Nothing +stepJoin pp = Pattern q first_t Nothing where q st@(State a c) = query (timecat $ retime $ slices $ query (rotL (sam $ start a) pp) (st {arc = Arc 0 1})) st + first_t :: Maybe Rational + first_t = tactus $ timecat $ retime $ slices $ queryArc pp (Arc 0 1) retime :: [(Time, Pattern a)] -> [(Time, Pattern a)] retime xs = map (\(dur, pat) -> adjust dur pat) xs where occupied_perc = sum $ map fst $ filter (isJust . tactus . snd) xs