Musicology·A Field Guide

§ I.5 · The CLI Workshop · No. XIV

Sieve
Generator.

After Xenakis 1990

Evaluates a Xenakis sieve expression(8,0) | (8,4) & (3,2) — over residue classes modulo n, combined with union (|), intersection (&), and complement (-). Outputs the resulting integer sequence as raw integers, MIDI pitches over a chosen range, or rhythmic positions at a given tempo. Algebra over the integers, set in motion.

Why a command line

Xenakis's sieve algebra generates pitch sets and rhythmic patterns from number-theoretic rules, but the answer to a question like “what does (12,0) ∪ (12,4) ∪ (12,8) sound like?” is hard to see by hand. The CLI turns the expression into a playable sequence in a single keystroke and lets you script through hundreds of variations — rotations, intersections, complements — in a Makefile.

Invocation

$ node 05-sieve.js "(12,0) | (12,4) | (12,8)" --output=integers
$ node 05-sieve.js "(8,0) & (5,1)" --output=midi --range=60-84
$ node 05-sieve.js "(16,0) | (16,6)" --output=rhythm --bpm=120
$ node 05-sieve.js "(7,0) | (7,2) - (3,1)" --length=24

Sample output

0
4
8
12
16
20
24
28
32
36
40
44

Scope

expression   sieve grammar:
             (n,r)            residue class r modulo n
             A | B            union
             A & B            intersection
             A - B            complement (set difference)
             precedence:      & binds tighter than |, parentheses override

flags        --output=integers|midi|rhythm
             --range=lo-hi    MIDI bounds for --output=midi (default 0-127)
             --length=N       cap the generated sequence length
             --bpm=N          tempo for --output=rhythm (default 120)
             --grid=ms        16th-note grid step for --output=rhythm

output       integers, MIDI pitches, or rhythmic positions in milliseconds.
             one element per line, suitable for piping to another tool.

References

Source

cli/05-sieve.js ↗ raw
loading source…
← Back to the CLI workshop