the ultimate vocal synthesizer - sing, speak, beatbox, and more
Rust
Milestone 2: gestural score, IPA inventory, consonants that behave physically
Jameson Hodge5b631fb07151
diff --git a/src/engine/airway/network.ts b/src/engine/airway/network.tsindex 0c6085e..350082a 100644--- a/src/engine/airway/network.ts+++ b/src/engine/airway/network.ts@@ -153,6 +153,8 @@ export class AirwayNetwork {enableVolumeSource = true;enableJunctionFloor = true;energySafe = true;+ /** diagnostics: use the larger kinetic coefficient for both flow directions */+ symmetricKinetic = false;/** current section length (cm) */dx!: Float64Array;private dxTarget!: Float64Array;@@ -550,9 +552,16 @@ export class AirwayNetwork {const isJ = this.isJunction;const invLsum = this.invLsum;- // 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).+ // 1) geometry ramps and the moving-wall volume source. The raw −dV/dt of each node is first+ // split between the node and its open neighbours (a nearly closed cell cannot hold the air+ // its walls displace), THEN each node's total injection is low-passed: dV/dt is piecewise+ // constant across control blocks and the split switches as cells close, and the output is a+ // derivative of flow, so unfiltered steps would radiate as clicks. Linear filtering after+ // the split keeps mass conserved.const sq = this.squeezeArea;+ const inj = this.spill; // reused as the per-node raw injection accumulator+ const volOn = this.enableVolumeSource;+ if (volOn) inj.fill(0);let anySpill = false;for (let k = 0; k < N; k++) {let a = area[k] + this.areaStep[k];@@ -564,44 +573,41 @@ export class AirwayNetwork {const d = (dx[k] += this.dxStep[k]);invA[k] = 1 / (a > 1e-6 ? a : 1e-6);const v = (a > minA ? a : minA) * d;- // −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) {+ if (volOn) {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]);+ const ae = amin[k] < a ? amin[k] : a; // a node sealed at its minimum cannot hold air either+ if (raw !== 0 && ae < sq) {+ const t = ae / sq;+ const keep = t * t * (3 - 2 * t);+ inj[k] += raw * keep;+ const sp = raw * (1 - keep);+ const s0 = this.nbrStart[k], s1 = this.nbrStart[k + 1];+ let nOpen = 0;+ for (let e = s0; e < s1; e++) {+ const m = this.nbrList[e];+ if (Math.min(area[m], amin[m]) >= sq || this.aminTarget[m] >= sq) nOpen++;+ }+ if (nOpen > 0) {+ const share = sp / nOpen;+ for (let e = s0; e < s1; e++) {+ const m = this.nbrList[e];+ if (Math.min(area[m], amin[m]) >= sq || this.aminTarget[m] >= sq) inj[m] += share;+ }+ } // else: fully sealed pocket, the squeezed air leaves laterally (absorbed)+ anySpill = true;+ } else inj[k] += raw;}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;- }+ flowSum[k] = this.extFlow[k];this.extFlow[k] = 0;}- if (anySpill) {- const cl = this.closedArea;+ void anySpill;+ if (volOn) {+ const c = this.volLpCoef;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;- }+ const s1 = (this.volSrc1[k] += c * (inj[k] - this.volSrc1[k]));+ flowSum[k] += this.volSrc2[k] += c * (s1 - this.volSrc2[k]);}}@@ -684,6 +690,11 @@ export class AirwayNetwork {this.branchArea[j] = aEff;// energy-safe momentum transfer when the inertance changes: closing (L↑) conserves// momentum (flow drops), opening (L↓) conserves flow — never injects kinetic energy+ if (this.symmetricKinetic) {+ const km = kf > kb ? kf : kb;+ kf = km;+ kb = km;+ }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;@@ -730,18 +741,26 @@ export class AirwayNetwork {const cl = this.closedArea;for (let k = 0; k < N; k++) {if (this.fixed[k]) continue;- 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++;+ // sealed if the cell itself, or its narrowest point, is closed (then all its series+ // branches are closed too, and compressing its remaining volume would trap pressure)+ if (area[k] < cl || amin[k] < cl) {+ const rr = this.radOf[k];+ if (rr >= 0) {+ // sealed aperture: its outer face is the atmosphere, so it relaxes to 0 (tracking the+ // pressurised cavity behind would discharge as a radiated spike on reopening)+ p[k] *= 0.98;+ } else {+ // sealed interior cell (tissue contact): no air of its own; follow open neighbours+ 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 && amin[m] >= cl) {+ sum += p[m];+ cnt++;+ }}+ if (cnt > 0) p[k] += 0.02 * (sum / cnt - p[k]);}- 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;@@ -769,12 +788,16 @@ export class AirwayNetwork {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;+ // Crank–Nicolson coupling of the node and its parallel R–L load (A-stable, energy-+ // conserving for the reactive part): Lr ∝ A^-½ against C ∝ A makes the explicit form+ // unstable at small apertures. U_L lives at integer steps; the node sees its mean.+ const h = T / (2 * Lr);const g = 0.5 / Rr;- const pNew = (pOld * (C * invT - g) + flowSum[k] - ul) / (C * invT + g);+ const pNew = (pOld * (C * invT - 0.5 * h - g) + flowSum[k] - ulPrev) / (C * invT + 0.5 * h + g);p[k] = pNew;- const ur = ul + g * (pNew + pOld);+ const ul = ulPrev + h * (pOld + pNew);+ radUL[r] = ul;+ const ur = 0.5 * (ulPrev + ul) + g * (pNew + pOld);this.radU[r] = ur;radTotal += ur;}diff --git a/src/engine/anatomy/human.ts b/src/engine/anatomy/human.tsindex 3aadeb8..2463acc 100644--- a/src/engine/anatomy/human.ts+++ b/src/engine/anatomy/human.ts@@ -13,7 +13,7 @@* The epilarynx is a short parametric tube above the glottis.*/import { type Vec, v, add, sub, scale, lerpV, polar, rotateAbout, Polyline, rayPolyline, bezier3, bezier2, arc, catmullRom, tangentAngle, dist, norm } from "./geom.ts";-import { clamp, lerp } from "../util/math.ts";+import { clamp, lerp, smoothstep } from "../util/math.ts";export interface HumanArtic {/** jaw opening at the incisors (cm) */@@ -162,6 +162,12 @@ export class HumanVocalTract {private readonly polarC: Vec;private readonly polarC2: Vec;private readonly tmpT: number[] = new Array(64);+ /** signed closest approach (cm) of tongue tip / dorsum to the oral roof in the last frame */+ contactTip = 1;+ contactBody = 1;+ /** unit normals at the contacts, pointing from the roof into the airway (body coords) */+ contactTipN = { x: 0, y: -1 };+ contactBodyN = { x: 0, y: -1 };/** area-law coefficients per region [α, β] */areaLaw = {pharynx: [2.0, 1.4] as [number, number],@@ -248,8 +254,10 @@ export class HumanVocalTract {if (p.y < uvY) outer.push(p);}// bridge to the uvula tip (velopharyngeal port window)+ const roofStart = outer.length;for (let i = velOral.length - 1; i >= 0; i--) outer.push(velOral[i]);outer.append(this.palate, true);+ const roofEnd = outer.length - 1;// upper lipconst prot = clamp(a.lipProt, -0.2, 1.6) * k;const spreadW = clamp(a.lipWidth, 0, 1);@@ -391,6 +399,58 @@ export class HumanVocalTract {grid.push({ ...m, mid: lerpV(m.inner, m.outer, 0.5), area: 0, s: 0, region: 3 });}+ // ---- soft-tissue contact model: the gap near the closest approach of the tongue (tip/blade,+ // and dorsum) to the oral roof follows a curved-body profile d = δ + Δs²/2R (δ < 0 = pressed in),+ // giving monotonic constriction areas and seals whose length grows with contact pressure.+ const roof = { xs: outer.xs.slice(roofStart, roofEnd + 1), ys: outer.ys.slice(roofStart, roofEnd + 1) };+ const cum = new Float64Array(roof.xs.length);+ for (let i = 1; i < roof.xs.length; i++) cum[i] = cum[i - 1] + Math.hypot(roof.xs[i] - roof.xs[i - 1], roof.ys[i] - roof.ys[i - 1]);+ const tipPts = [...blade.slice(2), ...under.slice(1, 3)];+ const tipC = closestApproach(roof, cum, tipPts);+ const bodyC = closestApproach(roof, cum, arcPts);+ this.contactTip = tipC.d;+ this.contactBody = bodyC.d;+ this.contactTipN = tipC.n;+ this.contactBodyN = bodyC.n;+ // Near a close approach the contact model *defines* the gap (one parabolic constriction):+ // the raw ray crossings of the tissue polygon can leave sealed pockets beside the contact,+ // and a jet released into such a pocket water-hammers. Blended back to the rays with distance.+ if (tipC.d < 0.6 * k || bodyC.d < 0.6 * k) {+ const Rt = 0.45 * k, Rb = 1.6 * k;+ const apply = (g: GridSample, c: { d: number; s: number }, R: number, sArc: number, win: number) => {+ const ds = sArc - c.s;+ const ad = Math.abs(ds);+ if (ad > 2 * win) return;+ const dc = Math.max(0, c.d + (ds * ds) / (2 * R));+ // override weight: full inside the window, fading out to 2× window; strongest when pressed in+ const near = 1 - smoothstep(win, 2 * win, ad);+ const regime = 1 - smoothstep(0.15 * k, 0.6 * k, c.d);+ const w = near * regime;+ const dm = Math.min(g.d, dc);+ g.d = dm + (dc - dm) * w;+ };+ for (const g of grid) {+ if (g.region === 0) continue;+ const pr = projectOn(roof, cum, g.outer.x, g.outer.y);+ if (pr.dist > 0.25 * k) continue; // this ray's outer point is not on the oral roof+ if (g.region >= 2 && tipC.d < 0.6 * k) apply(g, tipC, Rt, pr.s, 0.9 * k);+ if (bodyC.d < 0.6 * k) apply(g, bodyC, Rb, pr.s, 1.6 * k);+ }+ }++ // lip contact: between the lips the gap follows aperture + Δx²/2R back from the lip edge, so+ // compressed lips (aperture < 0) seal over a length that grows with compression+ {+ const edgeX = Math.min(ulEdge.x, llEdge.x);+ const Rl = 0.6 * k;+ const apEff = lab > 0.5 ? Infinity : ap; // labiodental uses its own geometry+ for (const g of grid) {+ if (g.region !== 3 || g.mid.x < this.palate[this.palate.length - 1].x) continue;+ const dxl = Math.max(0, edgeX - g.mid.x);+ g.d = Math.min(g.d, Math.max(0, apEff + (dxl * dxl) / (2 * Rl)));+ }+ }+// ---- areasconst [aP, bP] = this.areaLaw.pharynx;const [aO, bO] = this.areaLaw.oral;@@ -501,6 +561,7 @@ export class HumanVocalTract {const fill = (s0: number, s1: number, n: number, out: Float64Array, mins?: Float64Array) => {const d = (s1 - s0) / n;const sub = 8;+ let gi = 0;for (let i = 0; i < n; i++) {let inv = 0;let closed = false;@@ -514,8 +575,15 @@ export class HumanVocalTract {}inv += 1 / A;}+ // actual grid samples inside the section (a point closure must seal the section)+ const a0 = s0 + d * i, a1 = s0 + d * (i + 1) + (i === n - 1 ? 1e-6 : 0);+ while (gi < g.length && g[gi].s < a0) gi++;+ for (let q = gi; q < g.length && g[q].s <= a1; q++) {+ if (g[q].area < mn) mn = g[q].area;+ if (g[q].area <= 1e-5) closed = true;+ }out[i] = closed ? 0 : sub / inv;- if (mins) mins[i] = closed ? 0 : mn;+ if (mins) mins[i] = closed ? 0 : Math.min(mn, out[i]);}};const sp = f.pharynxLength;@@ -524,3 +592,56 @@ export class HumanVocalTract {return { phLen: sp, orLen: f.lipS - sp };}}++/** Project a point onto a polyline: arc position, distance, and the side (cross<0 = airway side). */+function projectOn(pl: { xs: number[]; ys: number[] }, cum: Float64Array, px: number, py: number): { s: number; dist: number; signed: number; x: number; y: number; seg: number } {+ let best = Infinity, bs = 0, bx = 0, by = 0, sign = 1, bseg = 0;+ for (let i = 0; i < pl.xs.length - 1; i++) {+ const ax = pl.xs[i], ay = pl.ys[i];+ const ex = pl.xs[i + 1] - ax, ey = pl.ys[i + 1] - ay;+ const L2 = ex * ex + ey * ey;+ if (L2 < 1e-12) continue;+ let t = ((px - ax) * ex + (py - ay) * ey) / L2;+ t = t < 0 ? 0 : t > 1 ? 1 : t;+ const qx = ax + ex * t, qy = ay + ey * t;+ const d = Math.hypot(px - qx, py - qy);+ if (d < best) {+ best = d;+ bs = cum[i] + t * Math.sqrt(L2);+ bx = qx;+ by = qy;+ const cross = ex * (py - ay) - ey * (px - ax);+ sign = cross < 0 ? 1 : -1;+ bseg = i;+ }+ }+ return { s: bs, dist: best, signed: sign * best, x: bx, y: by, seg: bseg };+}++/** Closest approach of a set of tissue points to the roof: signed gap δ (negative = pressed in) and arc position. */+function closestApproach(pl: { xs: number[]; ys: number[] }, cum: Float64Array, pts: Vec[]): { d: number; s: number; n: { x: number; y: number } } {+ let d = Infinity, sAt = 0, seg = 0;+ for (const p of pts) {+ const pr = projectOn(pl, cum, p.x, p.y);+ if (pr.signed < d) {+ d = pr.signed;+ sAt = pr.s;+ seg = pr.seg;+ }+ }+ // inward normal of the roof segment (airway side is to the right of travel: (ey, −ex))+ const ex = pl.xs[seg + 1] - pl.xs[seg], ey = pl.ys[seg + 1] - pl.ys[seg];+ const L = Math.hypot(ex, ey) || 1;+ return { d, s: sAt, n: { x: ey / L, y: -ex / L } };+}++/** Clamp drawn tissue points that penetrate a wall onto its surface (drawing only). */+export function clampToWall(points: Vec[], wall: Vec[]): Vec[] {+ const pl = { xs: wall.map((p) => p.x), ys: wall.map((p) => p.y) };+ const cum = new Float64Array(wall.length);+ for (let i = 1; i < wall.length; i++) cum[i] = cum[i - 1] + Math.hypot(wall[i].x - wall[i - 1].x, wall[i].y - wall[i - 1].y);+ return points.map((p) => {+ const pr = projectOn(pl, cum, p.x, p.y);+ return pr.signed < 0 && pr.dist < 1.5 ? { x: pr.x, y: pr.y } : p;+ });+}diff --git a/src/engine/control/articulators.ts b/src/engine/control/articulators.tsindex b71a768..2b1cc2e 100644--- a/src/engine/control/articulators.ts+++ b/src/engine/control/articulators.ts@@ -76,18 +76,44 @@ export class ArticulatorBank {}}- step(dt: number): void {+ /** effective targets used in the last step (base blended with gestures), for telemetry */+ readonly effective: HumanArtic = { ...NEUTRAL };++ /**+ * Advance the dynamics. `blend(k)` may return a gesture blend for key k: weighted mean value,+ * total weight and a speed multiplier. The performer's base target joins with weight `baseWeight`.+ */+ step(dt: number, blend?: (k: ArticKey) => { value: number; weight: number; speed: number } | null, baseWeight = 1): void {+ let restX = 0, restY = 0;if (this.tipFree) {const tip = restTip(this.x.jaw, this.x.tbX, this.x.tbY);+ restX = tip.x;+ restY = tip.y;this.target.ttX = tip.x;this.target.ttY = tip.y;}for (const k of ARTIC_KEYS) {- const w = this.omega[k] * this.speed[k];+ let tgt = this.target[k];+ let sp = this.speed[k];+ if (blend) {+ const b = blend(k);+ if (b && b.weight > 0) {+ const bw = baseWeight;+ tgt = (tgt * bw + b.value * b.weight) / (bw + b.weight);+ sp *= b.speed;+ }+ }+ const s = ARTIC_SPECS[k];+ if (tgt < s.min) tgt = s.min;+ else if (tgt > s.max) tgt = s.max;+ this.effective[k] = tgt;+ const w = this.omega[k] * sp;// 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];+ const acc = w * w * (tgt - this.x[k]) - 2 * w * this.v[k];this.v[k] += acc * dt;this.x[k] += this.v[k] * dt;}+ void restX;+ void restY;}}diff --git a/src/engine/control/score.ts b/src/engine/control/score.tsnew file mode 100644index 0000000..11ef3b0--- /dev/null+++ b/src/engine/control/score.ts@@ -0,0 +1,112 @@+/**+ * Gestural score (Articulatory-Phonology style). A gesture drives a subset of control keys+ * toward targets over an activation interval with smooth ramps and a blending strength.+ * At each control step, every key's target is the strength-weighted mean of the active+ * gestures' targets, blended with the performer's base value (weight 1 when nothing is active).+ * Consonant gestures use high strength on their articulators; vowel gestures are long and+ * overlapping, so the tongue body keeps moving vowel-to-vowel through consonants (coarticulation).+ */+import type { ArticKey } from "./articulators.ts";++/** Non-articulator control channels a gesture may drive. */+export type SourceKey =+ /** extra glottal abduction (cm², body-scaled at use) */+ | "abduction"+ /** forced glottal closure 0..1 (glottal stop, ejectives) */+ | "closure"+ /** breath pressure multiplier (0 = no breath, 1 = performer's pressure, <0 = ingressive) */+ | "breath"+ /** pitch in Hz (absolute) */+ | "f0";++export type ControlKey = ArticKey | SourceKey;++export interface Gesture {+ t0: number;+ t1: number;+ rampIn: number;+ rampOut: number;+ strength: number;+ targets: Partial<Record<ControlKey, number>>;+ /** articulator speed multiplier while active and during `releaseHold` seconds after t1 */+ speed?: number;+ releaseHold?: number;+ /** label for visualisation (phoneme / gesture name) */+ label?: string;+}++export interface Blended {+ value: number;+ /** total active weight (0 = no gesture controls this key) */+ weight: number;+ speed: number;+}++/** Smooth activation 0..1..0 with cosine ramps. */+export function activation(g: Gesture, t: number): number {+ if (t <= g.t0 - g.rampIn || t >= g.t1 + g.rampOut) return 0;+ if (t < g.t0) {+ const u = (t - (g.t0 - g.rampIn)) / Math.max(1e-6, g.rampIn);+ return 0.5 - 0.5 * Math.cos(Math.PI * u);+ }+ if (t > g.t1) {+ const u = (t - g.t1) / Math.max(1e-6, g.rampOut);+ return 0.5 + 0.5 * Math.cos(Math.PI * u);+ }+ return 1;+}++export class GestureScore {+ private gestures: Gesture[] = [];+ /** end time of the latest gesture (s) */+ end = 0;++ add(g: Gesture): void {+ this.gestures.push(g);+ this.end = Math.max(this.end, g.t1 + g.rampOut + (g.releaseHold ?? 0));+ }++ addAll(gs: Gesture[]): void {+ for (const g of gs) this.add(g);+ }++ clear(): void {+ this.gestures.length = 0;+ this.end = 0;+ }++ /** Drop gestures that have fully finished before time t. */+ prune(t: number): void {+ if (this.gestures.length === 0) return;+ this.gestures = this.gestures.filter((g) => g.t1 + g.rampOut + (g.releaseHold ?? 0) > t);+ }++ get size(): number {+ return this.gestures.length;+ }++ /** Active gestures at time t (for visualisation). */+ activeAt(t: number): Gesture[] {+ return this.gestures.filter((g) => activation(g, t) > 0);+ }++ /** Blend for one key at time t. */+ blend(key: ControlKey, t: number, out: Blended): Blended {+ let wsum = 0, vsum = 0, speed = 1;+ for (let i = 0; i < this.gestures.length; i++) {+ const g = this.gestures[i];+ const target = g.targets[key];+ if (target === undefined) continue;+ const act = activation(g, t);+ if (g.speed && g.speed > speed && t >= g.t0 - g.rampIn && t <= g.t1 + g.rampOut + (g.releaseHold ?? 0)) speed = g.speed;+ if (act <= 0) continue;+ const w = act * g.strength;+ wsum += w;+ vsum += w * target;+ }+ out.value = wsum > 0 ? vsum / wsum : 0;+ out.weight = wsum;+ out.speed = speed;+ return out;+ }+}diff --git a/src/engine/phonetics/consonantTargets.generated.json b/src/engine/phonetics/consonantTargets.generated.jsonnew file mode 100644index 0000000..9cafaeb--- /dev/null+++ b/src/engine/phonetics/consonantTargets.generated.json@@ -0,0 +1,188 @@+{+ "male": {+ "ɸ": {+ "lipAp": 0.032+ },+ "β": {+ "lipAp": 0.04+ },+ "f": {+ "lipAp": 0.016+ },+ "v": {+ "lipAp": 0.031+ },+ "θ": {+ "ttY": 8.236+ },+ "ð": {+ "ttY": 8.21+ },+ "s": {+ "ttY": 9.132+ },+ "z": {+ "ttY": 9.112+ },+ "ʃ": {+ "ttY": 9.512+ },+ "ʒ": {+ "ttY": 9.498+ },+ "ʂ": {+ "ttY": 9.747+ },+ "ʐ": {+ "ttY": 9.735+ },+ "ç": {+ "tbY": 7.928+ },+ "ʝ": {+ "tbY": 7.916+ },+ "x": {+ "tbY": 7.124+ },+ "ɣ": {+ "tbY": 7.105+ },+ "χ": {+ "tbY": 6.902+ },+ "ʁ": {+ "tbY": 6.891+ },+ "ħ": {+ "tbX": 1.245+ },+ "ʕ": {+ "tbX": 1.282+ }+ },+ "female": {+ "ɸ": {+ "lipAp": 0.033+ },+ "β": {+ "lipAp": 0.042+ },+ "f": {+ "lipAp": 0.013+ },+ "v": {+ "lipAp": 0.028+ },+ "θ": {+ "ttY": 8.252+ },+ "ð": {+ "ttY": 8.228+ },+ "s": {+ "ttY": 9.135+ },+ "z": {+ "ttY": 9.116+ },+ "ʃ": {+ "ttY": 9.521+ },+ "ʒ": {+ "ttY": 9.508+ },+ "ʂ": {+ "ttY": 9.754+ },+ "ʐ": {+ "ttY": 9.742+ },+ "ç": {+ "tbY": 7.983+ },+ "ʝ": {+ "tbY": 7.971+ },+ "x": {+ "tbY": 7.189+ },+ "ɣ": {+ "tbY": 7.17+ },+ "χ": {+ "tbY": 6.961+ },+ "ʁ": {+ "tbY": 6.949+ },+ "ħ": {+ "tbX": 1.183+ },+ "ʕ": {+ "tbX": 1.218+ }+ },+ "child": {+ "ɸ": {+ "lipAp": 0.037+ },+ "β": {+ "lipAp": 0.046+ },+ "f": {+ "lipAp": 0.007+ },+ "v": {+ "lipAp": 0.021+ },+ "θ": {+ "ttY": 8.276+ },+ "ð": {+ "ttY": 8.253+ },+ "s": {+ "ttY": 9.144+ },+ "z": {+ "ttY": 9.127+ },+ "ʃ": {+ "ttY": 9.537+ },+ "ʒ": {+ "ttY": 9.524+ },+ "ʂ": {+ "ttY": 9.763+ },+ "ʐ": {+ "ttY": 9.754+ },+ "ç": {+ "tbY": 8.043+ },+ "ʝ": {+ "tbY": 8.032+ },+ "x": {+ "tbY": 7.276+ },+ "ɣ": {+ "tbY": 7.25+ },+ "χ": {+ "tbY": 7.039+ },+ "ʁ": {+ "tbY": 7.029+ },+ "ħ": {+ "tbX": 1.104+ },+ "ʕ": {+ "tbX": 1.136+ }+ }+}\ No newline at end of filediff --git a/src/engine/phonetics/inventory.ts b/src/engine/phonetics/inventory.tsnew file mode 100644index 0000000..b7d028b--- /dev/null+++ b/src/engine/phonetics/inventory.ts@@ -0,0 +1,141 @@+/**+ * Phoneme inventory (IPA) as articulatory specifications for the human model.+ * Coordinates are template-space (cm) and apply to every body (the anatomy scales them).+ * Fricative/approximant constriction heights are refined by tools/calibrate-consonants.ts+ * to hit target constriction areas; calibrated values override the defaults here.+ */+import type { HumanArtic } from "../anatomy/human.ts";+import type { ArticKey } from "../control/articulators.ts";+import consonantCal from "./consonantTargets.generated.json";++export type Manner = "vowel" | "stop" | "nasal" | "fricative" | "affricate" | "approximant" | "lateral" | "tap" | "trill" | "glottal";+export type Voicing = "voiced" | "voiceless";++export interface PhonemeDef {+ ipa: string;+ name: string;+ manner: Manner;+ voicing: Voicing;+ place: string;+ targets: Partial<HumanArtic>;+ /** articulators this segment controls strongly (others coarticulate with vowels) */+ dominant: ArticKey[];+ nasal?: boolean;+ /** default duration (s) */+ dur: number;+ /** target constriction area (cm², adult male) for calibration of the main coordinate */+ area?: number;+ /** which coordinate the calibration adjusts */+ calKey?: ArticKey;+ /** affricate: the fricative release */+ release?: string;+ /** glottal-only segments */+ glottal?: "open" | "stop" | "breathy";+}++const TIP: ArticKey[] = ["ttX", "ttY"];+const BODY: ArticKey[] = ["tbX", "tbY"];+const LIPS: ArticKey[] = ["lipAp"];++function c(ipa: string, name: string, manner: Manner, voicing: Voicing, place: string, targets: Partial<HumanArtic>, dominant: ArticKey[], dur: number, extra: Partial<PhonemeDef> = {}): PhonemeDef {+ return { ipa, name, manner, voicing, place, targets, dominant, dur, ...extra };+}++// place templates+const BILABIAL = { lipAp: -0.25 };+const ALV_STOP = { ttX: 6.25, ttY: 9.68 };+const DENT_STOP = { ttX: 6.85, ttY: 9.0 };+const POSTALV_STOP = { ttX: 5.75, ttY: 10.0 };+const RETRO_STOP = { ttX: 5.45, ttY: 10.05, ttCurl: 0.95 };+const PAL_STOP = { tbX: 3.75, tbY: 8.45 };+const VEL_STOP = { tbX: 2.3, tbY: 7.85 };+const UVU_STOP = { tbX: 1.55, tbY: 7.6 };++const BASE: PhonemeDef[] = [+ // stops+ c("p", "voiceless bilabial stop", "stop", "voiceless", "bilabial", BILABIAL, LIPS, 0.085),+ c("b", "voiced bilabial stop", "stop", "voiced", "bilabial", BILABIAL, LIPS, 0.07),+ c("t", "voiceless alveolar stop", "stop", "voiceless", "alveolar", ALV_STOP, TIP, 0.075),+ c("d", "voiced alveolar stop", "stop", "voiced", "alveolar", ALV_STOP, TIP, 0.06),+ c("ʈ", "voiceless retroflex stop", "stop", "voiceless", "retroflex", RETRO_STOP, [...TIP, "ttCurl"], 0.075),+ c("ɖ", "voiced retroflex stop", "stop", "voiced", "retroflex", RETRO_STOP, [...TIP, "ttCurl"], 0.065),+ c("c", "voiceless palatal stop", "stop", "voiceless", "palatal", PAL_STOP, BODY, 0.08),+ c("ɟ", "voiced palatal stop", "stop", "voiced", "palatal", PAL_STOP, BODY, 0.07),+ c("k", "voiceless velar stop", "stop", "voiceless", "velar", VEL_STOP, ["tbY"], 0.08),+ c("g", "voiced velar stop", "stop", "voiced", "velar", VEL_STOP, ["tbY"], 0.07),+ c("q", "voiceless uvular stop", "stop", "voiceless", "uvular", UVU_STOP, BODY, 0.085),+ c("ɢ", "voiced uvular stop", "stop", "voiced", "uvular", UVU_STOP, BODY, 0.075),+ c("ʔ", "glottal stop", "glottal", "voiceless", "glottal", {}, [], 0.06, { glottal: "stop" }),+ // nasals+ c("m", "bilabial nasal", "nasal", "voiced", "bilabial", BILABIAL, LIPS, 0.075, { nasal: true }),+ c("ɱ", "labiodental nasal", "nasal", "voiced", "labiodental", { labiodental: 1, lipAp: -0.1 }, ["labiodental", "lipAp"], 0.075, { nasal: true }),+ c("n", "alveolar nasal", "nasal", "voiced", "alveolar", ALV_STOP, TIP, 0.07, { nasal: true }),+ c("ɳ", "retroflex nasal", "nasal", "voiced", "retroflex", RETRO_STOP, [...TIP, "ttCurl"], 0.07, { nasal: true }),+ c("ɲ", "palatal nasal", "nasal", "voiced", "palatal", PAL_STOP, BODY, 0.075, { nasal: true }),+ c("ŋ", "velar nasal", "nasal", "voiced", "velar", VEL_STOP, ["tbY"], 0.08, { nasal: true }),+ c("ɴ", "uvular nasal", "nasal", "voiced", "uvular", UVU_STOP, BODY, 0.08, { nasal: true }),+ // fricatives+ c("ɸ", "voiceless bilabial fricative", "fricative", "voiceless", "bilabial", { lipAp: 0.08 }, LIPS, 0.11, { area: 0.12, calKey: "lipAp" }),+ c("β", "voiced bilabial fricative", "fricative", "voiced", "bilabial", { lipAp: 0.1 }, LIPS, 0.09, { area: 0.15, calKey: "lipAp" }),+ c("f", "voiceless labiodental fricative", "fricative", "voiceless", "labiodental", { labiodental: 1, lipAp: 0.05 }, ["labiodental", "lipAp"], 0.11, { area: 0.11, calKey: "lipAp" }),+ c("v", "voiced labiodental fricative", "fricative", "voiced", "labiodental", { labiodental: 1, lipAp: 0.06 }, ["labiodental", "lipAp"], 0.08, { area: 0.13, calKey: "lipAp" }),+ c("θ", "voiceless dental fricative", "fricative", "voiceless", "dental", { ttX: 6.85, ttY: 8.5 }, TIP, 0.11, { area: 0.15, calKey: "ttY" }),+ c("ð", "voiced dental fricative", "fricative", "voiced", "dental", { ttX: 6.85, ttY: 8.5 }, TIP, 0.07, { area: 0.17, calKey: "ttY" }),+ c("s", "voiceless alveolar fricative", "fricative", "voiceless", "alveolar", { ttX: 6.3, ttY: 9.15, jaw: 0.3 }, [...TIP, "jaw"], 0.12, { area: 0.085, calKey: "ttY" }),+ c("z", "voiced alveolar fricative", "fricative", "voiced", "alveolar", { ttX: 6.3, ttY: 9.15, jaw: 0.3 }, [...TIP, "jaw"], 0.09, { area: 0.1, calKey: "ttY" }),+ c("ʃ", "voiceless postalveolar fricative", "fricative", "voiceless", "postalveolar", { ttX: 5.7, ttY: 9.5, jaw: 0.35, lipProt: 0.75, lipWidth: 0.2 }, [...TIP, "jaw", "lipProt", "lipWidth"], 0.12, { area: 0.2, calKey: "ttY" }),+ c("ʒ", "voiced postalveolar fricative", "fricative", "voiced", "postalveolar", { ttX: 5.7, ttY: 9.5, jaw: 0.35, lipProt: 0.75, lipWidth: 0.2 }, [...TIP, "jaw", "lipProt", "lipWidth"], 0.09, { area: 0.22, calKey: "ttY" }),+ c("ʂ", "voiceless retroflex fricative", "fricative", "voiceless", "retroflex", { ttX: 5.45, ttY: 9.7, ttCurl: 0.9 }, [...TIP, "ttCurl"], 0.12, { area: 0.15, calKey: "ttY" }),+ c("ʐ", "voiced retroflex fricative", "fricative", "voiced", "retroflex", { ttX: 5.45, ttY: 9.7, ttCurl: 0.9 }, [...TIP, "ttCurl"], 0.09, { area: 0.17, calKey: "ttY" }),+ c("ç", "voiceless palatal fricative", "fricative", "voiceless", "palatal", { tbX: 3.75, tbY: 8.25 }, BODY, 0.12, { area: 0.14, calKey: "tbY" }),+ c("ʝ", "voiced palatal fricative", "fricative", "voiced", "palatal", { tbX: 3.75, tbY: 8.25 }, BODY, 0.09, { area: 0.16, calKey: "tbY" }),+ c("x", "voiceless velar fricative", "fricative", "voiceless", "velar", { tbX: 2.3, tbY: 7.7 }, ["tbY"], 0.12, { area: 0.18, calKey: "tbY" }),+ c("ɣ", "voiced velar fricative", "fricative", "voiced", "velar", { tbX: 2.3, tbY: 7.7 }, ["tbY"], 0.09, { area: 0.2, calKey: "tbY" }),+ c("χ", "voiceless uvular fricative", "fricative", "voiceless", "uvular", { tbX: 1.55, tbY: 7.6 }, BODY, 0.12, { area: 0.2, calKey: "tbY" }),+ c("ʁ", "voiced uvular fricative", "fricative", "voiced", "uvular", { tbX: 1.55, tbY: 7.6 }, BODY, 0.09, { area: 0.22, calKey: "tbY" }),+ c("ħ", "voiceless pharyngeal fricative", "fricative", "voiceless", "pharyngeal", { root: -0.95, tbX: 1.3, tbY: 6.2 }, ["root", "tbX", "tbY"], 0.12, { area: 0.25, calKey: "tbX" }),+ c("ʕ", "voiced pharyngeal fricative", "fricative", "voiced", "pharyngeal", { root: -0.95, tbX: 1.3, tbY: 6.2 }, ["root", "tbX", "tbY"], 0.09, { area: 0.3, calKey: "tbX" }),+ c("h", "voiceless glottal fricative", "glottal", "voiceless", "glottal", {}, [], 0.09, { glottal: "open" }),+ c("ɦ", "voiced glottal fricative", "glottal", "voiced", "glottal", {}, [], 0.08, { glottal: "breathy" }),+ c("ɬ", "voiceless lateral fricative", "fricative", "voiceless", "alveolar", { ...ALV_STOP, lateral: 0.35 }, [...TIP, "lateral"], 0.12),+ c("ɮ", "voiced lateral fricative", "fricative", "voiced", "alveolar", { ...ALV_STOP, lateral: 0.45 }, [...TIP, "lateral"], 0.09),+ // affricates+ c("ts", "voiceless alveolar affricate", "affricate", "voiceless", "alveolar", ALV_STOP, TIP, 0.14, { release: "s" }),+ c("dz", "voiced alveolar affricate", "affricate", "voiced", "alveolar", ALV_STOP, TIP, 0.12, { release: "z" }),+ c("tʃ", "voiceless postalveolar affricate", "affricate", "voiceless", "postalveolar", { ...POSTALV_STOP, lipProt: 0.75, lipWidth: 0.2 }, [...TIP, "lipProt", "lipWidth"], 0.15, { release: "ʃ" }),+ c("dʒ", "voiced postalveolar affricate", "affricate", "voiced", "postalveolar", { ...POSTALV_STOP, lipProt: 0.75, lipWidth: 0.2 }, [...TIP, "lipProt", "lipWidth"], 0.13, { release: "ʒ" }),+ c("pf", "voiceless labiodental affricate", "affricate", "voiceless", "labiodental", BILABIAL, LIPS, 0.14, { release: "f" }),+ // approximants, laterals, taps, trills+ c("w", "labial-velar approximant", "approximant", "voiced", "labial-velar", { lipAp: 0.28, lipProt: 1.0, lipWidth: 0.05, tbX: 2.45, tbY: 7.45 }, ["lipAp", "lipProt", "lipWidth", "tbX", "tbY"], 0.06),+ c("ʋ", "labiodental approximant", "approximant", "voiced", "labiodental", { labiodental: 0.9, lipAp: 0.25 }, ["labiodental", "lipAp"], 0.06),+ c("ɹ", "alveolar approximant", "approximant", "voiced", "postalveolar", { ttX: 5.35, ttY: 9.35, ttCurl: 0.85, lipProt: 0.5, lipWidth: 0.3, root: -0.6, tbX: 2.3, tbY: 7.1 }, ["ttX", "ttY", "ttCurl", "lipProt", "lipWidth", "root"], 0.065),+ c("ɻ", "retroflex approximant", "approximant", "voiced", "retroflex", { ttX: 5.4, ttY: 9.55, ttCurl: 1 }, [...TIP, "ttCurl"], 0.065),+ c("j", "palatal approximant", "approximant", "voiced", "palatal", { tbX: 3.8, tbY: 7.95, jaw: 0.25 }, BODY, 0.055),+ c("ɰ", "velar approximant", "approximant", "voiced", "velar", { tbX: 2.35, tbY: 7.45 }, BODY, 0.06),+ c("l", "alveolar lateral approximant", "lateral", "voiced", "alveolar", { ...ALV_STOP, lateral: 1 }, [...TIP, "lateral"], 0.065),+ c("ɫ", "velarised lateral", "lateral", "voiced", "alveolar", { ...ALV_STOP, lateral: 1, tbX: 1.9, tbY: 6.8 }, [...TIP, "lateral", "tbX", "tbY"], 0.075),+ c("ɭ", "retroflex lateral", "lateral", "voiced", "retroflex", { ...RETRO_STOP, lateral: 1 }, [...TIP, "ttCurl", "lateral"], 0.065),+ c("ʎ", "palatal lateral", "lateral", "voiced", "palatal", { ...PAL_STOP, lateral: 1 }, [...BODY, "lateral"], 0.07),+ c("ɾ", "alveolar tap", "tap", "voiced", "alveolar", ALV_STOP, TIP, 0.025),+ c("ɽ", "retroflex flap", "tap", "voiced", "retroflex", RETRO_STOP, [...TIP, "ttCurl"], 0.03),+ c("r", "alveolar trill", "trill", "voiced", "alveolar", { ttX: 6.25, ttY: 9.45 }, TIP, 0.11),+ c("ʀ", "uvular trill", "trill", "voiced", "uvular", { tbX: 1.55, tbY: 7.85 }, BODY, 0.11),+ c("ʙ", "bilabial trill", "trill", "voiced", "bilabial", { lipAp: 0.02 }, LIPS, 0.12),+];+void DENT_STOP;++type CalTable = Record<string, Record<string, Partial<HumanArtic>>>;+const CAL = consonantCal as unknown as CalTable;++const byIpa = new Map<string, PhonemeDef>(BASE.map((p) => [p.ipa, p]));++/** Phoneme definition with calibrated targets for a body (falls back to defaults). */+export function phoneme(ipa: string, body: string = "male"): PhonemeDef | undefined {+ const p = byIpa.get(ipa);+ if (!p) return undefined;+ const cal = CAL[body]?.[ipa];+ return cal ? { ...p, targets: { ...p.targets, ...cal } } : p;+}++export const CONSONANTS: readonly PhonemeDef[] = BASE;+export const CONSONANT_SYMBOLS = BASE.map((p) => p.ipa);diff --git a/src/engine/phonetics/ipa.ts b/src/engine/phonetics/ipa.tsnew file mode 100644index 0000000..814f3bc--- /dev/null+++ b/src/engine/phonetics/ipa.ts@@ -0,0 +1,53 @@+/** IPA string → segments (stress ˈ ˌ, length ː, tie bars, affricates, diphthongs, word gaps). */+import type { Segment } from "./planner.ts";+import { CONSONANT_SYMBOLS } from "./inventory.ts";++const VOWEL_CHARS = "iyɨʉɯuɪʏʊeøɘɵɤoəɛœɜɞʌɔæɐaɶɑɒɝɚ";+const MULTI = ["tʃ", "dʒ", "ts", "dz", "pf", "aɪ", "aʊ", "ɔɪ", "eɪ", "oʊ"];+const ALIASES: Record<string, string> = { "t͡ʃ": "tʃ", "d͡ʒ": "dʒ", "t͡s": "ts", "d͡z": "dz", ɡ: "g", ʧ: "tʃ", ʤ: "dʒ", r̥: "r", ɐ̯: "ɐ" };++export function tokenizeIpa(input: string): Segment[] {+ let s = input.normalize("NFC");+ for (const [a, b] of Object.entries(ALIASES)) s = s.split(a).join(b);+ s = s.replace(/[͜͡]/g, ""); // tie bars+ const out: Segment[] = [];+ let stress = 0;+ let i = 0;+ const known = new Set([...CONSONANT_SYMBOLS, ...VOWEL_CHARS.split(""), ...MULTI]);+ while (i < s.length) {+ const ch = s[i];+ if (ch === "ˈ" || ch === "'") {+ stress = 1;+ i++;+ continue;+ }+ if (ch === "ˌ") {+ stress = 2;+ i++;+ continue;+ }+ if (ch === " " || ch === "." || ch === "|" || ch === ",") {+ if (out.length) out[out.length - 1].wordEnd = true;+ if (ch === "," || ch === "|") out.push({ ipa: "_", dur: 0.16 });+ i++;+ continue;+ }+ if (ch === "ː" || ch === ":") {+ const last = out[out.length - 1];+ if (last) last.dur = (last.dur ?? (VOWEL_CHARS.includes(last.ipa[0]) ? 0.15 : 0.09)) * 1.7;+ i++;+ continue;+ }+ let tok = "";+ for (const m of MULTI) if (s.startsWith(m, i)) tok = m;+ if (!tok) tok = ch;+ i += tok.length;+ // skip combining diacritics we do not model+ while (i < s.length && /[̀-ͯ]/.test(s[i])) i++;+ if (!known.has(tok)) continue;+ const isV = VOWEL_CHARS.includes(tok[0]) && !CONSONANT_SYMBOLS.includes(tok);+ out.push({ ipa: tok, stress: isV ? stress : 0 });+ if (isV) stress = 0;+ }+ return out.filter((x) => x.ipa !== "_" || true);+}diff --git a/src/engine/phonetics/planner.ts b/src/engine/phonetics/planner.tsnew file mode 100644index 0000000..e6fc7f2--- /dev/null+++ b/src/engine/phonetics/planner.ts@@ -0,0 +1,224 @@+/**+ * Segment sequence → gestural score. Timing and phonation are articulatory: aspiration is a+ * glottal opening gesture peaking at the release (VOT emerges), nasality is velum lowering with+ * anticipation, coarticulation comes from overlapping vowel gestures beneath consonant gestures.+ */+import type { Gesture } from "../control/score.ts";+import type { HumanArtic } from "../anatomy/human.ts";+import { phoneme, type PhonemeDef } from "./inventory.ts";+import vowelTable from "./vowelTargets.generated.json";++export interface Segment {+ ipa: string;+ /** duration override (s) */+ dur?: number;+ /** 0 unstressed, 1 primary, 2 secondary */+ stress?: number;+ /** explicit pitch (Hz) for this segment (singing) */+ f0?: number;+ /** word boundary after this segment */+ wordEnd?: boolean;+}++export interface PlanOptions {+ body: string;+ /** voice-clock start time (s) */+ t0: number;+ /** speaking-rate multiplier (>1 = faster) */+ rate?: number;+ /** baseline pitch (Hz) */+ f0?: number;+ /** "statement" (final fall) or "question" (final rise) */+ intonation?: "statement" | "question" | "flat";+ /** pitch excursion for stressed syllables (fraction) */+ accent?: number;+}++export interface PlannedSegment {+ ipa: string;+ t0: number;+ t1: number;+ kind: string;+}++export interface Plan {+ gestures: Gesture[];+ segments: PlannedSegment[];+ end: number;+}++const VOWEL_KEYS = ["tbX", "tbY", "jaw", "lipAp", "lipProt", "lipWidth", "root", "larynx", "ttCurl"] as const;+type VTable = Record<string, Record<string, { artic: Partial<HumanArtic> }>>;+const VT = vowelTable as unknown as VTable;++/** Diphthongs and r-coloured vowels expand to vowel sequences. */+const EXPAND: Record<string, string[]> = {+ aɪ: ["a", "ɪ"],+ aʊ: ["a", "ʊ"],+ ɔɪ: ["ɔ", "ɪ"],+ eɪ: ["e", "ɪ"],+ oʊ: ["o", "ʊ"],+ ɚ: ["ɝ"],+};++export function isVowel(ipa: string, body = "male"): boolean {+ return !!VT[body]?.[ipa] || ipa in EXPAND;+}++function vowelArtic(ipa: string, body: string): Partial<HumanArtic> | null {+ const v = VT[body]?.[ipa] ?? VT.male?.[ipa];+ if (!v) return null;+ const out: Partial<HumanArtic> = {};+ for (const k of VOWEL_KEYS) if (v.artic[k] !== undefined) out[k] = v.artic[k] as number;+ return out;+}++export function planUtterance(input: Segment[], o: PlanOptions): Plan {+ const rate = o.rate ?? 1;+ const body = o.body;+ // expand diphthongs into two vowel targets sharing the duration+ const segs: (Segment & { def?: PhonemeDef; vowel?: Partial<HumanArtic>; glideFrom?: boolean })[] = [];+ for (const s of input) {+ if (EXPAND[s.ipa]) {+ const parts = EXPAND[s.ipa];+ const base = s.dur ?? (s.stress ? 0.2 : 0.14);+ parts.forEach((p, i) => segs.push({ ...s, ipa: p, dur: parts.length > 1 ? base * (i === 0 ? 0.55 : 0.45) : base, glideFrom: i > 0, wordEnd: i === parts.length - 1 ? s.wordEnd : false }));+ } else segs.push({ ...s });+ }+ for (const s of segs) {+ const v = vowelArtic(s.ipa, body);+ if (v) s.vowel = v;+ else s.def = phoneme(s.ipa, body);+ }+ const gestures: Gesture[] = [];+ const planned: PlannedSegment[] = [];+ let t = o.t0 + 0.06; // breath onset lead+ const times: { t0: number; t1: number }[] = [];+ for (const s of segs) {+ let d: number;+ if (s.dur !== undefined) d = s.dur;+ else if (s.vowel) d = s.stress === 1 ? 0.17 : s.stress === 2 ? 0.13 : 0.095;+ else d = s.def?.dur ?? 0.08;+ // final lengthening on the last syllable rhyme+ d /= rate;+ times.push({ t0: t, t1: t + d });+ t += d;+ }+ const end = t;+ // ---- vowel gestures: overlap neighbours so the tongue travels vowel-to-vowel+ const vIdx = segs.map((s, i) => (s.vowel ? i : -1)).filter((i) => i >= 0);+ vIdx.forEach((i, n) => {+ const prev = n > 0 ? times[vIdx[n - 1]].t1 : times[i].t0 - 0.08;+ const next = n < vIdx.length - 1 ? times[vIdx[n + 1]].t0 : times[i].t1 + 0.08;+ const rIn = Math.max(0.04, 0.85 * (times[i].t0 - prev)) + 0.02;+ const rOut = Math.max(0.04, 0.85 * (next - times[i].t1)) + 0.02;+ gestures.push({ t0: times[i].t0, t1: times[i].t1, rampIn: rIn, rampOut: rOut, strength: 1, targets: segs[i].vowel!, label: segs[i].ipa });+ });+ // utterance-initial/final consonants: lend them the nearest vowel's body posture+ // ---- consonant gestures+ segs.forEach((s, i) => {+ const { t0, t1 } = times[i];+ const dur = t1 - t0;+ planned.push({ ipa: s.ipa, t0, t1, kind: s.vowel ? "vowel" : s.def?.manner ?? "?" });+ const def = s.def;+ if (!def) return;+ const prevVowel = i > 0 && !!segs[i - 1].vowel;+ const nextVowel = i < segs.length - 1 && !!segs[i + 1].vowel;+ const prevSeg = i > 0 ? segs[i - 1] : null;+ const addOral = (tg: Partial<HumanArtic>, a: number, b: number, speed: number, label: string) => {+ const dom: Partial<HumanArtic> = {};+ const sec: Partial<HumanArtic> = {};+ for (const [k, v] of Object.entries(tg) as [keyof HumanArtic, number][]) (def.dominant.includes(k) ? dom : sec)[k] = v;+ // the dorsum is heavy: its releases are slower than tip and lip releases+ const bodyOnly = def.dominant.every((k) => k === "tbX" || k === "tbY" || k === "root");+ const sp = bodyOnly ? 1 + (speed - 1) * 0.35 : speed;+ // articulators need ~10–15 ms to climb out of the overshoot (contact) target, so the+ // gesture releases early and the acoustic release lands on the planned boundary+ // measured movement latencies (closure lag / release lag) per articulator class, so the+ // acoustic closure and release land on the planned segment boundaries+ const closing = def.manner === "stop" || def.manner === "nasal" || def.manner === "affricate";+ const lipsOnly = def.dominant.every((k) => k === "lipAp" || k === "labiodental");+ const lead = closing ? (bodyOnly ? 0.034 : lipsOnly ? 0.019 : 0.02) : 0;+ // a consonant must own its constriction articulators (Task-Dynamics style): at strength 40+ // the overlapping vowel contributes ~2 %, so closures seal instead of being diluted+ const early = closing ? (bodyOnly ? 0.024 : lipsOnly ? 0.022 : 0.031) : 0.008;+ if (Object.keys(dom).length) gestures.push({ t0: a - early, t1: Math.max(a + 0.01, b - lead), rampIn: 0.03, rampOut: bodyOnly ? 0.03 : 0.018, strength: 40, targets: dom, speed: sp, releaseHold: 0.045, label });+ if (Object.keys(sec).length) gestures.push({ t0: a, t1: b, rampIn: 0.05, rampOut: 0.05, strength: 2.2, targets: sec, label });+ };+ switch (def.manner) {+ case "stop":+ case "nasal":+ addOral(def.targets, t0, t1, 1.55, def.ipa);+ break;+ case "tap":+ addOral(def.targets, t0, t1, 2.8, def.ipa);+ break;+ case "trill": {+ // driven trill: rapid alternation of near-closure and release at ~26 Hz+ const n = Math.max(2, Math.round(dur * 26));+ for (let k = 0; k < n; k++) {+ const a = t0 + (k / n) * dur;+ addOral(def.targets, a, a + 0.35 / 26, 3.2, def.ipa);+ }+ break;+ }+ case "affricate": {+ const split = t0 + dur * 0.55;+ addOral(def.targets, t0, split, 2.0, def.ipa);+ const rel = def.release ? phoneme(def.release, body) : undefined;+ if (rel) addOral(rel.targets, split + 0.008, t1, 1.4, def.ipa);+ break;+ }+ case "fricative":+ case "approximant":+ case "lateral":+ addOral(def.targets, t0, t1, 1.3, def.ipa);+ break;+ case "glottal":+ break;+ }+ // nasality: velum lowering with anticipation into the preceding vowel+ if (def.nasal) gestures.push({ t0: t0 - 0.03, t1: t1 + 0.01, rampIn: 0.06, rampOut: 0.05, strength: 4, targets: { velum: 0.85 }, label: "velum" });+ // phonation+ const k2 = 1; // abduction is body-scaled in the voice+ if (def.glottal === "open") gestures.push({ t0: t0 - 0.01, t1, rampIn: 0.03, rampOut: 0.035, strength: 5, targets: { abduction: 0.33 * k2 }, label: "h" });+ else if (def.glottal === "breathy") gestures.push({ t0, t1, rampIn: 0.03, rampOut: 0.03, strength: 5, targets: { abduction: 0.1 * k2 }, label: "ɦ" });+ else if (def.glottal === "stop") gestures.push({ t0, t1, rampIn: 0.012, rampOut: 0.015, strength: 8, targets: { closure: 1 }, label: "ʔ" });+ else if (def.voicing === "voiceless") {+ if (def.manner === "stop" || def.manner === "affricate") {+ // aspirated when syllable-initial before a vowel and not after /s/ (English-like)+ const aspirated = nextVowel && !(prevSeg && prevSeg.ipa === "s");+ const vot = aspirated ? 0.05 / rate : 0.012;+ gestures.push({ t0: t0 + 0.25 * dur, t1: t1 + vot * 0.4, rampIn: 0.035, rampOut: aspirated ? 0.045 : 0.02, strength: 6, targets: { abduction: aspirated ? 0.36 : 0.22 }, label: "aspiration" });+ } else {+ gestures.push({ t0: t0 - 0.015, t1: t1 + 0.005, rampIn: 0.03, rampOut: 0.03, strength: 6, targets: { abduction: 0.3 }, label: "voiceless" });+ }+ } else if (def.manner === "fricative") {+ gestures.push({ t0, t1, rampIn: 0.03, rampOut: 0.03, strength: 3, targets: { abduction: 0.035 }, label: "voiced frication" });+ }+ void prevVowel;+ });+ // ---- breath: on through the utterance+ gestures.push({ t0: o.t0 + 0.04, t1: end, rampIn: 0.04, rampOut: 0.07, strength: 1, targets: { breath: 1 }, label: "breath" });+ // ---- intonation: pitch targets on vowels+ const f0 = o.f0 ?? 110;+ const accent = o.accent ?? 0.14;+ const total = Math.max(0.2, end - o.t0);+ vIdx.forEach((i, n) => {+ const s = segs[i];+ const { t0, t1 } = times[i];+ let target: number;+ if (s.f0) target = s.f0;+ else {+ const prog = (t0 - o.t0) / total;+ const decl = 1 - 0.1 * prog;+ const acc = s.stress === 1 ? 1 + accent : s.stress === 2 ? 1 + accent * 0.5 : 1;+ target = f0 * decl * acc;+ const last = n === vIdx.length - 1;+ if (last && o.intonation === "question") target = f0 * 1.35;+ if (last && (o.intonation ?? "statement") === "statement") target = f0 * 0.82;+ }+ gestures.push({ t0, t1, rampIn: 0.06, rampOut: 0.06, strength: s.f0 ? 6 : 1, targets: { f0: target }, label: "pitch" });+ });+ return { gestures, segments: planned, end };+}diff --git a/src/engine/phonetics/vowelTargets.generated.json b/src/engine/phonetics/vowelTargets.generated.jsonindex cb0d6e8..43c4366 100644--- a/src/engine/phonetics/vowelTargets.generated.json+++ b/src/engine/phonetics/vowelTargets.generated.json@@ -2,23 +2,23 @@"male": {"i": {"artic": {- "tbX": 3.713,- "tbY": 7.759,- "jaw": 0.388,- "lipAp": 1.003,- "lipProt": 0,- "lipWidth": 1,- "root": 0.627,- "larynx": 0.666,- "ttX": 6.563,- "ttY": 7.318,- "ttCurl": 0+ "tbX": 3.741,+ "tbY": 7.754,+ "jaw": 0.199,+ "lipAp": 0.873,+ "lipProt": 0.024,+ "lipWidth": 0.998,+ "root": 0.521,+ "larynx": 0.751,+ "ttX": 6.636,+ "ttY": 7.492,+ "ttCurl": 0.003},"formants": [- 338,+ 337,2237,- 2941,- 3923+ 2918,+ 3946],"target": [342,@@ -26,30 +26,30 @@3000],"err": [- -1.2,+ -1.4,-3.7,- -2+ -2.7]},"ɪ": {"artic": {- "tbX": 3.779,- "tbY": 7.343,- "jaw": 0.574,- "lipAp": 1.138,+ "tbX": 3.798,+ "tbY": 7.328,+ "jaw": 0.571,+ "lipAp": 1.144,"lipProt": 0,"lipWidth": 1,- "root": 0.176,- "larynx": 0.196,- "ttX": 6.515,- "ttY": 7.006,+ "root": 0.18,+ "larynx": 0.235,+ "ttX": 6.522,+ "ttY": 7.003,"ttCurl": 0},"formants": [425,2005,- 2644,- 3781+ 2643,+ 3785],"target": [427,@@ -64,23 +64,23 @@},"e": {"artic": {- "tbX": 3.747,- "tbY": 7.138,- "jaw": 0.781,- "lipAp": 1.305,+ "tbX": 3.758,+ "tbY": 7.129,+ "jaw": 0.796,+ "lipAp": 1.335,"lipProt": 0,"lipWidth": 1,- "root": 0.284,- "larynx": 0.52,- "ttX": 6.426,- "ttY": 6.752,+ "root": 0.29,+ "larynx": 0.548,+ "ttX": 6.424,+ "ttY": 6.735,"ttCurl": 0},"formants": [- 470,- 1996,+ 469,+ 1994,2644,- 3837+ 3836],"target": [476,@@ -88,30 +88,30 @@2691],"err": [- -1.2,+ -1.4,-4.5,-1.8]},"ɛ": {"artic": {- "tbX": 3.739,- "tbY": 6.169,- "jaw": 1.074,- "lipAp": 1.512,+ "tbX": 3.715,+ "tbY": 6.187,+ "jaw": 1.08,+ "lipAp": 1.526,"lipProt": 0,"lipWidth": 1,- "root": -0.005,- "larynx": 0.181,- "ttX": 6.305,- "ttY": 6.156,- "ttCurl": 0+ "root": 0.037,+ "larynx": 0.199,+ "ttX": 6.295,+ "ttY": 6.158,+ "ttCurl": 0.001},"formants": [- 578,- 1781,- 2625,- 3802+ 576,+ 1777,+ 2618,+ 3797],"target": [580,@@ -119,30 +119,30 @@2605],"err": [- -0.3,- -1,- 0.8+ -0.6,+ -1.2,+ 0.5]},"æ": {"artic": {- "tbX": 3.52,- "tbY": 5.574,- "jaw": 1.502,- "lipAp": 1.833,- "lipProt": 0.227,+ "tbX": 3.533,+ "tbY": 5.379,+ "jaw": 1.527,+ "lipAp": 1.86,+ "lipProt": 0.322,"lipWidth": 1,- "root": -0.156,- "larynx": 0.162,- "ttX": 6.052,- "ttY": 5.583,- "ttCurl": 0.002+ "root": -0.183,+ "larynx": 0.096,+ "ttX": 6.045,+ "ttY": 5.492,+ "ttCurl": 0.001},"formants": [- 636,- 1731,- 2633,- 3861+ 634,+ 1730,+ 2637,+ 3876],"target": [640,@@ -150,30 +150,30 @@2500],"err": [- -0.6,+ -0.9,-1.7,- 5.3+ 5.5]},"a": {"artic": {- "tbX": 2.193,- "tbY": 5.688,- "jaw": 1.809,+ "tbX": 2.161,+ "tbY": 5.731,+ "jaw": 1.729,"lipAp": 2,"lipProt": 0,"lipWidth": 1,- "root": -0.249,- "larynx": 0.323,- "ttX": 5.511,- "ttY": 5.361,+ "root": -0.254,+ "larynx": 0.501,+ "ttX": 5.54,+ "ttY": 5.443,"ttCurl": 0},"formants": [- 745,- 1435,- 2556,- 3980+ 744,+ 1436,+ 2553,+ 4014],"target": [780,@@ -181,30 +181,30 @@2550],"err": [- -4.5,- -1.1,- 0.2+ -4.6,+ -1,+ 0.1]},"ɑ": {"artic": {- "tbX": 1.961,- "tbY": 5.771,- "jaw": 1.767,+ "tbX": 1.966,+ "tbY": 5.775,+ "jaw": 1.728,"lipAp": 2,"lipProt": 0,"lipWidth": 1,- "root": -0.24,- "larynx": 0.169,- "ttX": 5.462,- "ttY": 5.424,+ "root": -0.27,+ "larynx": 0.212,+ "ttX": 5.482,+ "ttY": 5.459,"ttCurl": 0},"formants": [- 745,- 1331,- 2535,- 3935+ 741,+ 1330,+ 2528,+ 3950],"target": [768,@@ -212,30 +212,30 @@2522],"err": [- -2.9,- -0.1,- 0.5+ -3.5,+ -0.2,+ 0.3]},"ɒ": {"artic": {- "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,+ "tbX": 1.333,+ "tbY": 5.818,+ "jaw": 1.539,+ "lipAp": 0.957,+ "lipProt": 0.354,+ "lipWidth": 0.476,+ "root": -0.239,+ "larynx": 0.016,+ "ttX": 5.38,+ "ttY": 5.633,"ttCurl": 0},"formants": [- 611,- 888,- 2542,- 3899+ 606,+ 890,+ 2529,+ 3898],"target": [620,@@ -243,30 +243,30 @@2500],"err": [- -1.5,- 1,- 1.7+ -2.2,+ 1.1,+ 1.1]},"ɔ": {"artic": {- "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,+ "tbX": 1.491,+ "tbY": 5.896,+ "jaw": 1.22,+ "lipAp": 0.851,+ "lipProt": 0.306,+ "lipWidth": 0.547,+ "root": -0.29,+ "larynx": 0.133,+ "ttX": 5.569,+ "ttY": 5.933,"ttCurl": 0},"formants": [- 640,- 1001,- 2520,- 3914+ 629,+ 1002,+ 2481,+ 3913],"target": [652,@@ -274,30 +274,30 @@2538],"err": [- -1.9,- 0.4,- -0.7+ -3.5,+ 0.5,+ -2.3]},"o": {"artic": {- "tbX": 1.462,- "tbY": 5.761,- "jaw": 0.725,- "lipAp": 0.473,- "lipProt": 0.614,- "lipWidth": 0.001,- "root": 0,- "larynx": 0,- "ttX": 5.762,- "ttY": 6.319,- "ttCurl": 0+ "tbX": 1.885,+ "tbY": 6.87,+ "jaw": 1.022,+ "lipAp": 0.482,+ "lipProt": 1.4,+ "lipWidth": 0.127,+ "root": 0.596,+ "larynx": 0.586,+ "ttX": 5.768,+ "ttY": 6.457,+ "ttCurl": 0.006},"formants": [- 497,- 910,- 2459,- 3898+ 490,+ 923,+ 2213,+ 3821],"target": [497,@@ -305,30 +305,30 @@2459],"err": [- 0,- 0,- 0+ -1.4,+ 1.5,+ -10]},"ʊ": {"artic": {- "tbX": 1.832,- "tbY": 5.652,- "jaw": 0.5,- "lipAp": 0.412,- "lipProt": 1.263,- "lipWidth": 0.149,- "root": 0,- "larynx": 0,- "ttX": 5.958,- "ttY": 6.48,+ "tbX": 2.489,+ "tbY": 6.894,+ "jaw": 0.528,+ "lipAp": 0.44,+ "lipProt": 1.4,+ "lipWidth": 0.154,+ "root": 0.421,+ "larynx": 0.342,+ "ttX": 6.145,+ "ttY": 6.89,"ttCurl": 0},"formants": [- 469,- 1122,- 2434,- 3881+ 467,+ 1127,+ 2284,+ 3681],"target": [469,@@ -336,30 +336,30 @@2434],"err": [- 0,- 0,- 0+ -0.3,+ 0.4,+ -6.1]},"u": {"artic": {- "tbX": 1.627,- "tbY": 5.692,- "jaw": 0.151,- "lipAp": 0.12,- "lipProt": 1.4,- "lipWidth": 0,- "root": -0.004,- "larynx": -0.074,- "ttX": 6.019,- "ttY": 6.808,+ "tbX": 2.633,+ "tbY": 7.283,+ "jaw": 0.177,+ "lipAp": 0.122,+ "lipProt": 0.856,+ "lipWidth": 0.089,+ "root": 0.451,+ "larynx": -0.011,+ "ttX": 6.312,+ "ttY": 7.341,"ttCurl": 0},"formants": [- 380,+ 377,998,- 2448,- 3889+ 2237,+ 3677],"target": [378,@@ -367,30 +367,30 @@2343],"err": [- 0.5,+ -0.4,0.1,- 4.5+ -4.5]},"ʌ": {"artic": {- "tbX": 1.386,- "tbY": 6.46,- "jaw": 1.216,- "lipAp": 1.648,- "lipProt": 0,- "lipWidth": 1,- "root": 0.33,- "larynx": 0.035,- "ttX": 5.538,- "ttY": 6.14,- "ttCurl": 0.003+ "tbX": 1.858,+ "tbY": 5.449,+ "jaw": 1.1,+ "lipAp": 0.838,+ "lipProt": 0.35,+ "lipWidth": 0.71,+ "root": 0,+ "larynx": 0,+ "ttX": 5.73,+ "ttY": 5.881,+ "ttCurl": 0},"formants": [- 629,- 1176,- 2403,- 3794+ 623,+ 1200,+ 2550,+ 3928],"target": [623,@@ -398,30 +398,30 @@2550],"err": [- 0.9,- -2,- -5.8+ 0,+ 0,+ 0]},"ə": {"artic": {- "tbX": 2.574,- "tbY": 7.162,- "jaw": 0.838,- "lipAp": 0.619,- "lipProt": 0.357,+ "tbX": 2.881,+ "tbY": 7.023,+ "jaw": 0.832,+ "lipAp": 0.603,+ "lipProt": 0.354,"lipWidth": 0.54,- "root": 0.648,- "larynx": 0.324,- "ttX": 6.052,- "ttY": 6.709,- "ttCurl": 0+ "root": 0.425,+ "larynx": 0.238,+ "ttX": 6.146,+ "ttY": 6.667,+ "ttCurl": 0.001},"formants": [- 502,+ 501,1455,- 2308,- 3728+ 2321,+ 3690],"target": [500,@@ -429,30 +429,30 @@2450],"err": [+ 0.2,0.4,- 0.3,- -5.8+ -5.3]},"ɐ": {"artic": {- "tbX": 2.238,- "tbY": 5.506,- "jaw": 1.347,- "lipAp": 1.004,- "lipProt": 0.356,- "lipWidth": 0.542,- "root": 0.007,- "larynx": -0.021,- "ttX": 5.738,- "ttY": 5.688,+ "tbX": 2.24,+ "tbY": 5.538,+ "jaw": 1.4,+ "lipAp": 1.05,+ "lipProt": 0.246,+ "lipWidth": 0.67,+ "root": 0,+ "larynx": 0,+ "ttX": 5.715,+ "ttY": 5.654,"ttCurl": 0},"formants": [- 641,- 1351,- 2504,- 3893+ 640,+ 1350,+ 2500,+ 3895],"target": [640,@@ -460,30 +460,30 @@2500],"err": [- 0.2,- 0.1,- 0.2+ 0,+ 0,+ 0]},"ɝ": {"artic": {- "tbX": 2.487,- "tbY": 7.214,- "jaw": 0.737,- "lipAp": 0.65,- "lipProt": 0.575,- "lipWidth": 0.374,+ "tbX": 2.581,+ "tbY": 7.127,+ "jaw": 0.647,+ "lipAp": 0.69,+ "lipProt": 0.555,+ "lipWidth": 0.394,"root": -0.9,- "larynx": -0.871,- "ttX": 5.665,- "ttY": 8.817,+ "larynx": -0.818,+ "ttX": 5.728,+ "ttY": 8.866,"ttCurl": 1},"formants": [- 465,- 1354,- 1820,- 3031+ 464,+ 1346,+ 1848,+ 2968],"target": [474,@@ -491,30 +491,30 @@1710],"err": [- -1.9,- -1.8,- 6.4+ -2.2,+ -2.4,+ 8.1]},"y": {"artic": {- "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,+ "tbX": 3.665,+ "tbY": 7.814,+ "jaw": 0.199,+ "lipAp": 0.172,+ "lipProt": 0.675,+ "lipWidth": 0,+ "root": 0.053,+ "larynx": 0.016,+ "ttX": 6.614,+ "ttY": 7.507,"ttCurl": 0},"formants": [300,1800,- 2135,- 3771+ 2136,+ 3647],"target": [300,@@ -524,27 +524,27 @@"err": [0,0,- -0.7+ -0.6]},"ø": {"artic": {- "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+ "tbX": 3.55,+ "tbY": 7.332,+ "jaw": 0.637,+ "lipAp": 0.325,+ "lipProt": 0.6,+ "lipWidth": 0.04,+ "root": 0.025,+ "larynx": 0.016,+ "ttX": 6.423,+ "ttY": 6.947,+ "ttCurl": 0},"formants": [390,- 1551,- 2213,+ 1550,+ 2247,3399],"target": [@@ -555,28 +555,28 @@"err": [0,0,- -1.6+ -0.1]},"œ": {"artic": {- "tbX": 3.051,- "tbY": 6.037,+ "tbX": 3.048,+ "tbY": 6.091,"jaw": 1.025,- "lipAp": 0.683,- "lipProt": 1.14,- "lipWidth": 0.3,+ "lipAp": 0.684,+ "lipProt": 0.777,+ "lipWidth": 0.297,"root": 0,"larynx": 0,- "ttX": 6.119,- "ttY": 6.152,+ "ttX": 6.118,+ "ttY": 6.171,"ttCurl": 0},"formants": [520,1450,2350,- 3566+ 3579],"target": [520,@@ -591,23 +591,23 @@},"ɨ": {"artic": {- "tbX": 3.026,- "tbY": 7.671,- "jaw": 0.05,- "lipAp": 0.12,- "lipProt": 0.405,- "lipWidth": 0.48,- "root": 0.888,- "larynx": 0.098,- "ttX": 6.472,- "ttY": 7.592,+ "tbX": 3.22,+ "tbY": 7.692,+ "jaw": 0.165,+ "lipAp": 0.162,+ "lipProt": 0.005,+ "lipWidth": 0.549,+ "root": 0.547,+ "larynx": 0.195,+ "ttX": 6.492,+ "ttY": 7.496,"ttCurl": 0},"formants": [- 336,- 1624,- 2285,- 3715+ 331,+ 1600,+ 2331,+ 3904],"target": [330,@@ -615,30 +615,30 @@2400],"err": [- 1.8,- 1.5,- -4.8+ 0.3,+ 0,+ -2.9]},"ɯ": {"artic": {- "tbX": 2.746,- "tbY": 7.484,- "jaw": 0.05,- "lipAp": 0.12,- "lipProt": 0.359,- "lipWidth": 0.411,+ "tbX": 2.811,+ "tbY": 7.459,+ "jaw": 0.055,+ "lipAp": 0.19,+ "lipProt": 0.309,+ "lipWidth": 0.637,"root": 0.9,- "larynx": -0.027,- "ttX": 6.388,- "ttY": 7.526,- "ttCurl": 0+ "larynx": 0.01,+ "ttX": 6.405,+ "ttY": 7.516,+ "ttCurl": 0.001},"formants": [- 358,- 1387,- 2250,- 3570+ 354,+ 1342,+ 2296,+ 3662],"target": [340,@@ -646,30 +646,30 @@2400],"err": [- 5.2,- 2.7,- -6.3+ 4.2,+ -0.6,+ -4.3]},"ɤ": {"artic": {- "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.144,- "ttY": 7.155,+ "tbX": 2.602,+ "tbY": 7.127,+ "jaw": 0.491,+ "lipAp": 0.316,+ "lipProt": 0.355,+ "lipWidth": 0.534,+ "root": 0.5,+ "larynx": 0.357,+ "ttX": 6.192,+ "ttY": 7.005,"ttCurl": 0},"formants": [- 461,- 1257,- 2284,- 3801+ 460,+ 1256,+ 2309,+ 3830],"target": [460,@@ -677,32 +677,32 @@2450],"err": [- 0.3,- 0.6,- -6.8+ 0,+ 0.5,+ -5.8]}},"female": {"i": {"artic": {- "tbX": 3.83,- "tbY": 7.64,- "jaw": 0.474,- "lipAp": 1.074,+ "tbX": 3.757,+ "tbY": 7.68,+ "jaw": 0.557,+ "lipAp": 1.178,"lipProt": 0,"lipWidth": 1,- "root": 0.442,- "larynx": 0.922,- "ttX": 6.567,- "ttY": 7.199,+ "root": 0.276,+ "larynx": 0.825,+ "ttX": 6.515,+ "ttY": 7.139,"ttCurl": 0},"formants": [- 430,- 2644,- 3269,- 4479+ 424,+ 2643,+ 3201,+ 4499],"target": [437,@@ -710,30 +710,30 @@3372],"err": [- -1.7,- -4.2,- -3.1+ -3.1,+ -4.3,+ -5.1]},"ɪ": {"artic": {- "tbX": 3.821,- "tbY": 7.348,- "jaw": 0.541,- "lipAp": 1.109,+ "tbX": 3.824,+ "tbY": 7.342,+ "jaw": 0.548,+ "lipAp": 1.12,"lipProt": 0,"lipWidth": 1,- "root": 0.061,- "larynx": 0.095,- "ttX": 6.54,- "ttY": 7.037,+ "root": 0.072,+ "larynx": 0.118,+ "ttX": 6.538,+ "ttY": 7.029,"ttCurl": 0},"formants": [- 482,- 2348,- 3038,- 4401+ 481,+ 2345,+ 3030,+ 4391],"target": [483,@@ -742,29 +742,29 @@],"err": [-0.3,- -0.7,- -0.5+ -0.8,+ -0.7]},"e": {"artic": {- "tbX": 3.612,- "tbY": 7.388,- "jaw": 0.87,- "lipAp": 1.38,+ "tbX": 3.628,+ "tbY": 7.385,+ "jaw": 0.908,+ "lipAp": 1.439,"lipProt": 0,"lipWidth": 1,- "root": 0.192,+ "root": 0.196,"larynx": 0.714,- "ttX": 6.351,- "ttY": 6.76,+ "ttX": 6.34,+ "ttY": 6.726,"ttCurl": 0},"formants": [- 524,- 2420,- 3012,- 4460+ 522,+ 2417,+ 3011,+ 4448],"target": [536,@@ -772,30 +772,30 @@3047],"err": [- -2.3,- -4.3,+ -2.7,+ -4.5,-1.2]},"ɛ": {"artic": {- "tbX": 3.363,- "tbY": 5.402,- "jaw": 1.157,- "lipAp": 1.581,+ "tbX": 3.246,+ "tbY": 6.134,+ "jaw": 1.251,+ "lipAp": 1.684,"lipProt": 0,"lipWidth": 1,- "root": -0.124,- "larynx": 0.084,- "ttX": 6.157,- "ttY": 5.815,- "ttCurl": 0+ "root": 0.011,+ "larynx": 0.395,+ "ttX": 6.08,+ "ttY": 6,+ "ttCurl": 0.005},"formants": [- 726,- 2028,- 3065,- 4522+ 717,+ 2014,+ 2989,+ 4453],"target": [731,@@ -803,29 +803,29 @@2979],"err": [- -0.7,- -1.5,- 2.9+ -1.9,+ -2.1,+ 0.3]},"æ": {"artic": {- "tbX": 4.376,- "tbY": 5.228,- "jaw": 1.495,- "lipAp": 1.829,- "lipProt": 0.005,+ "tbX": 4.329,+ "tbY": 5.141,+ "jaw": 1.502,+ "lipAp": 1.837,+ "lipProt": 0.091,"lipWidth": 1,- "root": -0.265,- "larynx": 0.482,- "ttX": 6.313,- "ttY": 5.464,+ "root": -0.198,+ "larynx": 0.535,+ "ttX": 6.296,+ "ttY": 5.428,"ttCurl": 0},"formants": [666,- 2259,- 3247,+ 2260,+ 3243,4474],"target": [@@ -834,30 +834,30 @@2972],"err": [- -0.5,+ -0.4,-3.8,- 9.2+ 9.1]},"a": {"artic": {- "tbX": 2.106,- "tbY": 5.691,- "jaw": 1.869,+ "tbX": 2.072,+ "tbY": 5.688,+ "jaw": 1.728,"lipAp": 2,"lipProt": 0,"lipWidth": 1,- "root": -0.324,- "larynx": 0.567,- "ttX": 5.456,- "ttY": 5.313,- "ttCurl": 0.001+ "root": -0.295,+ "larynx": 0.69,+ "ttX": 5.514,+ "ttY": 5.429,+ "ttCurl": 0},"formants": [- 855,+ 852,1712,- 2922,- 4469+ 2934,+ 4435],"target": [913,@@ -865,30 +865,30 @@2933],"err": [- -6.3,+ -6.7,-1.6,- -0.3+ 0]},"ɑ": {"artic": {- "tbX": 1.804,- "tbY": 5.898,- "jaw": 1.86,+ "tbX": 1.783,+ "tbY": 5.944,+ "jaw": 1.73,"lipAp": 2,"lipProt": 0,"lipWidth": 1,- "root": -0.55,- "larynx": 0.452,- "ttX": 5.37,- "ttY": 5.392,+ "root": -0.572,+ "larynx": 0.608,+ "ttX": 5.426,+ "ttY": 5.517,"ttCurl": 0},"formants": [- 866,- 1543,- 2847,- 4498+ 865,+ 1544,+ 2848,+ 4464],"target": [936,@@ -896,29 +896,29 @@2815],"err": [- -7.5,- -0.5,- 1.1+ -7.6,+ -0.4,+ 1.2]},"ɒ": {"artic": {- "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+ "tbX": 1.304,+ "tbY": 5.782,+ "jaw": 1.513,+ "lipAp": 0.997,+ "lipProt": 0.326,+ "lipWidth": 0.518,+ "root": -0.226,+ "larynx": 0.059,+ "ttX": 5.383,+ "ttY": 5.643,+ "ttCurl": 0},"formants": [- 717,- 1061,- 2873+ 706,+ 1063,+ 2831],"target": [725,@@ -926,30 +926,30 @@2875],"err": [- -1.2,- 0.5,- -0.1+ -2.7,+ 0.7,+ -1.5]},"ɔ": {"artic": {- "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,+ "tbX": 1.37,+ "tbY": 6.087,+ "jaw": 1.244,+ "lipAp": 0.901,+ "lipProt": 0.279,+ "lipWidth": 0.595,+ "root": -0.521,+ "larynx": 0.32,+ "ttX": 5.522,+ "ttY": 5.979,"ttCurl": 0},"formants": [- 745,- 1151,- 2796,- 4548+ 732,+ 1153,+ 2755,+ 4556],"target": [781,@@ -957,30 +957,30 @@2824],"err": [- -4.5,- 1.3,- -1+ -6.2,+ 1.5,+ -2.5]},"o": {"artic": {- "tbX": 1.848,- "tbY": 7.035,- "jaw": 0.866,- "lipAp": 0.292,- "lipProt": 1.4,+ "tbX": 1.991,+ "tbY": 6.966,+ "jaw": 1.013,+ "lipAp": 0.547,+ "lipProt": 1.395,"lipWidth": 0.148,- "root": 0.282,- "larynx": 0.5,- "ttX": 5.823,- "ttY": 6.64,+ "root": 0.33,+ "larynx": 0.512,+ "ttX": 5.806,+ "ttY": 6.488,"ttCurl": 0},"formants": [- 551,- 1043,- 2631,- 4287+ 545,+ 1051,+ 2616,+ 4342],"target": [555,@@ -988,30 +988,30 @@2828],"err": [- -0.8,- 0.7,- -7+ -1.8,+ 1.6,+ -7.5]},"ʊ": {"artic": {- "tbX": 2.388,- "tbY": 7.144,- "jaw": 0.531,- "lipAp": 0.44,- "lipProt": 1.4,- "lipWidth": 0.11,- "root": 0.362,- "larynx": 0.308,- "ttX": 6.113,- "ttY": 6.976,- "ttCurl": 0+ "tbX": 2.506,+ "tbY": 7.103,+ "jaw": 0.591,+ "lipAp": 0.394,+ "lipProt": 1.394,+ "lipWidth": 0.301,+ "root": 0.269,+ "larynx": 0.296,+ "ttX": 6.126,+ "ttY": 6.908,+ "ttCurl": 0.001},"formants": [- 518,- 1228,- 2713,- 4307+ 516,+ 1230,+ 2727,+ 4236],"target": [519,@@ -1019,30 +1019,30 @@2827],"err": [- -0.2,- 0.3,- -4+ -0.6,+ 0.4,+ -3.5]},"u": {"artic": {- "tbX": 2.378,- "tbY": 7.235,- "jaw": 0.23,- "lipAp": 0.12,- "lipProt": 1.4,- "lipWidth": 0.028,- "root": 0.232,- "larynx": 0.184,- "ttX": 6.217,- "ttY": 7.278,- "ttCurl": 0.001+ "tbX": 1.851,+ "tbY": 7.769,+ "jaw": 0.764,+ "lipAp": 0.305,+ "lipProt": 0.556,+ "lipWidth": 0.308,+ "root": -0.9,+ "larynx": -1.3,+ "ttX": 5.821,+ "ttY": 7.202,+ "ttCurl": 0.108},"formants": [- 459,- 1106,- 2658,- 4373+ 284,+ 2000,+ 2484,+ 4319],"target": [459,@@ -1050,30 +1050,30 @@2735],"err": [- -0.1,- 0.1,- -2.8+ -38,+ 81,+ -9.2]},"ʌ": {"artic": {- "tbX": 1.742,- "tbY": 5.312,+ "tbX": 1.74,+ "tbY": 5.289,"jaw": 1.1,- "lipAp": 0.957,- "lipProt": 0.253,- "lipWidth": 0.847,+ "lipAp": 1.391,+ "lipProt": 0.343,+ "lipWidth": 0.797,"root": 0,"larynx": 0,"ttX": 5.695,- "ttY": 5.833,+ "ttY": 5.825,"ttCurl": 0},"formants": [753,1426,2933,- 4576+ 4577],"target": [753,@@ -1088,23 +1088,23 @@},"ə": {"artic": {- "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,+ "tbX": 2.99,+ "tbY": 7.037,+ "jaw": 0.944,+ "lipAp": 0.707,+ "lipProt": 0.35,+ "lipWidth": 0.774,+ "root": 0.159,+ "larynx": 0.136,+ "ttX": 6.134,+ "ttY": 6.573,"ttCurl": 0},"formants": [- 586,- 1744,- 2728,- 4289+ 584,+ 1743,+ 2756,+ 4241],"target": [585,@@ -1112,29 +1112,29 @@2818],"err": [- 0.2,- 0.2,- -3.2+ -0.1,+ 0.1,+ -2.2]},"ɐ": {"artic": {"tbX": 2.163,- "tbY": 5.404,- "jaw": 1.4,- "lipAp": 1.541,- "lipProt": 0.335,- "lipWidth": 0.55,+ "tbY": 5.406,+ "jaw": 1.399,+ "lipAp": 1.587,+ "lipProt": 0.286,+ "lipWidth": 0.594,"root": 0,- "larynx": -0.001,+ "larynx": 0,"ttX": 5.692,- "ttY": 5.607,+ "ttY": 5.608,"ttCurl": 0},"formants": [749,1620,- 2874+ 2875],"target": [749,@@ -1149,23 +1149,23 @@},"ɝ": {"artic": {- "tbX": 2.008,- "tbY": 7.081,- "jaw": 0.05,- "lipAp": 0.632,- "lipProt": 0.573,- "lipWidth": 0.345,- "root": -0.9,- "larynx": -0.974,- "ttX": 5.766,- "ttY": 9.385,- "ttCurl": 1+ "tbX": 3.174,+ "tbY": 7.114,+ "jaw": 0.962,+ "lipAp": 0.668,+ "lipProt": 1.235,+ "lipWidth": 0.391,+ "root": -0.842,+ "larynx": -1.072,+ "ttX": 5.801,+ "ttY": 8.488,+ "ttCurl": 0.952},"formants": [- 512,- 1535,- 2095,- 2954+ 516,+ 1547,+ 2216,+ 3401],"target": [523,@@ -1173,30 +1173,30 @@1929],"err": [- -2.1,- -3.3,- 8.6+ -1.3,+ -2.6,+ 14.9]},"y": {"artic": {- "tbX": 3.396,- "tbY": 7.888,- "jaw": 0.213,- "lipAp": 0.284,+ "tbX": 3.504,+ "tbY": 7.881,+ "jaw": 0.217,+ "lipAp": 0.301,"lipProt": 0.6,- "lipWidth": 0.3,- "root": -0.268,- "larynx": -0.088,- "ttX": 6.528,- "ttY": 7.52,+ "lipWidth": 0.301,+ "root": -0.272,+ "larynx": -0.087,+ "ttX": 6.559,+ "ttY": 7.514,"ttCurl": 0},"formants": [351,2159,2514,- 4545+ 4453],"target": [351,@@ -1205,29 +1205,29 @@],"err": [-0.1,- 0,+ -0.1,1.7]},"ø": {"artic": {- "tbX": 3.385,- "tbY": 7.508,- "jaw": 0.659,- "lipAp": 0.51,- "lipProt": 1.138,- "lipWidth": 0.3,- "root": -0.067,- "larynx": -0.036,- "ttX": 6.365,- "ttY": 6.989,+ "tbX": 3.53,+ "tbY": 7.388,+ "jaw": 0.67,+ "lipAp": 0.449,+ "lipProt": 1.189,+ "lipWidth": 0.301,+ "root": -0.099,+ "larynx": -0.052,+ "ttX": 6.404,+ "ttY": 6.936,"ttCurl": 0},"formants": [456,- 1860,- 2607,- 4019+ 1859,+ 2608,+ 3892],"target": [456,@@ -1237,28 +1237,28 @@"err": [0,0,- 0.7+ 0.8]},"œ": {"artic": {- "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,+ "tbX": 3.083,+ "tbY": 6.591,+ "jaw": 1.002,+ "lipAp": 0.744,+ "lipProt": 0.573,+ "lipWidth": 0.375,+ "root": -0.175,+ "larynx": 0.087,+ "ttX": 6.138,+ "ttY": 6.366,"ttCurl": 0},"formants": [- 606,- 1734,- 2711,- 4137+ 599,+ 1723,+ 2713,+ 4148],"target": [608,@@ -1266,30 +1266,30 @@2703],"err": [- -0.4,- -0.3,- 0.3+ -1.6,+ -1,+ 0.4]},"ɨ": {"artic": {- "tbX": 3.021,- "tbY": 7.733,- "jaw": 0.183,- "lipAp": 0.361,- "lipProt": 0.336,+ "tbX": 3.183,+ "tbY": 7.729,+ "jaw": 0.414,+ "lipAp": 0.458,+ "lipProt": 0.229,"lipWidth": 0.55,- "root": 0.383,- "larynx": 0.126,- "ttX": 6.426,- "ttY": 7.494,+ "root": 0.144,+ "larynx": 0.06,+ "ttX": 6.395,+ "ttY": 7.284,"ttCurl": 0},"formants": [- 387,+ 386,1920,- 2698,- 4575+ 2741,+ 4456],"target": [386,@@ -1297,30 +1297,30 @@2760],"err": [- 0.1,0,- -2.2+ 0,+ -0.7]},"ɯ": {"artic": {- "tbX": 2.866,- "tbY": 7.604,- "jaw": 0.05,- "lipAp": 0.12,- "lipProt": 0.401,- "lipWidth": 0.483,- "root": 0.714,- "larynx": -0.04,- "ttX": 6.424,- "ttY": 7.568,- "ttCurl": 0+ "tbX": 2.806,+ "tbY": 7.503,+ "jaw": 0.052,+ "lipAp": 0.253,+ "lipProt": 0,+ "lipWidth": 0.997,+ "root": 0.851,+ "larynx": 0.033,+ "ttX": 6.4,+ "ttY": 7.555,+ "ttCurl": 0.012},"formants": [- 405,- 1644,- 2713,- 4416+ 407,+ 1615,+ 2790,+ 4459],"target": [398,@@ -1328,30 +1328,30 @@2760],"err": [- 1.7,- 1.5,- -1.7+ 2.2,+ -0.3,+ 1.1]},"ɤ": {"artic": {- "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,+ "tbX": 2.701,+ "tbY": 7.185,+ "jaw": 0.671,+ "lipAp": 0.485,+ "lipProt": 0.354,+ "lipWidth": 0.542,+ "root": 0.279,+ "larynx": 0.195,+ "ttX": 6.155,+ "ttY": 6.864,"ttCurl": 0},"formants": [- 539,- 1505,- 2712,- 4490+ 538,+ 1504,+ 2742,+ 4411],"target": [538,@@ -1359,31 +1359,31 @@2818],"err": [- 0.1,+ -0.1,0.3,- -3.7+ -2.7]}},"child": {"i": {"artic": {- "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,+ "tbX": 3.903,+ "tbY": 7.7,+ "jaw": 0.2,+ "lipAp": 0.208,+ "lipProt": 0.343,+ "lipWidth": 0.996,+ "root": 0,+ "larynx": 0,+ "ttX": 6.685,+ "ttY": 7.466,"ttCurl": 0},"formants": [452,- 3085,- 3593+ 3081,+ 3702],"target": [452,@@ -1391,29 +1391,29 @@3702],"err": [- 0.1,- 0.1,- -2.9+ 0,+ 0,+ 0]},"ɪ": {"artic": {- "tbX": 3.147,- "tbY": 7.762,- "jaw": 0.497,- "lipAp": 0.391,+ "tbX": 3.315,+ "tbY": 7.757,+ "jaw": 0.517,+ "lipAp": 0.491,"lipProt": 0.35,- "lipWidth": 0.942,- "root": -0.078,- "larynx": -0.033,- "ttX": 6.354,- "ttY": 7.221,+ "lipWidth": 0.954,+ "root": -0.289,+ "larynx": -0.122,+ "ttX": 6.397,+ "ttY": 7.202,"ttCurl": 0},"formants": [511,- 2552,- 3420+ 2551,+ 3457],"target": [511,@@ -1421,29 +1421,29 @@3403],"err": [+ -0.1,0,- 0,- 0.5+ 1.6]},"e": {"artic": {- "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+ "tbX": 3.559,+ "tbY": 7.554,+ "jaw": 0.703,+ "lipAp": 0.585,+ "lipProt": 0.353,+ "lipWidth": 0.549,+ "root": -0.367,+ "larynx": -0.129,+ "ttX": 6.399,+ "ttY": 6.968,+ "ttCurl": 0.001},"formants": [- 564,- 2655,- 3384+ 562,+ 2656,+ 3402],"target": [564,@@ -1451,29 +1451,29 @@3323],"err": [- -0.1,+ -0.4,0,- 1.8+ 2.4]},"ɛ": {"artic": {- "tbX": 2.611,- "tbY": 7.242,- "jaw": 1.046,- "lipAp": 1.486,- "lipProt": 0,- "lipWidth": 1,- "root": -0.216,- "larynx": -0.108,- "ttX": 5.979,- "ttY": 6.555,- "ttCurl": 0+ "tbX": 3.009,+ "tbY": 7.056,+ "jaw": 1.058,+ "lipAp": 1.456,+ "lipProt": 0.351,+ "lipWidth": 0.549,+ "root": -0.292,+ "larynx": -0.185,+ "ttX": 6.093,+ "ttY": 6.481,+ "ttCurl": 0.001},"formants": [- 748,+ 749,2264,- 3367+ 3387],"target": [749,@@ -1481,29 +1481,29 @@3310],"err": [+ 0,-0.1,- -0.1,- 1.7+ 2.3]},"æ": {"artic": {- "tbX": 2.934,- "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,+ "tbX": 3.236,+ "tbY": 7.218,+ "jaw": 1.474,+ "lipAp": 1.452,+ "lipProt": 0.354,+ "lipWidth": 0.978,+ "root": -0.412,+ "larynx": -0.146,+ "ttX": 5.981,+ "ttY": 6.179,"ttCurl": 0},"formants": [- 717,- 2497,- 3385+ 715,+ 2496,+ 3398],"target": [717,@@ -1511,29 +1511,29 @@3289],"err": [- 0,- -0.1,- 2.9+ -0.2,+ -0.2,+ 3.3]},"a": {"artic": {- "tbX": 1.863,- "tbY": 6.502,- "jaw": 1.749,+ "tbX": 1.895,+ "tbY": 6.435,+ "jaw": 1.732,"lipAp": 2,"lipProt": 0,"lipWidth": 1,- "root": -0.525,- "larynx": -0.066,- "ttX": 5.441,- "ttY": 5.695,+ "root": -0.494,+ "larynx": -0.08,+ "ttX": 5.459,+ "ttY": 5.686,"ttCurl": 0},"formants": [- 1003,- 1918,- 3318+ 1001,+ 1916,+ 3331],"target": [1014,@@ -1541,29 +1541,29 @@3162],"err": [- -1.1,+ -1.3,-0.6,- 4.9+ 5.3]},"ɑ": {"artic": {- "tbX": 1.534,- "tbY": 6.608,- "jaw": 1.842,+ "tbX": 1.437,+ "tbY": 6.434,+ "jaw": 2.067,"lipAp": 2,- "lipProt": 0.352,+ "lipProt": 0.063,"lipWidth": 1,- "root": -0.9,- "larynx": -0.174,- "ttX": 5.297,- "ttY": 5.654,+ "root": -0.505,+ "larynx": 0.039,+ "ttX": 5.158,+ "ttY": 5.408,"ttCurl": 0},"formants": [- 980,+ 981,1697,- 3179+ 3083],"target": [1002,@@ -1571,29 +1571,29 @@2950],"err": [- -2.2,- 0.6,- 7.8+ -2.1,+ 0.5,+ 4.5]},"ɒ": {"artic": {"tbX": 1.2,- "tbY": 6.749,- "jaw": 1.732,- "lipAp": 0.655,+ "tbY": 6.423,+ "jaw": 1.878,+ "lipAp": 0.932,"lipProt": 1.4,- "lipWidth": 0.453,- "root": -0.369,- "larynx": -0.016,- "ttX": 5.25,- "ttY": 5.796,- "ttCurl": 0+ "lipWidth": 0.432,+ "root": -0.057,+ "larynx": -0.093,+ "ttX": 5.179,+ "ttY": 5.565,+ "ttCurl": 0.003},"formants": [784,- 1204,- 3130+ 1213,+ 3011],"target": [806,@@ -1602,28 +1602,28 @@],"err": [-2.7,- 2.9,- 1+ 3.6,+ -2.9]},"ɔ": {"artic": {"tbX": 1.2,- "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,+ "tbY": 6.42,+ "jaw": 1.304,+ "lipAp": 0.761,+ "lipProt": 1.119,+ "lipWidth": 0.459,+ "root": -0.141,+ "larynx": -0.044,+ "ttX": 5.445,+ "ttY": 6.045,"ttCurl": 0},"formants": [- 786,- 1225,- 3067+ 788,+ 1236,+ 2992],"target": [803,@@ -1631,29 +1631,29 @@2982],"err": [- -2.2,- 1.2,- 2.8+ -1.8,+ 2.2,+ 0.3]},"o": {"artic": {- "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+ "tbX": 1.621,+ "tbY": 7.075,+ "jaw": 0.671,+ "lipAp": 0.545,+ "lipProt": 1.4,+ "lipWidth": 0.233,+ "root": 0.028,+ "larynx": -0.067,+ "ttX": 5.831,+ "ttY": 6.828,+ "ttCurl": 0.001},"formants": [- 600,- 1134,- 3048+ 599,+ 1135,+ 3004],"target": [597,@@ -1661,29 +1661,29 @@2987],"err": [- 0.5,+ 0.4,-0.2,- 2.1+ 0.6]},"ʊ": {"artic": {- "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,+ "tbX": 2.49,+ "tbY": 7.318,+ "jaw": 0.576,+ "lipAp": 0.436,+ "lipProt": 0.599,+ "lipWidth": 0.309,+ "root": -0.65,+ "larynx": -0.295,+ "ttX": 6.127,+ "ttY": 6.996,"ttCurl": 0},"formants": [- 569,- 1488,- 3163+ 568,+ 1489,+ 3179],"target": [568,@@ -1691,29 +1691,29 @@3072],"err": [- 0.2,+ 0,-0.1,- 3+ 3.5]},"u": {"artic": {- "tbX": 2.449,- "tbY": 7.47,- "jaw": 0.076,- "lipAp": 0.162,- "lipProt": 1.356,- "lipWidth": 0.301,- "root": -0.684,- "larynx": -0.364,- "ttX": 6.29,- "ttY": 7.501,- "ttCurl": 0.001+ "tbX": 2.513,+ "tbY": 7.448,+ "jaw": 0.508,+ "lipAp": 0.291,+ "lipProt": 1.121,+ "lipWidth": 0.302,+ "root": -0.445,+ "larynx": -0.452,+ "ttX": 6.155,+ "ttY": 7.122,+ "ttCurl": 0.01},"formants": [- 497,+ 496,1343,- 3082+ 3176],"target": [494,@@ -1721,29 +1721,29 @@2988],"err": [- 0.5,- -0.2,- 3.1+ 0.3,+ -0.1,+ 6.3]},"ʌ": {"artic": {- "tbX": 1.576,- "tbY": 7.064,- "jaw": 1.1,- "lipAp": 0.826,- "lipProt": 0.316,- "lipWidth": 0.593,- "root": 0,- "larynx": 0,- "ttX": 5.646,- "ttY": 6.446,+ "tbX": 1.725,+ "tbY": 6.997,+ "jaw": 1.105,+ "lipAp": 0.829,+ "lipProt": 0.291,+ "lipWidth": 0.703,+ "root": -0.007,+ "larynx": -0.004,+ "ttX": 5.688,+ "ttY": 6.418,"ttCurl": 0},"formants": [749,1546,- 3145+ 3147],"target": [749,@@ -1753,27 +1753,27 @@"err": [0,0,- 0+ 0.1]},"ə": {"artic": {- "tbX": 2.044,- "tbY": 7.25,- "jaw": 0.973,- "lipAp": 1.432,- "lipProt": 0.043,- "lipWidth": 0.997,- "root": -0.42,- "larynx": -0.248,+ "tbX": 2.126,+ "tbY": 7.173,+ "jaw": 1.035,+ "lipAp": 1.493,+ "lipProt": 0,+ "lipWidth": 1,+ "root": -0.508,+ "larynx": -0.187,"ttX": 5.838,- "ttY": 6.622,+ "ttY": 6.542,"ttCurl": 0},"formants": [- 652,- 1925,- 3130+ 650,+ 1918,+ 3131],"target": [650,@@ -1781,29 +1781,29 @@3038],"err": [- 0.3,- -0.2,- 3+ 0,+ -0.5,+ 3.1]},"ɐ": {"artic": {- "tbX": 1.562,- "tbY": 7,- "jaw": 1.424,- "lipAp": 1.774,- "lipProt": 0,- "lipWidth": 1,- "root": -0.188,- "larynx": -0.061,- "ttX": 5.501,- "ttY": 6.146,+ "tbX": 1.66,+ "tbY": 6.872,+ "jaw": 1.4,+ "lipAp": 1.73,+ "lipProt": 0.031,+ "lipWidth": 0.99,+ "root": 0,+ "larynx": 0,+ "ttX": 5.541,+ "ttY": 6.12,"ttCurl": 0},"formants": [- 831,- 1789,- 3147+ 832,+ 1795,+ 3100],"target": [832,@@ -1811,30 +1811,30 @@3100],"err": [- -0.2,- -0.4,- 1.5+ 0,+ 0,+ 0]},"ɝ": {"artic": {- "tbX": 1.629,- "tbY": 7.129,- "jaw": 0.05,- "lipAp": 0.711,- "lipProt": 1.395,- "lipWidth": 0.514,- "root": -0.9,- "larynx": -1.299,- "ttX": 5.652,- "ttY": 9.402,- "ttCurl": 1+ "tbX": 2.344,+ "tbY": 6.637,+ "jaw": 0.379,+ "lipAp": 0.144,+ "lipProt": 1.4,+ "lipWidth": 0.331,+ "root": -0.897,+ "larynx": -1.3,+ "ttX": 5.774,+ "ttY": 8.837,+ "ttCurl": 0.952},"formants": [- 596,- 1618,- 2487,- 3488+ 584,+ 1669,+ 2689,+ 3987],"target": [586,@@ -1842,29 +1842,29 @@2143],"err": [- 1.7,- -5.9,- 16+ -0.4,+ -2.9,+ 25.5]},"y": {"artic": {- "tbX": 3.443,- "tbY": 7.983,- "jaw": 0.226,- "lipAp": 0.301,- "lipProt": 1.156,- "lipWidth": 0.301,- "root": -0.9,- "larynx": -0.8,- "ttX": 6.537,- "ttY": 7.545,- "ttCurl": 0.002+ "tbX": 3.464,+ "tbY": 7.98,+ "jaw": 0.175,+ "lipAp": 0.23,+ "lipProt": 0.766,+ "lipWidth": 0.302,+ "root": -0.898,+ "larynx": -0.765,+ "ttX": 6.562,+ "ttY": 7.588,+ "ttCurl": 0.001},"formants": [390,2392,- 2910+ 2924],"target": [390,@@ -1872,29 +1872,29 @@2666],"err": [- 0,-0.1,- 9.1+ -0.1,+ 9.7]},"ø": {"artic": {- "tbX": 2.998,- "tbY": 7.748,- "jaw": 0.66,- "lipAp": 0.512,- "lipProt": 0.597,- "lipWidth": 0.304,+ "tbX": 3.444,+ "tbY": 7.712,+ "jaw": 0.797,+ "lipAp": 0.363,+ "lipProt": 1.399,+ "lipWidth": 0.306,"root": -0.9,- "larynx": -0.463,- "ttX": 6.248,- "ttY": 7.073,+ "larynx": -0.469,+ "ttX": 6.329,+ "ttY": 6.939,"ttCurl": 0},"formants": [- 506,- 2060,- 3016+ 505,+ 2062,+ 3032],"target": [507,@@ -1902,29 +1902,29 @@2790],"err": [- -0.1,- -0.1,- 8.1+ -0.4,+ 0,+ 8.7]},"œ": {"artic": {- "tbX": 2.794,- "tbY": 7.333,- "jaw": 1.043,- "lipAp": 0.691,- "lipProt": 0.592,- "lipWidth": 0.313,- "root": -0.9,- "larynx": -0.424,- "ttX": 6.035,- "ttY": 6.59,- "ttCurl": 0+ "tbX": 2.99,+ "tbY": 7.044,+ "jaw": 1.089,+ "lipAp": 0.692,+ "lipProt": 0.999,+ "lipWidth": 0.316,+ "root": -0.899,+ "larynx": -0.514,+ "ttX": 6.073,+ "ttY": 6.457,+ "ttCurl": 0.004},"formants": [675,- 1923,- 3081+ 1924,+ 3097],"target": [676,@@ -1933,28 +1933,28 @@],"err": [-0.2,- -0.3,- 5.7+ -0.2,+ 6.3]},"ɨ": {"artic": {- "tbX": 3.023,- "tbY": 7.846,- "jaw": 0.165,- "lipAp": 0.12,- "lipProt": 0.4,- "lipWidth": 0.496,- "root": -0.636,- "larynx": -0.405,- "ttX": 6.433,- "ttY": 7.549,+ "tbX": 3.099,+ "tbY": 7.867,+ "jaw": 0.213,+ "lipAp": 0.205,+ "lipProt": 0.332,+ "lipWidth": 0.75,+ "root": -0.891,+ "larynx": -0.333,+ "ttX": 6.44,+ "ttY": 7.513,"ttCurl": 0},"formants": [- 434,- 2152,- 3113+ 429,+ 2128,+ 3129],"target": [429,@@ -1962,29 +1962,29 @@2976],"err": [- 1.1,- 1.1,- 4.6+ -0.1,+ 0,+ 5.1]},"ɯ": {"artic": {- "tbX": 2.808,- "tbY": 7.684,- "jaw": 0.05,- "lipAp": 0.12,- "lipProt": 0.491,- "lipWidth": 0.409,- "root": -0.023,- "larynx": -0.72,- "ttX": 6.406,- "ttY": 7.596,- "ttCurl": 0+ "tbX": 2.756,+ "tbY": 7.577,+ "jaw": 0.297,+ "lipAp": 0.373,+ "lipProt": 0.374,+ "lipWidth": 0.549,+ "root": 0.377,+ "larynx": -0.82,+ "ttX": 6.306,+ "ttY": 7.342,+ "ttCurl": 0.003},"formants": [- 456,- 1840,- 3179+ 458,+ 1786,+ 3279],"target": [442,@@ -1992,23 +1992,23 @@2976],"err": [- 3.1,- 2.5,- 6.8+ 3.6,+ -0.5,+ 10.2]},"ɤ": {"artic": {- "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,+ "tbX": 2.14,+ "tbY": 7.19,+ "jaw": 0.723,+ "lipAp": 1.037,+ "lipProt": 0.355,+ "lipWidth": 0.554,+ "root": -0.325,+ "larynx": -0.297,+ "ttX": 5.967,+ "ttY": 6.821,"ttCurl": 0},"formants": [@@ -2024,7 +2024,7 @@"err": [0.7,-0.1,- 3.5+ 3.6]}}diff --git a/src/engine/sources/glottis.ts b/src/engine/sources/glottis.tsindex eef1b91..b00d017 100644--- a/src/engine/sources/glottis.ts+++ b/src/engine/sources/glottis.ts@@ -89,12 +89,19 @@ export class ParametricGlottis {f0Now = 110;/** phonation threshold pressure (dyn/cm²) */threshold = 2.5 * CM_H2O;+ // per-sample smoothing of control-rate parameters (steps in the glottal area at high airflow+ // radiate as clicks, because the output is the derivative of flow)+ private staticSm = 0;+ private closureSm = 0;+ private ampSm = 0;+ private readonly smCoef: number;constructor(fs: number) {this.fs = fs;this.drift = new Drift(fs / 64, 0.3, 4242);this.dpCoef = 1 - Math.exp(-TAU * 30 / fs);this.voiceCoef = 1 - Math.exp(-TAU * 25 / fs);+ this.smCoef = 1 - Math.exp(-1 / (0.004 * fs));}/** Reset phase etc. */@@ -127,8 +134,8 @@ export class ParametricGlottis {// voicing gate: pressure above threshold, adduction sufficient, not forcibly closedconst pressureGate = smoothstep(this.threshold * 0.8, this.threshold * 1.6, this.dpSm);- const adductGate = 1 - smoothstep(0.08, 0.22, P.abduction);- const target = pressureGate * adductGate * (1 - P.closure);+ const adductGate = 1 - smoothstep(0.08, 0.22, this.staticSm - P.chink);+ const target = pressureGate * adductGate * (1 - this.closureSm);this.voicingSm += this.voiceCoef * (target - this.voicingSm);this.voicing = this.voicingSm;@@ -153,8 +160,12 @@ export class ParametricGlottis {if (ph2 > 0) pulse += 0.55 * smoothstep(0.3, 0.8, P.fry) * this.shape(ph2, oq * 0.8, P.skew, P.closureSharpness);}const effortScale = 0.45 + 0.75 * P.effort;- const vib = P.amplitude * effortScale * this.cycleAmp * this.voicingSm * pulse;- const statics = (P.abduction + P.chink) * (1 - 0.92 * P.closure);+ const sc = this.smCoef;+ this.ampSm += sc * (P.amplitude * effortScale - this.ampSm);+ this.closureSm += sc * (P.closure - this.closureSm);+ this.staticSm += sc * (P.abduction + P.chink - this.staticSm);+ const vib = this.ampSm * this.cycleAmp * this.voicingSm * pulse;+ const statics = this.staticSm * (1 - 0.92 * this.closureSm);const a = Math.max(0, vib + statics);this.area = a;return a;diff --git a/src/engine/voice/humanAirway.ts b/src/engine/voice/humanAirway.tsindex 0dc95e5..8ec9d9f 100644--- a/src/engine/voice/humanAirway.ts+++ b/src/engine/voice/humanAirway.ts@@ -40,7 +40,7 @@ export class HumanAirway {phLen = 8.8;orLen = 8.3;/** noise gains (tunable) */- noiseGain = { glottis: 2.4e-6, constriction: 3.0e-6, teeth: 9e-6 };+ noiseGain = { glottis: 3.2e-6, constriction: 2.2e-6, teeth: 3.0e-6 };constructor(opts: HumanAirwayOptions) {const body = (this.body = opts.body ?? BODY_MALE);@@ -96,26 +96,40 @@ export class HumanAirway {}/** max area change rate (cm²/s, body-scaled): a physiological guard against geometric jumps */- maxAreaRate = 160;+ maxAreaRate = 45;+ /** additional rate per cm² of current area (1/s) */+ areaRateGain = 40;/** 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 oldPh = dt > 0 ? Float64Array.from(this.phAreas) : null;const oldOr = dt > 0 ? Float64Array.from(this.orAreas) : null;+ const oldPhMin = dt > 0 ? Float64Array.from(this.phMin) : null;+ const oldOrMin = dt > 0 ? Float64Array.from(this.orMin) : 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) => {+ if (oldPh && oldOr && oldPhMin && oldOrMin) {+ // both section areas and sub-section minima are rate-limited: the minima set the jet+ // (Borda–Carnot) losses ∝ 1/A², so a fast drop chokes the flow within a block+ // rate limit grows with cross-section: wide cavities reshape fast, narrow constrictions+ // (lateral extent ~1–2 cm) open and close at physiological rates (sets burst sharpness)+ const k2 = this.body.scale * this.body.scale;+ const clampArr = (cur: Float64Array, old: Float64Array, mins: Float64Array, oldMins: Float64Array) => {for (let i = 0; i < cur.length; i++) {+ const lim = (this.maxAreaRate * k2 + this.areaRateGain * Math.max(old[i], cur[i])) * dt;const d = cur[i] - old[i];if (d > lim) cur[i] = old[i] + lim;else if (d < -lim) cur[i] = old[i] - lim;+ const limM = (this.maxAreaRate * k2 + this.areaRateGain * Math.max(oldMins[i], mins[i])) * dt;+ const dm = mins[i] - oldMins[i];+ if (dm > limM) mins[i] = oldMins[i] + limM;+ else if (dm < -limM) mins[i] = oldMins[i] - limM;if (mins[i] > cur[i]) mins[i] = cur[i];+ if (mins[i] < 0) mins[i] = 0;}};- clampArr(this.phAreas, oldPh, this.phMin);- clampArr(this.orAreas, oldOr, this.orMin);+ clampArr(this.phAreas, oldPh, this.phMin, oldPhMin);+ clampArr(this.orAreas, oldOr, this.orMin, oldOrMin);}this.phLen = phLen;this.orLen = orLen;@@ -131,7 +145,7 @@ export class HumanAirway {const g = this.noiseGain;const list: { src: number; fwd: number; bwd: number; gain: number; lowpassHz?: number; highpassHz?: number }[] = [];// aspiration: jet from the glottis hits the epilarynx/ventricular region- list.push({ src: this.glottisPort, fwd: this.branchOf(this.pharynx, 1), bwd: this.branchOf(this.trachea, this.trachea.n - 2), gain: g.glottis, lowpassHz: 6000, highpassHz: 500 });+ list.push({ src: this.glottisPort, fwd: this.branchOf(this.pharynx, 1), bwd: this.branchOf(this.trachea, this.trachea.n - 2), gain: g.glottis, lowpassHz: 3500, highpassHz: 300 });// narrowest open point in pharynx+oral (global position index p over concatenated tubes)const nPh = this.nPh, nOr = this.nOr;let minA = Infinity, minI = -1;@@ -155,17 +169,17 @@ export class HumanAirway {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 * wArea, lowpassHz: 9000, highpassHz: 700 });+ list.push({ src, fwd, bwd, gain: g.constriction * wArea, lowpassHz: 2600, highpassHz: 350 });// 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) / 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 wDist = smooth(0.15, 0.5, behind) * (1 - smooth(2.6, 4.0, behind));+ const wJet = 1 - smooth(0.2 * k2, 0.5 * 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, gain: g.teeth * wt, lowpassHz: 11000, highpassHz: 1800 });+ if (tb >= 0) list.push({ src, fwd: tb, bwd, gain: g.teeth * wt, lowpassHz: 5000, highpassHz: 1200 });}}}diff --git a/src/engine/voice/humanVoice.ts b/src/engine/voice/humanVoice.tsindex 40b84d9..9dcad4e 100644--- a/src/engine/voice/humanVoice.ts+++ b/src/engine/voice/humanVoice.ts@@ -9,6 +9,7 @@ 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";+import { GestureScore, type Blended, type Gesture } from "../control/score.ts";export interface VoiceSource {/** target fundamental frequency (Hz) */@@ -65,6 +66,10 @@ export interface VoiceTelemetry {noiseLevel: number;noiseNode: number;gate: number;+ /** voice clock (s) for score playheads */+ clock: number;+ /** labels of gestures active now (most recent first) */+ active: string[];}const SCOPE_LEN = 4096;@@ -103,6 +108,13 @@ export class HumanVoice {private outAcc = 0;private outCount = 0;private sub = 0;+ /** gestural score and voice clock (s) */+ readonly score = new GestureScore();+ clock = 0;+ private readonly tmpBlend: Blended = { value: 0, weight: 0, speed: 1 };+ private baseAbduction = 0;+ private baseClosure = 0;+ private scoreF0: number | null = null;constructor(opts: { fsOut: number; body?: HumanBody; oversample?: number }) {this.fsOut = opts.fsOut;@@ -133,6 +145,16 @@ export class HumanVoice {this.applySource();}+ /** Add gestures (times on the voice clock). */+ schedule(gestures: Gesture[]): void {+ this.score.addAll(gestures);+ }++ /** Cancel scheduled gestures (speech stops; the voice returns to the performer's posture). */+ cancelScore(): void {+ this.score.clear();+ }+/** breath/voice on (1) or off (0); intermediate values scale the pressure */setGate(level: number): void {this.gateTarget = clamp(level, 0, 1.5);@@ -144,6 +166,8 @@ export class HumanVoice {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;+ this.baseAbduction = g.abduction;+ this.baseClosure = 0;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;@@ -225,17 +249,51 @@ export class HumanVoice {/** Control-rate update: articulator dynamics, geometry → areas, breath, pitch. */private control(): void {const dt = this.ctrlEvery / this.fs;- this.artic.step(dt);+ const t = this.clock;+ const score = this.score;+ const tmp = this.tmpBlend;+ let breathAct = 0, breathVal = 0;+ let f0Target = this.source.f0;+ const gp = this.glottis.params;+ if (score.size > 0) {+ // performer's base posture keeps a small say on keys the score controls+ this.artic.step(dt, (k) => score.blend(k, t, tmp), 0.05);+ const k2 = this.airway.body.scale * this.airway.body.scale;+ const ab = score.blend("abduction", t, tmp);+ const abAct = ab.weight > 0 ? Math.min(1, ab.weight / 2) : 0;+ gp.abduction = this.baseAbduction + ab.value * abAct * k2;+ const cl = score.blend("closure", t, tmp);+ gp.closure = Math.max(this.baseClosure, cl.weight > 0 ? cl.value * Math.min(1, cl.weight / 2) : 0);+ const br = score.blend("breath", t, tmp);+ if (br.weight > 0) {+ breathAct = Math.min(1, br.weight);+ breathVal = br.value;+ }+ const pf = score.blend("f0", t, tmp);+ if (pf.weight > 0) {+ f0Target = (this.source.f0 * 0.02 + pf.value * pf.weight) / (0.02 + pf.weight);+ this.scoreF0 = f0Target;+ } else this.scoreF0 = null;+ if (((this.clock * 10) | 0) !== (((this.clock - dt) * 10) | 0)) score.prune(t - 0.2);+ } else {+ this.artic.step(dt);+ gp.abduction = this.baseAbduction;+ gp.closure = this.baseClosure;+ this.scoreF0 = null;+ }+ this.clock += dt;+ this.enforceContacts();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));+ // breath: fast attack, slower release; a speaking score breathes on its own+ const gateGoal = Math.max(this.gateTarget, breathVal * breathAct);+ const tau = gateGoal > this.gate ? 0.025 : 0.07;+ this.gate += (gateGoal - 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));+ const g = Math.max(0.002, this.scoreF0 !== null ? 0.03 : this.source.glide);+ this.f0 *= Math.pow(f0Target / 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;@@ -247,6 +305,39 @@ export class HumanVoice {}}+ /** tissue may compress this far (cm) before the palate stops the articulator */+ maxPenetration = 0.1;++ /**+ * Contact constraint: articulators cannot travel into the palate. Beyond `maxPenetration` of+ * tissue compression, the tongue tip/body is projected back along the contact normal and its+ * inward velocity removed (inelastic). Keeps held closures still (no air pumping), makes+ * releases start at the surface, and keeps the drawn anatomy physical.+ */+ private enforceContacts(): void {+ const tract = this.airway.tract;+ const x = this.artic.x, vel = this.artic.v;+ tract.compute(x);+ const k = tract.scale;+ const lim = -this.maxPenetration * k;+ const fix = (d: number, n: { x: number; y: number }, kx: "ttX" | "tbX", ky: "ttY" | "tbY") => {+ if (!(d < lim)) return;+ const depth = lim - d; // > 0, body cm+ // body → template displacement (oral x is compressed by 0.86 in the template map)+ const sx = (x[kx] > 0.5 ? 1 / 0.86 : 1) / k;+ const sy = 1 / k;+ x[kx] += n.x * depth * sx;+ x[ky] += n.y * depth * sy;+ const vn = vel[kx] * n.x / sx + vel[ky] * n.y / sy; // normal velocity (body units)+ if (vn < 0) {+ vel[kx] -= vn * n.x * sx;+ vel[ky] -= vn * n.y * sy;+ }+ };+ fix(tract.contactTip, tract.contactTipN, "ttX", "ttY");+ fix(tract.contactBody, tract.contactBodyN, "tbX", "tbY");+ }+telemetry(): VoiceTelemetry {const air = this.airway;const nT = air.nPh + air.nOr;@@ -305,6 +396,8 @@ export class HumanVoice {noiseLevel,noiseNode,gate: this.gate,+ clock: this.clock,+ active: this.score.activeAt(this.clock).filter((g) => g.label && g.label !== "breath" && g.label !== "pitch").map((g) => g.label as string).slice(0, 4),};}}diff --git a/tests/airway-adversarial.test.ts b/tests/airway-adversarial.test.tsindex fe7967f..c70bc8b 100644--- a/tests/airway-adversarial.test.ts+++ b/tests/airway-adversarial.test.ts@@ -131,7 +131,7 @@ test("a realistic sliding closure with trapped pressure releases without spikes"net.addRadiation(t.lastNode);net.finalize();const block = 64;- let peakP = 0, peakOut = 0, peakOpenOut = 0;+ let peakP = 0, peakOut = 0, peakOpenOut = 0, peakSlide = 0, peakRelease = 0;const total = FS * 0.6;const P = 8 * CM_H2O;for (let i = 0; i < total; i++) {@@ -147,13 +147,20 @@ test("a realistic sliding closure with trapped pressure releases without spikes"}net.setFixedPressure(lung, P * Math.min(1, time / 0.03));const y = net.step();+ expect(Number.isFinite(y)).toBe(true);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)]));+ if (time > 0.09 && time < 0.39) peakSlide = Math.max(peakSlide, Math.abs(y));+ if (time > 0.395 && time < 0.45) peakRelease = Math.max(peakRelease, Math.abs(y));+ // acoustically open cells only: squeeze-film pressure inside a closing gap is physical+ for (let k = 0; k < n; k++) if (net.area[t.node(k)] > 0.1) peakP = Math.max(peakP, Math.abs(net.p[t.node(k)]));}- // pressure stays within a small multiple of the driving pressureexpect(peakP).toBeLessThan(2.5 * P);- expect(Number.isFinite(peakOut)).toBe(true);+ // a held, sliding closure must stay quiet (no spurious pops); the release burst is the+ // largest event and is of physical size (comparable to the breathing onset, not orders above)+ expect(peakSlide).toBeLessThan(0.25 * peakRelease);+ expect(peakRelease).toBeLessThan(10 * peakOpenOut);+ void peakOut;});test("fast (but articulator-limited) closure gives bounded piston pressure", () => {@@ -173,8 +180,8 @@ test("fast (but articulator-limited) closure gives bounded piston pressure", ()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(Number.isFinite(net.step())).toBe(true);+ for (let k = 0; k < n; k++) if (net.area[t.node(k)] > 0.1) peakP = Math.max(peakP, Math.abs(net.p[t.node(k)]));}expect(peakP).toBeLessThan(20 * CM_H2O);});diff --git a/tools/calibrate-consonants.ts b/tools/calibrate-consonants.tsnew file mode 100644index 0000000..366cc12--- /dev/null+++ b/tools/calibrate-consonants.ts@@ -0,0 +1,45 @@+/**+ * Calibrate the main coordinate of fricatives so the constriction area matches its target+ * (adult-male target × body scale²), in an /a/-like context. Bisection on the monotonic+ * contact model. Writes src/engine/phonetics/consonantTargets.generated.json+ */+import { writeFileSync } from "node:fs";+import { HumanAirway } from "../src/engine/voice/humanAirway.ts";+import { NEUTRAL, BODY_MALE, BODY_FEMALE, BODY_CHILD, type HumanArtic } from "../src/engine/anatomy/human.ts";+import { CONSONANTS } from "../src/engine/phonetics/inventory.ts";+import vowels from "../src/engine/phonetics/vowelTargets.generated.json";++const out: Record<string, Record<string, Partial<HumanArtic>>> = {};+for (const [name, body] of [["male", BODY_MALE], ["female", BODY_FEMALE], ["child", BODY_CHILD]] as const) {+ const air = new HumanAirway({ fs: 96000, body });+ const ctx = { ...NEUTRAL, ...(vowels as any)[name]["ɑ"].artic, jaw: 0.55 } as HumanArtic;+ out[name] = {};+ for (const p of CONSONANTS) {+ if (!p.area || !p.calKey) continue;+ const target = p.area * body.scale * body.scale;+ const key = p.calKey;+ const minArea = (v: number) => {+ const a = { ...ctx, ...p.targets, [key]: v } as HumanArtic;+ air.apply(a);+ let m = Infinity;+ for (const x of air.phMin) if (x < m) m = x;+ for (const x of air.orMin) if (x < m) m = x;+ return m;+ };+ // search direction: area decreases as the coordinate moves toward closure+ const base = p.targets[key] as number;+ let lo = base - 1.2, hi = base + 1.2;+ const decreasing = minArea(hi) < minArea(lo); // area falls as value rises?+ for (let i = 0; i < 40; i++) {+ const mid = (lo + hi) / 2;+ const A = minArea(mid);+ if ((A > target) === decreasing) lo = mid;+ else hi = mid;+ }+ const v = (lo + hi) / 2;+ const got = minArea(v);+ out[name][p.ipa] = { [key]: Math.round(v * 1000) / 1000 };+ console.log(`${name.padEnd(6)} ${p.ipa.padEnd(3)} ${key}=${v.toFixed(3)} area ${got.toFixed(3)} (target ${target.toFixed(3)})`);+ }+}+writeFileSync("src/engine/phonetics/consonantTargets.generated.json", JSON.stringify(out, null, 1));diff --git a/tools/measure-consonants.ts b/tools/measure-consonants.tsnew file mode 100644index 0000000..f89b115--- /dev/null+++ b/tools/measure-consonants.ts@@ -0,0 +1,53 @@+/**+ * Objective consonant metrics from rendered VCV syllables (adult male):+ * - frication level relative to the vowel (RMS, dB) and spectral centroid / peak+ * - release transient peak relative to the vowel peak+ * Usage: bun tools/measure-consonants.ts+ */+import { HumanVoice } from "../src/engine/voice/humanVoice.ts";+import { planUtterance } from "../src/engine/phonetics/planner.ts";+import { tokenizeIpa } from "../src/engine/phonetics/ipa.ts";+import { FFT, hann } from "../src/engine/analysis/fft.ts";++const FS = 48000;+const items = (process.argv[2] ?? "s,ʃ,f,θ,x,h,p,t,k,b,d,g,m,n").split(",");+const fft = new FFT(1024);+const win = hann(1024);+for (const c of items) {+ const v = new HumanVoice({ fsOut: FS });+ const plan = planUtterance(tokenizeIpa(`ˈɑ${c}ɑ`), { body: "male", t0: 0.05, f0: 110 });+ v.schedule(plan.gestures);+ const N = Math.round(FS * (plan.end + 0.2));+ const out = new Float32Array(N);+ for (let i = 0; i < N; i += 128) v.render(out, i, Math.min(128, N - i));+ const seg = plan.segments[1];+ const rms = (a: number, b: number) => {+ let s = 0;+ for (let i = Math.round(a * FS); i < Math.round(b * FS); i++) s += out[i] * out[i];+ return Math.sqrt(s / Math.max(1, Math.round((b - a) * FS)));+ };+ const vowel = rms(0.14, 0.26);+ const mid = (seg.t0 + seg.t1) / 2;+ const fric = rms(seg.t0 + 0.02, seg.t1 - 0.01);+ let vpk = 0;+ for (let i = Math.round(0.14 * FS); i < Math.round(0.26 * FS); i++) vpk = Math.max(vpk, Math.abs(out[i]));+ let rpk = 0;+ for (let i = Math.round(seg.t1 * FS); i < Math.round((seg.t1 + 0.04) * FS); i++) rpk = Math.max(rpk, Math.abs(out[i]));+ // spectrum of the consonant middle+ const re = new Float64Array(1024), im = new Float64Array(1024);+ const s0 = Math.round(mid * FS) - 512;+ for (let i = 0; i < 1024; i++) re[i] = (out[s0 + i] ?? 0) * win[i];+ fft.transform(re, im);+ let num = 0, den = 0, pkBin = 1, pkVal = 0;+ for (let k = 4; k < 512; k++) {+ const p = re[k] * re[k] + im[k] * im[k];+ const f = (k * FS) / 1024;+ num += f * p;+ den += p;+ if (f > 1000 && p > pkVal) { pkVal = p; pkBin = k; }+ }+ const db = (x: number) => (20 * Math.log10(Math.max(1e-9, x))).toFixed(1);+ const burst = rms(seg.t1, seg.t1 + 0.012);+ const asp = rms(seg.t1 + 0.012, seg.t1 + 0.04);+ console.log(`${c.padEnd(2)} level ${db(fric / vowel).padStart(6)} dB centroid ${(num / den / 1000).toFixed(2)} kHz peak ${((pkBin * FS) / 1024 / 1000).toFixed(2)} kHz release/vowel peak ${(rpk / vpk).toFixed(2)} burst ${db(burst / vowel).padStart(6)} dB post ${db(asp / vowel).padStart(6)} dB`);+}diff --git a/tools/render-speech.ts b/tools/render-speech.tsnew file mode 100644index 0000000..f8d14ed--- /dev/null+++ b/tools/render-speech.ts@@ -0,0 +1,39 @@+/**+ * Render IPA utterances through the real-time voice with the gestural planner.+ * Usage: bun tools/render-speech.ts out/name "ˈɑpɑ ˈɑbɑ" [male|female|child]+ * Writes <name>.wav and <name>.png (spectrogram with segment marks).+ */+import { HumanVoice } from "../src/engine/voice/humanVoice.ts";+import { BODY_MALE, BODY_FEMALE, BODY_CHILD } from "../src/engine/anatomy/human.ts";+import { planUtterance } from "../src/engine/phonetics/planner.ts";+import { tokenizeIpa } from "../src/engine/phonetics/ipa.ts";+import { writeWav } from "./lib/wav.ts";+import { renderSpectrogram } from "./lib/spectrogram.ts";++const name = process.argv[2] ?? "out/speech";+const text = process.argv[3] ?? "ˈɑpɑ";+const bodyName = (process.argv[4] ?? "male") as "male" | "female" | "child";+const body = { male: BODY_MALE, female: BODY_FEMALE, child: BODY_CHILD }[bodyName];+const f0 = { male: 110, female: 200, child: 250 }[bodyName];+const FS = 48000;+const voice = new HumanVoice({ fsOut: FS, body });+voice.setSource({ f0 });+const utterances = text.split("/").map((u) => u.trim()).filter(Boolean);+const marks: { t: number; label: string }[] = [];+let t0 = 0.05;+for (const u of utterances) {+ const segs = tokenizeIpa(u);+ const plan = planUtterance(segs, { body: bodyName, t0, f0 });+ voice.schedule(plan.gestures);+ for (const s of plan.segments) marks.push({ t: s.t0, label: s.ipa });+ t0 = plan.end + 0.35;+}+const total = Math.round(FS * (t0 + 0.2));+const out = new Float32Array(total);+for (let i = 0; i < total; i += 128) voice.render(out, i, Math.min(128, total - i));+let pk = 0;+for (const x of out) pk = Math.max(pk, Math.abs(x));+writeWav(`${name}.wav`, [out], FS);+renderSpectrogram(`${name}.png`, out, FS, { title: `${text} (${bodyName})`.replace(/[^\x20-\x7e]/g, "?"), maxFreq: 9000, windowMs: 5, marks: marks.map((m) => ({ t: m.t, label: "" })) });+console.log(`wrote ${name}.wav/.png ${(total / FS).toFixed(2)} s peak ${pk.toFixed(3)}`);+console.log(marks.map((m) => `${m.label}@${m.t.toFixed(3)}`).join(" "));