Variation and randomness

In the last section, we introduced how to make very simple patterns and showed a single transformation on them. Now, let's briefly touch on a couple of quick topics. The first is how to have your patterns vary over time. The second is going to be two small ways to make patterns that have randomness built into them.

To make a pattern change over time you can use the <> syntax, like in the following example

d1 $ s "<bd bd*2 bd*4 bd*8 ~>"

which will vary between one, two, four, and eight bass drums, and then none at all in a cycle. It will march around between these on each consecutive cycle, looping back around to the beginning after the silent cycle.

These can also be nested in more complicated patterns like

d1 $ s "<bd*4 <bd bd*2>>"

Try playing around and seeing how the rhythms of it feel when you put in different variations.

Back to our complementary hi-hats, it's time to introduce variation in the form of randomness. Enter the following code and try running it.

d2 $ s "hh27*16?"

The ? symbol in the pattern means that each event in the pattern you're modifying has a fifty percent chance of being silent, in other words of an equal sized rest being put in its place. So even though there's no other variation with the angle brackets in this pattern, it's going to sound different every cycle. Personally what I like to do is use it for creating extra texture in background percussion like hi-hats! We can even combine this with all the tricks we've seen so far to get a bass drum pattern that's also changing with every cycle.

d1 $ s "<bd*4 bd bd*2> bd*4? bd <bd*2 bd*4?>"  

If you play with both of these you should be able to get something pretty satisfying for just two lines of code and two samples.