Class: Rhythm

Rhythm

Generates {time, intensity, duration} values to control the groove of a Part.

Constructor

new Rhythm(options)

Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Default Description
pattern String | Iterable

When a String, it can contain the following characters:

  • "X" → accented note
  • "x" → normal note
  • "=" → tie
  • "." → rest

Each characters' duration is determined by the pulse option. NOTE: Other characters are ignored and can be used to improve readability, for example "X.x.|x==.|..x=|x=X="

When an Iterable of delta-start times, it represents the time between each note (with the first note always starting immediately). NOTE: Negative numbers can be used as rests, and the absolute value is the time until the next note.

pulse Number <optional>
1

The duration in beats of each character in a String pattern. Only relevant if the pattern option is a String.

intensities Iterable <optional>
[0.7]

Determines the note intensities in an Iterable pattern. Ignored if the pattern option is a String.

durations Iterable <optional>
time between notes

Determines the note durations in an Iterable pattern. Ignored if the pattern option is a String.

length Iterable <optional>
pattern length

Overrides the length of this rhythm to be different than the pattern length. Useful when this rhythm is looped or when using Random.durations.

looped Iterable <optional>
false

If true, this rhythm will repeat infinitely. Note that delta-start times, intensities, and durations loop independently for Iterable patterns, which creates less repetitive rhythms.

Source:

Extends

Methods

(static) distribute(pulses, total, options)

Generates a Rhythm pattern string by evenly distributes the given number of pulses into the given total number of time units. Also known as a "Euclidean rhythm". Use the return value for the constructor's pattern option.

Parameters:
Name Type Description
pulses number
total number
options Object
Properties
Name Type Attributes Default Description
shift Number <optional>
0

shifts the pattern (with wrap-around) by the given number of time units

rotation Number <optional>
0

shifts the pattern (with wrap-around) to the given pulse index

Source:

@@iterator()

The [Symbol.iterator]() generator function* that implements the iterable protocol

Inherited From:
Source:
See: