Skip to content

Commit

Permalink
Add extractN and extend getN
Browse files Browse the repository at this point in the history
  • Loading branch information
thgrund committed Mar 2, 2023
1 parent f7e3314 commit 55c3afd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Sound/Tidal/Pattern.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 55c3afd

Please sign in to comment.