diff --git a/src/Sound/Tidal/Pattern.hs b/src/Sound/Tidal/Pattern.hs index e13a9555..49229d9f 100644 --- a/src/Sound/Tidal/Pattern.hs +++ b/src/Sound/Tidal/Pattern.hs @@ -41,7 +41,7 @@ import qualified Data.Map.Strict as Map import Data.Maybe (catMaybes, fromJust, isJust, mapMaybe) import Data.Typeable (Typeable) import Data.Word (Word8) -import GHC.Generics +import GHC.Generics (Generic) import Sound.Tidal.Time @@ -267,13 +267,13 @@ _trigJoin cycleZero pat_of_pats = pattern q where q st = catMaybes $ concatMap - (\(Event oc (Just jow) op ov) -> + (\(Event oc jow op ov) -> map (\(Event ic (iw) ip iv) -> - do w <- subMaybeArc (Just jow) iw + do w <- subMaybeArc jow iw p <- subArc op ip return $ Event (combineContexts [ic, oc]) w p iv ) - $ query (((if cycleZero then id else cyclePos) $ start jow) `rotR` ov) st + $ query (((if cycleZero then id else cyclePos) $ start (fromJust jow)) `rotR` ov) st ) (query (filterDigital pat_of_pats) st) diff --git a/src/Sound/Tidal/Stream.hs b/src/Sound/Tidal/Stream.hs index bba195c5..ff30c0ff 100644 --- a/src/Sound/Tidal/Stream.hs +++ b/src/Sound/Tidal/Stream.hs @@ -361,7 +361,7 @@ toOSC busses pe osc@(OSC _ _) -- (but perhaps we should explicitly crash with an error message if it contains something else?). -- Map.mapKeys tail is used to remove ^ from the keys. -- In case (value e) has the key "", we will get a crash here. - playmap' = Map.union (Map.mapKeys tail $ Map.map (\(VI i) -> VS ('c':(show $ toBus i))) busmap) playmap + playmap' = Map.union (Map.mapKeys tail $ Map.map (\v -> VS ('c':(show $ toBus $ fromMaybe 0 $ getI v))) busmap) playmap val = value . peEvent -- Only events that start within the current nowArc are included playmsg | peHasOnset pe = do @@ -382,11 +382,13 @@ toOSC busses pe osc@(OSC _ _) toBus n | null busses = n | otherwise = busses !!! n busmsgs = map - (\(('^':k), (VI b)) -> do v <- Map.lookup k playmap - return $ (tsPart, - True, -- bus message ? - O.Message "/c_set" [O.int32 b, toDatum v] - ) + (\(k, b) -> do k' <- if (not $ null k) && head k == '^' then Just (tail k) else Nothing + v <- Map.lookup k' playmap + bi <- getI b + return $ (tsPart, + True, -- bus message ? + O.Message "/c_set" [O.int32 bi, toDatum v] + ) ) (Map.toList busmap) where diff --git a/src/Sound/Tidal/UI.hs b/src/Sound/Tidal/UI.hs index dd525980..2a0eb611 100644 --- a/src/Sound/Tidal/UI.hs +++ b/src/Sound/Tidal/UI.hs @@ -1308,7 +1308,7 @@ randArcs n = -- TODO - what does this do? Something for @stripe@ .. randStruct :: Int -> Pattern Int -randStruct n = splitQueries $ Pattern {query = f} +randStruct n = splitQueries $ Pattern f Nothing Nothing where f st = map (\(a,b,c) -> Event (Context []) (Just a) (fromJust b) c) $ filter (\(_,x,_) -> isJust x) as where as = map (\(i, Arc s' e') -> (Arc (s' + sam s) (e' + sam s), @@ -1862,7 +1862,8 @@ ur t outer_p ps fs = _slow t $ unwrap $ adjust <$> timedValues (getPat . split < transform _ _ = id transform' str (Arc s e) p = s `rotR` inside (pure $ 1/(e-s)) (matchF str) p matchF str = fromMaybe id $ lookup str fs - timedValues = withEvent (\(Event c (Just a) a' v) -> Event c (Just a) a' (a,v)) . filterDigital + timedValues = filterJust . withEvent (\(Event c ma a' v) -> Event c ma a' (ma >>= \a -> Just (a,v)) + ) . filterDigital {- | A simpler version of 'ur' that just provides name-value bindings that are reflected in the provided pattern.