Tidal icon indicating copy to clipboard operation
Tidal copied to clipboard

Backport fastgap fix

Open yaxu opened this issue 9 months ago • 1 comments

fastgap got bugfixed in 2.0 https://github.com/tidalcycles/Tidal/blob/2263c2e348579519cf3589965889faed7c88dffe/src/Sound/Tidal/Signal/Base.hs#L462-L482

Originally posted by @yaxu in #1076

As noticed by Claude: https://discord.com/channels/779427371270275082/779743442288377876/1347507824145731616

yaxu avatar Mar 30 '25 07:03 yaxu

this is the version I patched my local copy with, not sure if it is correct....

_fastGap :: Time -> Pattern a -> Pattern a
_fastGap 0 _ = empty
_fastGap r p = splitQueries $ p {query = map mungeResult . f}
  where
    r' = max r 1
    -- zero width queries of the next sam should return zero in this case..
    f st@(State a _)
      | start a' == nextSam (start a) = []
      | otherwise = query p st {arc = a'}
      where
        mungeQuery t = sam t + min 1 (r' * cyclePos t)
        a' = (\(Arc s e) -> Arc (mungeQuery s) (mungeQuery e)) a
    mungeResult e = e
      { whole = fmap (mungeArc (part e)) (whole e)
      , part = mungeArc (part e) (part e)
      }
    mungeArc (Arc s0 e0) (Arc s e) = Arc
      (sam s0 + ((s - sam s0) / r'))
      (sam s0 + ((e - sam s0) / r'))

claudeha avatar May 28 '25 15:05 claudeha