Skip to content

Commit

Permalink
Merge pull request #999 from thgrund/add-extractN
Browse files Browse the repository at this point in the history
Add extractN and extend getN
  • Loading branch information
yaxu authored Mar 9, 2023
2 parents 2242fe0 + 55c3afd commit fa556ef
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 @@ -487,6 +487,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 @@ -930,6 +934,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 fa556ef

Please sign in to comment.