From da741d64e0c67d36cc4ebcffd094d57c8539fc67 Mon Sep 17 00:00:00 2001 From: Renzo Torr- <56176668+geikha@users.noreply.github.com> Date: Fri, 19 Jul 2024 03:19:55 -0300 Subject: [PATCH] minor fixes --- src/Sound/Tidal/Pattern.hs | 8 ++++---- src/Sound/Tidal/UI.hs | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Sound/Tidal/Pattern.hs b/src/Sound/Tidal/Pattern.hs index e0f57541..498e8360 100644 --- a/src/Sound/Tidal/Pattern.hs +++ b/src/Sound/Tidal/Pattern.hs @@ -914,8 +914,8 @@ eventHasOnset e | isAnalog e = False -- | Given any event, return it as if it was queried between the given arc encloseEvent :: Arc -> Event a -> Maybe (Event a) -encloseEvent _ (Event _ Nothing _ _) = Nothing -encloseEvent (Arc as ae) ev@(Event ctx (Just (Arc ws we)) part val) +encloseEvent _ (Event _ Nothing _ _) = Nothing -- TODO how to handle analogs +encloseEvent (Arc as ae) ev@(Event _ (Just (Arc ws we)) _ _) | we <= as = Nothing | ws >= ae = Nothing | ws >= as && we <= ae = Just ev -- fully within @@ -926,8 +926,8 @@ encloseEvent (Arc as ae) ev@(Event ctx (Just (Arc ws we)) part val) -- | If an event ends before it starts, switch starts with ends unflipEvent :: Event a -> Event a -unflipEvent ev@(Event _ (Just (Arc ws we)) (Arc ps pe) _) | we >= ws = ev - | ws > we = ev { whole = (Just (Arc we ws)), part = (Arc pe ps) } +unflipEvent ev@(Event _ (Just (Arc ws we)) (Arc ps pe) _) = if we >= ws then ev else ev { whole = (Just (Arc we ws)), part = (Arc pe ps) } +unflipEvent ev@(Event _ Nothing (Arc ps pe) _) = if pe >= ps then ev else ev { part = (Arc pe ps) } -- TODO - Is this used anywhere? Just tests, it seems -- TODO - support 'context' field diff --git a/src/Sound/Tidal/UI.hs b/src/Sound/Tidal/UI.hs index b27f1ea6..e5e3fc0b 100644 --- a/src/Sound/Tidal/UI.hs +++ b/src/Sound/Tidal/UI.hs @@ -44,7 +44,7 @@ import Data.Bool (bool) import Data.Fixed (mod') import Data.List (elemIndex, findIndex, findIndices, groupBy, intercalate, sort, sortOn, - transpose) + sortBy, transpose) import qualified Data.Map.Strict as Map import Data.Maybe (catMaybes, fromJust, fromMaybe, isJust, mapMaybe) @@ -2072,7 +2072,7 @@ _fill :: Time -> Time -> Pattern a -> Pattern a _fill l m pat = withEventsOnArc (map multiplyEvent . updateEvents . sortEvents) (lookahead) pat where lookahead a = a { start = (`subtract` l) $ start a, stop = (+l) $ stop a } - sortEvents = Data.List.sortBy (\e0 e1 -> compare (start $ part e0) (start $ part e1)) + sortEvents = sortBy (\e0 e1 -> compare (start $ part e0) (start $ part e1)) updateEvents es = (zipWith updatePair es (drop 1 es)) ++ safeLast es safeLast [] = [] safeLast es = [last es] @@ -2088,7 +2088,7 @@ fill' :: Pattern Time -> Pattern Time -> Pattern a -> Pattern a fill' = patternify2 _fill alterT :: (Time -> Time) -> Pattern a -> Pattern a -alter f pat = +alterT f pat = withEventOnArc (unflipEvent . alterEvent) (timeToCycleArc . start) pat where alterEvent ev = ev { whole = (fmap alterTime <$> whole ev) } alterTime w = (sam $ w) + (f $ cyclePos $ w)