Time and Rhythm
Rhythm Patterns
Generate and manipulate rhythmic patterns
A rhythmic pattern is an array of 1 and 0 indicating beats or rests (respectively). They are dimension-less:
Generate patterns
binary(numbers) ⇒ number[]
Create a rhythm pattern from a number or concatenation of numbers in binary form: first the numbers are converted to binary, and the result is concatenated:
hex(hexNumber) ⇒ number[]
Create a rhythmic pattern using an hexadecimal numbers. Same as before, but using hexadecimal numbers:
onsets(numbers) ⇒ number[]
Create a rhythm pattern from the onsets. The onsets is the space between beats:
random(length, probability, rnd) ⇒ number[]
Create a random rhythm pattern with a specified length
| Param | Description |
|---|---|
| length | length of the pattern |
| probability | Threshold where random number is considered a beat (defaults to 0.5) |
| rnd | A random function (Math.random by default) |
probability(probabilities, rnd) ⇒ number[]
Create a rhythm pattern based on the given probability thresholds
| Param | Description |
|---|---|
| probabilities | An array with the probability of each step to be a beat |
| rnd | A random function (Math.random by default) |
euclid(steps, beats) ⇒ number[]
Generates an euclidean rhythm pattern
| Param | Description |
|---|---|
| steps | The length of the pattern |
| beats | The number of beats |
Manipulate
rotate(pattern, rotations) ⇒ number[]
Rotate a pattern to the right:
| Param | Description |
|---|---|
| pattern | the pattern to rotate |
| rotations | the number of steps to rotate |