Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.
Merged
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
23 changes: 5 additions & 18 deletions tidal-core/src/Sound/Tidal/Scales.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module Sound.Tidal.Scales (scale, scaleList, scaleTable, getScale, scaleWith, sc

import Data.Maybe (fromMaybe)
import Sound.Tidal.Core (slowcat)
import Sound.Tidal.Pattern (Pattern, arc, (<*))
import Sound.Tidal.Pattern (Pattern, (<*))
import Sound.Tidal.Utils ((!!!))
import Prelude hiding ((*>), (<*))

Expand Down Expand Up @@ -322,30 +322,17 @@ These are equivalent:

-}
scaleWith :: (Eq a, Fractional a) => Pattern String -> ([a] -> [a]) -> Pattern Int -> Pattern a
scaleWith = getScaleWith scaleTable
scaleWith = getScaleMod scaleTable

{- Variant of @scaleWith@ providing a list of modifier functions instead of a single function
-}
scaleWithList :: (Eq a, Fractional a) => Pattern String -> ([[a] -> [a]]) -> Pattern Int -> Pattern a
scaleWithList _ [] _ = silence
scaleWithList sp (f : []) p = scaleWith sp f p
scaleWithList sp fs p = Pattern q
where
n = length fs
q st =
concatMap (ff st) $
arcCyclesZW (arc st)
ff st a = query pp $ st {arc = a}
where
f = fs !! i
cyc = (floor $ start a) :: Int
i = cyc `mod` n
pp = (scaleWith sp f p)
scaleWithList sp fs p = slowcat $ map (\f -> scaleWith sp f p) fs

{- Variant of @getScale@ used to build the @scaleWith@ function
-}
getScaleWith :: (Eq a, Fractional a) => [(String, [a])] -> Pattern String -> ([a] -> [a]) -> Pattern Int -> Pattern a
getScaleWith table sp f p =
getScaleMod :: (Eq a, Fractional a) => [(String, [a])] -> Pattern String -> ([a] -> [a]) -> Pattern Int -> Pattern a
getScaleMod table sp f p =
( \n scaleName ->
noteInScale (uniq $ f $ fromMaybe [0] $ lookup scaleName table) n
)
Expand Down