Before getting to the really cool things patterns can do, we need to build up a basic vocabulary. We'll start with some words, then move into phrases in the next tutorial.
Some of the patterns will be demonstrated with a Pbind construct. This is a taste of things to come -- sequencing sonic events using patterns. Don't worry about how Pbind works just yet... all in good time.
Let's start with a very quick reference of some basic patterns. More complete descriptions follow this list. The list might seem long at first, but concentrate your attention on the patterns called "primary patterns". They are the most basic, and commonly used.
Again, the purpose is to start learning the vocabulary of patterns -- like learning new words when studying a human language. You can always come back and look at the rest later.
For more information on any of these patterns, select the class name and use the help key for your editor to open its help file.
Pseq(list, repeats, offset)repeats times. Like list.do.Prand(list, repeats)list.choose).Pxrand(list, repeats)Pshuf(list, repeats)repeats times. Like list.scramble.Pwrand(list, weights, repeats)list.wchoose(weights)).Pseries(start, step, length)Pgeom(start, grow, length)Pwhite(lo, hi, length)rrand(lo, hi) .Pexprand(lo, hi, length)exprand(lo, hi) .Pbrown(lo, hi, step, length)Pfunc(nextFunc, resetFunc)Pfuncn(func, repeats)repeats items.Prout(routineFunc).yield or .embedInStream.Pser(list, repeats, offset)repeats items.Pslide(list, repeats, len, step, start, wrapAtEnd)Pwalk(list, stepPattern, directionPattern, startPos)Place(list, repeats, offset)Ppatlace(list, repeats, offset)Ptuple(list, repeats)Pgbrown(lo, hi, step, length)Pbeta(lo, hi, prob1, prob2, length)prob1 = α (alpha) and prob2 = β (beta).Pcauchy(mean, spread, length)Pgauss(mean, dev, length)Phprand(lo, hi, length)Plprand(lo, hi, length)Pmeanrand(lo, hi, length)(x + y) / 2.Ppoisson(mean, length)Pprob(distribution, lo, hi, length, tableSize)The most obvious thing one would want to do with a pattern is to give it a list of values and have it read them out in order. You have a couple of choices, which differ in their handling of the repeats parameter.
Pseq(list, repeats, offset)repeats times.Pser(list, repeats, offset)repeats items.Pseq is an obvious choice for streaming out known pitch and rhythm values.
Before playing a Pbind pattern such as this, make sure the server is booted.
To stop the examples in this file, use the "stop" keyboard shortcut (cmd-. on macOS, alt-. on Windows, check documentation for other editors). Or:
A variation, Pslide, plays overlapping segments of the input list.
Pslide(list, repeats, len, step, start, wrapAtEnd)repeatslenstepstartwrapAtEndIf step == 1, then the first segment is at start, the second at start + 1, and so on.
Prand(list, repeats)list.choose).Pxrand(list, repeats)Pshuf(list, repeats)repeats times. Like list.scramble.Pwrand(list, weights, repeats)list.wchoose(weights)).Pwalk(list, stepPattern, directionPattern, startPos)These are opposing operations: interlacing means splitting arrays and merging them into a stream of single values, and arrays can be made out of single-value streams as well.
Place(list, repeats, offset)If we turn this into a matrix and read vertically, the original arrays are clearly visible:
Ppatlace(list, repeats, offset)That's also a taste of things to come: Patterns can be nested.
Ptuple(list, repeats)Now, let's move to patterns that produce values mathematically, without using a predefined list.
Pseries(start, step, length)step to the starting value, returning a total of length items.Pgeom(start, grow, length)grow.Third-party extension alert : If you want an arithmetic or geometric series to start at one number and end at another specific number, the step size/multiplier must be calculated from the endpoints and the number of items desired. The ddwPatterns quark includes a convenience method, fromEndpoints, for both Pseries and Pgeom that performs this calculation. It's necessary to give an exact number of repeats, at least two and less than infinity.
Prints:
Pwhite(lo, hi, length)length random numbers with equal distribution ('white' refers to white noise).Pexprand(lo, hi, length)Pbrown(lo, hi, step, length)step to the previous value, where the step has an equal distribution between -step and +step.Pgbrown(lo, hi, step, length)step factor to the previous value.Pbeta(lo, hi, prob1, prob2, length)prob1 = α (alpha) and prob2 = β (beta).Pcauchy(mean, spread, length)Pgauss(mean, dev, length)Phprand(lo, hi, length)Plprand(lo, hi, length)Pmeanrand(lo, hi, length)(x + y) / 2.Ppoisson(mean, length)Pprob(distribution, lo, hi, length, tableSize)To see a distribution, make a histogram out of it.
Not everything is pre-written as a pattern class. These patterns let you embed custom logic.
Pfunc(nextFunc, resetFunc)nextFunc. If .reset is called on a stream made from this pattern, resetFunc is evaluated. The stream will run indefinitely until nextFunc returns nil.Pfuncn(func, repeats)repeats values and then stops. The default number of repeats is 1.Prout(routineFunc)routineFunc in a routine. The stream's output values are whatever this function .yields. Prout ends when it yields nil.Next, we'll look at the central pattern for audio sequencing: Pbind.
Previous: Pattern Guide 01: Introduction
Next: Pattern Guide 03: What Is Pbind