Shorthand aliases for pattern methods.
Get the absolute value of the previous value in the pattern chain
Get the arccosine of the previous value in the pattern chain
Add a value to the previous value in the pattern chain.
a value, instance of Pattern, or Zen pattern string
Compare the previous value in the pattern chain with a value.
a value, instance of Pattern, or Zen pattern string
Get the arctangent of the previous value in the pattern chain
Get a value, or values, from the previous value in the pattern chain It is assumed that the previous value is an array
index of value to retrieve, or array of indexes to retrieve. Negative numbers are counted from the end of the array.
Get the arctangent of the previous value in the pattern chain
Get the arctangent of the previous value in the pattern chain
value to divide by
At, but reversed. Given an array of values, it returns the value at the index provided by the previous value in the pattern chain.
array of values
Generate truthy or falsy values from a binary string.
binary string
number of iterations of the pattern, either per cycle or per canvas. Default is 1, which means once per cycle.
Convert the previous value from beats to milliseconds, scaling by bpm. Or, if a value is passed, convert that value from beats to milliseconds, scaling by bpm.
Optionalvalue: patternableConvert the previous value from beats to seconds, scaling by bpm. Or, if a value is passed, convert that value from beats to seconds, scaling by bpm.
Optionalvalue: patternableReturn the current cycle
optional number to wrap the cycle count at
Cache the value. Set how many values to cache and how many times to repeat the cache before it clears
number of values to cache
number of times to repeat the cache before it clears. Default is 1.
Get the ceiling of the previous value in the pattern chain
Clamp the previous value in the pattern chain to a range.
minimum value
maximum value
Alias for sometimes
Get the cosine of the previous value in the pattern chain
Generate a cosine wave between lo and hi. Use as the first call in a pattern chain.
number of iterations of the pattern, either per cycle or per canvas. Default is 1, which means once per cycle.
lowest value in range
highest value in range
a value, instance of Pattern, or Zen pattern string
Count up from 0 to n-1 or Infinity if n is 0. Restarts the counter each time reset is true.
the number to count up to, default is 0
a value, instance of Pattern, or Zen pattern string that resets the counter
Generate a curve between lo and hi. Use as the first call in a pattern chain.
number of iterations of the pattern, either per cycle or per canvas. Default is 1, which means once per cycle.
lowest value in range
curve of the pattern. Default is 0.5, which means a linear curve.
highest value in range
Degrade the pattern, replacing values with 0 based on a probability
amount to degrade by. 1 is fully degraded (all 0s), 0 is not degraded at all
Divide the previous value in the pattern chain by a value.
a value, instance of Pattern, or Zen pattern string
Reverse divide the previous value in the pattern chain by a value.
a value, instance of Pattern, or Zen pattern string
If the previous value in the pattern chain is falsy, return a new value, otherwise return previous value.
a value, instance of Pattern, or Zen pattern string
Test if the previous value in the pattern chain is equal to a value using ==.
value to test against
Test if the previous value in the pattern chain is an even number
Generate truthy or falsy values every n divisions.
number of divisions
Get the exponential of the previous value in the pattern chain
Expand the previous value in the pattern chain to to an array of length n.
length of the array
Optionalcallback: (value: number, index: number, array: number[]) => numberoptional callback to modify each value in the array
Filter - filter the previous value in the pattern chain
callback function to apply to each value
Get the floor of the previous value in the pattern chain
Provide a callback function to the previous value in the pattern chain
callback function
Test if the previous value in the pattern chain is greater than a value.
value to test against
Test if the previous value in the pattern chain is greater than or equal to a value.
value to test against
When trigger is true, samples the value returned by the previous pattern in the chain, and holds it until the next trigger.
a value, instance of Pattern, or Zen pattern string
Alias for ifelse
a value, instance of Pattern, or Zen pattern string
a value, instance of Pattern, or Zen pattern string
If the previous value in the pattern chain is truthy, return a new value, otherwise return previous value.
a value, instance of Pattern, or Zen pattern string
Test if the previous value in the pattern chain is a truthy or falsy value If true return new value, if false, simply pass on the previous value
a value, instance of Pattern, or Zen pattern string
a value, instance of Pattern, or Zen pattern string
Interpolate between a value and the previous value in the pattern chain
value to interpolate to
Invert the previous value in the pattern chain - like a bitwise NOT. Returns a 0 if true, and a 1 if false.
On/off. Returns 1 when on, 0 when off. True values passed to the first argument will turn the pattern on, false values are ignored. True values passed to the second argument will turn the pattern off, false values are ignored.
a value, instance of Pattern, or Zen pattern string
a value, instance of Pattern, or Zen pattern string
Layer a value on top of the previous value in the pattern chain, forming an array of values
Get the natural log of the previous value in the pattern chain
Test if the previous value in the pattern chain is less than a value.
value to test against
Test if the previous value in the pattern chain is less than or equal to a value.
value to test against
Map - apply a function to each value in the previous value in the pattern chain
callback function to apply to each value
Markov pattern generator
transition matrix
number of states to generate in the pattern. If 0, uses z.q. Default is 0.
frequency - number of patterns to generate per cycle. Default is 1.
Get the maximum of the previous value in the pattern chain and a given value
value to compare to
Use a midi cc on the selected device
control change number
midi device index (default is 0)
initial value (default is 1)
Use the notes from a midi file
url path to midi file, must be available to the browser
e | n | dur. Default n.
Use the currently pressed key(s) on the selected device
midi device index (default is 0)
Get the minimum of the previous value in the pattern chain and a given value
value to compare to
Modulo the previous value in the pattern chain by a value.
a value, instance of Pattern, or Zen pattern string
Map the preceding value in the chain to a new range.
the new minimum value
the new maximum value
the minimum value of the input range. Default is 0.
the maximum value of the input range. Default is 1.
Multiply the previous value in the pattern chain by a value.
a value, instance of Pattern, or Zen pattern string
Test if the previous value in the pattern chain is not equal to a value using !=.
value to test against
Generate a number between lo and hi, using a simplex noise function.
Speed of the noise function.
lowest value in range
highest value in range
Negate the value passed as the first argument
a value, instance of Pattern, or Zen pattern string
Convert a number to binary string, then passes it to .bin().
a number
the length of the binary string
number of iterations of the pattern, either per cycle or per canvas. Default is 1, which means once per cycle.
Test if the previous value in the pattern chain is an odd number
Compare the previous value in the pattern chain with a value.
a value, instance of Pattern, or Zen pattern string
Pack all arguments into an array Arguments can be a value, instance of Pattern, or Zen pattern string Each will be evaluated and packed into an array
Modify the value returned by a previous iteration of the pattern
The previous value in the pattern chain to the power of a given value
Post the current value to the console
optional prefix to the message
Generate a pulse wave between lo and hi. Use as the first call in a pattern chain.
number of iterations of the pattern, either per cycle or per canvas. Default is 1, which means once per cycle.
width of the pulse. Default is 0.5, which means a square wave.
lowest value in range
highest value in range
Return the current divisions per cycle
Return the value of the measured qubit
qubit to measure
Returns the phase of a given state of the quantum system. Assuming that this value is between -PI and +PI, the result is normalised
state to get phase of, as an integer
Returns an array of phases for all basis states of the quantum system
Returns an array of probabilities (squared amplitude coefficients) for all possible states of the quantum system
Return the probability (squared amplitude coefficient) for a given state of the quantum system
state to get probability of, as an integer
Returns the measured state as an integer - ie. in a 2-qubit system, 00 = 0, 01 = 1, 10 = 2, 11 = 3
Generate a random number between lo and hi.
lowest value in range
highest value in range
Generate a range of values between lo and hi. Use as the first call in a pattern chain.
number of iterations of the pattern, either per cycle or per canvas. Default is 1, which means once per cycle.
lowest value in range
highest value in range
Reduce - reduce the previous value in the pattern chain to a single value
callback function to apply to each value
initial value to start the reduction
Round the previous value in the pattern chain
Generate a saw wave between lo and hi. Alias of range. Use as the first call in a pattern chain.
number of iterations of the pattern, either per cycle or per canvas. Default is 1, which means once per cycle.
lowest value in range
highest value in range
Choose from a sequence of values. Use as the first call in a pattern chain.
an array of values
number of iterations of the sequence, either per cycle or per canvas. Default is 1, which means once per cycle.
Set a single value
a single string or number or array of strings or numbers, or a Pattern, or a Zen pattern string
Get the sine of the previous value in the pattern chain
Generate a sine wave between lo and hi. Use as the first call in a pattern chain.
number of iterations of the pattern, either per cycle or per canvas. Default is 1, which means once per cycle.
lowest value in range
highest value in range
Size - number of values in the previous value in the pattern chain
Slice - slice the previous value in the pattern chain
start index of the slice
end index of the slice
Snap the previous value in the pattern chain to the nearest value in an array.
array of values to snap to
Some - test if some values in the previous value in the pattern chain pass a test
callback function to apply to each value
Get the square root of the previous value in the pattern chain
Generate a square wave between lo and hi. Use as the first call in a pattern chain. See also pulse.
number of iterations of the pattern, either per cycle or per canvas. Default is 1, which means once per cycle.
lowest value in range
highest value in range
Round the previous value in the pattern chain to the step value.
value to round to
Subtract a value from the previous value in the pattern chain.
a value, instance of Pattern, or Zen pattern string
Reverse subtract. Subtract the previous value in the pattern chain from a value.
a value, instance of Pattern, or Zen pattern string
Return the current time
optional number to wrap the time at
Get the tangent of the previous value in the pattern chain
Toggle on or off using the value passed as the first argument A true value will toggle the pattern on, a false value will toggle it off
a value, instance of Pattern, or Zen pattern string
Generate a triangle wave between lo and hi. Use as the first call in a pattern chain.
number of iterations of the pattern, either per cycle or per canvas. Default is 1, which means once per cycle.
lowest value in range
highest value in range
Convert the previous value from divisions of a bar to seconds, scaling by bpm
Round the previous value in the pattern chain to the nearest value in an array.
array of values to round to
Compare the previous value in the pattern chain with a value.
a value, instance of Pattern, or Zen pattern string
Patterns are the building blocks of Zen. They are used to generate patterns of values in interesting, concise ways.