Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix off-by-one error in striateBy #1106

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Sound/Tidal/Control.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import Prelude hiding ((*>), (<*))

import qualified Data.Map.Strict as Map
import Data.Maybe (fromJust, fromMaybe, isJust)

Check warning on line 30 in src/Sound/Tidal/Control.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.10.7

The import of ‘fromJust, isJust’

Check warning on line 30 in src/Sound/Tidal/Control.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.8.4

The import of ‘fromJust, isJust’

Check warning on line 30 in src/Sound/Tidal/Control.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.10.7

The import of ‘fromJust, isJust’

Check warning on line 30 in src/Sound/Tidal/Control.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.6.5

The import of ‘fromJust, isJust’

Check warning on line 30 in src/Sound/Tidal/Control.hs

View workflow job for this annotation

GitHub Actions / cabal 3.4.1.0 - ghc 9.0.2

The import of ‘fromJust, isJust’

Check warning on line 30 in src/Sound/Tidal/Control.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.8.4

The import of ‘fromJust, isJust’

Check warning on line 30 in src/Sound/Tidal/Control.hs

View workflow job for this annotation

GitHub Actions / cabal 3.4.1.0 - ghc 9.0.2

The import of ‘fromJust, isJust’

Check warning on line 30 in src/Sound/Tidal/Control.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.6.5

The import of ‘fromJust, isJust’

Check warning on line 30 in src/Sound/Tidal/Control.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘fromJust, isJust’

Check warning on line 30 in src/Sound/Tidal/Control.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘fromJust, isJust’

Check warning on line 30 in src/Sound/Tidal/Control.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘fromJust, isJust’

Check warning on line 30 in src/Sound/Tidal/Control.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘fromJust, isJust’
import Data.Ratio

import Sound.Tidal.Core
Expand All @@ -35,7 +35,7 @@
import Sound.Tidal.Pattern
import Sound.Tidal.Stream.Types (patternTimeID)
import Sound.Tidal.UI
import Sound.Tidal.Utils

Check warning on line 38 in src/Sound/Tidal/Control.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘Sound.Tidal.Utils’ is redundant

Check warning on line 38 in src/Sound/Tidal/Control.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘Sound.Tidal.Utils’ is redundant

Check warning on line 38 in src/Sound/Tidal/Control.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘Sound.Tidal.Utils’ is redundant

Check warning on line 38 in src/Sound/Tidal/Control.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘Sound.Tidal.Utils’ is redundant

{- | `spin` will "spin" and layer up a pattern the given number of times,
with each successive layer offset in time by an additional @1/n@ of a cycle,
Expand Down Expand Up @@ -165,9 +165,9 @@
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 = 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,
Expand Down
Loading