1--- 2title: Stepwise patterning 3layout: ../../layouts/MainLayout.astro 4--- 5 6import { MiniRepl } from '../../docs/MiniRepl'; 7import { JsDoc } from '../../docs/JsDoc'; 8 9# Stepwise patterning (experimental) 10 11This is a developing area of strudel, and behaviour might change or be renamed in future versions. Feedback and ideas are welcome! 12 13## Introduction 14 15Usually in strudel, the only reference point for most pattern transformations is the _cycle_. Now it is possible to also work with _steps_, via a growing range of functions. 16 17For example usually when you `fastcat` two patterns together, the cycles will be squashed into half a cycle each: 18 19<MiniRepl client:idle tune={`fastcat("bd hh hh", "bd hh hh cp hh").sound()`} /> 20 21With the new stepwise `stepcat` function, the steps of the two patterns will be evenly distributed across the cycle: 22 23<MiniRepl client:idle tune={`stepcat("bd hh hh", "bd hh hh cp hh").sound()`} /> 24 25By default, steps are counted according to the 'top level' in mini-notation. For example `"a [b c] d e"` has five events in it per cycle, but is counted as four steps, where `[b c]` is counted as a single step. 26 27However, you can mark a different metrical level to count steps relative to, using a `^` at the start of a sub-pattern. If we do this to the subpattern in our example: `"a [^b c] d e"`, then the pattern is now counted as having _eight_ steps. This is because 'b' and 'c' are each counted as single steps, and the events in the pattern are twice as long, and so counted as two steps each. 28 29## Pacing the steps 30 31Some stepwise functions don't appear to do very much on their own, for example these two examples of the `expand` function sound exactly the same despite being expanded by different amounts: 32 33<MiniRepl client:idle tune={`"c a f e".expand(2).note().sound("folkharp")`} /> 34 35<MiniRepl client:idle tune={`"c a f e".expand(4).note().sound("folkharp")`} /> 36 37The number of steps per cycle is being changed behind the scenes, but on its own, that doesn't do anything. You will hear a difference however, once you use another stepwise function with it, for example `stepcat`: 38 39<MiniRepl 40 client:idle 41 tune={`stepcat("c a f e".expand(2), "g d").note() 42 .sound("folkharp")`} 43/> 44 45<MiniRepl 46 client:idle 47 tune={`stepcat("c a f e".expand(4), "g d").note() 48 .sound("folkharp")`} 49/> 50 51You should be able to hear that `expand` increases the duration of the steps of the first subpattern, proportionally to the second one. 52 53You can also change the speed of a pattern to match a given number of steps per cycle, with the `pace` function: 54 55<MiniRepl 56 client:idle 57 tune={`stepcat("c a f e".expand(2), "g d").note() 58 .sound("folkharp") 59 .pace(8)`} 60/> 61 62<MiniRepl 63 client:idle 64 tune={`stepcat("c a f e".expand(4), "g d").note() 65 .sound("folkharp") 66 .pace(8)`} 67/> 68 69The first example has ten steps, and the second example has 18 steps, but are then both played a rate of 8 steps per cycle. 70 71The argument to `expand` can also be patterned, and will be treated in a stepwise fashion. This means that the patterns from the changing values in the argument will be `stepcat`ted together: 72 73<MiniRepl client:idle tune={`note("c a f e").sound("folkharp").expand("3 2 1 1 2 3")`} /> 74 75This results in a dense pattern, because the different expanded versions are squashed into a single cycle. `pace` is again handy here for slowing down the pattern to a particular number of steps per cycle: 76 77<MiniRepl client:idle tune={`note("c a f e").sound("folkharp").expand("3 2 1 1 2 3").pace(8)`} /> 78 79Earlier versions of many of these functions had `s_` prefixes, and the `pace` function was previously known as `steps`. These still exist as aliases, but may have changed behaviour and will soon be removed. Please update your patterns! 80 81## Stepwise functions 82 83### pace 84 85<JsDoc client:idle name="pace" h={0} /> 86 87### stepcat 88 89<JsDoc client:idle name="stepcat" h={0} /> 90 91### stepalt 92 93<JsDoc client:idle name="stepalt" h={0} /> 94 95### expand 96 97<JsDoc client:idle name="expand" h={0} /> 98 99### contract 100 101<JsDoc client:idle name="contract" h={0} /> 102 103### extend 104 105<JsDoc client:idle name="extend" h={0} /> 106 107### take 108 109<JsDoc client:idle name="take" h={0} /> 110 111### drop 112 113<JsDoc client:idle name="drop" h={0} /> 114 115### polymeter 116 117<JsDoc client:idle name="polymeter" h={0} /> 118 119### shrink 120 121<JsDoc client:idle name="shrink" h={0} /> 122 123### grow 124 125<JsDoc client:idle name="grow" h={0} /> 126 127### tour 128 129<JsDoc client:idle name="tour" h={0} /> 130 131### zip 132 133<JsDoc client:idle name="zip" h={0} />