Skip to main content

Module sieve

Module sieve 

Source
Expand description

Xenakis sieves, ported from music21’s sieve module.

A sieve is a logical expression over residual classes. 3@0 selects every integer congruent to 0 modulo 3; |, & and ^ combine classes as union, intersection and symmetric difference; - complements one; and {} or () group. Applied to semitones, the resulting integer set is a scale — the major scale is (-3@2 & 4) | (-3@1 & 4@1) | (3@2 & 4@2) | (-3 & 4@3).

What is here is the sieve itself — parsing an expression, testing membership, the segment formats and the interval widths of one period — and the number helpers music21 keeps beside it: primes by eratosthenes and rabin_miller, and the unit-interval spacings unit_norm_range, unit_norm_equal and unit_norm_step. Sieve compression and pitch-range realization stay music21’s.

Structs§

Sieve
A parsed Xenakis sieve.

Functions§

discrete_binary_pad
A set of integers as a run of ones and zeros over its range: music21’s discreteBinaryPad, so [3, 10, 12] is a one, six noughts, a one, a nought and a one.
eratosthenes
The primes in order from first_candidate up: music21’s eratosthenes.
rabin_miller
Whether a number is prime: music21’s rabinMiller, answered for the number’s magnitude, so a negative number is as prime as its opposite.
unit_norm_equal
The unit interval cut into parts points, nought and one included: music21’s unitNormEqual, so three parts are [0, 0.5, 1]. One part or none is a single nought.
unit_norm_range
Numbers spaced across the unit interval in proportion to where each falls between the smallest and the largest: music21’s unitNormRange, so [0, 3, 4] is [0, 0.75, 1].
unit_norm_step
The values a step of step reaches from a to b inclusive, either as they are or normalized onto the unit interval: music21’s unitNormStep. A range of no width answers nothing; a step of no width cannot cross one and is an error.