From 55c3afdf9a5a0254d389e833f86fcb12fd929722 Mon Sep 17 00:00:00 2001 From: Thomas Grund Date: Thu, 2 Mar 2023 12:03:29 +0100 Subject: [PATCH] Add extractN and extend getN --- src/Sound/Tidal/Pattern.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Sound/Tidal/Pattern.hs b/src/Sound/Tidal/Pattern.hs index 24eda8006..bb3282c33 100644 --- a/src/Sound/Tidal/Pattern.hs +++ b/src/Sound/Tidal/Pattern.hs @@ -453,6 +453,10 @@ extractB = _extract getB extractR :: String -> ControlPattern -> Pattern Rational extractR = _extract getR +-- | Extract a pattern of note values by from a control pattern, given the name of the control +extractN :: String -> ControlPattern -> Pattern Note +extractN = _extract getN + compressArc :: Arc -> Pattern a -> Pattern a compressArc (Arc s e) p | s > e = empty | s > 1 || e > 1 = empty @@ -896,6 +900,7 @@ getF (VI x) = Just $ fromIntegral x getF _ = Nothing getN :: Value -> Maybe Note +getN (VN n) = Just n getN (VF f) = Just $ Note f getN (VR x) = Just $ Note $ fromRational x getN (VI x) = Just $ Note $ fromIntegral x