From 50b443e8aff4bf6b8cea439a5ba2641c6ca300f2 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 17 Jan 2025 20:41:26 +0000 Subject: [PATCH 1/2] fix off-by-one error in striateBy, and make it work within any existing begin/end controls --- src/Sound/Tidal/Control.hs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Sound/Tidal/Control.hs b/src/Sound/Tidal/Control.hs index a009087d..29822c34 100644 --- a/src/Sound/Tidal/Control.hs +++ b/src/Sound/Tidal/Control.hs @@ -165,9 +165,16 @@ striate' :: Pattern Int -> Pattern Double -> ControlPattern -> ControlPattern striate' = striateBy _striateBy :: Int -> Double -> ControlPattern -> ControlPattern -_striateBy n f p = fastcat $ map (offset . fromIntegral) [0 .. n-1] - where offset i = p # P.begin (pure (slot * i) :: Pattern Double) # P.end (pure ((slot * i) + f) :: Pattern Double) - slot = (1 - f) / fromIntegral n +-- _striateBy n f p = fastcat $ map (offset . fromIntegral) [0 .. n-1] +-- where offset i = p # P.begin (pure (slot * i) :: Pattern Double) # P.end (pure ((slot * i) + f) :: Pattern Double) +-- slot = (1 - f) / fromIntegral n +-- _striateBy :: Int -> Double -> ControlPattern -> ControlPattern +-- _striateBy n f p = fastcat $ map (offset) [0 .. n-1] +-- where offset i = p # P.begin (pure (slot * i) :: Pattern Double) # P.end (pure ((slot * i) + f) :: Pattern Double) +-- slot = (1 - f) / fromIntegral (n-1) +_striateBy n f p = keepTactus (withTactus (* toRational n) p) $ fastcat $ map (offset . fromIntegral) [0 .. n-1] + where offset i = mergePlayRange (slot*i, (slot*i)+f) <$> p + slot = (1 - f) / fromIntegral (n-1) {- | `gap` is similar to `chop` in that it granualizes every sample in place as it is played, From 85ff62b10df76c7c55a25ed65ad2f2926c004e3c Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 17 Jan 2025 20:43:19 +0000 Subject: [PATCH 2/2] tidy --- src/Sound/Tidal/Control.hs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/Sound/Tidal/Control.hs b/src/Sound/Tidal/Control.hs index 29822c34..0e28794e 100644 --- a/src/Sound/Tidal/Control.hs +++ b/src/Sound/Tidal/Control.hs @@ -165,13 +165,6 @@ striate' :: Pattern Int -> Pattern Double -> ControlPattern -> ControlPattern striate' = striateBy _striateBy :: Int -> Double -> ControlPattern -> ControlPattern --- _striateBy n f p = fastcat $ map (offset . fromIntegral) [0 .. n-1] --- where offset i = p # P.begin (pure (slot * i) :: Pattern Double) # P.end (pure ((slot * i) + f) :: Pattern Double) --- slot = (1 - f) / fromIntegral n --- _striateBy :: Int -> Double -> ControlPattern -> ControlPattern --- _striateBy n f p = fastcat $ map (offset) [0 .. n-1] --- where offset i = p # P.begin (pure (slot * i) :: Pattern Double) # P.end (pure ((slot * i) + f) :: Pattern Double) --- slot = (1 - f) / fromIntegral (n-1) _striateBy n f p = keepTactus (withTactus (* toRational n) p) $ fastcat $ map (offset . fromIntegral) [0 .. n-1] where offset i = mergePlayRange (slot*i, (slot*i)+f) <$> p slot = (1 - f) / fromIntegral (n-1)