Core
Elemental patterns
sig
Takes a function of time to values, and turns it into a Pattern
.
Useful for creating continuous patterns such as sine
or perlin
.
For example, saw
is defined as
sine
Unipolar sine wave. A pattern of continuous values following a sine wave with frequency of one cycle, and amplitude from 0 to 1.
sine2
Bipolar sine wave. A pattern of continuous values following a sine wave with frequency of one cycle, and amplitude from -1 to 1.
cosine
Unipolar cosine wave. A pattern of continuous values
following a cosine with frequency of one cycle, and amplitude from
0 to 1. Equivalent to 0.25 ~> sine
.
cosine2
Bipolar cosine wave. A pattern of continuous values
following a cosine with frequency of one cycle, and amplitude from
-1 to 1. Equivalent to 0.25 ~> sine2
.
saw
Unipolar ascending sawtooth wave. A pattern of continuous values following a sawtooth with frequency of one cycle, and amplitude from 0 to 1.
saw2
Bipolar ascending sawtooth wave. A pattern of continuous values following a sawtooth with frequency of one cycle, and amplitude from -1 to 1.
isaw
Like saw
, but a descending (inverse) sawtooth.
isaw2
Like saw2
, but a descending (inverse) sawtooth.
tri
Unipolar triangle wave. A pattern of continuous values following a triangle wave with frequency of one cycle, and amplitude from 0 to 1.
tri2
Bipolar triangle wave. A pattern of continuous values following a triangle wave with frequency of one cycle, and amplitude from -1 to 1.
square
Unipolar square wave. A pattern of continuous values following a square wave with frequency of one cycle, and amplitude from 0 to 1.
square
is like sine
, for square waves.
square2
Bipolar square wave. A pattern of continuous values following a square wave with frequency of one cycle, and amplitude from -1 to 1.
envL
envL
is a Pattern
of continuous Double
values, representing
a linear interpolation between 0 and 1 during the first cycle, then
staying constant at 1 for all following cycles. Possibly only
useful if you’re using something like the retrig
function defined
in tidal.el
.
envLR
Like envL
but reversed.
envEq
’Equal power’ version of env
, for gain-based transitions
envEqR
Equal power reversed
Pattern algebra
union
(|+|)
(|+)
(+|)
(||+)
(|++|)
(|++)
(++|)
(||++)
(|/|)
(|/)
(/|)
(||/)
(|*|)
(|*)
(*|)
(||*)
(|-|)
(|-)
(-|)
(||-)
(|%|)
(|%)
(%|)
(||%)
(|**|)
(|**)
(**|)
(||**)
(|>|)
(|>)
(>|)
(||>)
(|<|)
(|<)
(<|)
(||<)
(#)
Constructing patterns
fromList
Turns a list of values into a pattern, playing one of them per cycle. The following are equivalent:
fastFromList
Turns a list of values into a pattern, playing all of them per cycle. The following are equivalent:
listToPat
A synonym for fastFromList
.
fromMaybes
fromMaybes
is similar to fromList
, but allows values to
be optional using the Maybe
type, so that Nothing
results in
gaps in the pattern.
The following are equivalent:
run
A pattern of whole numbers from 0 to the given number, in a single cycle.
Can be used to run
through a folder of samples in order:
The first parameter to run can be given as a pattern:
_run
scan
Similar to run
, but starts from 1
for the first cycle, successively
adds a number until it gets up to n
.
_scan
Combining patterns
append
Alternate between cycles of the two given patterns
cat
Like append
, but for a list of patterns. Interlaces them, playing the
first cycle from each in turn, then the second cycle from each, and so on. It
concatenates a list of patterns into a new pattern; each pattern in the list
will maintain its original duration. For example:
slowCat
Alias for cat
slowcat
slowAppend
Alias for append
slowappend
fastAppend
Like append
, but twice as fast
fastappend
fastCat
The same as cat
, but speeds up the result by the number of
patterns there are, so the cycles from each are squashed to fit a
single cycle.
fastcat
Alias for fastCat
timeCat
Similar to fastCat
, but each pattern is given a relative duration.
You provide proportionate sizes of the patterns to each other for when they’re
concatenated into one cycle. The larger the value in the list, the larger
relative size the pattern takes in the final loop. If all values are equal
then this is equivalent to fastcat
(e.g. the following two code fragments are
equivalent).
timecat
Alias for timeCat
overlay
overlay
combines two Pattern
s into a new pattern, so that their events
are combined over time. For example, the following two lines are equivalent:
overlay
is equal to <>
,
(<>)
which can thus be used as an infix operator equivalent of overlay
:
stack
stack
combines a list of Pattern
s into a new pattern, so that their
events are combined over time, i.e., all of the patterns in the list are played
simultaneously.
This is particularly useful if you want to apply a function or synth control pattern to multiple patterns at once:
Manipulating time
(<~)
Shifts a pattern back in time by the given amount, expressed in cycles
(~>)
Shifts a pattern forward in time by the given amount, expressed in cycles
slowSqueeze
Slow down a pattern by the factors in the given time pattern, “squeezing”
the pattern to fit the slot given in the time pattern. It is the slow analogue
to fastSqueeze
.
If the time pattern only has a single value in a cycle, slowSqueeze
becomes equivalent to slow. These are equivalent:
When the time pattern has multiple values, however, the behavior is a little different. Instead, a slowed version of the pattern will be made for each value in the time pattern, and they’re all combined together in a cycle according to the structure of the time pattern. For example, these are equivalent:
as are these:
sparsity
An alias for slow
zoom
Plays a portion of a pattern, specified by a time arc (start and end time). The new resulting pattern is played over the time period of the original pattern.
In the pattern above, zoom
is used with an arc from 25% to 75%. It is
equivalent to:
Here’s an example of it being used with a conditional:
zoomArc
fastGap
fastGap
is similar to fast
but maintains its cyclic alignment, i.e.,
rather than playing the pattern multiple times, it instead leaves a gap in
the remaining space of the cycle. For example, fastGap 2 p
would squash the
events in pattern p
into the first half of each cycle (and the second halves
would be empty). The factor should be at least 1.
densityGap
An alias for fastGap
compress
compress
takes a pattern and squeezes it within the specified time span (i.e.
the ‘arc’). The new resulting pattern is a sped up version of the original.
In the above example, the pattern will play in an arc spanning from 25% to 75% of the duration of a cycle. It is equivalent to:
Another example, where all events are different:
It differs from zoom
in that it preserves the original pattern but it speeds
up its events so to match with the new time period.
compressTo
repeatCycles
_repeatCycles
fastRepeatCycles
every
every n f p
applies the function f
to p
, but only affects
every n
cycles.
It takes three inputs: how often the function should be applied (e.g. 3 to apply it every 3 cycles), the function to be applied, and the pattern you are applying it to. For example: to reverse a pattern every three cycles (and for the other two play it normally)
Note that if the function you’re applying requires additional parameters itself (such as fast 2 to make a pattern twice as fast), then you’ll need to wrap it in parentheses, like so:
Otherwise, the every function will think it is being passed too many parameters.
_every
every'
every' n o f p
is like every n f p
but with an offset of o
cycles.
For example, every' 3 0 (fast 2)
will speed up the cycle on cycles 0,3,6,…
whereas every' 3 1 (fast 2)
will transform the pattern on cycles 1,4,7,….
With this in mind, setting the second argument of every'
to 0 gives the
equivalent every function. For example, every 3 is equivalent to every’ 3 0.
The every
functions can be used to silence a full cycle or part of a cycle
by using silent or mask ”~“. Mask provides additional flexibility to turn on/off
individual steps.
_every'
foldEvery
foldEvery ns f p
applies the function f
to p
, and is applied for
each cycle in ns
.
It is similar to chaining multiple every
functions together. It transforms
a pattern with a function, once per any of the given number of cycles. If a
particular cycle is the start of more than one of the given cycle periods, then
it is applied more than once.
The first Moog samples are tuned to C2, C3 and C4. Note how on cycles that are multiples of 3 or 5 the pitch is an octave higher, and on multiples of 15 the pitch is two octaves higher, as the transformation is applied twice.
when
The given pattern transformation is applied only when
the given test function
returns True
. The test function will be called with the current cycle as
a number.
The above will only apply striate 4
to the pattern if the current
cycle number contains the number 4. So the fourth cycle will be
striated and the fourteenth and so on. Expect lots of striates after
cycle number 399.
whenT
Like when
, but works on continuous time values rather than cycle numbers.
The following will apply # speed 2
only when the remainder of the current
Time
divided by 2 is less than 0.5: