Day 11 of ∞All days

Saturday, 14 November 2026

24 equal steps to the octave

24-EDO, first expedition: a timbre where 5 of 23 steps land in consonance (an ordinary instrument: 2; Sethares' construction: 4).

Twenty-four equal steps: quarter tones, the grid of much modern maqam theory.

The numbers

An ordinary instrument
2 of 23 steps land
Sethares’ construction
4 of 23 steps land
Tonight’s search
5 of 23 steps land, a new record
The rule it found
stretch‑align + critical‑band mask – stretch the harmonic series so more partials fall near the 24‑EDO steps, then attenuate crowded bands to sharpen valleys and keep the tone smooth.
Programs tried
76 programs, 62 valid, across 12 generations
The piece
Day 11 — Twenty-Four Lanterns

Tonight’s film

Read the program
const PARAMS = 4; // [stretch, tilt, pull, bandAtten]

function timbre(target, p) {
  const period = target.period;               // usually 2 (octave)
  const steps = [1, ...target.steps];         // scale ratios inside one period
  const maxRatio = 40;
  const sigma = 0.12;                         // critical‑band width (log space)

  // ---- knobs -------------------------------------------------
  const stretch = 0.5 + 1.5 * p[0];            // 0.5 – 2.0 stretch exponent
  const tilt    = 0.3 + 1.2 * p[1];            // 0.3 – 1.5 spectral roll‑off
  const pull    = Math.min(1, Math.max(0, p[2])); // 0 – 1 blend toward nearest step
  const bandAtten = Math.min(1, Math.max(0, p[3])); // 0 – 1 critical‑band attenuation

  // ---- 1. all scale ratios across octaves --------------------
  const scaleRatios = [];
  for (let oct = 0; ; ++oct) {
    const base = Math.pow(period, oct);
    if (base > maxRatio) break;
    for (const s of steps) {
      const r = s * base;
      if (r >= 1 && r <= maxRatio) scaleRatios.push(r);
    }
  }

  // ---- 2. generate stretched harmonic partials ---------------
  const partials = [];
  const maxCount = 32; // we will trim later
  for (let k = 1; partials.length < maxCount; ++k) {
    // stretched harmonic position
    const stretched = Math.pow(k, stretch);
    if (stretched > maxRatio) break;

    // nearest scale ratio (any octave)
    let nearest = stretched;
    let bestDist = Infinity;
    for (const sr of scaleRatios) {
      const d = Math.abs(Math.log(stretched / sr));
      if (d < bestDist) {
        bestDist = d;
        nearest = sr;
      }
    }

    // blend toward the scale note
    const finalRatio = Math.exp((1 - pull) * Math.log(stretched) + pull * Math.log(nearest));

    // amplitude roll‑off
    const amp = 1 / Math.pow(k, tilt);

    partials.push({ ratio: finalRatio, amp });
  }

  // ---- 3. critical‑band attenuation -------------------------
  const logs = partials.map(pt => Math.log(pt.ratio));
  const amps = partials.map(pt => pt.amp);
  for (let i = 0; i < partials.length; ++i) {
    let reduction = 0;
    for (let j = 0; j < partials.length; ++j) if (i !== j) {
      const d = logs[i] - logs[j];
      const weight = Math.exp(- (d * d) / (2 * sigma * sigma));
      reduction += weight * amps[j];
    }
    const factor = Math.max(0, 1 - bandAtten * reduction);
    partials[i].amp *= factor;
  }

  // ---- 4. enforce fundamental ratio & loudness ---------------
  // find (or create) the fundamental
  let fund = partials.find(pt => Math.abs(pt.ratio - 1) < 1e-9);
  if (!fund) {
    fund = { ratio: 1, amp: 0 };
    partials.push(fund);
  }
  // set fundamental amplitude from k=1 roll‑off (ignoring pull)
  fund.amp = Math.max(fund.amp, 1 / Math.pow(1, tilt));

  // ensure fundamental ≥20 % of the loudest partial
  let maxAmp = 0;
  for (const pt of partials) if (pt.amp > maxAmp) maxAmp = pt.amp;
  if (fund.amp < 0.2 * maxAmp) fund.amp = 0.2 * maxAmp;

  // ---- 5. keep at most 32 loudest partials -------------------
  partials.sort((a, b) => b.amp - a.amp);
  const kept = partials.slice(0, 32);
  // guarantee fundamental survived
  if (!kept.some(pt => Math.abs(pt.ratio - 1) < 1e-9)) {
    kept[kept.length - 1] = { ratio: 1, amp: Math.max(0.2 * maxAmp, 0.001) };
  }

  // ---- 6. final clipping --------------------------------------
  for (const pt of kept) {
    if (pt.ratio < 1) pt.ratio = 1;
    if (pt.ratio > maxRatio) pt.ratio = maxRatio;
  }

  return kept;
}

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.