Day 17 of ∞All days

Friday, 20 November 2026

17 equal steps to the octave

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

Seventeen equal steps: wide fifths and neutral thirds, an Arabic-leaning colour.

The numbers

An ordinary instrument
2 of 16 steps land
Sethares’ construction
5 of 16 steps land
Tonight’s search
6 of 16 steps land, a new record
The rule it found
boost amplitudes of induced partials that sit on scale steps to deepen valleys while merging close partials to keep smoothness.
Programs tried
76 programs, 63 valid, across 12 generations
The piece
Seventeen Lanterns

Tonight’s film

Read the program
const PARAMS = 5; // [harmonic count, tilt, pure‑induced mix, boost factor, merge‑width]

function timbre(target, p) {
  // ----- knobs -------------------------------------------------
  const cnt   = 4 + Math.round(p[0] * 12);          // 4‑16 partials
  const tilt  = 0.5 + 1.5 * p[1];                    // amplitude exponent 0.5‑2.0
  const mix   = Math.min(1, Math.max(0, p[2]));     // pure ↔ induced weight
  const boost = 1 + 2 * Math.min(1, Math.max(0, p[3])); // max amp multiplier (1‑3)
  const band  = 0.01 + 0.09 * Math.min(1, Math.max(0, p[4])); // log‑ratio merge width

  // ----- pre‑compute all scale ratios up to 40 -----------------
  const scale = [1];
  for (const step of target.steps) {
    for (let oct = 0; ; ++oct) {
      const r = step * Math.pow(target.period, oct);
      if (r > 40) break;
      scale.push(r);
    }
  }

  // ----- generate pure and induced partials -------------------
  const raw = [];
  for (let k = 1; k <= cnt; ++k) {
    // place harmonic in correct octave of the period
    const oct   = Math.floor(Math.log(k) / Math.log(target.period));
    const base  = Math.pow(target.period, oct);
    const pureR = base * k;
    if (pureR > 40) continue;

    // nearest scale ratio (induced)
    let bestR = pureR, bestDist = Infinity;
    for (const s of scale) {
      const r = base * s;
      if (r > 40) continue;
      const d = Math.abs(Math.log(r / pureR));
      if (d < bestDist) { bestDist = d; bestR = r; }
    }

    const amp0 = 1 / Math.pow(k, tilt);          // base amplitude
    const ampPure = amp0 * (1 - mix);
    const ampInd  = amp0 * mix;

    if (ampPure) raw.push({ ratio: pureR, amp: ampPure });
    if (ampInd)  raw.push({ ratio: bestR, amp: ampInd });
  }

  // ----- boost amplitudes that sit on (or near) scale steps ----
  for (const pt of raw) {
    // distance to nearest exact scale ratio (any octave)
    let mind = Infinity;
    for (const s of scale) {
      const d = Math.abs(Math.log(pt.ratio / s));
      if (d < mind) mind = d;
    }
    if (mind <= band) {
      const factor = 1 + (boost - 1) * (1 - mind / band);
      pt.amp *= factor;
    }
  }

  // ----- merge partials that lie within the band ----------------
  raw.sort((a, b) => a.ratio - b.ratio);
  const merged = [];
  for (let i = 0; i < raw.length; ) {
    let sumAmp = raw[i].amp;
    let sumLog = Math.log(raw[i].ratio) * sumAmp;
    let j = i + 1;
    while (
      j < raw.length &&
      Math.abs(Math.log(raw[j].ratio) - Math.log(raw[i].ratio)) < band
    ) {
      sumAmp += raw[j].amp;
      sumLog += Math.log(raw[j].ratio) * raw[j].amp;
      ++j;
    }
    merged.push({ ratio: Math.exp(sumLog / sumAmp), amp: sumAmp });
    i = j;
  }

  // ----- enforce fundamental loudness -------------------------
  let maxAmp = 0;
  for (const pt of merged) if (pt.amp > maxAmp) maxAmp = pt.amp;
  let fund = merged.find(pt => Math.abs(Math.log(pt.ratio)) < 1e-9);
  if (!fund) {
    fund = { ratio: 1, amp: 0.2 * maxAmp };
    merged.unshift(fund);
  } else if (fund.amp < 0.2 * maxAmp) {
    fund.amp = 0.2 * maxAmp;
  }

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

  return merged;
}

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.