Skip to content

Combinatorics

Miika Alonen edited this page Nov 19, 2021 · 6 revisions

Combinatorics

Ziffers has a built in support to create combinatoric patterns from the given melody. Given numbers of permutation, combination or iteration transforms the melody to a enumeration that will repeat certain parts of the melody.

Combinations are played on the fly so it is also possible to play large permutations that would play for years:

zplay "e 0 1 2 3 4 5 6 7 8 9 E T", scale: :chromatic, permutation: 12

Each cycle from the combination can also be transformed using Transformations, like reverse, retrograde etc.

For smaller enumerations (like 10000 combinations etc.), the whole melody can still be transformed using transform_enum: true, but it will try to create an array of arrays from the enumeration which can lead to program failure if the enumeration is too big to fit into the memory.

Permutation

Create permutation from the melody

z1 "q 0 1 2 3", permutation: 2

Combination

Create combination from the melody

z1 "q 0 1 2 3", combination: 2

Repeated Permutation or Combination

Create repeated permutation or combination

z1 "q 0 1 2 3", permutation: 2, repeated: true
# or
z1 "q 0 1 2 3", combination: 2, repeated: true

Iteration

Iterate melody in n-parts

z1 "q 0 1 2 3", iteration: 2  # Plays 0 1 1 2 2 3
z2 "q 0 1 2 3 4", iteration: 3 # Plays 0 1 2 1 2 3 2 3 4
Clone this wiki locally