VOLTAlearn

Learn Volta / Patterns

Alternation

Create evolving patterns with compact alternatives.

lesson 6 of 39 · about 7 minutes

Open this lesson in the workbench →

Angle brackets make a pattern bigger than its bar: <a b> plays a on the first cycle, b on the next. One line of code, a phrase that evolves.

!"c3 <eb3 f3> g3" is three steps per cycle — but the middle step alternates, so the loop only repeats every TWO cycles.

Alternations multiply: a <a b> next to a <x y z> makes a six-cycle phrase. This is how a two-bar, four-bar, twelve-bar form comes out of one short string.

*2 is the opposite move inside a single step: g3*2 plays that step twice as fast — a quick double where one note stood.

The timeline above the editor shows the pattern's true length — watch it stretch as you add alternations.

The starting point#

The lesson opens with this song in the editor. Every edit recompiles and plays.

-- Alternation: this arp repeats identically every cycle. Let it evolve.
pluck = patch {
  source = saw (freq pitch),
  ampEnv = adsr 2ms 140ms 0 120ms,
  cutoff = 1400Hz,
  gain   = vel * 0.5
}

arpLine = play pluck !"c3 eb3 g3 eb3"

What to watch#

Let it run past the end of the bar: the waveform's shape changes on the second cycle and changes back on the third. The pattern is longer than the loop.

Goals#

The workbench checks these as you work; the solution is there when you want it.

  1. Alternate a step with < >
  2. Make the phrase span two or more cycles
  3. Stretch: double-time one step with *2

Make it yours#

Write a melody whose last step alternates between three different endings — a 3-cycle question-answer-answer form.

Further reading#

Patterns: events over time in the reference.