Day 22 of ∞All days

Wednesday, 25 November 2026

Wilson's 1·3·5·7 hexany

Hexany, first expedition: a timbre where 5 of 5 steps land in consonance (an ordinary instrument: 0; Sethares' construction: 2).

Erv Wilson's six-note structure where every chord is built from the 7th harmonic.

The numbers

An ordinary instrument
0 of 5 steps land
Sethares’ construction
2 of 5 steps land
Tonight’s search
5 of 5 steps land, a new record
The rule it found
add a valley‑emphasis stage that boosts amplitudes of partials landing on scale notes and slightly attenuates nearby competitors to deepen the dissonance dips.
Programs tried
76 programs, 64 valid, across 12 generations
Also works for
Ptolemy (5 of 6)
The piece
Hexany Lantern

Tonight’s film

Read the program
const PARAMS = 7; // [size, tilt, stretch, pull, snap, crowd, valleyBoost]

function timbre(target, p) {
  // 1️⃣ parameters
  const count      = 4 + Math.round(p[0] * 12);          // 4‑16 partials
  const tilt       = 0.5 + 2.0 * p[1];                   // amplitude roll‑off
  const stretch    = 0.8 + 0.6 * p[2];                  // stretched‑harmonic exponent
  const pull       = Math.max(0, Math.min(1, p[3]));    // blend toward scale
  const snapTol    = 0.02 + 0.08 * p[4];                // log‑distance for snapping
  const crowdExp  = 0.5 + 1.5 * p[5];                   // crowding penalty exponent
  const valleyBoost= Math.max(0, Math.min(1, p[6]));    // strength of valley emphasis

  // 2️⃣ scale notes (including fundamental) inside one period
  const scale   = [1, ...target.steps];
  const period  = target.period;

  // 3️⃣ all scale‑note candidates up to ratio 40 (any octave)
  const candidates = [];
  for (let oct = 0; ; ++oct) {
    const mult = Math.pow(period, oct);
    if (mult > 40) break;
    for (const n of scale) {
      const r = n * mult;
      if (r >= 1 && r <= 40) candidates.push(r);
    }
  }

  // 4️⃣ build raw partials with adaptive snap‑pull
  const raw = [];
  for (let k = 1; k <= count; ++k) {
    const base = Math.pow(k, stretch); // stretched harmonic position

    // nearest candidate and its log‑distance
    let best = base, bestDist = Infinity;
    for (const r of candidates) {
      const d = Math.abs(Math.log(r / base));
      if (d < bestDist) { bestDist = d; best = r; }
    }

    // snap if within tolerance, otherwise blend toward the nearest candidate
    const ratio = (bestDist < snapTol)
        ? best
        : Math.exp((1 - pull) * Math.log(base) + pull * Math.log(best));

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

    // boost snapped partials a little (helps valley depth)
    if (bestDist < snapTol) {
      const boost = 1 + pull * (1 - bestDist / snapTol);
      amp *= boost;
    }

    raw.push({ ratio, amp });
  }

  // 5️⃣ valley emphasis – boost partials that sit on (or very near) a scale note
  const valleyTol = 0.015; // log‑distance ≈ 1.5 % (≈25 cents)
  for (const pt of raw) {
    // distance to nearest scale candidate
    let minDist = Infinity;
    for (const c of candidates) {
      const d = Math.abs(Math.log(pt.ratio / c));
      if (d < minDist) minDist = d;
    }
    if (minDist < valleyTol) {
      const boost = 1 + valleyBoost * (1 - minDist / valleyTol);
      pt.amp *= boost;
    }
  }

  // 6️⃣ crowding penalty (same as parent)
  const critBand = 0.03; // ≈3 % ratio ≈ 30 cents
  for (let i = 0; i < raw.length; ++i) {
    let minDist = Infinity;
    for (let j = 0; j < raw.length; ++j) if (i !== j) {
      const d = Math.abs(Math.log(raw[i].ratio / raw[j].ratio));
      if (d < minDist) minDist = d;
    }
    if (minDist < critBand) {
      const factor = Math.pow(minDist / critBand, crowdExp);
      raw[i].amp *= factor;
    }
  }

  // 7️⃣ enforce fundamental ≥20 % of loudest
  let maxAmp = 0;
  for (const pt of raw) if (pt.amp > maxAmp) maxAmp = pt.amp;
  const fundIdx = raw.findIndex(pt => Math.abs(pt.ratio - 1) < 1e-12);
  if (fundIdx >= 0 && raw[fundIdx].amp < 0.2 * maxAmp) {
    raw[fundIdx].amp = 0.2 * maxAmp;
  }

  // 8️⃣ normalise (loudest = 1) and clamp ratios
  maxAmp = 0;
  for (const pt of raw) if (pt.amp > maxAmp) maxAmp = pt.amp;
  const partials = raw.map(pt => ({
    ratio: Math.min(40, Math.max(1, pt.ratio)),
    amp:   pt.amp / maxAmp
  }));

  // 9️⃣ trim to 32 partials
  if (partials.length > 32) 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.