From 9b01e1405496a176c18528e086718f1266d266d5 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 27 May 2026 21:43:43 +0100 Subject: [PATCH] Correct graph pressure scattering --- docs/acoustic-graph-flow-audit.md | 65 ++++++++++++++----- src/AquaSynth.Core/FaustExport.cs | 11 ++-- src/AquaSynth.Core/PatchScript.cs | 2 +- state/evidence.jsonl | 1 + state/spine.yaml | 4 +- tests/AquaSynth.Dsl.Tests/PatchScriptTests.cs | 5 +- 6 files changed, 62 insertions(+), 26 deletions(-) diff --git a/docs/acoustic-graph-flow-audit.md b/docs/acoustic-graph-flow-audit.md index b95d666..68a1329 100644 --- a/docs/acoustic-graph-flow-audit.md +++ b/docs/acoustic-graph-flow-audit.md @@ -176,22 +176,55 @@ patches can read those bargraph zones after processing blocks, so passivity checks can sample probe values over time without turning probes into audio channels. -The first native probe report on the nasal-vowel graph shows same-path and -nasal branch energy ratios essentially at 1.0. That is useful: the current -tract does not appear to be exploding at the basic scatter sites. The audible -failure is more likely missing frequency-dependent tract losses/radiation color -and closure pressure storage than a gross non-passive junction. +The first native probe report on the nasal-vowel graph showed same-path and +nasal branch energy ratios essentially at 1.0. That was useful but incomplete: +the original two-port same-path area law was passive while still carrying the +wrong pressure relation for unequal areas. It could conserve a local energy +proxy and still phase-mangle the tract. -The next coherent implementation target is to make that law passive and -radiation-aware: +Same-path two-port area discontinuities now use the same pressure-continuity +shape as the branch law: compute admittance-weighted junction pressure, then +emit each outgoing wave as `pressure - incoming`. This is a structural fix even +where PT log-mel worsens, because matching a reference through a sign error is +not an acoustic model. -1. Normalize branch scattering by power/admittance, not by a global damping - scalar. -2. Keep the main path continuous when side admittance approaches zero. -3. Normalize radiation against local aperture/admittance so removing a damper - does not become raw loudness. -4. Extend the new named radiation flow/admittance probes toward connection - energy probes before further PT audio golf. +The generated graph clock also now defaults to continuous fractional delay for +`propagation=graph`. Cell-centered source terminals had doubled the segment +count; keeping a half-sample floor silently lengthened the tube. Fractional +delay keeps terminal density from changing morphology, which is the invariant +we need for differentiable tract graphs. -If that law still floods, radiation normalization should be audited at the same -layer. Do not fix this with another global gain. +A per-segment Faust low-pass loss experiment was cut. Frequency-dependent wall +loss remains a real missing feature, but one `fi.lowpass` per tiny segment made +parity runs slow and collapsed body energy without improving articulation. A +softer radiation-color experiment was also cut after it worsened `papa`. Those +lessons belong here, not as dead compensators in the emitter. + +The latest pressure-law/fractional-clock evidence is: + +- static PT graph artifact + `artifacts/parity/pink-trombone-logmel/20260527T204022933`; +- utterance artifact + `artifacts/parity/pink-trombone-utterance-logmel/20260527T203950790`; +- probe artifact + `artifacts/parity/pink-trombone-graph-probes/20260527T203414610`. + +The remaining audible failure is still speech-band articulation: `mama` and +`papa` have weak 500-2500 Hz energy and plosive motion, while closure/release +still lacks a true upstream pressure reservoir. + +The next coherent implementation target is source/boundary coupling, not more +global gain: + +1. Add graph-native closure/reservoir state so a sealed constriction stores + upstream pressure and releases through the same path when opening returns. +2. Audit glottal/source impedance against the corrected pressure law so source + ports inject flow/pressure into the correct wave variables. +3. Revisit frequency-dependent tract loss with a Faust-friendly formulation + that does not cascade heavyweight filters across every tiny segment. +4. Keep radiation local to aperture/admittance and boundary flow; do not + restore a global output scalar as a speech-band patch. + +If the graph remains under-articulated after closure storage exists, inspect +the source and boundary probes at the same layer. Do not fix this with another +global gain. diff --git a/src/AquaSynth.Core/FaustExport.cs b/src/AquaSynth.Core/FaustExport.cs index ac7a9d0..a114631 100644 --- a/src/AquaSynth.Core/FaustExport.cs +++ b/src/AquaSynth.Core/FaustExport.cs @@ -884,7 +884,7 @@ public static class FaustEmitter ? "1.0" : $"(0.20 + 2.80 * clip01((abs({localPressure}) * ({closure})) : + ~ *(0.992)))"; var turbulence = $"(no.noise : fi.highpass(2, 900.0 + 2600.0 * clip01(1.0 - {opening})))"; - var apertureNoiseGate = $"min(clip01((0.8 - {opening}) / 0.8), clip01(8.0 * (0.7 - {opening})) * clip01(30.0 * ({opening} - 0.3)))"; + var apertureNoiseGate = $"min(clip01((0.85 - {opening}) / 0.85), clip01(25.0 * ({opening} - 0.04)))"; var releaseBurstGate = $"clip01({opening} / 0.8) * {release}"; return port.Kind switch { @@ -1706,15 +1706,16 @@ public static class FaustEmitter var second = ports[1]; var firstArea = GraphPortArea(voiceName, first); var secondArea = GraphPortArea(voiceName, second); - var reflection = $"(({secondArea}) - ({firstArea})) / max(0.000001, ({firstArea}) + ({secondArea}))"; var firstIncoming = GraphIncoming(voiceName, first); var secondIncoming = GraphIncoming(voiceName, second); var firstOutgoing = GraphOutgoing(voiceName, first); var secondOutgoing = GraphOutgoing(voiceName, second); + var areaSum = $"max(0.000001, ({firstArea}) + ({secondArea}))"; + var pressure = $"{voiceName}_graph_area_pressure_{node.Name}"; - source.AppendLine($" {voiceName}_graph_area_reflection_{node.Name} = {reflection};"); - source.AppendLine($" {firstOutgoing} = {secondIncoming} + {voiceName}_graph_area_reflection_{node.Name} * ({firstIncoming} + {secondIncoming}) + ({sourceInjection}) / 2;"); - source.AppendLine($" {secondOutgoing} = {firstIncoming} - {voiceName}_graph_area_reflection_{node.Name} * ({firstIncoming} + {secondIncoming}) + ({sourceInjection}) / 2;"); + source.AppendLine($" {pressure} = 2.0 * (({firstArea}) * {firstIncoming} + ({secondArea}) * {secondIncoming}) / {areaSum};"); + source.AppendLine($" {firstOutgoing} = {pressure} - {firstIncoming} + ({sourceInjection}) / 2;"); + source.AppendLine($" {secondOutgoing} = {pressure} - {secondIncoming} + ({sourceInjection}) / 2;"); var energyIn = $"({firstArea}) * pow({firstIncoming}, 2.0) + ({secondArea}) * pow({secondIncoming}, 2.0)"; var energyOut = $"({firstArea}) * pow({firstOutgoing}, 2.0) + ({secondArea}) * pow({secondOutgoing}, 2.0)"; source.AppendLine($" {voiceName}_graph_area_energy_in_{node.Name} = {ProbeSignal(options, $"/debug/{voiceName}/area/{node.Name}/energy_in", energyIn, 0, 4)};"); diff --git a/src/AquaSynth.Core/PatchScript.cs b/src/AquaSynth.Core/PatchScript.cs index 665860e..e5e88e7 100644 --- a/src/AquaSynth.Core/PatchScript.cs +++ b/src/AquaSynth.Core/PatchScript.cs @@ -1502,7 +1502,7 @@ public static class PatchScript tract.Propagation == TractPropagationMode.Waveguide ? WaveClockDelayStrategy.UnitGrid : tract.Propagation == TractPropagationMode.Graph - ? WaveClockDelayStrategy.HalfSampleGrid + ? WaveClockDelayStrategy.FractionalLinear : WaveClockDelayStrategy.FractionalLinear)); var network = new AcousticPortNetwork( diff --git a/state/evidence.jsonl b/state/evidence.jsonl index c35be25..b965a10 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -189,3 +189,4 @@ {"evidence":"Extended Mimir's native streaming Faust path to split writable controls from read-only bargraph probe zones. `AquaSynthCompiledPatch.ProbePaths`, `AquaSynthStreamingPatch.ProbePaths`, `ReadProbe`, and `SnapshotProbes` now expose debug probe telemetry after processing blocks. Focused native streaming, debug-probe, graph, and Faust-validation tests passed.","claim":"Graph probe UI is now measurable through the native streaming host without changing DSP audio outputs. This is the right observability layer for passivity and radiation debugging: process blocks, sample `/debug/...` bargraphs, then compare scatter-site energy instead of inferring everything from rendered WAVs.","timestamp":"2026-05-27T18:14:00+01:00","topic":"native-faust-debug-probe-sampling"} {"evidence":"Added `PinkTromboneGraphDebugProbesWritePassivityReportWhenNativeFaustIsInstalled`; focused probe and native tests passed. Latest artifact `artifacts/parity/pink-trombone-graph-probes/20260527T200828013/passivity-report.txt` shows same-path area scatter and `voices_0_nose_connection` energy out/in ratios at 1.0 for nasal-vowel.","claim":"The current graph's basic same-path and nasal branch scatter are not grossly non-passive under the nasal-vowel probe. The audible speech failure is more likely missing frequency-dependent tract losses/radiation color and closure pressure storage than scatter-site energy explosion.","timestamp":"2026-05-27T20:10:00+01:00","topic":"acoustic-graph-passivity-probe-report"} {"evidence":"Added `AquaSynthStreamingPatch` on top of the existing native Faust factory/runtime. Compiled patches can now keep a DSP instance alive, cache Faust control zones, report input/output counts, set controls without rebuilding the UI map, and process either raw channel-pointer blocks or managed float[][] blocks. `AquaSynth.Faust` is bumped to 0.1.0-alpha.4 for downstream Fensalir consumption. `dotnet build AquaSynth.sln --no-restore` passed before the existing dirty `src/AquaSynth.Core/FaustExport.cs` worktree edit blocked focused test rebuilds with unrelated compile errors.","claim":"AquaSynth owns streaming Faust DSP sessions as the reusable compiler/runtime boundary; host engines should use the persistent session for audio-rate processing instead of one-shot offline render. The pointer-based API is the realtime surface; the managed array helper is a test/convenience lane.","timestamp":"2026-05-27T18:49:28+01:00","topic":"native-faust-streaming-session"} +{"evidence":"Replaced same-path two-port area scatter with an admittance-weighted pressure-continuity law (`junction pressure`, then `pressure - incoming`) and switched generated graph tracts from half-sample grid to continuous fractional delay so added source terminals do not lengthen the tract. Narrow-open turbulence now starts above diameter 0.04 instead of 0.3. Focused graph/Faust checks passed; static PT graph artifact `artifacts/parity/pink-trombone-logmel/20260527T204022933` passed smoke floors. Utterance artifact `artifacts/parity/pink-trombone-utterance-logmel/20260527T203950790` still fails at papa with cosine 0.7314, articulation 0.1140, and speechBandRatio 0.0151. A per-segment Faust low-pass loss experiment and a softer radiation blend were tested and cut because they added cost or worsened papa without fixing articulation.","claim":"Passivity probes were not enough: the old two-port scatter could conserve local energy while using the wrong pressure relation for unequal areas. Correct pressure scattering and fractional graph delay are structural fixes even when PT metrics expose new failures. The next coherent target is graph-native closure reservoir/source impedance, not global gain or radiation-color compensation.","timestamp":"2026-05-27T20:45:00+01:00","topic":"acoustic-graph-pressure-law-fractional-delay"} diff --git a/state/spine.yaml b/state/spine.yaml index 0202589..2c2153b 100644 --- a/state/spine.yaml +++ b/state/spine.yaml @@ -1,6 +1,6 @@ project: AquaSynth spine_version: 1 -updated: 2026-05-27T20:10:00+01:00 +updated: 2026-05-27T20:45:00+01:00 prime_directive: > Build coherent synth machinery. References exist to reveal missing structure, @@ -120,7 +120,7 @@ live_invariants: - Physical voice implementation has started moving PT pressure into neutral acoustic owners: `AcousticPath`, `AcousticTerminal`, `AcousticConnection`, `AcousticSourcePort`, `AcousticBranch`, `AcousticRadiationPort`, `WaveClockPolicy`, and `AcousticPortNetwork`. Parser commands `path`, `terminal`, `connect`, `source_port`, `branch`, `radiation_port`, `wave_clock`, and `acoustic_network` now exist. Existing `tract_shape`, `glottis`, `tract_injection`, `nasal_branch`, and `tract` commands populate acoustic records as compatibility aliases while the current `Voice.Tract` Faust renderer still owns audio. - `acoustic` / `acoustic_voice` can now render an `AcousticPortNetwork` through a compact Faust response proxy or, when typed terminals are present, a compiled bidirectional Faust segment graph. Graph lowering splits paths at terminal positions, aggregates co-located terminals into graph nodes, orders connection ports deterministically, scatters area-weighted/pressure/bypass connection groups, injects source terminals even at connected nodes, and sums radiation terminals. Segment delay follows physical segment length and the network `wave_clock` strategy through unit-grid, half-sample, linear fractional, Lagrange, or Thiran/allpass Faust delay primitives. Source, branch, radiation, terminal, and connection controls can bind through ordinary Aqua parameters into emitted Faust. PT-shaped `tract` authoring now routes accepted parity through `propagation=graph`; the old waveguide parity lane is not a comparison baseline or historical pressure lane. - Pink Trombone log-mel parity now writes graph candidates only. Generated tract graphs mirror live `/pink/...` tract bindings into acoustic source, terminal, radiation, and path-area fields. Graph generation stopped baking first-frame tongue/constriction/lip morphology into the path; `AcousticPath.AreaControl` now turns tongue/constriction/lip controls into live area expressions at graph sample points. Velum owns nasal branch entrance diameter, which lowers through a squared parameter-binding transform into side-port admittance; generated nasal connections keep full connection coupling, and the nasal terminal carries the side-port admittance limit. The first nasal tube sample is no longer allowed to decide the velum opening. Lip opening owns path area and radiation aperture, not terminal area scaling. Graph radiation now uses aperture as a boundary impedance owner: lip/beak opening blends boundary reflection from near-closed termination to declared open-end reflection, names per-port boundary flow (`incoming - outgoing`), and weights output by bounded local terminal admittance rather than a fixed 4x output scalar. Latest static graph evidence after radiation admittance normalization is under `artifacts/parity/pink-trombone-logmel/20260527T170548495`: open/front/nasal/ma/sibilant/closure cosine 0.6675/0.7216/0.7251/0.7098/0.4862/0.6513; latest utterance evidence under `artifacts/parity/pink-trombone-utterance-logmel/20260527T170618466`: mama/papa/thrombosis cosine 0.7428/0.7830/0.5442 with rmsRatio 2.7955/2.4594/2.7397 and articulation 0.1288/0.1226/0.1151. The output is less absurdly loud, but articulation and speech-band motion are still the live failure. - - `docs/acoustic-graph-flow-audit.md` compares Aqua's graph to Birkholz/VTL, Story/TubeTalker, Smith waveguides, ArtiSynth, and PT/SndKit. The graph records can name the research-backed architecture, but current Faust lowering still mangles multi-port branch sample flow. The kept physical fix moves nasal coupling from global connection damping into transformed side-port admittance and emits a named three-port branch scatter for two same-path ports plus one side branch. Radiation now has named flow/admittance probes and local terminal-admittance weighting, reducing over-radiation without restoring the old damper. The three-port branch law also emits `graph_connection_energy_in_*` and `graph_connection_energy_out_*` probes so passivity can be inspected at the actual scatter site. Do not revert that ownership fix just because the next broken subsystem screams; next cut is passive/admittance-normalized three-port scattering plus graph-native pressure storage/release. + - `docs/acoustic-graph-flow-audit.md` compares Aqua's graph to Birkholz/VTL, Story/TubeTalker, Smith waveguides, ArtiSynth, and PT/SndKit. The graph records can name the research-backed architecture, but current Faust lowering still lacks graph-native closure pressure storage. The kept physical fixes move nasal coupling from global connection damping into transformed side-port admittance, emit a named three-port branch scatter for two same-path ports plus one side branch, and use pressure-continuity scattering for ordinary same-path two-port area discontinuities. Radiation now has named flow/admittance probes and local terminal-admittance weighting, reducing over-radiation without restoring the old damper. The graph clock for generated tract graphs is continuous fractional delay so adding terminals does not silently lengthen the morphology. Do not revert these ownership fixes just because the next broken subsystem screams; next cut is graph-native closure reservoir/source impedance, not global gain or PT-shaped modules. - Graph source lowering now names per-node incident pressure and node-local source sums inside the recursive graph loop. Generated tract injection source banks now use cell-centered positions and `1 / sections` index scaling, so turbulence/release energy is born inside tube cells rather than directly on graph/radiation nodes. Latest source-position artifact under `artifacts/parity/pink-trombone-utterance-logmel/20260527T172949293`: mama/papa/thrombosis cosine 0.6654/0.7746/0.5522, rmsRatio 3.0010/2.5712/2.4943, articulation 0.1444/0.1177/0.1193. Static closure-release RMS improved to 1.0078 under `artifacts/parity/pink-trombone-logmel/20260527T172843945`, but papa articulation worsened; keep the cell-centered source placement because it is the correct graph-level source geometry, not because metrics liked it. - TurbulenceJet now includes a release-timed burst-noise component in addition to the deterministic pressure pulse, but a stronger trial barely moved papa; the source is not the main remaining articulation bottleneck. Graph radiation now mixes 30% raw boundary flow with 70% high-passed flow after local admittance weighting, down from the over-bright 15/85 blend. Latest radiation/source artifact under `artifacts/parity/pink-trombone-utterance-logmel/20260527T174236049`: mama/papa/thrombosis cosine 0.6578/0.7692/0.5585, rmsRatio 3.0006/2.6153/2.3488, articulation 0.1437/0.1173/0.1191. Static `closure-release` under `artifacts/parity/pink-trombone-logmel/20260527T174139661` has rmsRatio 0.9900 and speechBandRatio 0.0842. This is still not speaking; next pressure is true tract resonance/passive scattering and pressure storage, not more burst gain. - Same-path two-port area discontinuities now emit `graph_area_energy_in_*` and `graph_area_energy_out_*` probes alongside the three-port branch `graph_connection_energy_*` probes. Use these to inspect passivity and formant-body failures at the scatter sites rather than judging only final output loudness. diff --git a/tests/AquaSynth.Dsl.Tests/PatchScriptTests.cs b/tests/AquaSynth.Dsl.Tests/PatchScriptTests.cs index e586e3f..a16d2c6 100644 --- a/tests/AquaSynth.Dsl.Tests/PatchScriptTests.cs +++ b/tests/AquaSynth.Dsl.Tests/PatchScriptTests.cs @@ -276,12 +276,12 @@ public sealed class PatchScriptTests Assert.NotEmpty(network.Terminals); Assert.Contains("voices_0_source", network.Terminals); Assert.Contains("voices_0_lip", network.Terminals); - Assert.Equal(WaveClockDelayStrategy.HalfSampleGrid, Assert.Single(patch.WaveClocks).Strategy); + Assert.Equal(WaveClockDelayStrategy.FractionalLinear, Assert.Single(patch.WaveClocks).Strategy); var export = FaustEmitter.Emit(patch, new FaustExportOptions("tract_graph")); Assert.Contains("acoustic_graph_radiated", export.Source); Assert.Contains("de.fdelay", export.Source); - Assert.Contains("max(0.5,", export.Source); + Assert.Contains("max(0.000001,", export.Source); Assert.DoesNotContain("tract_lf", export.Source); } @@ -324,6 +324,7 @@ public sealed class PatchScriptTests Assert.Contains("graph_connection_energy_out_voices_0_nose_connection", export.Source); Assert.Contains("graph_node_incident_pressure_", export.Source); Assert.Contains("graph_node_source_", export.Source); + Assert.Contains("graph_area_pressure_", export.Source); Assert.Contains("graph_area_energy_in_", export.Source); Assert.Contains("graph_area_energy_out_", export.Source); Assert.Contains("graph_radiation_admittance_voices_0_lip", export.Source);