@@ -20,7 +20,7 @@ module Sound.Tidal.Scales (scale, scaleList, scaleTable, getScale, scaleWith, sc
20
20
21
21
import Data.Maybe (fromMaybe )
22
22
import Sound.Tidal.Core (slowcat )
23
- import Sound.Tidal.Pattern (Pattern , (<*) )
23
+ import Sound.Tidal.Pattern (Pattern , arc , (<*) )
24
24
import Sound.Tidal.Utils ((!!!) )
25
25
import Prelude hiding ((*>) , (<*) )
26
26
@@ -322,17 +322,30 @@ These are equivalent:
322
322
323
323
-}
324
324
scaleWith :: (Eq a , Fractional a ) => Pattern String -> ([a ] -> [a ]) -> Pattern Int -> Pattern a
325
- scaleWith = getScaleMod scaleTable
325
+ scaleWith = getScaleWith scaleTable
326
326
327
327
{- Variant of @scaleWith@ providing a list of modifier functions instead of a single function
328
328
-}
329
329
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)
331
344
332
345
{- Variant of @getScale@ used to build the @scaleWith@ function
333
346
-}
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 =
336
349
( \ n scaleName ->
337
350
noteInScale (uniq $ f $ fromMaybe [0 ] $ lookup scaleName table) n
338
351
)
0 commit comments