Skip to content

Commit

Permalink
updates to src/Sound.Tidal.UI.hs, change quantise to use round, add i…
Browse files Browse the repository at this point in the history
…n qfloor, gqceiling (#673)
  • Loading branch information
lwlsn committed Jun 7, 2020
1 parent ee1ec67 commit a032f47
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Sound/Tidal/UI.hs
Expand Up @@ -1754,7 +1754,17 @@ unfixRange = contrastRange id
-- | limit values in a Pattern (or other Functor) to n equally spaced
-- divisions of 1.
quantise :: (Functor f, RealFrac b) => b -> f b -> f b
quantise n = fmap ((/n) . (fromIntegral :: RealFrac b => Int -> b) . floor . (*n))
quantise n = fmap ((/n) . (fromIntegral :: RealFrac b => Int -> b) . round . (*n))

-- quantise but with floor
qfloor :: (Functor f, RealFrac b) => b -> f b -> f b
qfloor n = fmap ((/n) . (fromIntegral :: RealFrac b => Int -> b) . floor . (*n))

qceiling :: (Functor f, RealFrac b) => b -> f b -> f b
qceiling n = fmap ((/n) . (fromIntegral :: RealFrac b => Int -> b) . ceiling . (*n))

qround :: (Functor f, RealFrac b) => b -> f b -> f b
qround = quantise

-- | Inverts all the values in a boolean pattern
inv :: Functor f => f Bool -> f Bool
Expand Down

0 comments on commit a032f47

Please sign in to comment.