the ultimate vocal synthesizer - sing, speak, beatbox, and more
Rust
Solver hardening from design review; real-time HumanVoice
Jameson Hodge8958095aed15
diff --git a/src/engine/airway/network.ts b/src/engine/airway/network.tsindex dbaccec..0c6085e 100644--- a/src/engine/airway/network.ts+++ b/src/engine/airway/network.ts@@ -130,6 +130,29 @@ export class AirwayNetwork {area!: Float64Array;private areaTarget!: Float64Array;private areaStep!: Float64Array;+ /** current minimum (sub-section) area per node: drives kinetic losses and Reynolds numbers */+ amin!: Float64Array;+ private aminTarget!: Float64Array;+ private aminStep!: Float64Array;+ /** nodes with ≥3 connections get a compliance floor for leapfrog stability */+ private isJunction!: Uint8Array;+ private invLsum!: Float64Array;+ /** neighbour lists (CSR) for redistributing squeezed volume of nearly closed nodes */+ private nbrStart!: Int32Array;+ private nbrList!: Int32Array;+ private spill!: Float64Array;+ /** band-limited moving-wall volume source (2-pole low-pass state per node) */+ private volSrc1!: Float64Array;+ private volSrc2!: Float64Array;+ private volLpCoef = 0;+ /** cut-off of the moving-wall volume source (Hz): articulator-driven flow is sub-audio */+ volumeSourceHz = 60;+ /** below this node area (cm²) displaced volume is pushed into the neighbours */+ squeezeArea = 0.12;+ /** model switches (diagnostics / ablation) */+ enableVolumeSource = true;+ enableJunctionFloor = true;+ energySafe = true;/** current section length (cm) */dx!: Float64Array;private dxTarget!: Float64Array;@@ -165,6 +188,7 @@ export class AirwayNetwork {private bk!: Uint8Array;U!: Float64Array;private mom!: Float64Array;+ private Lprev!: Float64Array;/** extra series pressure sources (noise, driven sources), cleared each sample */psrc!: Float64Array;/** port branch area (cm²), current */@@ -184,6 +208,7 @@ export class AirwayNetwork {private radNodes: number[] = [];private radNodeArr!: Int32Array;private radUL!: Float64Array;+ private radLprev!: Float64Array;/** radiated volume velocity of each radiator (telemetry) */radU!: Float64Array;private radPrevTotal = 0;@@ -271,6 +296,11 @@ export class AirwayNetwork {this.area = new Float64Array(N);this.areaTarget = new Float64Array(N);this.areaStep = new Float64Array(N);+ this.amin = new Float64Array(N);+ this.aminTarget = new Float64Array(N);+ this.aminStep = new Float64Array(N);+ this.isJunction = new Uint8Array(N);+ this.invLsum = new Float64Array(N);this.dx = new Float64Array(N);this.dxTarget = new Float64Array(N);this.dxStep = new Float64Array(N);@@ -298,6 +328,7 @@ export class AirwayNetwork {const k = t.node(i);const a = typeof spec.area === "number" ? spec.area : spec.area[i];this.area[k] = this.areaTarget[k] = a;+ this.amin[k] = this.aminTarget[k] = a;this.dx[k] = this.dxTarget[k] = dx;this.nodeTube[k] = t.index;this.viscF[k] = spec.viscousFactor ?? 1;@@ -318,6 +349,25 @@ export class AirwayNetwork {this.bk = Uint8Array.from(this.bKind);this.U = new Float64Array(B);this.mom = new Float64Array(B);+ this.Lprev = new Float64Array(B);+ const degree = new Int32Array(N);+ for (let j = 0; j < B; j++) {+ degree[this.ba[j]]++;+ degree[this.bb[j]]++;+ }+ for (let k = 0; k < N; k++) this.isJunction[k] = degree[k] >= 3 ? 1 : 0;+ this.nbrStart = new Int32Array(N + 1);+ for (let k = 0; k < N; k++) this.nbrStart[k + 1] = this.nbrStart[k] + degree[k];+ this.nbrList = new Int32Array(this.nbrStart[N]);+ const fillN = this.nbrStart.slice(0, N);+ for (let j = 0; j < B; j++) {+ this.nbrList[fillN[this.ba[j]]++] = this.bb[j];+ this.nbrList[fillN[this.bb[j]]++] = this.ba[j];+ }+ this.spill = new Float64Array(N);+ this.volSrc1 = new Float64Array(N);+ this.volSrc2 = new Float64Array(N);+ this.volLpCoef = 1 - Math.exp((-2 * Math.PI * this.volumeSourceHz) / this.fs);this.psrc = new Float64Array(B);this.portArea = new Float64Array(B);this.portAreaTarget = new Float64Array(B);@@ -343,6 +393,7 @@ export class AirwayNetwork {}this.radNodeArr = Int32Array.from(this.radNodes);this.radUL = new Float64Array(this.radNodes.length);+ this.radLprev = new Float64Array(this.radNodes.length);this.radU = new Float64Array(this.radNodes.length);for (let r = 0; r < this.radNodes.length; r++) this.radOf[this.radNodes[r]] = r;for (let k = 0; k < N; k++) {@@ -364,8 +415,12 @@ export class AirwayNetwork {// ---------------------------------------------------------------- control-rate API/** Set target areas (and optionally total length) of a tube, reached at the end of the next block. */- setTubeTargets(t: Tube, areas: ArrayLike<number>, length?: number): void {- for (let i = 0; i < t.n; i++) this.areaTarget[t.node(i)] = Math.max(0, areas[i]);+ setTubeTargets(t: Tube, areas: ArrayLike<number>, length?: number, minAreas?: ArrayLike<number>): void {+ for (let i = 0; i < t.n; i++) {+ const a = Math.max(0, areas[i]);+ this.areaTarget[t.node(i)] = a;+ this.aminTarget[t.node(i)] = minAreas ? Math.max(0, Math.min(a, minAreas[i])) : a;+ }if (length !== undefined) {t.length = length;const d = length / t.n;@@ -375,6 +430,7 @@ export class AirwayNetwork {setNodeAreaTarget(node: number, area: number): void {this.areaTarget[node] = Math.max(0, area);+ this.aminTarget[node] = this.areaTarget[node];}setPortTarget(branch: number, area: number): void {@@ -392,12 +448,42 @@ export class AirwayNetwork {this.p[node] = p;}+ /** Jump the geometry to the current targets immediately (initialisation; no dV/dt transient). */+ snapToTargets(): void {+ for (let k = 0; k < this.nNodes; k++) {+ this.area[k] = this.areaTarget[k];+ this.amin[k] = this.aminTarget[k];+ this.dx[k] = this.dxTarget[k];+ this.vol[k] = Math.max(this.area[k], this.minNodeArea) * this.dx[k];+ this.invA[k] = 1 / Math.max(this.area[k], 1e-6);+ this.areaStep[k] = this.aminStep[k] = this.dxStep[k] = 0;+ }+ for (let j = 0; j < this.nBranches; j++) {+ if (this.bk[j] === KIND_PORT) {+ this.portArea[j] = this.portAreaTarget[j];+ this.portAreaStep[j] = 0;+ }+ }+ }+/** Prepare per-sample linear ramps toward the targets over `samples` internal samples. */beginBlock(samples: number): void {const inv = 1 / Math.max(1, samples);+ let maxP = 0;for (let k = 0; k < this.nNodes; k++) {this.areaStep[k] = (this.areaTarget[k] - this.area[k]) * inv;+ this.aminStep[k] = (this.aminTarget[k] - this.amin[k]) * inv;this.dxStep[k] = (this.dxTarget[k] - this.dx[k]) * inv;+ if (!this.fixed[k]) {+ const ap = Math.abs(this.p[k]);+ if (ap > maxP) maxP = ap;+ }+ }+ // flush decayed state to zero (avoids denormal slowdowns in silent tails)+ if (maxP < 1e-9) {+ let maxU = 0;+ for (let j = 0; j < this.nBranches; j++) maxU = Math.max(maxU, Math.abs(this.U[j]));+ if (maxU < 1e-9) this.flushState();}for (let j = 0; j < this.nBranches; j++) {if (this.bk[j] === KIND_PORT) this.portAreaStep[j] = (this.portAreaTarget[j] - this.portArea[j]) * inv;@@ -430,6 +516,17 @@ export class AirwayNetwork {this.noise = next;}+ private flushState(): void {+ for (let k = 0; k < this.nNodes; k++) {+ if (!this.fixed[k]) this.p[k] = 0;+ this.wallV[k] = 0;+ if (Math.abs(this.wallY[k]) < 1e-12) this.wallY[k] = 0;+ }+ this.U.fill(0);+ this.mom.fill(0);+ this.radUL.fill(0);+ }+get noiseSources(): readonly { src: number; level: number }[] {return this.noise;}@@ -444,23 +541,68 @@ export class AirwayNetwork {const invT = this.invT;const p = this.p;const area = this.area;+ const amin = this.amin;const dx = this.dx;const invA = this.invA;const vol = this.vol;const flowSum = this.flowSum;const minA = this.minNodeArea;+ const isJ = this.isJunction;+ const invLsum = this.invLsum;- // 1) geometry ramps; accumulate -dV/dt into the flow sums+ // 1) geometry ramps; accumulate -dV/dt into the flow sums. A nearly closed node cannot hold+ // the air its walls displace: that share is pushed into its neighbours (mass-conserving).+ const sq = this.squeezeArea;+ let anySpill = false;for (let k = 0; k < N; k++) {let a = area[k] + this.areaStep[k];if (a < 0) a = 0;area[k] = a;+ let am = amin[k] + this.aminStep[k];+ if (am < 0) am = 0;+ amin[k] = am > a ? a : am;const d = (dx[k] += this.dxStep[k]);invA[k] = 1 / (a > 1e-6 ? a : 1e-6);const v = (a > minA ? a : minA) * d;- flowSum[k] = -(v - vol[k]) * invT + this.extFlow[k];- this.extFlow[k] = 0;+ // −dV/dt is piecewise constant across control blocks (and kinks at geometric vertices);+ // its derivative would radiate as clicks, so it is low-passed (physical content is sub-audio)+ let src = 0;+ if (this.enableVolumeSource) {+ const raw = -(v - vol[k]) * invT;+ const c = this.volLpCoef;+ const s1 = (this.volSrc1[k] += c * (raw - this.volSrc1[k]));+ src = this.volSrc2[k] += c * (s1 - this.volSrc2[k]);+ }vol[k] = v;+ invLsum[k] = 0;+ if (a < sq && src !== 0) {+ const t = a / sq;+ const keep = t * t * (3 - 2 * t);+ flowSum[k] = src * keep + this.extFlow[k];+ this.spill[k] = src * (1 - keep);+ anySpill = true;+ } else {+ flowSum[k] = src + this.extFlow[k];+ this.spill[k] = 0;+ }+ this.extFlow[k] = 0;+ }+ if (anySpill) {+ const cl = this.closedArea;+ for (let k = 0; k < N; k++) {+ const sp = this.spill[k];+ if (sp === 0) continue;+ const s0 = this.nbrStart[k], s1 = this.nbrStart[k + 1];+ // only open neighbours can receive displaced air+ let nOpen = 0;+ for (let e = s0; e < s1; e++) if (area[this.nbrList[e]] >= cl) nOpen++;+ if (nOpen === 0) continue; // fully sealed pocket: the squeezed air is absorbed by contact+ const share = sp / nOpen;+ for (let e = s0; e < s1; e++) {+ const m = this.nbrList[e];+ if (area[m] >= cl) flowSum[m] += share;+ }+ }}// 2) turbulence noise → series pressure sources@@ -474,8 +616,10 @@ export class AirwayNetwork {const bk = this.bk;const U = this.U;const mom = this.mom;+ const Lprev = this.Lprev;const visc = Math.sqrt((RHO * MU * this.viscousOmega) / 2) * this.viscousScale;const closed = this.closedArea;+ const halfRho = 0.5 * RHO;for (let j = 0; j < B; j++) {const a = ba[j];const b = bb[j];@@ -487,8 +631,10 @@ export class AirwayNetwork {if (bk[j] === KIND_SERIES) {const Aa = area[a];const Ab = area[b];- aEff = Aa < Ab ? Aa : Ab;- if (aEff < closed) {+ const ma = amin[a];+ const mb = amin[b];+ aEff = ma < mb ? ma : mb;+ if ((Aa < Ab ? Aa : Ab) < closed || aEff < closed) {U[j] = 0;mom[j] = 0;this.branchArea[j] = aEff;@@ -496,14 +642,20 @@ export class AirwayNetwork {}const ia = invA[a];const ib = invA[b];- L = 0.5 * RHO * (dx[a] * ia + dx[b] * ib);+ L = halfRho * (dx[a] * ia + dx[b] * ib);// viscous: R = S·l/A² · sqrt(ρμω/2) with S = perimeter of each half-sectionR = 0.5 * visc * (this.wallPerim[a] * dx[a] * Math.sqrt(Aa) * ia * ia * this.viscF[a] + this.wallPerim[b] * dx[b] * Math.sqrt(Ab) * ib * ib * this.viscF[b]);- const diff = ia - ib; // >0 when a is narrower- const bc = 0.5 * RHO * diff * diff;- // flow a→b expands if b wider (diff>0); flow b→a expands if a wider (diff<0)- kf = diff > 0 ? bc : 0.1 * bc;- kb = diff < 0 ? bc : 0.1 * bc;+ // Borda–Carnot: the jet leaving the narrowest point of the upstream node expands into+ // the downstream node (sub-section minima make short constrictions lossy as they should be)+ const ef = 1 / ma - ib; // a→b+ const eb = 1 / mb - ia; // b→a+ kf = ef > 0 ? halfRho * ef * ef : 0;+ kb = eb > 0 ? halfRho * eb * eb : 0;+ // small contraction (vena contracta) loss entering a narrower node+ const cf = 1 / mb - ia;+ const cb = 1 / ma - ib;+ if (cf > 0) kf += 0.1 * halfRho * cf * cf;+ if (cb > 0) kb += 0.1 * halfRho * cb * cb;} else {let Ap = (this.portArea[j] += this.portAreaStep[j]);if (Ap < 0) Ap = this.portArea[j] = 0;@@ -517,22 +669,24 @@ export class AirwayNetwork {const ip = 1 / Ap;const len = this.portLen[j];L = RHO * len * ip;- if (this.portHalf[j]) L += 0.5 * RHO * (dx[a] * invA[a] + dx[b] * invA[b]);+ if (this.portHalf[j]) L += halfRho * (dx[a] * invA[a] + dx[b] * invA[b]);const w = this.portSlit[j];if (w > 0) R = (12 * MU * len * w * w) * ip * ip * ip;else R = visc * 2 * Math.sqrt(Math.PI) * len * Math.sqrt(Ap) * ip * ip;R += this.portExtraR[j];// kinetic: entrance (contraction) + exit (jet expansion into the downstream node)- const ipa = invA[a];- const ipb = invA[b];- const exF = ip - ipb; // flow a→b exits into b- const exB = ip - ipa; // flow b→a exits into a- const kin = this.portKin[j] * 0.5 * RHO * ip * ip;- kf = kin + this.portKex[j] * 0.5 * RHO * (exF > 0 ? exF * exF : 0);- kb = kin + this.portKex[j] * 0.5 * RHO * (exB > 0 ? exB * exB : 0);+ const exF = ip - invA[b]; // flow a→b exits into b+ const exB = ip - invA[a]; // flow b→a exits into a+ const kin = this.portKin[j] * halfRho * ip * ip;+ kf = kin + this.portKex[j] * halfRho * (exF > 0 ? exF * exF : 0);+ kb = kin + this.portKex[j] * halfRho * (exB > 0 ? exB * exB : 0);}this.branchArea[j] = aEff;- const c = p[a] - p[b] + psrc[j] + mom[j] * invT;+ // energy-safe momentum transfer when the inertance changes: closing (L↑) conserves+ // momentum (flow drops), opening (L↓) conserves flow — never injects kinetic energy+ const Lp = Lprev[j];+ const m0 = this.energySafe && L < Lp ? L * U[j] : mom[j];+ const c = p[a] - p[b] + psrc[j] + m0 * invT;const bq = L * invT + R;let u: number;if (c >= 0) {@@ -542,8 +696,14 @@ export class AirwayNetwork {}U[j] = u;mom[j] = L * u;+ Lprev[j] = L;flowSum[a] -= u;flowSum[b] += u;+ if (isJ[a] | isJ[b]) {+ const il = 1 / L;+ invLsum[a] += il;+ invLsum[b] += il;+ }}// 4) walls (velocity at half step from p(n), displacement integrates)@@ -565,10 +725,37 @@ export class AirwayNetwork {// 5) nodes (radiation loads handled semi-implicitly)const radUL = this.radUL;+ const T2 = T * T;let radTotal = wallRadSum;+ const cl = this.closedArea;for (let k = 0; k < N; k++) {if (this.fixed[k]) continue;- const C = vol[k] / RHO_C2;+ if (area[k] < cl) {+ // sealed cell (tissue contact): no air of its own; follow the open neighbours' mean+ let sum = 0, cnt = 0;+ for (let e = this.nbrStart[k]; e < this.nbrStart[k + 1]; e++) {+ const m = this.nbrList[e];+ if (area[m] >= cl) {+ sum += p[m];+ cnt++;+ }+ }+ if (cnt > 0) p[k] += 0.02 * (sum / cnt - p[k]);+ const rr = this.radOf[k];+ if (rr >= 0) {+ // sealed aperture: let the radiated flow die away smoothly (no derivative step)+ radUL[rr] *= 0.995;+ this.radU[rr] = radUL[rr];+ radTotal += radUL[rr];+ }+ continue;+ }+ let C = vol[k] / RHO_C2;+ // junction stability: local breathing mode ω² ≈ ΣL⁻¹/C must satisfy T²ω² ≤ 2.4+ if (isJ[k] && this.enableJunctionFloor) {+ const cMin = (T2 * invLsum[k]) / 2.4;+ if (C < cMin) C = cMin;+ }const r = this.radOf[k];if (r < 0) {p[k] += (T / C) * flowSum[k];@@ -577,7 +764,12 @@ export class AirwayNetwork {const Lr = (8 * RHO) / (3 * Math.PI * Math.sqrt(Math.PI * a));const Rr = (128 * RHO * C_SOUND) / (9 * Math.PI * Math.PI * a);const pOld = p[k];- const ul = radUL[r] + (T / Lr) * pOld;+ // energy-safe: when the radiation inertance grows (aperture closing) conserve momentum+ const Lp = this.radLprev[r];+ let ulPrev = radUL[r];+ if (Lp > 0 && Lr > Lp) ulPrev *= Lp / Lr;+ this.radLprev[r] = Lr;+ const ul = ulPrev + (T / Lr) * pOld;radUL[r] = ul;const g = 0.5 / Rr;const pNew = (pOld * (C * invT - g) + flowSum[k] - ul) / (C * invT + g);@@ -597,7 +789,9 @@ export class AirwayNetwork {const U = this.U;const psrc = this.psrc;const rng = this.rng;- const scale = this.noiseScale;+ // white noise power per Hz scales with fs: normalise to a 96 kHz reference+ const scale = this.noiseScale * Math.sqrt(96000 / this.fs);+ const sat = 12000 * 12000 - RE_CRIT * RE_CRIT;for (let i = 0; i < this.noise.length; i++) {const s = this.noise[i];const a = this.branchArea[s.src];@@ -606,7 +800,10 @@ export class AirwayNetwork {if (a > this.closedArea) {// Re = v·d_h/ν with d_h = 2√(A/π) → Re = |U|·2/(ν·√(πA))const re = (Math.abs(u) * 2) / (NU * Math.sqrt(Math.PI * a));- if (re > RE_CRIT) amp = s.gain * scale * (re * re - RE_CRIT * RE_CRIT);+ if (re > RE_CRIT) {+ const x = re * re - RE_CRIT * RE_CRIT;+ amp = (s.gain * scale * x) / (1 + x / sat); // bounded growth at very high Re+ }}// white → high-pass (1st order) → 2nd-order low-passconst w = rng.bipolar() * 1.732;@@ -699,9 +896,11 @@ export class AirwayNetwork {this.p.fill(0);this.U.fill(0);this.mom.fill(0);+ this.Lprev.fill(0);this.wallY.fill(0);this.wallV.fill(0);this.radUL.fill(0);+ this.radLprev.fill(0);this.radPrevTotal = 0;}}diff --git a/src/engine/anatomy/human.ts b/src/engine/anatomy/human.tsindex e0aa93a..26f39de 100644--- a/src/engine/anatomy/human.ts+++ b/src/engine/anatomy/human.ts@@ -303,9 +303,14 @@ export class HumanVocalTract {const llBase = J(7.12, 7.45);const lowerLipIn = bezier3(llBase, add(llBase, v(0.25 * k + prot * 0.3, -0.05 * k)), add(llEdge, v(-0.3 * k, -0.12 * k)), llEdge, 7);+ // acoustic inner wall: epiglottis (laryngeal surface) then the tongue root *above* the+ // epiglottis tip — the vallecula pocket is omitted so the wall is single-valued along the+ // pharyngeal rays (a pocket makes ray crossings flip discontinuously)const inner = new Polyline();- inner.push(epiBase).push(epiTip).push(vallecula);- inner.append(root, true);+ inner.push(epiBase).push(epiTip);+ let rootStart = root.findIndex((q) => q.y > epiTip.y + 0.05 * k);+ if (rootStart < 0) rootStart = root.length - 1;+ for (let i = rootStart; i < root.length; i++) inner.push(root[i]);inner.append(arcPts, true);inner.append(blade, true);inner.append(under, true);@@ -461,7 +466,7 @@ export class HumanVocalTract {* Uses the harmonic mean of area over each section (preserves constriction inertance and* exact closures).*/- resample(a: HumanArtic, f: HumanFrame, nPh: number, nOr: number, outPh: Float64Array, outOr: Float64Array): { phLen: number; orLen: number } {+ resample(a: HumanArtic, f: HumanFrame, nPh: number, nOr: number, outPh: Float64Array, outOr: Float64Array, minPh?: Float64Array, minOr?: Float64Array): { phLen: number; orLen: number } {const epiLen = 2.4 * this.k * this.body.pharynx;const g = f.grid;const areaAt = (s: number): number => {@@ -478,14 +483,16 @@ export class HumanVocalTract {const t = (s - g[lo].s) / Math.max(1e-9, g[hi].s - g[lo].s);return lerp(g[lo].area, g[hi].area, t);};- const fill = (s0: number, s1: number, n: number, out: Float64Array) => {+ const fill = (s0: number, s1: number, n: number, out: Float64Array, mins?: Float64Array) => {const d = (s1 - s0) / n;const sub = 8;for (let i = 0; i < n; i++) {let inv = 0;let closed = false;+ let mn = Infinity;for (let j = 0; j < sub; j++) {const A = areaAt(s0 + d * (i + (j + 0.5) / sub));+ if (A < mn) mn = A;if (A <= 1e-5) {closed = true;break;@@ -493,11 +500,12 @@ export class HumanVocalTract {inv += 1 / A;}out[i] = closed ? 0 : sub / inv;+ if (mins) mins[i] = closed ? 0 : mn;}};const sp = f.pharynxLength;- fill(0, sp, nPh, outPh);- fill(sp, f.lipS, nOr, outOr);+ fill(0, sp, nPh, outPh, minPh);+ fill(sp, f.lipS, nOr, outOr, minOr);return { phLen: sp, orLen: f.lipS - sp };}}diff --git a/src/engine/control/articulators.ts b/src/engine/control/articulators.tsnew file mode 100644index 0000000..b71a768--- /dev/null+++ b/src/engine/control/articulators.ts@@ -0,0 +1,93 @@+/**+ * Articulator dynamics: each articulator is a critically damped second-order system tracking+ * its target (Task-Dynamics style), with physiological natural frequencies. Runs at control+ * rate. Velocities are bounded implicitly by the dynamics, so UI drags and gestures produce+ * physiologically plausible motion (and therefore plausible dV/dt in the airway).+ */+import type { HumanArtic } from "../anatomy/human.ts";+import { NEUTRAL, restTip } from "../anatomy/human.ts";++export type ArticKey = keyof HumanArtic;++export const ARTIC_KEYS: ArticKey[] = ["jaw", "tbX", "tbY", "ttX", "ttY", "ttCurl", "root", "lipAp", "lipProt", "lipWidth", "labiodental", "velum", "larynx", "epilarynx", "ventricular", "lateral", "dorsum"];++export interface ArticSpec {+ min: number;+ max: number;+ /** natural frequency (Hz) of the critically damped tracking dynamics */+ hz: number;+}++export const ARTIC_SPECS: Record<ArticKey, ArticSpec> = {+ jaw: { min: -0.1, max: 2.6, hz: 5 },+ tbX: { min: 1.0, max: 4.8, hz: 6.5 },+ tbY: { min: 4.8, max: 9.2, hz: 6.5 },+ ttX: { min: 3.5, max: 8.0, hz: 13 },+ ttY: { min: 5.0, max: 10.8, hz: 13 },+ ttCurl: { min: 0, max: 1, hz: 9 },+ root: { min: -1, max: 1, hz: 5 },+ lipAp: { min: -0.4, max: 2.4, hz: 11 },+ lipProt: { min: -0.2, max: 1.5, hz: 7 },+ lipWidth: { min: 0, max: 1, hz: 7 },+ labiodental: { min: 0, max: 1, hz: 10 },+ velum: { min: 0, max: 1.4, hz: 5 },+ larynx: { min: -1.6, max: 1.6, hz: 3.5 },+ epilarynx: { min: 0, max: 1, hz: 6 },+ ventricular: { min: 0, max: 1, hz: 6 },+ lateral: { min: 0, max: 1, hz: 10 },+ dorsum: { min: 0, max: 1, hz: 9 },+};++export class ArticulatorBank {+ readonly x: HumanArtic = { ...NEUTRAL };+ readonly v: Record<ArticKey, number>;+ readonly target: HumanArtic = { ...NEUTRAL };+ /** when true the tongue tip rests behind the lower incisors (follows jaw & tongue body) */+ tipFree = true;+ /** per-articulator speed multiplier (gestures can request faster/slower motion) */+ readonly speed: Record<ArticKey, number>;+ private readonly omega: Record<ArticKey, number>;++ constructor() {+ this.v = Object.fromEntries(ARTIC_KEYS.map((k) => [k, 0])) as Record<ArticKey, number>;+ this.speed = Object.fromEntries(ARTIC_KEYS.map((k) => [k, 1])) as Record<ArticKey, number>;+ this.omega = Object.fromEntries(ARTIC_KEYS.map((k) => [k, 2 * Math.PI * ARTIC_SPECS[k].hz])) as Record<ArticKey, number>;+ const tip = restTip(NEUTRAL.jaw, NEUTRAL.tbX, NEUTRAL.tbY);+ this.x.ttX = this.target.ttX = tip.x;+ this.x.ttY = this.target.ttY = tip.y;+ }++ setTarget(values: Partial<HumanArtic>): void {+ for (const k of Object.keys(values) as ArticKey[]) {+ const val = values[k];+ if (val === undefined || !Number.isFinite(val)) continue;+ const s = ARTIC_SPECS[k];+ if (!s) continue;+ this.target[k] = Math.min(s.max, Math.max(s.min, val));+ }+ }++ /** Jump immediately (no dynamics), e.g. on voice creation. */+ snap(values: Partial<HumanArtic>): void {+ this.setTarget(values);+ for (const k of ARTIC_KEYS) {+ this.x[k] = this.target[k];+ this.v[k] = 0;+ }+ }++ step(dt: number): void {+ if (this.tipFree) {+ const tip = restTip(this.x.jaw, this.x.tbX, this.x.tbY);+ this.target.ttX = tip.x;+ this.target.ttY = tip.y;+ }+ for (const k of ARTIC_KEYS) {+ const w = this.omega[k] * this.speed[k];+ // semi-implicit Euler on x'' = w²(T − x) − 2w x' (stable for w·dt < 1)+ const acc = w * w * (this.target[k] - this.x[k]) - 2 * w * this.v[k];+ this.v[k] += acc * dt;+ this.x[k] += this.v[k] * dt;+ }+ }+}diff --git a/src/engine/phonetics/vowelTargets.generated.json b/src/engine/phonetics/vowelTargets.generated.jsonindex 14666ae..cb0d6e8 100644--- a/src/engine/phonetics/vowelTargets.generated.json+++ b/src/engine/phonetics/vowelTargets.generated.json@@ -3,22 +3,22 @@"i": {"artic": {"tbX": 3.713,- "tbY": 7.752,- "jaw": 0.409,- "lipAp": 1.02,+ "tbY": 7.759,+ "jaw": 0.388,+ "lipAp": 1.003,"lipProt": 0,"lipWidth": 1,- "root": 0.584,- "larynx": 0.734,- "ttX": 6.555,- "ttY": 7.297,+ "root": 0.627,+ "larynx": 0.666,+ "ttX": 6.563,+ "ttY": 7.318,"ttCurl": 0},"formants": [338,2237,- 2930,- 3878+ 2941,+ 3923],"target": [342,@@ -26,30 +26,30 @@3000],"err": [- -1.3,+ -1.2,-3.7,- -2.3+ -2]},"ɪ": {"artic": {- "tbX": 3.748,- "tbY": 7.347,+ "tbX": 3.779,+ "tbY": 7.343,"jaw": 0.574,- "lipAp": 1.14,+ "lipAp": 1.138,"lipProt": 0,"lipWidth": 1,- "root": 0.083,- "larynx": 0.234,- "ttX": 6.506,- "ttY": 7.007,+ "root": 0.176,+ "larynx": 0.196,+ "ttX": 6.515,+ "ttY": 7.006,"ttCurl": 0},"formants": [- 424,- 2014,- 2632,- 3728+ 425,+ 2005,+ 2644,+ 3781],"target": [427,@@ -57,30 +57,30 @@2684],"err": [- -0.7,- -1,- -1.9+ -0.6,+ -1.4,+ -1.5]},"e": {"artic": {- "tbX": 3.625,- "tbY": 7.232,- "jaw": 0.825,- "lipAp": 1.346,+ "tbX": 3.747,+ "tbY": 7.138,+ "jaw": 0.781,+ "lipAp": 1.305,"lipProt": 0,"lipWidth": 1,- "root": 0.114,- "larynx": 0.592,- "ttX": 6.372,- "ttY": 6.745,+ "root": 0.284,+ "larynx": 0.52,+ "ttX": 6.426,+ "ttY": 6.752,"ttCurl": 0},"formants": [- 467,- 2014,- 2602,- 3790+ 470,+ 1996,+ 2644,+ 3837],"target": [476,@@ -88,30 +88,30 @@2691],"err": [- -1.9,- -3.6,- -3.3+ -1.2,+ -4.5,+ -1.8]},"ɛ": {"artic": {- "tbX": 3.912,- "tbY": 5.899,- "jaw": 1.073,- "lipAp": 1.509,+ "tbX": 3.739,+ "tbY": 6.169,+ "jaw": 1.074,+ "lipAp": 1.512,"lipProt": 0,"lipWidth": 1,- "root": -0.03,- "larynx": 0.107,- "ttX": 6.357,- "ttY": 6.064,- "ttCurl": 0.001+ "root": -0.005,+ "larynx": 0.181,+ "ttX": 6.305,+ "ttY": 6.156,+ "ttCurl": 0},"formants": [578,- 1778,- 2655,- 3811+ 1781,+ 2625,+ 3802],"target": [580,@@ -120,29 +120,29 @@],"err": [-0.3,- -1.2,- 1.9+ -1,+ 0.8]},"æ": {"artic": {- "tbX": 3.382,- "tbY": 5.995,- "jaw": 1.503,- "lipAp": 1.841,- "lipProt": 0,+ "tbX": 3.52,+ "tbY": 5.574,+ "jaw": 1.502,+ "lipAp": 1.833,+ "lipProt": 0.227,"lipWidth": 1,- "root": -0.1,- "larynx": 0.212,- "ttX": 6.011,- "ttY": 5.727,- "ttCurl": 0+ "root": -0.156,+ "larynx": 0.162,+ "ttX": 6.052,+ "ttY": 5.583,+ "ttCurl": 0.002},"formants": [- 632,- 1714,- 2583,- 3790+ 636,+ 1731,+ 2633,+ 3861],"target": [640,@@ -150,30 +150,30 @@2500],"err": [- -1.2,- -2.6,- 3.3+ -0.6,+ -1.7,+ 5.3]},"a": {"artic": {- "tbX": 2.19,- "tbY": 5.661,- "jaw": 1.808,+ "tbX": 2.193,+ "tbY": 5.688,+ "jaw": 1.809,"lipAp": 2,"lipProt": 0,"lipWidth": 1,- "root": -0.479,- "larynx": 0.336,+ "root": -0.249,+ "larynx": 0.323,"ttX": 5.511,- "ttY": 5.352,+ "ttY": 5.361,"ttCurl": 0},"formants": [- 751,+ 745,1435,- 2540,- 3971+ 2556,+ 3980],"target": [780,@@ -181,30 +181,30 @@2550],"err": [- -3.7,+ -4.5,-1.1,- -0.4+ 0.2]},"ɑ": {"artic": {- "tbX": 1.949,- "tbY": 5.713,- "jaw": 1.751,+ "tbX": 1.961,+ "tbY": 5.771,+ "jaw": 1.767,"lipAp": 2,"lipProt": 0,"lipWidth": 1,- "root": -0.428,- "larynx": 0.19,- "ttX": 5.466,- "ttY": 5.418,+ "root": -0.24,+ "larynx": 0.169,+ "ttX": 5.462,+ "ttY": 5.424,"ttCurl": 0},"formants": [- 755,+ 745,1331,- 2537,- 3922+ 2535,+ 3935],"target": [768,@@ -212,30 +212,30 @@2522],"err": [- -1.7,- -0.2,- 0.6+ -2.9,+ -0.1,+ 0.5]},"ɒ": {"artic": {- "tbX": 1.308,- "tbY": 5.809,- "jaw": 1.573,- "lipAp": 0.932,- "lipProt": 0.586,- "lipWidth": 0.454,- "root": -0.187,- "larynx": 0.026,- "ttX": 5.357,- "ttY": 5.602,+ "tbX": 1.322,+ "tbY": 5.765,+ "jaw": 1.59,+ "lipAp": 0.933,+ "lipProt": 0.553,+ "lipWidth": 0.458,+ "root": -0.163,+ "larynx": 0.007,+ "ttX": 5.354,+ "ttY": 5.572,"ttCurl": 0},"formants": [- 615,- 884,- 2527,- 3915+ 611,+ 888,+ 2542,+ 3899],"target": [620,@@ -243,30 +243,30 @@2500],"err": [- -0.7,- 0.5,- 1.1+ -1.5,+ 1,+ 1.7]},"ɔ": {"artic": {- "tbX": 1.476,- "tbY": 5.76,- "jaw": 1.254,- "lipAp": 0.775,- "lipProt": 0.326,- "lipWidth": 0.488,- "root": -0.22,- "larynx": 0.063,- "ttX": 5.55,- "ttY": 5.857,+ "tbX": 1.482,+ "tbY": 5.783,+ "jaw": 1.287,+ "lipAp": 0.78,+ "lipProt": 0.32,+ "lipWidth": 0.497,+ "root": -0.166,+ "larynx": 0.05,+ "ttX": 5.537,+ "ttY": 5.836,"ttCurl": 0},"formants": [- 643,- 999,+ 640,+ 1001,2520,- 3933+ 3914],"target": [652,@@ -274,30 +274,30 @@2538],"err": [- -1.3,- 0.2,+ -1.9,+ 0.4,-0.7]},"o": {"artic": {- "tbX": 1.457,- "tbY": 5.707,+ "tbX": 1.462,+ "tbY": 5.761,"jaw": 0.725,- "lipAp": 0.535,- "lipProt": 1.156,- "lipWidth": 0.133,+ "lipAp": 0.473,+ "lipProt": 0.614,+ "lipWidth": 0.001,"root": 0,"larynx": 0,- "ttX": 5.761,- "ttY": 6.3,+ "ttX": 5.762,+ "ttY": 6.319,"ttCurl": 0},"formants": [497,910,2459,- 3914+ 3898],"target": [497,@@ -312,23 +312,23 @@},"ʊ": {"artic": {- "tbX": 1.839,- "tbY": 5.697,+ "tbX": 1.832,+ "tbY": 5.652,"jaw": 0.5,- "lipAp": 0.357,- "lipProt": 0.703,- "lipWidth": 0.012,+ "lipAp": 0.412,+ "lipProt": 1.263,+ "lipWidth": 0.149,"root": 0,"larynx": 0,- "ttX": 5.96,- "ttY": 6.496,+ "ttX": 5.958,+ "ttY": 6.48,"ttCurl": 0},"formants": [469,1122,2434,- 3877+ 3881],"target": [469,@@ -343,23 +343,23 @@},"u": {"artic": {- "tbX": 2.602,- "tbY": 7.348,- "jaw": 0.205,+ "tbX": 1.627,+ "tbY": 5.692,+ "jaw": 0.151,"lipAp": 0.12,"lipProt": 1.4,"lipWidth": 0,- "root": 0.436,- "larynx": 0.281,- "ttX": 6.293,- "ttY": 7.338,+ "root": -0.004,+ "larynx": -0.074,+ "ttX": 6.019,+ "ttY": 6.808,"ttCurl": 0},"formants": [- 378,+ 380,998,- 2260,- 3696+ 2448,+ 3889],"target": [378,@@ -367,29 +367,29 @@2343],"err": [- 0,+ 0.5,0.1,- -3.5+ 4.5]},"ʌ": {"artic": {- "tbX": 1.396,- "tbY": 6.473,- "jaw": 1.192,- "lipAp": 1.627,+ "tbX": 1.386,+ "tbY": 6.46,+ "jaw": 1.216,+ "lipAp": 1.648,"lipProt": 0,"lipWidth": 1,- "root": 0.307,- "larynx": 0.004,- "ttX": 5.552,- "ttY": 6.165,+ "root": 0.33,+ "larynx": 0.035,+ "ttX": 5.538,+ "ttY": 6.14,"ttCurl": 0.003},"formants": [- 628,- 1181,- 2394,+ 629,+ 1176,+ 2403,3794],"target": [@@ -398,30 +398,30 @@2550],"err": [- 0.8,- -1.6,- -6.1+ 0.9,+ -2,+ -5.8]},"ə": {"artic": {- "tbX": 2.575,- "tbY": 7.153,- "jaw": 0.848,- "lipAp": 0.626,+ "tbX": 2.574,+ "tbY": 7.162,+ "jaw": 0.838,+ "lipAp": 0.619,"lipProt": 0.357,- "lipWidth": 0.541,- "root": 0.533,- "larynx": 0.365,- "ttX": 6.048,- "ttY": 6.698,+ "lipWidth": 0.54,+ "root": 0.648,+ "larynx": 0.324,+ "ttX": 6.052,+ "ttY": 6.709,"ttCurl": 0},"formants": [- 501,+ 502,1455,2308,- 3682+ 3728],"target": [500,@@ -429,30 +429,30 @@2450],"err": [- 0.3,+ 0.4,0.3,-5.8]},"ɐ": {"artic": {- "tbX": 2.24,- "tbY": 5.522,- "jaw": 1.35,- "lipAp": 1.006,- "lipProt": 0.355,+ "tbX": 2.238,+ "tbY": 5.506,+ "jaw": 1.347,+ "lipAp": 1.004,+ "lipProt": 0.356,"lipWidth": 0.542,"root": 0.007,- "larynx": -0.02,- "ttX": 5.737,- "ttY": 5.691,+ "larynx": -0.021,+ "ttX": 5.738,+ "ttY": 5.688,"ttCurl": 0},"formants": [641,1351,2504,- 3875+ 3893],"target": [640,@@ -462,28 +462,28 @@"err": [0.2,0.1,- 0.1+ 0.2]},"ɝ": {"artic": {- "tbX": 2.194,- "tbY": 7.146,- "jaw": 0.468,- "lipAp": 0.656,- "lipProt": 0.545,- "lipWidth": 0.39,+ "tbX": 2.487,+ "tbY": 7.214,+ "jaw": 0.737,+ "lipAp": 0.65,+ "lipProt": 0.575,+ "lipWidth": 0.374,"root": -0.9,- "larynx": -0.653,- "ttX": 5.678,- "ttY": 9.032,+ "larynx": -0.871,+ "ttX": 5.665,+ "ttY": 8.817,"ttCurl": 1},"formants": [- 467,- 1347,- 1783,- 2877+ 465,+ 1354,+ 1820,+ 3031],"target": [474,@@ -491,30 +491,30 @@1710],"err": [- -1.4,- -2.3,- 4.3+ -1.9,+ -1.8,+ 6.4]},"y": {"artic": {- "tbX": 3.454,- "tbY": 7.858,- "jaw": 0.2,- "lipAp": 0.124,- "lipProt": 0.903,- "lipWidth": 0.204,- "root": 0.014,- "larynx": 0.007,- "ttX": 6.55,- "ttY": 7.522,+ "tbX": 3.472,+ "tbY": 7.862,+ "jaw": 0.194,+ "lipAp": 0.3,+ "lipProt": 0.814,+ "lipWidth": 0.034,+ "root": 0.083,+ "larynx": 0.024,+ "ttX": 6.558,+ "ttY": 7.529,"ttCurl": 0},"formants": [300,1800,- 2147,- 3711+ 2135,+ 3771],"target": [300,@@ -524,28 +524,28 @@"err": [0,0,- -0.2+ -0.7]},"ø": {"artic": {- "tbX": 3.664,- "tbY": 6.958,- "jaw": 0.65,- "lipAp": 0.167,- "lipProt": 1.265,- "lipWidth": 0.028,- "root": 0,- "larynx": 0,- "ttX": 6.452,- "ttY": 6.804,- "ttCurl": 0+ "tbX": 3.472,+ "tbY": 7.35,+ "jaw": 0.606,+ "lipAp": 0.499,+ "lipProt": 1.274,+ "lipWidth": 0.016,+ "root": 0.204,+ "larynx": 0.035,+ "ttX": 6.41,+ "ttY": 6.986,+ "ttCurl": 0.003},"formants": [390,- 1550,- 2250,- 3342+ 1551,+ 2213,+ 3399],"target": [390,@@ -555,28 +555,28 @@"err": [0,0,- 0+ -1.6]},"œ": {"artic": {- "tbX": 3.048,- "tbY": 6.082,+ "tbX": 3.051,+ "tbY": 6.037,"jaw": 1.025,- "lipAp": 0.568,- "lipProt": 0.881,- "lipWidth": 0.25,+ "lipAp": 0.683,+ "lipProt": 1.14,+ "lipWidth": 0.3,"root": 0,"larynx": 0,- "ttX": 6.118,- "ttY": 6.168,+ "ttX": 6.119,+ "ttY": 6.152,"ttCurl": 0},"formants": [520,1450,2350,- 3577+ 3566],"target": [520,@@ -591,23 +591,23 @@},"ɨ": {"artic": {- "tbX": 3.005,- "tbY": 7.654,+ "tbX": 3.026,+ "tbY": 7.671,"jaw": 0.05,"lipAp": 0.12,- "lipProt": 0.364,- "lipWidth": 0.502,- "root": 0.883,- "larynx": 0.174,- "ttX": 6.465,- "ttY": 7.586,+ "lipProt": 0.405,+ "lipWidth": 0.48,+ "root": 0.888,+ "larynx": 0.098,+ "ttX": 6.472,+ "ttY": 7.592,"ttCurl": 0},"formants": [- 335,- 1620,- 2296,- 3655+ 336,+ 1624,+ 2285,+ 3715],"target": [330,@@ -615,30 +615,30 @@2400],"err": [+ 1.8,1.5,- 1.3,- -4.3+ -4.8]},"ɯ": {"artic": {- "tbX": 2.75,- "tbY": 7.486,+ "tbX": 2.746,+ "tbY": 7.484,"jaw": 0.05,"lipAp": 0.12,- "lipProt": 0.356,- "lipWidth": 0.405,+ "lipProt": 0.359,+ "lipWidth": 0.411,"root": 0.9,- "larynx": -0.03,- "ttX": 6.389,- "ttY": 7.527,+ "larynx": -0.027,+ "ttX": 6.388,+ "ttY": 7.526,"ttCurl": 0},"formants": [- 357,- 1388,- 2249,- 3568+ 358,+ 1387,+ 2250,+ 3570],"target": [340,@@ -646,30 +646,30 @@2400],"err": [- 5,- 2.8,+ 5.2,+ 2.7,-6.3]},"ɤ": {"artic": {- "tbX": 2.243,- "tbY": 7.17,- "jaw": 0.438,- "lipAp": 0.288,- "lipProt": 0.37,- "lipWidth": 0.522,- "root": 0.66,+ "tbX": 2.269,+ "tbY": 7.186,+ "jaw": 0.346,+ "lipAp": 0.223,+ "lipProt": 0.369,+ "lipWidth": 0.529,+ "root": 0.657,"larynx": 0.431,- "ttX": 6.104,- "ttY": 7.067,+ "ttX": 6.144,+ "ttY": 7.155,"ttCurl": 0},"formants": [461,- 1259,+ 1257,2284,- 3726+ 3801],"target": [460,@@ -677,8 +677,8 @@2450],"err": [- 0.2,- 0.7,+ 0.3,+ 0.6,-6.8]}@@ -686,23 +686,23 @@"female": {"i": {"artic": {- "tbX": 3.787,- "tbY": 7.646,- "jaw": 0.52,- "lipAp": 1.116,+ "tbX": 3.83,+ "tbY": 7.64,+ "jaw": 0.474,+ "lipAp": 1.074,"lipProt": 0,"lipWidth": 1,- "root": 0.296,- "larynx": 0.874,- "ttX": 6.537,- "ttY": 7.16,+ "root": 0.442,+ "larynx": 0.922,+ "ttX": 6.567,+ "ttY": 7.199,"ttCurl": 0},"formants": [- 427,- 2630,- 3222,- 4501+ 430,+ 2644,+ 3269,+ 4479],"target": [437,@@ -710,30 +710,30 @@3372],"err": [- -2.2,- -4.7,- -4.5+ -1.7,+ -4.2,+ -3.1]},"ɪ": {"artic": {- "tbX": 3.793,+ "tbX": 3.821,"tbY": 7.348,- "jaw": 0.551,- "lipAp": 1.118,+ "jaw": 0.541,+ "lipAp": 1.109,"lipProt": 0,"lipWidth": 1,- "root": 0.023,- "larynx": 0.116,- "ttX": 6.528,- "ttY": 7.028,+ "root": 0.061,+ "larynx": 0.095,+ "ttX": 6.54,+ "ttY": 7.037,"ttCurl": 0},"formants": [- 481,+ 482,2348,- 3030,- 4345+ 3038,+ 4401],"target": [483,@@ -743,28 +743,28 @@"err": [-0.3,-0.7,- -0.8+ -0.5]},"e": {"artic": {- "tbX": 3.602,- "tbY": 7.381,- "jaw": 0.897,- "lipAp": 1.406,+ "tbX": 3.612,+ "tbY": 7.388,+ "jaw": 0.87,+ "lipAp": 1.38,"lipProt": 0,"lipWidth": 1,- "root": 0.103,- "larynx": 0.729,- "ttX": 6.337,- "ttY": 6.734,+ "root": 0.192,+ "larynx": 0.714,+ "ttX": 6.351,+ "ttY": 6.76,"ttCurl": 0},"formants": [- 522,- 2406,- 3000,- 4444+ 524,+ 2420,+ 3012,+ 4460],"target": [536,@@ -772,30 +772,30 @@3047],"err": [- -2.7,- -4.9,- -1.5+ -2.3,+ -4.3,+ -1.2]},"ɛ": {"artic": {- "tbX": 3.357,- "tbY": 5.587,- "jaw": 1.179,- "lipAp": 1.602,- "lipProt": 0.002,- "lipWidth": 0.997,- "root": -0.045,- "larynx": 0.263,- "ttX": 6.146,- "ttY": 5.861,+ "tbX": 3.363,+ "tbY": 5.402,+ "jaw": 1.157,+ "lipAp": 1.581,+ "lipProt": 0,+ "lipWidth": 1,+ "root": -0.124,+ "larynx": 0.084,+ "ttX": 6.157,+ "ttY": 5.815,"ttCurl": 0},"formants": [726,- 2027,- 3046,- 4519+ 2028,+ 3065,+ 4522],"target": [731,@@ -805,28 +805,28 @@"err": [-0.7,-1.5,- 2.3+ 2.9]},"æ": {"artic": {- "tbX": 4.337,- "tbY": 5.237,- "jaw": 1.49,- "lipAp": 1.823,- "lipProt": 0.071,+ "tbX": 4.376,+ "tbY": 5.228,+ "jaw": 1.495,+ "lipAp": 1.829,+ "lipProt": 0.005,"lipWidth": 1,- "root": -0.271,- "larynx": 0.477,- "ttX": 6.304,- "ttY": 5.472,+ "root": -0.265,+ "larynx": 0.482,+ "ttX": 6.313,+ "ttY": 5.464,"ttCurl": 0},"formants": [- 665,- 2249,- 3232,- 4479+ 666,+ 2259,+ 3247,+ 4474],"target": [669,@@ -835,29 +835,29 @@],"err": [-0.5,- -4.3,- 8.8+ -3.8,+ 9.2]},"a": {"artic": {- "tbX": 1.972,- "tbY": 5.52,- "jaw": 1.798,+ "tbX": 2.106,+ "tbY": 5.691,+ "jaw": 1.869,"lipAp": 2,"lipProt": 0,"lipWidth": 1,- "root": -0.656,- "larynx": 0.713,- "ttX": 5.45,- "ttY": 5.312,+ "root": -0.324,+ "larynx": 0.567,+ "ttX": 5.456,+ "ttY": 5.313,"ttCurl": 0.001},"formants": [- 875,- 1722,- 2936,- 4295+ 855,+ 1712,+ 2922,+ 4469],"target": [913,@@ -865,30 +865,30 @@2933],"err": [- -4.1,- -1,- 0.1+ -6.3,+ -1.6,+ -0.3]},"ɑ": {"artic": {- "tbX": 1.796,- "tbY": 5.91,- "jaw": 1.828,+ "tbX": 1.804,+ "tbY": 5.898,+ "jaw": 1.86,"lipAp": 2,"lipProt": 0,"lipWidth": 1,- "root": -0.639,- "larynx": 0.471,- "ttX": 5.383,- "ttY": 5.423,+ "root": -0.55,+ "larynx": 0.452,+ "ttX": 5.37,+ "ttY": 5.392,"ttCurl": 0},"formants": [- 880,- 1541,- 2802,- 4488+ 866,+ 1543,+ 2847,+ 4498],"target": [936,@@ -896,29 +896,29 @@2815],"err": [- -6,- -0.6,- -0.4+ -7.5,+ -0.5,+ 1.1]},"ɒ": {"artic": {- "tbX": 1.286,- "tbY": 5.607,- "jaw": 1.568,- "lipAp": 0.934,- "lipProt": 0.344,- "lipWidth": 0.46,- "root": -0.09,- "larynx": 0.055,- "ttX": 5.353,- "ttY": 5.535,- "ttCurl": 0+ "tbX": 1.289,+ "tbY": 5.68,+ "jaw": 1.597,+ "lipAp": 0.94,+ "lipProt": 0.334,+ "lipWidth": 0.475,+ "root": -0.107,+ "larynx": 0.075,+ "ttX": 5.34,+ "ttY": 5.537,+ "ttCurl": 0.001},"formants": [- 722,- 1057,- 2880+ 717,+ 1061,+ 2873],"target": [725,@@ -926,30 +926,30 @@2875],"err": [- -0.4,- 0.1,- 0.2+ -1.2,+ 0.5,+ -0.1]},"ɔ": {"artic": {- "tbX": 1.325,- "tbY": 5.966,- "jaw": 1.333,- "lipAp": 0.799,- "lipProt": 0.297,- "lipWidth": 0.522,- "root": -0.386,- "larynx": 0.363,- "ttX": 5.47,- "ttY": 5.861,+ "tbX": 1.351,+ "tbY": 5.968,+ "jaw": 1.421,+ "lipAp": 0.807,+ "lipProt": 0.284,+ "lipWidth": 0.538,+ "root": -0.41,+ "larynx": 0.326,+ "ttX": 5.439,+ "ttY": 5.787,"ttCurl": 0},"formants": [- 757,- 1143,- 2784,- 4504+ 745,+ 1151,+ 2796,+ 4548],"target": [781,@@ -957,30 +957,30 @@2824],"err": [- -3.1,- 0.6,- -1.4+ -4.5,+ 1.3,+ -1]},"o": {"artic": {- "tbX": 1.846,- "tbY": 7.032,- "jaw": 0.872,- "lipAp": 0.254,- "lipProt": 1.035,- "lipWidth": 0.072,- "root": 0.279,- "larynx": 0.527,- "ttX": 5.82,- "ttY": 6.634,+ "tbX": 1.848,+ "tbY": 7.035,+ "jaw": 0.866,+ "lipAp": 0.292,+ "lipProt": 1.4,+ "lipWidth": 0.148,+ "root": 0.282,+ "larynx": 0.5,+ "ttX": 5.823,+ "ttY": 6.64,"ttCurl": 0},"formants": [- 550,- 1046,- 2643,- 4360+ 551,+ 1043,+ 2631,+ 4287],"target": [555,@@ -988,30 +988,30 @@2828],"err": [- -1,- 1,- -6.5+ -0.8,+ 0.7,+ -7]},"ʊ": {"artic": {- "tbX": 2.378,- "tbY": 7.148,- "jaw": 0.533,+ "tbX": 2.388,+ "tbY": 7.144,+ "jaw": 0.531,"lipAp": 0.44,"lipProt": 1.4,- "lipWidth": 0.135,- "root": 0.309,- "larynx": 0.29,- "ttX": 6.109,+ "lipWidth": 0.11,+ "root": 0.362,+ "larynx": 0.308,+ "ttX": 6.113,"ttY": 6.976,- "ttCurl": 0.001+ "ttCurl": 0},"formants": [518,1228,- 2699,- 4293+ 2713,+ 4307],"target": [519,@@ -1020,29 +1020,29 @@],"err": [-0.2,- 0.2,- -4.5+ 0.3,+ -4]},"u": {"artic": {- "tbX": 2.368,- "tbY": 7.239,- "jaw": 0.231,+ "tbX": 2.378,+ "tbY": 7.235,+ "jaw": 0.23,"lipAp": 0.12,"lipProt": 1.4,- "lipWidth": 0.059,- "root": 0.222,- "larynx": 0.176,- "ttX": 6.214,- "ttY": 7.276,- "ttCurl": 0+ "lipWidth": 0.028,+ "root": 0.232,+ "larynx": 0.184,+ "ttX": 6.217,+ "ttY": 7.278,+ "ttCurl": 0.001},"formants": [- 458,+ 459,1106,2658,- 4359+ 4373],"target": [459,@@ -1057,23 +1057,23 @@},"ʌ": {"artic": {- "tbX": 1.747,- "tbY": 5.29,+ "tbX": 1.742,+ "tbY": 5.312,"jaw": 1.1,- "lipAp": 1.053,- "lipProt": 0.125,- "lipWidth": 0.671,+ "lipAp": 0.957,+ "lipProt": 0.253,+ "lipWidth": 0.847,"root": 0,"larynx": 0,- "ttX": 5.697,- "ttY": 5.825,+ "ttX": 5.695,+ "ttY": 5.833,"ttCurl": 0},"formants": [753,1426,2933,- 4571+ 4576],"target": [753,@@ -1088,23 +1088,23 @@},"ə": {"artic": {- "tbX": 2.829,- "tbY": 7.14,- "jaw": 0.893,- "lipAp": 0.666,- "lipProt": 0.353,- "lipWidth": 0.546,- "root": 0.247,- "larynx": 0.199,- "ttX": 6.106,- "ttY": 6.654,+ "tbX": 2.827,+ "tbY": 7.154,+ "jaw": 0.882,+ "lipAp": 0.656,+ "lipProt": 0.354,+ "lipWidth": 0.544,+ "root": 0.307,+ "larynx": 0.169,+ "ttX": 6.11,+ "ttY": 6.668,"ttCurl": 0},"formants": [586,- 1743,+ 1744,2728,- 4260+ 4289],"target": [585,@@ -1112,29 +1112,29 @@2818],"err": [- 0.1,+ 0.2,0.2,-3.2]},"ɐ": {"artic": {- "tbX": 2.164,- "tbY": 5.414,+ "tbX": 2.163,+ "tbY": 5.404,"jaw": 1.4,- "lipAp": 1.359,- "lipProt": 0.256,- "lipWidth": 0.563,+ "lipAp": 1.541,+ "lipProt": 0.335,+ "lipWidth": 0.55,"root": 0,- "larynx": 0,+ "larynx": -0.001,"ttX": 5.692,- "ttY": 5.61,+ "ttY": 5.607,"ttCurl": 0},"formants": [749,1620,- 2875+ 2874],"target": [749,@@ -1149,23 +1149,23 @@},"ɝ": {"artic": {- "tbX": 2.794,- "tbY": 7.352,- "jaw": 0.958,- "lipAp": 0.64,- "lipProt": 0.572,- "lipWidth": 0.356,+ "tbX": 2.008,+ "tbY": 7.081,+ "jaw": 0.05,+ "lipAp": 0.632,+ "lipProt": 0.573,+ "lipWidth": 0.345,"root": -0.9,- "larynx": -0.841,- "ttX": 5.67,- "ttY": 8.671,+ "larynx": -0.974,+ "ttX": 5.766,+ "ttY": 9.385,"ttCurl": 1},"formants": [- 514,- 1566,- 2183,- 3440+ 512,+ 1535,+ 2095,+ 2954],"target": [523,@@ -1173,30 +1173,30 @@1929],"err": [- -1.8,- -1.4,- 13.2+ -2.1,+ -3.3,+ 8.6]},"y": {"artic": {- "tbX": 3.525,- "tbY": 7.873,- "jaw": 0.222,- "lipAp": 0.3,- "lipProt": 1.006,- "lipWidth": 0.301,- "root": -0.293,- "larynx": -0.139,- "ttX": 6.564,- "ttY": 7.507,+ "tbX": 3.396,+ "tbY": 7.888,+ "jaw": 0.213,+ "lipAp": 0.284,+ "lipProt": 0.6,+ "lipWidth": 0.3,+ "root": -0.268,+ "larynx": -0.088,+ "ttX": 6.528,+ "ttY": 7.52,"ttCurl": 0},"formants": [351,2159,- 2527,- 4346+ 2514,+ 4545],"target": [351,@@ -1205,29 +1205,29 @@],"err": [-0.1,- -0.1,- 2.2+ 0,+ 1.7]},"ø": {"artic": {- "tbX": 3.246,- "tbY": 7.564,- "jaw": 0.656,+ "tbX": 3.385,+ "tbY": 7.508,+ "jaw": 0.659,"lipAp": 0.51,- "lipProt": 0.766,+ "lipProt": 1.138,"lipWidth": 0.3,- "root": -0.065,- "larynx": -0.035,- "ttX": 6.324,- "ttY": 7.011,+ "root": -0.067,+ "larynx": -0.036,+ "ttX": 6.365,+ "ttY": 6.989,"ttCurl": 0},"formants": [456,1860,- 2606,- 4172+ 2607,+ 4019],"target": [456,@@ -1242,23 +1242,23 @@},"œ": {"artic": {- "tbX": 3.105,- "tbY": 6.441,- "jaw": 1.063,- "lipAp": 0.692,- "lipProt": 0.592,- "lipWidth": 0.318,- "root": -0.102,- "larynx": -0.002,- "ttX": 6.12,- "ttY": 6.261,+ "tbX": 3.089,+ "tbY": 6.581,+ "jaw": 1.059,+ "lipAp": 0.694,+ "lipProt": 0.589,+ "lipWidth": 0.322,+ "root": -0.075,+ "larynx": 0.014,+ "ttX": 6.117,+ "ttY": 6.313,"ttCurl": 0},"formants": [606,1734,- 2721,- 4133+ 2711,+ 4137],"target": [608,@@ -1266,30 +1266,30 @@2703],"err": [- -0.3,-0.4,- 0.7+ -0.3,+ 0.3]},"ɨ": {"artic": {- "tbX": 3.025,- "tbY": 7.738,- "jaw": 0.185,- "lipAp": 0.138,- "lipProt": 0.243,- "lipWidth": 0.673,- "root": 0.189,- "larynx": 0.211,- "ttX": 6.427,+ "tbX": 3.021,+ "tbY": 7.733,+ "jaw": 0.183,+ "lipAp": 0.361,+ "lipProt": 0.336,+ "lipWidth": 0.55,+ "root": 0.383,+ "larynx": 0.126,+ "ttX": 6.426,"ttY": 7.494,"ttCurl": 0},"formants": [- 386,+ 387,1920,- 2713,- 4553+ 2698,+ 4575],"target": [386,@@ -1297,30 +1297,30 @@2760],"err": [+ 0.1,0,- 0,- -1.7+ -2.2]},"ɯ": {"artic": {- "tbX": 2.861,- "tbY": 7.6,+ "tbX": 2.866,+ "tbY": 7.604,"jaw": 0.05,"lipAp": 0.12,"lipProt": 0.401,- "lipWidth": 0.489,- "root": 0.642,- "larynx": 0.024,- "ttX": 6.422,- "ttY": 7.567,+ "lipWidth": 0.483,+ "root": 0.714,+ "larynx": -0.04,+ "ttX": 6.424,+ "ttY": 7.568,"ttCurl": 0},"formants": [- 403,- 1642,+ 405,+ 1644,2713,- 4373+ 4416],"target": [398,@@ -1328,30 +1328,30 @@2760],"err": [- 1.4,- 1.4,+ 1.7,+ 1.5,-1.7]},"ɤ": {"artic": {- "tbX": 2.393,- "tbY": 7.254,- "jaw": 0.663,- "lipAp": 0.487,- "lipProt": 0.357,- "lipWidth": 0.541,- "root": 0.313,- "larynx": 0.267,- "ttX": 6.065,- "ttY": 6.896,+ "tbX": 2.4,+ "tbY": 7.26,+ "jaw": 0.646,+ "lipAp": 0.473,+ "lipProt": 0.358,+ "lipWidth": 0.54,+ "root": 0.461,+ "larynx": 0.275,+ "ttX": 6.074,+ "ttY": 6.913,"ttCurl": 0},"formants": [- 538,- 1504,- 2700,- 4454+ 539,+ 1505,+ 2712,+ 4490],"target": [538,@@ -1359,31 +1359,31 @@2818],"err": [- 0,+ 0.1,0.3,- -4.2+ -3.7]}},"child": {"i": {"artic": {- "tbX": 3.882,- "tbY": 7.712,- "jaw": 0.159,- "lipAp": 0.12,- "lipProt": 0.354,- "lipWidth": 0.547,- "root": 0.027,- "larynx": -0.043,- "ttX": 6.692,- "ttY": 7.509,- "ttCurl": 0.001+ "tbX": 3.339,+ "tbY": 7.875,+ "jaw": 0.164,+ "lipAp": 0.823,+ "lipProt": 0.036,+ "lipWidth": 1,+ "root": 0.422,+ "larynx": 0.292,+ "ttX": 6.528,+ "ttY": 7.561,+ "ttCurl": 0},"formants": [- 453,- 3091,- 3701+ 452,+ 3085,+ 3593],"target": [452,@@ -1391,29 +1391,29 @@3702],"err": [- 0.2,- 0.3,- 0+ 0.1,+ 0.1,+ -2.9]},"ɪ": {"artic": {- "tbX": 2.925,- "tbY": 7.705,- "jaw": 0.502,- "lipAp": 1.077,- "lipProt": 0.005,- "lipWidth": 1,- "root": -0.077,- "larynx": -0.046,- "ttX": 6.285,- "ttY": 7.197,+ "tbX": 3.147,+ "tbY": 7.762,+ "jaw": 0.497,+ "lipAp": 0.391,+ "lipProt": 0.35,+ "lipWidth": 0.942,+ "root": -0.078,+ "larynx": -0.033,+ "ttX": 6.354,+ "ttY": 7.221,"ttCurl": 0},"formants": [511,2552,- 3436+ 3420],"target": [511,@@ -1423,26 +1423,26 @@"err": [0,0,- 1+ 0.5]},"e": {"artic": {- "tbX": 3.144,- "tbY": 7.658,- "jaw": 0.668,- "lipAp": 1.202,- "lipProt": 0.35,- "lipWidth": 0.998,- "root": -0.209,- "larynx": -0.148,- "ttX": 6.289,- "ttY": 7.033,+ "tbX": 3.023,+ "tbY": 7.663,+ "jaw": 0.662,+ "lipAp": 1.197,+ "lipProt": 0,+ "lipWidth": 1,+ "root": -0.232,+ "larynx": -0.11,+ "ttX": 6.255,+ "ttY": 7.04,"ttCurl": 0},"formants": [564,- 2654,+ 2655,3384],"target": [@@ -1452,28 +1452,28 @@],"err": [-0.1,- -0.1,+ 0,1.8]},"ɛ": {"artic": {- "tbX": 2.617,- "tbY": 7.227,- "jaw": 1.049,- "lipAp": 1.488,+ "tbX": 2.611,+ "tbY": 7.242,+ "jaw": 1.046,+ "lipAp": 1.486,"lipProt": 0,"lipWidth": 1,- "root": -0.233,- "larynx": -0.123,+ "root": -0.216,+ "larynx": -0.108,"ttX": 5.979,- "ttY": 6.548,+ "ttY": 6.555,"ttCurl": 0},"formants": [748,- 2263,- 3368+ 2264,+ 3367],"target": [749,@@ -1482,28 +1482,28 @@],"err": [-0.1,- -0.2,- 1.8+ -0.1,+ 1.7]},"æ": {"artic": {"tbX": 2.934,- "tbY": 7.323,- "jaw": 1.43,- "lipAp": 1.775,- "lipProt": 0,- "lipWidth": 1,- "root": -0.346,- "larynx": -0.165,- "ttX": 5.909,- "ttY": 6.252,+ "tbY": 7.35,+ "jaw": 1.42,+ "lipAp": 1.765,+ "lipProt": 0.009,+ "lipWidth": 0.942,+ "root": -0.388,+ "larynx": -0.029,+ "ttX": 5.914,+ "ttY": 6.27,"ttCurl": 0},"formants": [- 716,- 2494,- 3369+ 717,+ 2497,+ 3385],"target": [717,@@ -1511,29 +1511,29 @@3289],"err": [- -0.2,- -0.3,- 2.4+ 0,+ -0.1,+ 2.9]},"a": {"artic": {- "tbX": 1.855,- "tbY": 6.601,- "jaw": 1.732,+ "tbX": 1.863,+ "tbY": 6.502,+ "jaw": 1.749,"lipAp": 2,"lipProt": 0,"lipWidth": 1,- "root": -0.65,- "larynx": 0.006,- "ttX": 5.446,- "ttY": 5.745,+ "root": -0.525,+ "larynx": -0.066,+ "ttX": 5.441,+ "ttY": 5.695,"ttCurl": 0},"formants": [- 1009,- 1922,- 3246+ 1003,+ 1918,+ 3318],"target": [1014,@@ -1541,29 +1541,29 @@3162],"err": [- -0.5,- -0.3,- 2.7+ -1.1,+ -0.6,+ 4.9]},"ɑ": {"artic": {- "tbX": 1.437,- "tbY": 6.735,- "jaw": 1.732,+ "tbX": 1.534,+ "tbY": 6.608,+ "jaw": 1.842,"lipAp": 2,- "lipProt": 0.178,+ "lipProt": 0.352,"lipWidth": 1,"root": -0.9,- "larynx": -0.051,- "ttX": 5.321,- "ttY": 5.791,+ "larynx": -0.174,+ "ttX": 5.297,+ "ttY": 5.654,"ttCurl": 0},"formants": [- 995,- 1690,- 3013+ 980,+ 1697,+ 3179],"target": [1002,@@ -1571,29 +1571,29 @@2950],"err": [- -0.7,- 0.1,- 2.1+ -2.2,+ 0.6,+ 7.8]},"ɒ": {"artic": {"tbX": 1.2,- "tbY": 6.815,- "jaw": 1.702,- "lipAp": 0.525,+ "tbY": 6.749,+ "jaw": 1.732,+ "lipAp": 0.655,"lipProt": 1.4,- "lipWidth": 0.452,- "root": -0.429,- "larynx": 0.018,- "ttX": 5.264,- "ttY": 5.845,+ "lipWidth": 0.453,+ "root": -0.369,+ "larynx": -0.016,+ "ttX": 5.25,+ "ttY": 5.796,"ttCurl": 0},"formants": [- 789,- 1198,- 3076+ 784,+ 1204,+ 3130],"target": [806,@@ -1601,29 +1601,29 @@3100],"err": [- -2.1,- 2.4,- -0.8+ -2.7,+ 2.9,+ 1]},"ɔ": {"artic": {"tbX": 1.2,- "tbY": 6.887,- "jaw": 1.255,- "lipAp": 0.727,- "lipProt": 1.4,- "lipWidth": 0.451,- "root": -0.557,- "larynx": 0.079,- "ttX": 5.467,- "ttY": 6.251,+ "tbY": 6.84,+ "jaw": 1.327,+ "lipAp": 0.758,+ "lipProt": 1.29,+ "lipWidth": 0.458,+ "root": -0.561,+ "larynx": -0.008,+ "ttX": 5.435,+ "ttY": 6.172,"ttCurl": 0},"formants": [- 796,- 1218,- 3005+ 786,+ 1225,+ 3067],"target": [803,@@ -1631,29 +1631,29 @@2982],"err": [- -0.9,- 0.7,- 0.8+ -2.2,+ 1.2,+ 2.8]},"o": {"artic": {- "tbX": 1.685,- "tbY": 7.171,- "jaw": 0.787,- "lipAp": 0.12,- "lipProt": 0.988,- "lipWidth": 0.261,- "root": -0.312,- "larynx": -0.11,- "ttX": 5.805,- "ttY": 6.758,- "ttCurl": 0+ "tbX": 1.619,+ "tbY": 7.152,+ "jaw": 0.767,+ "lipAp": 0.544,+ "lipProt": 0.954,+ "lipWidth": 0.049,+ "root": -0.101,+ "larynx": -0.144,+ "ttX": 5.792,+ "ttY": 6.774,+ "ttCurl": 0.003},"formants": [- 598,- 1137,- 3049+ 600,+ 1134,+ 3048],"target": [597,@@ -1661,29 +1661,29 @@2987],"err": [- 0.1,- 0,+ 0.5,+ -0.2,2.1]},"ʊ": {"artic": {- "tbX": 2.279,- "tbY": 7.367,- "jaw": 0.488,- "lipAp": 0.442,- "lipProt": 0.773,- "lipWidth": 0.304,- "root": -0.609,- "larynx": -0.174,- "ttX": 6.096,- "ttY": 7.091,+ "tbX": 2.23,+ "tbY": 7.346,+ "jaw": 0.489,+ "lipAp": 0.443,+ "lipProt": 0.696,+ "lipWidth": 0.305,+ "root": -0.438,+ "larynx": -0.253,+ "ttX": 6.081,+ "ttY": 7.083,"ttCurl": 0},"formants": [569,1488,- 3130+ 3163],"target": [568,@@ -1693,27 +1693,27 @@"err": [0.2,-0.1,- 1.9+ 3]},"u": {"artic": {- "tbX": 2.425,- "tbY": 7.451,- "jaw": 0.083,- "lipAp": 0.181,+ "tbX": 2.449,+ "tbY": 7.47,+ "jaw": 0.076,+ "lipAp": 0.162,"lipProt": 1.356,"lipWidth": 0.301,- "root": -0.543,- "larynx": -0.434,- "ttX": 6.279,- "ttY": 7.493,- "ttCurl": 0.004+ "root": -0.684,+ "larynx": -0.364,+ "ttX": 6.29,+ "ttY": 7.501,+ "ttCurl": 0.001},"formants": [497,- 1341,- 3097+ 1343,+ 3082],"target": [494,@@ -1721,22 +1721,22 @@2988],"err": [- 0.7,- -0.3,- 3.7+ 0.5,+ -0.2,+ 3.1]},"ʌ": {"artic": {- "tbX": 1.573,- "tbY": 7.063,+ "tbX": 1.576,+ "tbY": 7.064,"jaw": 1.1,- "lipAp": 0.876,- "lipProt": 0.337,- "lipWidth": 0.588,+ "lipAp": 0.826,+ "lipProt": 0.316,+ "lipWidth": 0.593,"root": 0,"larynx": 0,- "ttX": 5.645,+ "ttX": 5.646,"ttY": 6.446,"ttCurl": 0},@@ -1758,22 +1758,22 @@},"ə": {"artic": {- "tbX": 2.089,- "tbY": 7.272,- "jaw": 0.968,- "lipAp": 1.428,- "lipProt": 0.122,- "lipWidth": 1,- "root": -0.582,- "larynx": -0.166,- "ttX": 5.854,- "ttY": 6.634,+ "tbX": 2.044,+ "tbY": 7.25,+ "jaw": 0.973,+ "lipAp": 1.432,+ "lipProt": 0.043,+ "lipWidth": 0.997,+ "root": -0.42,+ "larynx": -0.248,+ "ttX": 5.838,+ "ttY": 6.622,"ttCurl": 0},"formants": [- 651,- 1926,- 3098+ 652,+ 1925,+ 3130],"target": [650,@@ -1781,29 +1781,29 @@3038],"err": [- 0.2,- -0.1,- 2+ 0.3,+ -0.2,+ 3]},"ɐ": {"artic": {- "tbX": 1.564,- "tbY": 7.004,- "jaw": 1.418,- "lipAp": 1.769,+ "tbX": 1.562,+ "tbY": 7,+ "jaw": 1.424,+ "lipAp": 1.774,"lipProt": 0,"lipWidth": 1,- "root": -0.206,- "larynx": -0.04,- "ttX": 5.504,- "ttY": 6.152,+ "root": -0.188,+ "larynx": -0.061,+ "ttX": 5.501,+ "ttY": 6.146,"ttCurl": 0},"formants": [831,- 1790,- 3145+ 1789,+ 3147],"target": [832,@@ -1811,30 +1811,30 @@3100],"err": [- -0.1,- -0.3,+ -0.2,+ -0.4,1.5]},"ɝ": {"artic": {- "tbX": 2.003,- "tbY": 7.002,- "jaw": 0.053,- "lipAp": 0.617,- "lipProt": 1.218,- "lipWidth": 0.097,+ "tbX": 1.629,+ "tbY": 7.129,+ "jaw": 0.05,+ "lipAp": 0.711,+ "lipProt": 1.395,+ "lipWidth": 0.514,"root": -0.9,- "larynx": -1.217,- "ttX": 5.764,- "ttY": 9.355,+ "larynx": -1.299,+ "ttX": 5.652,+ "ttY": 9.402,"ttCurl": 1},"formants": [- 608,- 1635,- 2502,- 3708+ 596,+ 1618,+ 2487,+ 3488],"target": [586,@@ -1842,29 +1842,29 @@2143],"err": [- 3.8,- -4.9,- 16.7+ 1.7,+ -5.9,+ 16]},"y": {"artic": {- "tbX": 3.447,- "tbY": 7.984,- "jaw": 0.229,- "lipAp": 0.3,- "lipProt": 1.17,- "lipWidth": 0.302,+ "tbX": 3.443,+ "tbY": 7.983,+ "jaw": 0.226,+ "lipAp": 0.301,+ "lipProt": 1.156,+ "lipWidth": 0.301,"root": -0.9,- "larynx": -0.759,- "ttX": 6.538,- "ttY": 7.54,- "ttCurl": 0.001+ "larynx": -0.8,+ "ttX": 6.537,+ "ttY": 7.545,+ "ttCurl": 0.002},"formants": [390,2392,- 2924+ 2910],"target": [390,@@ -1874,27 +1874,27 @@"err": [0,-0.1,- 9.7+ 9.1]},"ø": {"artic": {- "tbX": 2.974,- "tbY": 7.736,- "jaw": 0.624,- "lipAp": 0.519,- "lipProt": 0.587,- "lipWidth": 0.313,+ "tbX": 2.998,+ "tbY": 7.748,+ "jaw": 0.66,+ "lipAp": 0.512,+ "lipProt": 0.597,+ "lipWidth": 0.304,"root": -0.9,- "larynx": -0.561,- "ttX": 6.253,- "ttY": 7.105,- "ttCurl": 0.003+ "larynx": -0.463,+ "ttX": 6.248,+ "ttY": 7.073,+ "ttCurl": 0},"formants": [- 507,- 2051,- 2986+ 506,+ 2060,+ 3016],"target": [507,@@ -1902,29 +1902,29 @@2790],"err": [- 0,- -0.5,- 7+ -0.1,+ -0.1,+ 8.1]},"œ": {"artic": {- "tbX": 2.783,- "tbY": 7.347,- "jaw": 1.021,- "lipAp": 0.693,- "lipProt": 0.589,- "lipWidth": 0.319,+ "tbX": 2.794,+ "tbY": 7.333,+ "jaw": 1.043,+ "lipAp": 0.691,+ "lipProt": 0.592,+ "lipWidth": 0.313,"root": -0.9,- "larynx": -0.331,- "ttX": 6.04,- "ttY": 6.616,- "ttCurl": 0.001+ "larynx": -0.424,+ "ttX": 6.035,+ "ttY": 6.59,+ "ttCurl": 0},"formants": [675,- 1921,- 3065+ 1923,+ 3081],"target": [676,@@ -1932,28 +1932,28 @@2914],"err": [- -0.1,- -0.4,- 5.2+ -0.2,+ -0.3,+ 5.7]},"ɨ": {"artic": {- "tbX": 2.996,- "tbY": 7.83,- "jaw": 0.111,+ "tbX": 3.023,+ "tbY": 7.846,+ "jaw": 0.165,"lipAp": 0.12,- "lipProt": 0.382,- "lipWidth": 0.52,- "root": -0.56,- "larynx": -0.533,- "ttX": 6.442,- "ttY": 7.593,+ "lipProt": 0.4,+ "lipWidth": 0.496,+ "root": -0.636,+ "larynx": -0.405,+ "ttX": 6.433,+ "ttY": 7.549,"ttCurl": 0},"formants": [- 433,- 2141,+ 434,+ 2152,3113],"target": [@@ -1962,29 +1962,29 @@2976],"err": [- 1,- 0.6,+ 1.1,+ 1.1,4.6]},"ɯ": {"artic": {- "tbX": 2.803,- "tbY": 7.681,- "jaw": 0.168,+ "tbX": 2.808,+ "tbY": 7.684,+ "jaw": 0.05,"lipAp": 0.12,- "lipProt": 0.486,- "lipWidth": 0.414,- "root": 0.007,- "larynx": -0.809,- "ttX": 6.366,- "ttY": 7.489,+ "lipProt": 0.491,+ "lipWidth": 0.409,+ "root": -0.023,+ "larynx": -0.72,+ "ttX": 6.406,+ "ttY": 7.596,"ttCurl": 0},"formants": [- 455,- 1839,- 3147+ 456,+ 1840,+ 3179],"target": [442,@@ -1992,29 +1992,29 @@2976],"err": [- 2.9,- 2.4,- 5.7+ 3.1,+ 2.5,+ 6.8]},"ɤ": {"artic": {- "tbX": 2.183,- "tbY": 7.312,- "jaw": 0.702,- "lipAp": 0.522,- "lipProt": 0.359,- "lipWidth": 0.546,- "root": -0.356,- "larynx": -0.286,- "ttX": 5.986,- "ttY": 6.888,- "ttCurl": 0.003+ "tbX": 2.139,+ "tbY": 7.291,+ "jaw": 0.729,+ "lipAp": 0.604,+ "lipProt": 0.357,+ "lipWidth": 0.55,+ "root": -0.243,+ "larynx": -0.374,+ "ttX": 5.964,+ "ttY": 6.851,+ "ttCurl": 0},"formants": [- 601,- 1663,- 3162+ 602,+ 1661,+ 3146],"target": [598,@@ -2022,9 +2022,9 @@3038],"err": [- 0.5,- 0,- 4.1+ 0.7,+ -0.1,+ 3.5]}}diff --git a/src/engine/voice/humanAirway.ts b/src/engine/voice/humanAirway.tsindex 859f512..0dc95e5 100644--- a/src/engine/voice/humanAirway.ts+++ b/src/engine/voice/humanAirway.ts@@ -8,6 +8,7 @@import { AirwayNetwork, type Tube } from "../airway/network.ts";import { HumanVocalTract, type HumanArtic, type HumanBody, type HumanFrame, BODY_MALE } from "../anatomy/human.ts";import { WALL_SOFT, WALL_TRACHEA, WALL_NASAL, RHO, C_SOUND } from "../physics.ts";+import { smoothstep as smooth } from "../util/math.ts";export interface HumanAirwayOptions {body?: HumanBody;@@ -33,6 +34,8 @@ export class HumanAirway {readonly nOr: number;readonly phAreas: Float64Array;readonly orAreas: Float64Array;+ readonly phMin: Float64Array;+ readonly orMin: Float64Array;frame: HumanFrame | null = null;phLen = 8.8;orLen = 8.3;@@ -53,6 +56,8 @@ export class HumanAirway {this.nOr = Math.max(8, Math.floor(orMin / dxMin));this.phAreas = new Float64Array(this.nPh);this.orAreas = new Float64Array(this.nOr);+ this.phMin = new Float64Array(this.nPh);+ this.orMin = new Float64Array(this.nOr);const trLen = 12 * k;this.trachea = net.addTube({ name: "trachea", n: Math.max(6, Math.floor(trLen / Math.max(dxMin, 0.9 * k))), length: trLen, area: 2.5 * k * k, wall: WALL_TRACHEA });@@ -90,14 +95,32 @@ export class HumanAirway {return t.branch(Math.max(0, Math.min(t.n - 2, i)));}- /** Geometry → targets for the next block. Returns the computed frame. */- apply(a: HumanArtic): HumanFrame {+ /** max area change rate (cm²/s, body-scaled): a physiological guard against geometric jumps */+ maxAreaRate = 160;++ /** Geometry → targets for the next block. Returns the computed frame. `dt` enables slew limiting. */+ apply(a: HumanArtic, dt = 0): HumanFrame {const f = (this.frame = this.tract.compute(a));- const { phLen, orLen } = this.tract.resample(a, f, this.nPh, this.nOr, this.phAreas, this.orAreas);+ const oldPh = dt > 0 ? Float64Array.from(this.phAreas) : null;+ const oldOr = dt > 0 ? Float64Array.from(this.orAreas) : null;+ const { phLen, orLen } = this.tract.resample(a, f, this.nPh, this.nOr, this.phAreas, this.orAreas, this.phMin, this.orMin);+ if (oldPh && oldOr) {+ const lim = this.maxAreaRate * this.body.scale * this.body.scale * dt;+ const clampArr = (cur: Float64Array, old: Float64Array, mins: Float64Array) => {+ for (let i = 0; i < cur.length; i++) {+ const d = cur[i] - old[i];+ if (d > lim) cur[i] = old[i] + lim;+ else if (d < -lim) cur[i] = old[i] - lim;+ if (mins[i] > cur[i]) mins[i] = cur[i];+ }+ };+ clampArr(this.phAreas, oldPh, this.phMin);+ clampArr(this.orAreas, oldOr, this.orMin);+ }this.phLen = phLen;this.orLen = orLen;- this.net.setTubeTargets(this.pharynx, this.phAreas, phLen);- this.net.setTubeTargets(this.oral, this.orAreas, orLen);+ this.net.setTubeTargets(this.pharynx, this.phAreas, phLen, this.phMin);+ this.net.setTubeTargets(this.oral, this.orAreas, orLen, this.orMin);this.net.setPortTarget(this.velumPort, f.velumPort);this.updateNoise(f);return f;@@ -113,32 +136,36 @@ export class HumanAirway {const nPh = this.nPh, nOr = this.nOr;let minA = Infinity, minI = -1;for (let i = 0; i < nPh + nOr; i++) {- const A = i < nPh ? this.phAreas[i] : this.orAreas[i - nPh];+ const A = i < nPh ? this.phMin[i] : this.orMin[i - nPh];if (A > 0 && A < minA) {minA = A;minI = i;}}- // also consider closures adjacent to open sections (release bursts): the open neighbour of a zero- if (minI >= 0 && minA < 0.8 * this.body.scale * this.body.scale) {+ // narrowest open point: its jet makes frication noise. Every weight below is a smooth function+ // of geometry so sources fade in/out instead of toggling (toggling = audible noise bursts).+ const k2 = this.body.scale * this.body.scale;+ const wArea = minI >= 0 ? 1 - smooth(0.35 * k2, 0.9 * k2, minA) : 0;+ if (wArea > 0) {const dxPh = this.phLen / nPh, dxOr = this.orLen / nOr;const toBranch = (gi: number): number => (gi < nPh ? this.branchOf(this.pharynx, gi) : gi === nPh ? -1 : this.branchOf(this.oral, gi - nPh));const dx = minI < nPh ? dxPh : dxOr;- const off = Math.max(1, Math.round(0.9 * this.body.scale / dx));+ const off = Math.max(1, Math.round((0.9 * this.body.scale) / dx));const src = toBranch(Math.min(minI, nPh + nOr - 2));- const fwdI = Math.min(nPh + nOr - 2, minI + off);- const bwdI = Math.max(0, minI - off);- const fwd = toBranch(fwdI);- const bwd = toBranch(bwdI);+ const fwd = toBranch(Math.min(nPh + nOr - 2, minI + off));+ const bwd = toBranch(Math.max(0, minI - off));if (src >= 0 && fwd >= 0 && bwd >= 0) {- list.push({ src, fwd, bwd, gain: g.constriction, lowpassHz: 9000, highpassHz: 700 });- // obstacle source at the teeth for constrictions 0.3–3 cm behind the incisors+ list.push({ src, fwd, bwd, gain: g.constriction * wArea, lowpassHz: 9000, highpassHz: 700 });+ // obstacle source: a narrow anterior jet impinging on the incisors (sibilants)const sMin = minI < nPh ? (minI + 0.5) * dxPh : this.phLen + (minI - nPh + 0.5) * dxOr;- const behind = f.teethS - sMin;- if (behind > 0.3 * this.body.scale && behind < 3.2 * this.body.scale) {+ const behind = (f.teethS - sMin) / this.body.scale;+ const wDist = smooth(0.15, 0.5, behind) * (1 - smooth(1.8, 3.0, behind));+ const wJet = 1 - smooth(0.12 * k2, 0.35 * k2, minA);+ const wt = wDist * wJet;+ if (wt > 1e-3) {const teethI = nPh + Math.min(nOr - 2, Math.max(0, Math.round((f.teethS - this.phLen) / dxOr)));const tb = toBranch(teethI);- if (tb >= 0) list.push({ src, fwd: tb, bwd: bwd, gain: g.teeth * (1 - Math.abs(behind - 1.2) / 3), lowpassHz: 11000, highpassHz: 1800 });+ if (tb >= 0) list.push({ src, fwd: tb, bwd, gain: g.teeth * wt, lowpassHz: 11000, highpassHz: 1800 });}}}diff --git a/src/engine/voice/humanVoice.ts b/src/engine/voice/humanVoice.tsnew file mode 100644index 0000000..40b84d9--- /dev/null+++ b/src/engine/voice/humanVoice.ts@@ -0,0 +1,310 @@+/**+ * Real-time human voice: lungs → parametric glottis → articulated airway, rendered at an+ * oversampled internal rate and decimated. Runs identically in the AudioWorklet and in Bun.+ */+import { HumanAirway } from "./humanAirway.ts";+import { ParametricGlottis } from "../sources/glottis.ts";+import { ArticulatorBank, ARTIC_KEYS } from "../control/articulators.ts";+import { Decimator } from "../airway/decimator.ts";+import { BODY_MALE, type HumanArtic, type HumanBody } from "../anatomy/human.ts";+import { CM_H2O } from "../physics.ts";+import { clamp } from "../util/math.ts";++export interface VoiceSource {+ /** target fundamental frequency (Hz) */+ f0: number;+ /** pitch glide time constant (s) */+ glide: number;+ /** lung pressure while breathing out (cmH2O); negative = ingressive */+ pressure: number;+ /** 0..1 breathy (abducted, chink) */+ breathiness: number;+ /** 0 lax … 1 pressed */+ tension: number;+ /** vocal fry 0..1 */+ fry: number;+ /** jitter / shimmer / period doubling 0..1 */+ roughness: number;+ vibratoDepth: number;+ vibratoRate: number;+ /** random pitch drift (cents) */+ drift: number;+ /** false → whisper (no fold vibration) */+ voiced: boolean;+}++export const DEFAULT_SOURCE: VoiceSource = {+ f0: 110,+ glide: 0.06,+ pressure: 8,+ breathiness: 0.15,+ tension: 0.5,+ fry: 0,+ roughness: 0.1,+ vibratoDepth: 0,+ vibratoRate: 5.5,+ drift: 5,+ voiced: true,+};++export interface VoiceTelemetry {+ artic: Float32Array;+ phAreas: Float32Array;+ orAreas: Float32Array;+ phLen: number;+ orLen: number;+ pressureRms: Float32Array;+ flow: Float32Array;+ velumPort: number;+ glottalArea: Float32Array;+ glottalFlow: Float32Array;+ f0: number;+ voicing: number;+ pLung: number;+ outRms: number;+ noiseLevel: number;+ noiseNode: number;+ gate: number;+}++const SCOPE_LEN = 4096;+const SCOPE_POINTS = 256;++export class HumanVoice {+ readonly fsOut: number;+ readonly M: number;+ readonly fs: number;+ readonly airway: HumanAirway;+ readonly glottis: ParametricGlottis;+ readonly artic = new ArticulatorBank();+ readonly source: VoiceSource = { ...DEFAULT_SOURCE };+ private readonly dec: Decimator;+ private readonly ctrlEvery: number; // internal samples per control step+ private ctrlCounter = 0;+ /** breath gate 0..1 (note on/off) */+ gate = 0;+ private gateTarget = 0;+ private pLung = 0;+ private f0 = DEFAULT_SOURCE.f0;+ outputGain = 5.5e-7;+ private dcX = 0;+ private dcY = 0;+ private readonly dcCoef: number;+ // telemetry accumulators+ private readonly rmsAcc: Float64Array;+ private rmsCount = 0;+ private readonly flowSm: Float64Array;+ private readonly scopeArea = new Float32Array(SCOPE_LEN);+ private readonly scopeFlow = new Float32Array(SCOPE_LEN);+ private scopePos = 0;+ private readonly cycleStarts = new Int32Array(8);+ private cycleIdx = 0;+ private lastPhase = 0;+ private outAcc = 0;+ private outCount = 0;+ private sub = 0;++ constructor(opts: { fsOut: number; body?: HumanBody; oversample?: number }) {+ this.fsOut = opts.fsOut;+ this.M = opts.oversample ?? 2;+ this.fs = this.fsOut * this.M;+ this.airway = new HumanAirway({ fs: this.fs, body: opts.body ?? BODY_MALE });+ this.glottis = new ParametricGlottis(this.fs);+ this.dec = new Decimator(this.M);+ this.ctrlEvery = 64 * this.M;+ this.dcCoef = Math.exp((-2 * Math.PI * 25) / this.fsOut);+ const nTract = this.airway.nPh + this.airway.nOr;+ this.rmsAcc = new Float64Array(nTract);+ this.flowSm = new Float64Array(nTract);+ this.airway.apply(this.artic.x);+ this.airway.net.snapToTargets();+ // smaller bodies radiate more high-frequency (derivative) energy at their higher f0+ this.outputGain *= this.airway.body.scale < 0.95 ? 0.55 : 1;+ this.applySource();+ }++ setArticulation(values: Partial<HumanArtic>, tipFree?: boolean): void {+ if (tipFree !== undefined) this.artic.tipFree = tipFree;+ this.artic.setTarget(values);+ }++ setSource(values: Partial<VoiceSource>): void {+ Object.assign(this.source, values);+ this.applySource();+ }++ /** breath/voice on (1) or off (0); intermediate values scale the pressure */+ setGate(level: number): void {+ this.gateTarget = clamp(level, 0, 1.5);+ }++ private applySource(): void {+ const s = this.source;+ const g = this.glottis.params;+ const k2 = this.airway.body.scale * this.airway.body.scale;+ g.amplitude = 0.17 * k2 * (s.voiced ? 1 : 0);+ g.abduction = (s.voiced ? 0.1 * s.breathiness * s.breathiness : 0.2 + 0.1 * s.breathiness) * k2;+ g.chink = (0.004 + 0.03 * s.breathiness) * k2;+ g.openQuotient = 0.78 - 0.36 * s.tension;+ g.closureSharpness = 0.25 + 0.7 * s.tension;+ g.skew = 0.56 + 0.16 * s.tension;+ g.fry = s.fry;+ g.jitter = 0.003 + 0.035 * s.roughness;+ g.shimmer = 0.02 + 0.22 * s.roughness;+ g.diplophonia = s.roughness > 0.5 ? (s.roughness - 0.5) * 1.4 : 0;+ g.vibratoDepth = s.vibratoDepth;+ g.vibratoRate = s.vibratoRate;+ g.drift = s.drift;+ g.effort = clamp((Math.abs(s.pressure) - 3) / 10, 0, 1);+ }++ /** Render n output samples into out[offset..]. */+ render(out: Float32Array, offset: number, n: number): void {+ const air = this.airway;+ const net = air.net;+ const M = this.M;+ const lungs = air.lungs;+ const sub = air.trachea.lastNode;+ const supra = air.pharynx.firstNode;+ const gp = air.glottisPort;+ const glot = this.glottis;+ const nPh = air.nPh;+ const nOr = air.nOr;+ const phFirst = air.pharynx.firstNode;+ const orFirst = air.oral.firstNode;+ const p = net.p;+ for (let i = 0; i < n; i++) {+ for (let m = 0; m < M; m++) {+ if (this.ctrlCounter <= 0) this.control();+ this.ctrlCounter--;+ net.setFixedPressure(lungs, this.pLung);+ const a = glot.next(p[sub] - p[supra]);+ net.setPortArea(gp, a);+ const y = net.step();+ if (this.dec.push(y)) {+ // output sample+ let v = this.dec.value * this.outputGain;+ // DC blocker+ const hp = v - this.dcX + this.dcCoef * this.dcY;+ this.dcX = v;+ this.dcY = hp;+ v = hp;+ // soft limiter+ const av = Math.abs(v);+ if (av > 0.7) v = Math.sign(v) * (0.7 + 0.3 * Math.tanh((av - 0.7) / 0.3));+ out[offset + i] = v;+ this.outAcc += v * v;+ this.outCount++;+ // glottal scope at output rate+ this.scopeArea[this.scopePos] = a;+ this.scopeFlow[this.scopePos] = net.U[gp];+ const ph = glot.cyclePhase;+ if (ph < this.lastPhase) {+ this.cycleStarts[this.cycleIdx & 7] = this.scopePos;+ this.cycleIdx++;+ }+ this.lastPhase = ph;+ this.scopePos = (this.scopePos + 1) % SCOPE_LEN;+ }+ // decimated RMS accumulation for the pressure visualisation+ if ((++this.sub & 3) === 0) {+ for (let k = 0; k < nPh; k++) {+ const v = p[phFirst + k];+ this.rmsAcc[k] += v * v;+ }+ for (let k = 0; k < nOr; k++) {+ const v = p[orFirst + k];+ this.rmsAcc[nPh + k] += v * v;+ }+ this.rmsCount++;+ }+ }+ }+ }++ /** Control-rate update: articulator dynamics, geometry → areas, breath, pitch. */+ private control(): void {+ const dt = this.ctrlEvery / this.fs;+ this.artic.step(dt);+ this.airway.apply(this.artic.x, dt);+ this.airway.net.beginBlock(this.ctrlEvery);+ this.ctrlCounter = this.ctrlEvery;+ // breath: fast attack, slower release+ const tau = this.gateTarget > this.gate ? 0.025 : 0.07;+ this.gate += (this.gateTarget - this.gate) * (1 - Math.exp(-dt / tau));+ this.pLung = this.source.pressure * CM_H2O * this.gate;+ // pitch glide+ const g = Math.max(0.002, this.source.glide);+ this.f0 *= Math.pow(this.source.f0 / this.f0, 1 - Math.exp(-dt / g));+ this.glottis.params.f0 = this.f0;+ // smoothed mean flow per tract node (for particle speeds)+ const U = this.airway.net.U;+ const a = 1 - Math.exp(-dt / 0.03);+ const nPh = this.airway.nPh;+ for (let k = 0; k < nPh + this.airway.nOr; k++) {+ const br = k < nPh ? this.airway.branchOf(this.airway.pharynx, k) : this.airway.branchOf(this.airway.oral, k - nPh);+ this.flowSm[k] += a * (U[br] - this.flowSm[k]);+ }+ }++ telemetry(): VoiceTelemetry {+ const air = this.airway;+ const nT = air.nPh + air.nOr;+ const artic = new Float32Array(ARTIC_KEYS.length);+ ARTIC_KEYS.forEach((k, i) => (artic[i] = this.artic.x[k]));+ const rms = new Float32Array(nT);+ const c = Math.max(1, this.rmsCount);+ for (let k = 0; k < nT; k++) rms[k] = Math.sqrt(this.rmsAcc[k] / c);+ this.rmsAcc.fill(0);+ this.rmsCount = 0;+ // phase-locked glottal scope: two most recent complete cycles+ const ga = new Float32Array(SCOPE_POINTS);+ const gf = new Float32Array(SCOPE_POINTS);+ let start = (this.scopePos - 1024 + SCOPE_LEN) % SCOPE_LEN;+ let len = 1024;+ if (this.cycleIdx >= 3 && this.glottis.voicing > 0.2) {+ const c2 = this.cycleStarts[(this.cycleIdx - 3) & 7];+ const c0 = this.cycleStarts[(this.cycleIdx - 1) & 7];+ const span = (c0 - c2 + SCOPE_LEN) % SCOPE_LEN;+ if (span > 8 && span < SCOPE_LEN / 2) {+ start = c2;+ len = span;+ }+ }+ for (let i = 0; i < SCOPE_POINTS; i++) {+ const idx = (start + Math.floor((i * len) / SCOPE_POINTS)) % SCOPE_LEN;+ ga[i] = this.scopeArea[idx];+ gf[i] = this.scopeFlow[idx];+ }+ let noiseLevel = 0;+ let noiseNode = -1;+ for (const s of air.net.noiseSources) {+ if (s.level > noiseLevel) {+ noiseLevel = s.level;+ noiseNode = s.src;+ }+ }+ const outRms = Math.sqrt(this.outAcc / Math.max(1, this.outCount));+ this.outAcc = 0;+ this.outCount = 0;+ return {+ artic,+ phAreas: Float32Array.from(air.phAreas),+ orAreas: Float32Array.from(air.orAreas),+ phLen: air.phLen,+ orLen: air.orLen,+ pressureRms: rms,+ flow: Float32Array.from(this.flowSm),+ velumPort: air.frame?.velumPort ?? 0,+ glottalArea: ga,+ glottalFlow: gf,+ f0: this.glottis.f0Now,+ voicing: this.glottis.voicing,+ pLung: this.pLung / CM_H2O,+ outRms,+ noiseLevel,+ noiseNode,+ gate: this.gate,+ };+ }+}diff --git a/tests/airway-adversarial.test.ts b/tests/airway-adversarial.test.tsnew file mode 100644index 0000000..fe7967f--- /dev/null+++ b/tests/airway-adversarial.test.ts@@ -0,0 +1,180 @@+import { test, expect } from "bun:test";+import { AirwayNetwork } from "../src/engine/airway/network.ts";+import { transferFunction, findPeaks, linspace } from "../src/engine/airway/frequency.ts";+import { FFT } from "../src/engine/analysis/fft.ts";+import { RHO, RHO_C2, CM_H2O, WALL_SOFT } from "../src/engine/physics.ts";++const FS = 96000;++test("nearly closed three-way junction stays stable at the working CFL", () => {+ const net = new AirwayNetwork(FS);+ const n = 20, len = 8; // Δ = 0.4 cm → CFL ≈ 0.91+ const a = net.addTube({ name: "a", n, length: len, area: 3 });+ const b = net.addTube({ name: "b", n, length: len, area: 3 });+ const c = net.addTube({ name: "c", n, length: len, area: 3 });+ // junction = last node of a, which we squeeze to a tiny area+ net.connect(a.lastNode, b.firstNode);+ net.connect(a.lastNode, c.firstNode);+ net.addRadiation(b.lastNode);+ net.addRadiation(c.lastNode);+ net.finalize();+ const areas = new Float64Array(n).fill(3);+ areas[n - 1] = 0.002;+ net.setTubeTargets(a, areas);+ net.beginBlock(64);+ let peak = 0;+ for (let i = 0; i < FS; i++) {+ if (i % 64 === 0) net.beginBlock(64);+ if (i < 400) net.extFlow[a.firstNode] = 200 * Math.sin(i * 0.3);+ const y = net.step();+ expect(Number.isFinite(y)).toBe(true);+ peak = Math.max(peak, Math.abs(net.p[a.lastNode]));+ }+ expect(peak).toBeLessThan(1e7);+ // decays once excitation stops+ let tail = 0;+ for (let i = 0; i < FS / 10; i++) tail = Math.max(tail, Math.abs(net.p[a.lastNode] + net.step() * 0));+ expect(tail).toBeLessThan(peak);+});++test("sealed cavity compression follows the (linearised) adiabatic law", () => {+ const net = new AirwayNetwork(FS);+ const t = net.addTube({ name: "cav", n: 10, length: 4, area: 2 });+ net.finalize();+ // shrink volume by 5 % over 20 ms+ const steps = FS * 0.02;+ const block = 64;+ for (let i = 0; i < steps; i++) {+ if (i % block === 0) {+ const f = Math.min(1, (i + block) / steps);+ net.setTubeTargets(t, new Float64Array(10).fill(2 * (1 - 0.05 * f)));+ net.beginBlock(block);+ }+ net.step();+ }+ for (let i = 0; i < FS * 0.02; i++) {+ if (i % block === 0) net.beginBlock(block);+ net.step();+ }+ const expected = RHO_C2 * Math.log(1 / 0.95); // ∫ρc² dV/V+ let mean = 0;+ for (let k = 0; k < 10; k++) mean += net.p[t.node(k)] / 10;+ expect(Math.abs(mean - expected) / expected).toBeLessThan(0.03);+});++test("steady flow through a short constriction obeys Bernoulli with jet loss", () => {+ for (const lengthFrac of [1, 0.25]) {+ const net = new AirwayNetwork(FS);+ const n = 30;+ const t = net.addTube({ name: "t", n, length: 12, area: 3 });+ const lung = net.addPressureNode("lung");+ net.addPort(lung, t.firstNode, { area: 3, length: 1, kEntrance: 0, kExit: 0 });+ net.addRadiation(t.lastNode);+ net.finalize();+ const Ac = 0.08;+ const areas = new Float64Array(n).fill(3);+ const mins = new Float64Array(n).fill(3);+ // constriction occupying a whole section, or only a quarter of it (sub-grid)+ const harmonic = 1 / (lengthFrac / Ac + (1 - lengthFrac) / 3);+ areas[20] = harmonic;+ mins[20] = Ac;+ net.setTubeTargets(t, areas, undefined, mins);+ const P = 6 * CM_H2O;+ for (let i = 0; i < FS * 0.25; i++) {+ if (i % 64 === 0) net.beginBlock(64);+ net.setFixedPressure(lung, P * Math.min(1, i / (FS * 0.02)));+ net.step();+ }+ const U = Math.abs(net.U[t.branch(20)]);+ const bernoulli = Ac * Math.sqrt((2 * P) / RHO);+ expect(Math.abs(U - bernoulli) / bernoulli).toBeLessThan(0.15);+ }+});++test("formant bandwidths agree between FDTD and the frequency-domain model", () => {+ const net = new AirwayNetwork(FS);+ const t = net.addTube({ name: "t", n: 40, length: 17.5, area: Array.from({ length: 40 }, (_, i) => 1.5 + 2.5 * Math.sin((i / 39) * 2.5) ** 2), wall: WALL_SOFT });+ net.addRadiation(t.lastNode);+ net.finalize();+ const fr = linspace(80, 4500, 6000);+ const ref = findPeaks(fr, transferFunction(net.linearElements(), t.firstNode, fr).mag).filter((p) => p.freq < 4000);+ const n = FS;+ const nfft = 1 << 17;+ const re = new Float64Array(nfft), im = new Float64Array(nfft);+ net.beginBlock(1);+ for (let i = 0; i < n; i++) {+ if (i === 0) net.extFlow[t.firstNode] = FS;+ re[i] = net.step();+ }+ new FFT(nfft).transform(re, im);+ const freqs = new Float64Array(nfft / 2), mag = new Float64Array(nfft / 2);+ for (let k = 0; k < nfft / 2; k++) {+ freqs[k] = (k * FS) / nfft;+ mag[k] = Math.hypot(re[k], im[k]) / (2 * Math.PI * Math.max(freqs[k], 1));+ }+ const got = findPeaks(freqs, mag, 80).filter((p) => p.freq < 4200);+ for (const r of ref) {+ const g = got.reduce((b, c) => (Math.abs(c.freq - r.freq) < Math.abs(b.freq - r.freq) ? c : b));+ expect(Math.abs(g.freq - r.freq) / r.freq).toBeLessThan(0.012);+ if (Number.isFinite(r.bw) && Number.isFinite(g.bw)) expect(Math.abs(g.bw - r.bw) / r.bw).toBeLessThan(0.2);+ }+});++test("a realistic sliding closure with trapped pressure releases without spikes", () => {+ // closure forms over 25 ms (as articulator dynamics produce), slides 6 sections back toward the+ // lungs while held (trapped pressure behind it), then releases over 12 ms+ const net = new AirwayNetwork(FS);+ const n = 40;+ const t = net.addTube({ name: "t", n, length: 17, area: 3, wall: WALL_SOFT });+ const lung = net.addPressureNode("lung");+ net.addPort(lung, t.firstNode, { area: 3, length: 1 });+ net.addRadiation(t.lastNode);+ net.finalize();+ const block = 64;+ let peakP = 0, peakOut = 0, peakOpenOut = 0;+ const total = FS * 0.6;+ const P = 8 * CM_H2O;+ for (let i = 0; i < total; i++) {+ const time = i / FS;+ if (i % block === 0) {+ const tt = (i + block) / FS;+ const depth = tt < 0.05 ? 0 : tt < 0.075 ? 1.3 * (tt - 0.05) / 0.025 : tt < 0.4 ? 1.3 : Math.max(0, 1.3 - (1.3 * (tt - 0.4)) / 0.012);+ const pos = 30 - 6 * Math.min(1, Math.max(0, (tt - 0.1) / 0.25));+ const areas = new Float64Array(n);+ for (let k = 0; k < n; k++) areas[k] = Math.max(0, 3 * (1 - depth * Math.exp(-(((k - pos) / 1.6) ** 2))));+ net.setTubeTargets(t, areas);+ net.beginBlock(block);+ }+ net.setFixedPressure(lung, P * Math.min(1, time / 0.03));+ const y = net.step();+ if (time > 0.03) peakOut = Math.max(peakOut, Math.abs(y));+ if (time > 0.03 && time < 0.05) peakOpenOut = Math.max(peakOpenOut, Math.abs(y));+ for (let k = 0; k < n; k++) peakP = Math.max(peakP, Math.abs(net.p[t.node(k)]));+ }+ // pressure stays within a small multiple of the driving pressure+ expect(peakP).toBeLessThan(2.5 * P);+ expect(Number.isFinite(peakOut)).toBe(true);+});++test("fast (but articulator-limited) closure gives bounded piston pressure", () => {+ // closing 3 cm² → 0 over 8 ms is near the fastest lip/tongue motion; pressure must stay sane+ const net = new AirwayNetwork(FS);+ const n = 40;+ const t = net.addTube({ name: "t", n, length: 17, area: 3, wall: WALL_SOFT });+ net.addRadiation(t.lastNode);+ net.finalize();+ let peakP = 0;+ for (let i = 0; i < FS * 0.1; i++) {+ if (i % 64 === 0) {+ const tt = (i + 64) / FS;+ const depth = Math.min(1.2, (1.2 * tt) / 0.008);+ const areas = new Float64Array(n);+ for (let k = 0; k < n; k++) areas[k] = Math.max(0, 3 * (1 - depth * Math.exp(-(((k - 30) / 1.6) ** 2))));+ net.setTubeTargets(t, areas);+ net.beginBlock(64);+ }+ net.step();+ for (let k = 0; k < n; k++) peakP = Math.max(peakP, Math.abs(net.p[t.node(k)]));+ }+ expect(peakP).toBeLessThan(20 * CM_H2O);+});diff --git a/tools/render-vowels.ts b/tools/render-vowels.tsnew file mode 100644index 0000000..a9cdab8--- /dev/null+++ b/tools/render-vowels.ts@@ -0,0 +1,52 @@+/**+ * Render calibrated vowels through the real-time HumanVoice path, measure formants (LPC) and+ * f0 (YIN) from the audio, benchmark speed. Usage: bun tools/render-vowels.ts [male|female|child]+ */+import { HumanVoice } from "../src/engine/voice/humanVoice.ts";+import { BODY_MALE, BODY_FEMALE, BODY_CHILD } from "../src/engine/anatomy/human.ts";+import { estimateFormants } from "../src/engine/analysis/lpc.ts";+import { yinPitch } from "../src/engine/analysis/pitch.ts";+import targets from "../src/engine/phonetics/vowelTargets.generated.json";+import { writeWav } from "./lib/wav.ts";+import { renderSpectrogram } from "./lib/spectrogram.ts";++const bodyName = (process.argv[2] ?? "male") as "male" | "female" | "child";+const body = { male: BODY_MALE, female: BODY_FEMALE, child: BODY_CHILD }[bodyName];+const f0 = { male: 110, female: 205, child: 260 }[bodyName];+const FS = 48000;+const voice = new HumanVoice({ fsOut: FS, body });+voice.setSource({ f0 });+const list = ["i", "e", "ɛ", "æ", "ɑ", "ɔ", "o", "u", "ʌ", "ɝ"];+const seg = 0.6;+const out = new Float32Array(Math.round(FS * seg * list.length));+const T = (targets as Record<string, Record<string, { artic: Record<string, number>; formants: number[] }>>)[bodyName];+const t0 = performance.now();+const block = 128;+let pos = 0;+for (let v = 0; v < list.length; v++) {+ voice.setArticulation(T[list[v]].artic, true);+ const n = Math.round(FS * seg);+ for (let i = 0; i < n; i += block) {+ const local = i / FS;+ voice.setGate(local < seg - 0.12 ? 1 : 0);+ voice.render(out, pos, Math.min(block, out.length - pos));+ pos += block;+ if (pos >= out.length) break;+ }+}+const ms = performance.now() - t0;+let peak = 0;+for (const x of out) peak = Math.max(peak, Math.abs(x));+console.log(`${bodyName}: rendered ${(out.length / FS).toFixed(1)} s in ${ms.toFixed(0)} ms → ${((ms / 1000 / (out.length / FS)) * 100).toFixed(1)}% of real time; peak ${peak.toFixed(3)}`);+for (let v = 0; v < list.length; v++) {+ const c = Math.round(FS * (v * seg + 0.3));+ const frame = out.subarray(c, c + 1536);+ const ds = new Float64Array(384);+ for (let i = 0; i < 384; i++) ds[i] = (frame[4 * i] + frame[4 * i + 1] + frame[4 * i + 2] + frame[4 * i + 3]) / 4;+ const fm = estimateFormants(ds, FS / 4, { order: 12 });+ const { f0: est } = yinPitch(out.subarray(c, c + 2400), FS, { minF0: 60 });+ const ref = T[list[v]].formants;+ console.log(` ${list[v].padEnd(2)} f0=${est.toFixed(1)} LPC ${fm.slice(0, 3).map((f) => f.freq.toFixed(0).padStart(5)).join("")} model ${ref.slice(0, 3).map((f) => String(f).padStart(5)).join("")}`);+}+writeWav(`out/vowels-${bodyName}.wav`, [out], FS);+renderSpectrogram(`out/vowels-${bodyName}.png`, out, FS, { title: `CALIBRATED VOWELS ${bodyName.toUpperCase()}: ${list.join(" ")}`, maxFreq: 5000, windowMs: 5 });