Difference between revisions of "chunk"

From TidalCycles userbase
Jump to: navigation, search
 
Line 2: Line 2:
 
[[Type signature|Type]]: <syntaxhighlight lang="haskell" inline>chunk :: Int -> (Pattern b -> Pattern b) -> Pattern b -> Pattern b</syntaxhighlight>
 
[[Type signature|Type]]: <syntaxhighlight lang="haskell" inline>chunk :: Int -> (Pattern b -> Pattern b) -> Pattern b -> Pattern b</syntaxhighlight>
  
'''chunk''' divides a pattern into a given number of parts, then cycles through those parts in turn, applying the given function to each part in turn (one part per cycle). <source inline>chunk</source> has replaced <source inline>runWith</source>.
+
'''chunk''' divides a pattern into a given number of parts, then cycles through those parts in turn, applying the given function to each part in turn (one part per cycle).
  
 
Example:
 
Example:

Latest revision as of 01:37, 25 December 2020

Type: chunk :: Int -> (Pattern b -> Pattern b) -> Pattern b -> Pattern b

chunk divides a pattern into a given number of parts, then cycles through those parts in turn, applying the given function to each part in turn (one part per cycle).

Example:

d1 $ chunk 4 (# speed 2) $ sound "bd hh sn cp"

The below highlights in bold which part of the above pattern has the (# speed 2) function applied to it over four cycles:

bd hh sn cp
bd hh sn cp
bd hh sn cp
bd hh sn cp

Another example:

d1 $ chunk 4 (hurry 2) $ sound "bd sn:2 [~ bd] sn:2"

chunk'

chunk' does the same as chunk but cycles through the parts in the reverse direction.