Skip to content

Transformations

amiika edited this page Nov 5, 2019 · 34 revisions

Transforming melodies

Melody transformations alter the parsed melody. Transformations can be used with zplay or zloop.

Transformations can be executed to the current melody in a loop using cycle. Alternatively transformations can be stored to the cycles of the loop using store: true.

Phase

Phase will force the loop to go out of sync causing the phasing effect when multiple loops are playing.

Example:

z1 "q 1234"
z2 "q 1234", sync: :z1, phase: 0.1 # Sleeps 0.1 before each cycle

Retrograde

Retrograde inverses the melody. Use retrograde: true to inverse the whole melody.

Partial melody retrograde: [2,4] where first value is the start index and last valie is the end index.

Splitted melody retrograde: 3 where value is the number of parts the melody is splitted before the reverse.

Rotate

Rotate the melody

z1 "132435", rotate: 1

Swap

Swap places of degrees

zplay "1 2 3 4", swap: 1
zplay "1 2 3 4", swap: [1,3]

Flex

Flex will multiply or shorten the length of the melody

zplay "q 1 2 3 4"
zplay "q 1 2 3 4", flex: 1
zplay "q 1 2 3 4", flex: -0.5

Augment

Intervallic augmentation will alter the melody by adding intervals to the degrees and parsing new note for that degree.

Example:

z1 "q .0 .0|q0 e1 q.2|2 e1 q2 e3|h.4|e7 7 7 4 4 4 2 2 2 0 0 0|q4 e3 q2 e1|h.0", augment: {
  1=>"3",
  2=>"#",
  3=>->(){rrand_i 1,4},
  4=>->(){rrand_i 1,2}
}

Note that augmenting is done by means of intervals, meaning 2=>1 will do nothing (1 = unison).

Harmonize

Harmonizes existing melody by adding intervals.

zplay "1 3 2 5", harmonize: 3
zplay "-3 -2 -1 0 1 2 3", harmonize: [3,5]
zplay "1 3 2 4", harmonize: [2,"#5","b4"]
zplay "1 3 2 4", harmonize: {1=>3,4=>5}
zplay "1 3 2 4", harmonize: {1=>[3,5],4=>[2,3,4]}

# Harmonize creates chords so you could also play arpeggios from that and invert those chords
zplay "G'e1 2 3' q 9 8 7 6 5 4 3 2 1 0", harmonize: [-3,-5], chord_invert: -2

Note that harmonization is done by means of intervals, meaning 1=>1 will do nothing (1 = unison).

Compound

Adds compound interval to the harmonization, added note is one octave up or down.

zplay "q 9 8 7 6 5 4 3 2 1 0", harmonize: 3, compound: 1
zplay "q 9 8 7 6 5 4 3 2 1 0", harmonize: -3, compound: 1

Group by division

Groups the melody using mod

z1 "q 0 1 2 3 4 5 6", division: 2
Clone this wiki locally