Day 15 of ∞All days

Wednesday, 18 November 2026

13 equal steps to the octave

13-EDO, first expedition: a timbre where 11 of 12 steps land in consonance (an ordinary instrument: 0; Sethares' construction: 7).

Thirteen equal steps: no fifth, no major third, sour on ordinary instruments.

The numbers

An ordinary instrument
0 of 12 steps land
Sethares’ construction
7 of 12 steps land
Tonight’s search
11 of 12 steps land, a new record
The rule it found
frequency‑dependent crowding penalty using an approximate critical‑band width per partial
Programs tried
76 programs, 63 valid, across 12 generations
Also works for
5-EDO (4 of 4), 7-EDO (6 of 6), 8-EDO (6 of 7), 9-EDO (7 of 8), 10-EDO (8 of 9), 11-EDO (9 of 10)
The piece
Thirteen Doors

Tonight’s film

Read the program
const PARAMS = 7; // [count‑factor, detune, stretch‑exp, tilt‑exp, boost‑thresh, boost‑gain, crowd‑penalty]

function timbre(target, p) {
	// ---------- parameters ----------
	const count   = 4 + Math.round(p[0] * 12);          // total partials (incl. fundamental) 4‑16
	const detune  = p[1];                               // 0‑1 pull toward nearest scale step
	const stretch = 0.5 + p[2];                         // exponent for stretched series (0.5‑1.5)
	const tilt    = 0.5 + 1.5 * p[3];                   // amplitude decay exponent (0.5‑2.0)
	const thresh  = 0.01 + 0.19 * p[4];                 // relative distance to step for boosting
	const boost   = 0.2 + 1.8 * p[5];                   // extra amplitude when within thresh
	const crowd   = 0.1 + 0.9 * p[6];                   // strength of crowding penalty (0‑1)

	// ---------- scale ratios up to 40 ----------
	const maxRatio = 40;
	const scale = [];
	for (let oct = 0; ; ++oct) {
		const base = Math.pow(target.period, oct);
		if (base > maxRatio) break;
		for (const s of target.steps) {
			const r = base * s;
			if (r > 1 && r <= maxRatio) scale.push(r);
		}
	}
	scale.push(1); // ensure fundamental is present

	// ---------- helper: nearest scale ----------
	function nearestScale(v) {
		let best = scale[0];
		let bestDiff = Math.abs(v - best);
		for (let i = 1; i < scale.length; ++i) {
			const d = Math.abs(v - scale[i]);
			if (d < bestDiff) { bestDiff = d; best = scale[i]; }
		}
		return best;
	}

	// ---------- build partials ----------
	const partials = [{ ratio: 1, amp: 1 }]; // fundamental

	for (let k = 2; k <= count; ++k) {
		const base = Math.pow(k, stretch);
		if (base > maxRatio) break;

		const nearest = nearestScale(base);
		const ratio   = base + detune * (nearest - base);

		let amp = 1 / Math.pow(k, tilt);

		// boost if close to a scale step
		const relDist = Math.abs(ratio - nearest) / nearest;
		if (relDist < thresh) {
			const factor = 1 + boost * (1 - relDist / thresh);
			amp *= factor;
		}
		partials.push({ ratio, amp });
	}

	// ---------- crowding penalty with frequency‑dependent bandwidth ----------
	for (let i = 0; i < partials.length; ++i) {
		const ri = partials[i].ratio;
		// approximate critical‑band width in octaves (grows with frequency)
		const critOct = 0.02 + 0.04 * Math.log2(ri); // ~100 cents at low freq, ~200 cents at 10 kHz
		let minDist = Infinity;
		for (let j = 0; j < partials.length; ++j) if (i !== j) {
			const rj = partials[j].ratio;
			const d = Math.abs(Math.log2(ri / rj));
			if (d < minDist) minDist = d;
		}
		if (minDist < critOct) {
			const factor = 1 - crowd * (1 - minDist / critOct);
			partials[i].amp *= factor;
		}
	}

	// ---------- enforce fundamental loudness ----------
	let maxAmp = 0;
	for (const pt of partials) if (pt.amp > maxAmp) maxAmp = pt.amp;
	if (partials[0].amp < 0.2 * maxAmp) partials[0].amp = 0.2 * maxAmp;

	// ---------- keep at most 32 partials ----------
	if (partials.length > 32) {
		partials.sort((a, b) => b.amp - a.amp);
		partials.length = 32;
	}

	return partials;
}

Consonance here is measured with Sethares’ model of sensory dissonance, not by ear. A step lands when it sits at the bottom of a valley in the timbre’s dissonance curve. Perfect harmony is out of reach — pure fifths and thirds never close into one scale — which is why the search does not end.

Every morning, what the night found.

One email a day at 7am Singapore time, with the discovery, the music and the film.