Skip to content

Commit 71b1a10

Browse files
authored
Merge pull request #1193 from aherrou/chromatic
Corrects the scaleWithList function
2 parents 0324922 + 7f6f1c6 commit 71b1a10

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

tidal-core/src/Sound/Tidal/Scales.hs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module Sound.Tidal.Scales (scale, scaleList, scaleTable, getScale, scaleWith, sc
2020

2121
import Data.Maybe (fromMaybe)
2222
import Sound.Tidal.Core (slowcat)
23-
import Sound.Tidal.Pattern (Pattern, (<*))
23+
import Sound.Tidal.Pattern (Pattern, arc, (<*))
2424
import Sound.Tidal.Utils ((!!!))
2525
import Prelude hiding ((*>), (<*))
2626

@@ -322,17 +322,30 @@ These are equivalent:
322322
323323
-}
324324
scaleWith :: (Eq a, Fractional a) => Pattern String -> ([a] -> [a]) -> Pattern Int -> Pattern a
325-
scaleWith = getScaleMod scaleTable
325+
scaleWith = getScaleWith scaleTable
326326

327327
{- Variant of @scaleWith@ providing a list of modifier functions instead of a single function
328328
-}
329329
scaleWithList :: (Eq a, Fractional a) => Pattern String -> ([[a] -> [a]]) -> Pattern Int -> Pattern a
330-
scaleWithList sp fs p = slowcat $ map (\f -> scaleWith sp f p) fs
330+
scaleWithList _ [] _ = silence
331+
scaleWithList sp (f : []) p = scaleWith sp f p
332+
scaleWithList sp fs p = Pattern q
333+
where
334+
n = length fs
335+
q st =
336+
concatMap (ff st) $
337+
arcCyclesZW (arc st)
338+
ff st a = query pp $ st {arc = a}
339+
where
340+
f = fs !! i
341+
cyc = (floor $ start a) :: Int
342+
i = cyc `mod` n
343+
pp = (scaleWith sp f p)
331344

332345
{- Variant of @getScale@ used to build the @scaleWith@ function
333346
-}
334-
getScaleMod :: (Eq a, Fractional a) => [(String, [a])] -> Pattern String -> ([a] -> [a]) -> Pattern Int -> Pattern a
335-
getScaleMod table sp f p =
347+
getScaleWith :: (Eq a, Fractional a) => [(String, [a])] -> Pattern String -> ([a] -> [a]) -> Pattern Int -> Pattern a
348+
getScaleWith table sp f p =
336349
( \n scaleName ->
337350
noteInScale (uniq $ f $ fromMaybe [0] $ lookup scaleName table) n
338351
)

0 commit comments

Comments
 (0)