diff --git a/docs/acoustic-graph-dsp-audit.md b/docs/acoustic-graph-dsp-audit.md index 65652d0..8a170d1 100644 --- a/docs/acoustic-graph-dsp-audit.md +++ b/docs/acoustic-graph-dsp-audit.md @@ -38,6 +38,28 @@ have a clean physical contract. That is the right high-level architecture. The weak parts are inside the lowering laws. +## 2026-05-28 Legacy Vocal Renderer Cut + +Owner: `AcousticPortNetwork` and typed graph lowering own vocal acoustics. + +Inputs: paths, terminals, connections, source ports, radiation ports, wave +clock, and ordinary Aqua parameter bindings. + +Outputs: one Faust graph loop plus named source, scattering, segment delay, and +radiation signals. + +Derived state: `tract`, `glottis`, `tract_injection`, and `nasal_branch` are +authoring conveniences that populate the acoustic graph records. + +Forbidden writers: the old `Voice.Tract` resonator, the old `Voice.Tract` +waveguide backend, and the acoustic response proxy no longer produce vocal +audio. Legacy `propagation=resonator`, `propagation=waveguide`, and related +aliases now fail at parse time. Invalid graph topology emits silence with a +warning instead of inventing a fallback body. + +Deletion line: do not restore a fake vocal renderer to make a test pass. If the +graph cannot express a vocal behavior, add or fix graph semantics. + ## Component Audit ### Topology Construction diff --git a/docs/physical-voice-modeling-research.md b/docs/physical-voice-modeling-research.md index 82faf2c..4b5e9cf 100644 --- a/docs/physical-voice-modeling-research.md +++ b/docs/physical-voice-modeling-research.md @@ -138,9 +138,10 @@ still needs generated named equations for tract-like acoustic networks because: - nasal, lateral, syrinx, and alien branch points need multi-port scattering rather than a fixed string/tube model. -The current `wg_loop ~ si.bus(...)` shape remains plausible as the low-level -state owner. It should learn from Faust's physical-modeling library instead of -pretending the library does not exist. +The old `wg_loop ~ si.bus(...)` tract backend was useful evidence, then became +a second vocal audio authority. It has been cut. The live state owner is the +typed acoustic graph (`graph_loop ~ si.bus(...)`), which should keep learning +from Faust's physical-modeling library without reviving a PT-shaped backend. ### Use Faust Library Delay Blocks Where They Match The Segment @@ -174,16 +175,17 @@ speech-like. ### Separate Fast Training From Final Rendering -Aqua should support at least two lowerings from the same acoustic morphology: +Aqua may eventually support at least two lowerings from the same acoustic +morphology, but only if their authority is explicit: -1. `waveguide-grid`: realtime Faust waveguide network for listening, gameplay, +1. `graph-waveguide`: realtime Faust graph network for listening, gameplay, and high-fidelity parity. -2. `response-proxy`: differentiable transfer-function or modal/SOS proxy for +2. `training-proxy`: differentiable transfer-function or modal/SOS proxy for fast optimization, initialized from the same geometry and periodically - checked against the waveguide render. + checked against the graph render. -That is not a cheat if the proxy is named and falsified by audio parity. It is -how the machine avoids making every gradient step pay for a full acoustic body. +That proxy is not allowed to be a fallback voice. It is acceptable only as a +named training artifact that cannot answer normal audio rendering requests. ## DSL Direction @@ -234,23 +236,19 @@ demotes to an `AcousticPath` plus `AcousticBranch`, and each `tract` voice gets an `AcousticPortNetwork` over generated oral/source/branch/radiation records. -The second cut gives those records an audible Faust proxy. An `acoustic` / -`acoustic_voice` command can reference an `acoustic_network`; Faust lowering -builds a compact source/body/radiation model from the declared source ports, -primary path, branches, and radiation ports. This is a response-proxy renderer, -not the final waveguide truth renderer: it derives modal resonances from path -length and area summaries, then mixes branch and radiation responses. It exists -so syrinx-like and alien topologies can be heard and tested before the full -bidirectional network lowering is complete. Source-port pressure/tension/opening -and branch/radiation opening-style controls can bind through normal Aqua -parameters, so the knobs used by training and playground surfaces are attached -to acoustic records instead of side-channel state. +The second cut made those records audible, and the teardown cut removed the +temporary response proxy. An `acoustic` / `acoustic_voice` command can reference +an `acoustic_network`; Faust lowering now compiles the typed terminals into a +bidirectional segment graph. Source-port pressure/tension/opening and +branch/radiation opening-style controls bind through normal Aqua parameters, so +the knobs used by training and playground surfaces are attached to acoustic +records instead of side-channel state. A syrinx can now be authored as two labial `source_port` records plus -bronchial/tract `branch` topology without a species mode. The next deeper cut -is to make `AcousticPortNetwork` own the waveguide renderer directly, at which -point `Voice.Tract` should become a larynx-shaped authoring convenience over -the same network rather than a separate audio authority. +bronchial/tract `branch` topology without a species mode. `AcousticPortNetwork` +now owns the vocal renderer directly; `Voice.Tract` is a larynx-shaped +authoring convenience over the same network rather than a separate audio +authority. The topology decision is now a path graph with typed terminals. `AcousticPath` owns tube geometry. `AcousticTerminal` owns a named position on a path and its diff --git a/docs/pink-trombone-dsl-parity-plan.md b/docs/pink-trombone-dsl-parity-plan.md index 8c5f5ce..46758fd 100644 --- a/docs/pink-trombone-dsl-parity-plan.md +++ b/docs/pink-trombone-dsl-parity-plan.md @@ -10,17 +10,18 @@ morphologies. ## Current Mechanism -`tract` currently lowers into `Voice.Tract`: a voice-local scalar control bundle -with a Faust source/filter proxy and an early waveguide backend. It is useful as -a playground surface and as a named failure against Pink Trombone, but the +`tract` currently lowers into a voice-local scalar control bundle plus a typed +`AcousticPortNetwork`. The graph is the only vocal-tract audio authority. The +old source/filter proxy and old tract waveguide backend are removed; legacy +propagation names now fail fast instead of quietly rendering a fake voice. The remaining anatomy ownership is still too discrete: - authored tract shapes now own physical length and continuous interpolation, and a tract voice may resample them to a chosen compiled grid; - `sections`, `nose_sections`, and integer junction indices still leak lowering grid choices into the script surface; -- `substeps` still exists as compatibility clock intent, but it should be - demoted in favor of acoustic length, propagation speed, and fractional delay; +- `substeps` is no longer a live lowering contract; acoustic length, + propagation speed, and fractional delay own timing; - topology changes can recompile, but morphology motion must remain runtime control data. @@ -38,11 +39,10 @@ remaining anatomy ownership is still too discrete: Aqua morphology model. - Reflection coefficients derive from adjacent areas. Caches and summaries may observe that derivation, but must not become independent truth. -- Waveguide clock derives from acoustic length, propagation speed, sample rate, - and delay approximation. A user-facing `substeps` count is only legacy - pressure until the fractional-delay waveguide owns this cleanly. -- Waveguide state owns delay-line propagation once it exists. Formant filters - may remain cheap approximations, but they must be named as approximations. +- Wave clock derives from acoustic length, propagation speed, sample rate, and + delay approximation. User-facing substeps must not own morphology timing. +- The typed acoustic graph owns delay-line propagation. Formant filters and + tract proxies are not valid fallbacks for voice parity. - Expressive parity comes before audio golf. Audio parity claims require rendered PT fixtures, Aqua renders, and log-mel cosine similarity. @@ -65,26 +65,24 @@ remaining anatomy ownership is still too discrete: transient behavior. - Can be driven by envelopes, LFOs, learned speech controls, or consonant gestures. - - Implemented as a named injection primitive consumed by `tract` voices and - distributed into waveguide section updates by position and width. + - Implemented as named graph source ports consumed by `tract` voices and + distributed over cell-centered source terminals by position and width. 4. `nasal_junction`: velum-controlled branch primitive. - Owns nasal opening and branch shape. - Derives the three-way junction coefficients from local areas. - - Implemented as `nasal_branch` plus generated three-way junction equations - when a waveguide tract references the branch. + - Implemented as `nasal_branch` sugar over acoustic path terminals and a + graph connection. -5. `waveguide_tract`: propagation primitive. +5. `acoustic_graph`: propagation primitive. - Owns right/left traveling-wave state, acoustic wave clock, fractional delay/loss approximation, and radiation. - Consumes area/reflection fields and source/injection events. - - First oral-tube lowering exists: generated right/left section equations - consume `tract_shape` reflection coefficients and boundary reflections. - - Waveguide lowering now derives live per-section diameter targets, areas, - and reflection coefficients from the tract shape plus tongue, constriction, - and lip controls before scattering. - Legacy substep clock intent is represented and lowering consumes it for - drive/loss scaling, but exact fractional-delay propagation remains missing. + - Graph lowering splits paths at typed terminals, emits bidirectional + segment state, and scatters two-port and N-port junctions from live area + and admittance. + - Tract graph generation derives live per-terminal area from the tract shape + plus tongue, constriction, and lip controls before scattering. 6. `tract_motion`: control-rate slew and obstruction history. - Owns diameter/constriction/velum slew rates and obstruction threshold. @@ -106,7 +104,7 @@ remaining anatomy ownership is still too discrete: ## First Cut Implemented owners: `tract_shape`, `glottis`, `tract_injection`, -`nasal_branch`, `tract_motion`, and first-pass `propagation=waveguide`. +`nasal_branch`, `tract_motion`, and graph-native `propagation=graph`. `tract_shape` owns section diameter/area fields and reflection derivation. `glottis` owns excitation quality. `tract_injection` owns positioned frication/burst pressure. The current Faust proxy consumes these primitives @@ -121,17 +119,10 @@ cosine 0.51 open vowel, 0.54 front vowel, 0.39 nasal, 0.12 sibilant, and -0.18 closure-release. That negative closure score correctly exposed the wrong machine. -The waveguide backend now uses a Faust-friendly state owner: -`wg_loop ~ si.bus(...)`. One feedback component owns the right/left oral and -nasal traveling-wave state instead of hundreds of named recursive equations. -The backend now resamples continuous geometry to an acoustic unit-delay grid -when a waveguide tract does not explicitly request `sections=...`; a 17 cm oral -tract renders as 22 compiled sections at the current 44.1 kHz target instead of -leaking PT's 44 half-sample cells into Aqua as anatomy. Current waveguide -baseline: open vowel 0.6143, front vowel 0.6349, nasal 0.5425, sibilant -0.3744, closure-release -0.0820. Those are pressure readings, not parity. The -vowel/nasal/sibilant cases now respond to the physical clock correction and -runtime index scaling; the closure fixture remains an exposed failure. +The old `wg_loop ~ si.bus(...)` backend is now commit history, not a live +lowering. Graph output uses `graph_loop ~ si.bus(...)`, physical segment +lengths, and fractional delay. Generated tract graphs preserve declared +morphology unless the author explicitly asks for another compiled grid. The continuous morphology cut has started. `tract_shape length_cm=...` is now physical geometry, not just a list length. `TractAreaFunction` can interpolate @@ -150,15 +141,12 @@ The acoustic graph cut has also started. Aqua now has neutral model records for `terminal`, `connect`, `source_port`, `branch`, `radiation_port`, `wave_clock`, and `acoustic_network` can express a larynx, paired labial syrinx-like sources, a nasal/oral junction, or stranger source/topology -combinations without adding a species mode. Existing PT-shaped commands now -populate those acoustic records as compatibility aliases: source ports and +combinations without adding a species mode. Existing PT-shaped commands +populate those acoustic records as authoring aliases: source ports and radiation ports create typed terminals, while `branch` creates branch endpoint -terminals plus a connection. A first `acoustic` voice command now lowers an -`AcousticPortNetwork` to an audible Faust response proxy, so non-larynx -topologies can be heard before the full waveguide network owns them. Source, -branch, and radiation fields can be bound to parameters and survive into the -emitted Faust, which keeps playground/training knobs attached to declared -acoustic owners instead of dead UI state. +terminals plus a connection. `acoustic` and `tract` voices lower through the +same compiled graph; missing or invalid graph topology renders silence with a +warning rather than falling back to a pretend tract. ### Graph ownership decision @@ -187,24 +175,24 @@ parity. The old waveguide lane is not a baseline, pressure lane, or fallback. Authority map for the required rebuild: -- Owner: the acoustic network lowering must own an ordered scattering graph, - not `Voice.Tract` and not the response proxy. +- Owner: the acoustic network lowering owns an ordered scattering graph, not + `Voice.Tract`, not the removed tract waveguide, and not a response proxy. - Inputs: continuous paths, typed terminals, connections, source/radiation ports, branch sugar, wave-clock policy, and live parameter bindings. - Outputs: Faust state for delay-line segments, source injection points, junction scattering, radiation, and diagnostics. -- Derived state: `tract`/`nasal_branch` become larynx/PT-shaped authoring - conveniences over the same acoustic graph; the response proxy remains a - preview renderer only. -- Forbidden writers: `Voice.Tract` must stop being a parallel audio authority - once graph lowering exists; branch/radiation/source controls must not be - repaired by a separate playground model. +- Derived state: `tract`/`nasal_branch` are larynx/PT-shaped authoring + conveniences over the same acoustic graph. +- Forbidden writers: `Voice.Tract`, legacy propagation modes, and response + proxies must not produce alternate vocal audio; branch/radiation/source + controls must not be repaired by a separate playground model. - Shared paths: direct DSL authoring, PT compatibility commands, future syrinx/reed/alien voices, and training/playground parameter bindings must all commit through the same acoustic graph. -- Deletion line: do not expand the proxy into a second fake synthesizer. - `AcousticTerminal`/`AcousticConnection` records now own graph lowering; - `branch` can remain only as shorthand that emits those records. +- Deletion line: do not expand the proxy or revive the old waveguide into a + second fake synthesizer. `AcousticTerminal`/`AcousticConnection` records own + graph lowering; `branch` can remain only as shorthand that emits those + records. Exact Pink Trombone timing still needs pressure, but the next backend cut is no longer "add more substeps." The graph renderer now has fractional-delay clock diff --git a/patches/aquasynth-patch-cultcache.cc b/patches/aquasynth-patch-cultcache.cc index 7b1a712..ecec114 100644 Binary files a/patches/aquasynth-patch-cultcache.cc and b/patches/aquasynth-patch-cultcache.cc differ diff --git a/src/AquaSynth.Core/BuiltInScripts.cs b/src/AquaSynth.Core/BuiltInScripts.cs index 979eb5e..29ac09a 100644 --- a/src/AquaSynth.Core/BuiltInScripts.cs +++ b/src/AquaSynth.Core/BuiltInScripts.cs @@ -668,9 +668,8 @@ public static class BuiltInScripts injection=pt_constriction nasal_branch=pt_nose motion=pt_motion - propagation=waveguide - waveguide_loss=0.999 - substeps=2 + propagation=graph + loss=0.999 freq=@/pink/frequency gain=0.7 attack=0.004 @@ -1156,7 +1155,7 @@ public static class BuiltInScripts foreach (var item in Classic808PrimitiveGolfScripts) yield return ("808", item.Name, item.Script); foreach (var item in FmBellPrimitiveGolfScripts) yield return ("fm-bell", item.Name, item.Script); foreach (var item in WobbleBassPrimitiveGolfScripts) yield return ("wobble-bass", item.Name, item.Script); - yield return ("pink-trombone", "current-aquasynth-proxy", PinkTromboneProxy); + yield return ("pink-trombone", "current-aquasynth-graph", PinkTromboneProxy); foreach (var item in ReferenceRebuildCatalog.Dx7Rebuilds) yield return ("dx7", item.Name, item.Script); foreach (var item in ReferenceRebuildCatalog.ZynRebuilds) yield return ("zynaddsubfx", item.Name, item.Script); foreach (var item in AdvancedReferenceScripts) yield return ("advanced", item.Name, item.Script); diff --git a/src/AquaSynth.Core/CultCachePatchDocument.cs b/src/AquaSynth.Core/CultCachePatchDocument.cs index c5b66d8..0b51b36 100644 --- a/src/AquaSynth.Core/CultCachePatchDocument.cs +++ b/src/AquaSynth.Core/CultCachePatchDocument.cs @@ -175,6 +175,7 @@ public static class CultCachePatchDocumentCatalog PatchClaim("zyn/project-additive-lead/aquasynth", null, "ZynAddSubFX project-authored fixture", "tests/AquaSynth.Dsl.Tests/Fixtures/ZynAddSubFX/ProjectAuthored/additive-lead.xiz", "project-authored development fixture", "A layered additive lead expressed as named harmonic banks rather than anonymous partial piles.", "Zyn ADDsynth pressure for AquaSynth harmonic-bank syntax.", "pressure", "ReferenceRebuildCatalog.ZynRebuilds", MissingReceipt("tests/AquaSynth.Dsl.Tests/Fixtures/ZynAddSubFX/ProjectAuthored/additive-lead.xiz vs AquaSynth additive lead rebuild", "harmonic-bank naming and rebuild topology", "No accepted listening pass yet; Zyn oscillator phase/bandwidth and free-envelope timing remain contaminated.", "No witness yet. The card is still waiting for ears instead of paperwork."), "structural pressure only", ["not exact Zyn ADDsynth oscillator phase/bandwidth semantics", "not exact Zyn free-envelope timing"]), PatchClaim("zyn/project-pad-texture/aquasynth", null, "ZynAddSubFX project-authored fixture", "tests/AquaSynth.Dsl.Tests/Fixtures/ZynAddSubFX/ProjectAuthored/pad-texture.xiz", "project-authored development fixture", "A slow layered PAD texture with body, shimmer, air, and explicit spectral-cloud source authority.", "PAD syntax and FFT wavetable pressure.", "pressure", "artifacts/parity/zyn-pad-reference// when optional Zyn oracle is installed", new CultCacheListeningReceipt("tests/AquaSynth.Dsl.Tests/Fixtures/ZynAddSubFX/ProjectAuthored/pad-texture.xiz vs project-authored AquaSynth pad-texture rebuild", "optional Zyn PAD render comparison, log-mel/envelope report, and manual listening pass on the latest angry-bees candidate", "Early ear pass rejected the candidate; no accepted receipt exists yet, and full Zyn PAD profile/randomness/pitch-zone behavior still contaminates the claim.", "The thing still swarmed instead of blooming, so the witness sent it back into the tank."), "optional Zyn PAD render comparison writes log-mel/envelope report", ["not full Zyn PAD profile/randomness/pitch-zone behavior", "not arbitrary Zyn free-envelope curves"]), PatchClaim("zyn/project-vocal-layer/aquasynth", null, "ZynAddSubFX project-authored fixture", "tests/AquaSynth.Dsl.Tests/Fixtures/ZynAddSubFX/ProjectAuthored/vocal-layer.xiz", "project-authored development fixture", "A layered vocal-ish synth where air, body, and breath remain inspectable sound objects.", "Formant/layer pressure before the full speech lane.", "pressure", "ReferenceRebuildCatalog.ZynRebuilds", MissingReceipt("tests/AquaSynth.Dsl.Tests/Fixtures/ZynAddSubFX/ProjectAuthored/vocal-layer.xiz vs AquaSynth vocal-layer rebuild", "formant/layer pressure structure", "No accepted listening pass yet; Zyn kit-item/effect routing and moving formant behavior remain contaminated.", "No witness yet. It may sing, or it may commit fraud in a choir robe."), "structural pressure only", ["no exact Zyn kit-item/effect routing", "formant motion remains approximate"]), + PatchClaim("pink-trombone/current-aquasynth-graph", null, "Pink Trombone modular waveguide", "src/AquaSynth.Core/PinkTromboneReference.cs", "MIT source-readable parity pressure", "AquaSynth expresses the PT pressure lane as typed acoustic graph records rather than a source-filter proxy.", "Speech anatomy pressure for the graph-native vocal tract.", "pressure", "PinkTromboneLogMelParityTests graph artifacts", MissingReceipt("Pink Trombone reference renderer versus AquaSynth typed acoustic graph rebuild", "typed acoustic graph lowering, log-mel reports, and user listening corrections", "No accepted speech witness yet; closure/contact state and source impedance remain contaminated.", "The old proxy is dead. The graph still has to earn its aria."), "structural graph lowering plus non-passing log-mel pressure", ["not intelligible speech parity yet", "closure/contact pressure storage remains incomplete", "glottal source is bounded but not exact PT LF coefficients"]), PatchClaim("dx7/algo32-additive-organ/aquasynth", "patches/dx7/algorithm-32-additive-organ.aqua", "DX7 algorithm topology", "in-code topology reference", "derived structural reference", "DX7 algorithm 32 as the easy six-carrier additive case.", "Operator topology pressure where AquaSynth should avoid inventing FM machinery it does not need.", "sketch", "parser/export tests", MissingReceipt("patches/dx7/algorithm-32-additive-organ.aqua against DX7 algorithm 32 topology notes", "parser/export structure checks for six visible carriers", "No listening claim exists; DX7 envelope execution and ROM output compensation still contaminate any audible verdict.", "No witness yet. This one is still topology paperwork pretending to be a sound."), "structural tests only", ["not exact DX7 envelope execution", "not ROM output compensation"]), PatchClaim("dx7/algo8-bright-pair/aquasynth", "patches/dx7/algorithm-8-bright-pair.aqua", "DX7 algorithm topology", "in-code topology reference", "derived structural reference", "DX7 algorithm 8 as an explicit AquaSynth operator graph with visible modulation routes.", "Operator graph pressure for summed stacks and feedback.", "pressure", "parser/export tests", MissingReceipt("patches/dx7/algorithm-8-bright-pair.aqua against DX7 algorithm 8 topology notes", "operator-graph route layout, summed stack structure, and feedback ownership", "No accepted listening pass exists; DX7 feedback calibration and exact EG execution still contaminate the audible claim.", "No witness yet. The graph reads clean, but nobody has signed off on the bite."), "structural tests only", ["not calibrated DX7 feedback register", "not exact DX7 EG"]), PatchClaim("dx7/public-domain-mc-mm-5-3/aquasynth", "patches/dx7/public-domain-mc-mm-5-3.aqua", "Dexed/dexed-py render of public-domain DX7 SysEx", "tests/AquaSynth.Dsl.Tests/Fixtures/Dx7/PublicDomain/analog1.syx#13", "public-domain development fixture; not packaged", "A short C3-derived sine-like DX7 voice rebuilt as an AquaSynth parity rung.", "Lawful rendered-audio parity proof for the DX7 lane.", "parity", "Dx7ReferenceParityTests optional dexed-py/Faust render report", new CultCacheListeningReceipt("tests/AquaSynth.Dsl.Tests/Fixtures/Dx7/PublicDomain/analog1.syx#13 versus patches/dx7/public-domain-mc-mm-5-3.aqua", "Dexed reference render, Faust candidate render, log-mel/envelope gate, and manual parity listening", "Metrics pass, but operator-level execution is still not exact DX7 and the receipt does not claim keyboard-feel parity.", "The rebuilt tone bites close enough to the reference to count, even if the machinery under the hood is still wearing AquaSynth clothes."), "score>=0.75 log_mel<0.12 envelope<0.10", ["matches rendered behavior, not exact operator-level execution", "uses AquaSynth ADSR timing matched to audio"]), diff --git a/src/AquaSynth.Core/FaustExport.cs b/src/AquaSynth.Core/FaustExport.cs index faccc17..b9d758f 100644 --- a/src/AquaSynth.Core/FaustExport.cs +++ b/src/AquaSynth.Core/FaustExport.cs @@ -184,10 +184,10 @@ public static class FaustEmitter var dutyExpression = $"clip01({parameters.Expression(OwnerField(ownerPath, "osc/duty"), voice.Oscillator.Duty)} + {parameters.Expression(OwnerField(ownerPath, "duty/ramp"), voice.Duty.RampPerSecond)} * age + patch_mod_duty + {duty})"; var fmIndex = $"max(0.0, {parameters.Expression(OwnerField(ownerPath, "fm/index"), voice.Fm.Index)} + patch_mod_fm_index + {fmIndexMod}) * {FmDecay(parameters.Expression(OwnerField(ownerPath, "fm/decay"), voice.Fm.IndexDecaySeconds), voice.Fm.IndexDecaySeconds, parameters.IsBound(OwnerField(ownerPath, "fm/decay")))}"; var oscillator = oscillatorOverride ?? - (voice.Tract is { Propagation: TractPropagationMode.Graph } && voice.AcousticNetwork is { } tractGraph + (voice.Tract is not null && voice.AcousticNetwork is { } tractGraph ? AcousticNetworkExpression(source, patch, tractGraph, ownerPath, name, frequency, parameters, warnings, options) - : voice.Tract is { } tract - ? TractExpression(source, tract, ownerPath, name, frequency, noteGate, parameters) + : voice.Tract is not null + ? MissingGraphTractExpression(source, warnings, name) : voice.AcousticNetwork is { } acousticNetwork ? AcousticNetworkExpression(source, patch, acousticNetwork, ownerPath, name, frequency, parameters, warnings, options) : OscillatorExpression(patch, voice, ownerPath, frequency, dutyExpression, fmIndex, parameters)); @@ -421,89 +421,15 @@ public static class FaustEmitter } } - var sourceExpressions = new List(); - foreach (var sourceName in network.SourcePorts) - { - if (!sources.TryGetValue(sourceName, out var port)) - { - warnings.Add($"{name}: acoustic network `{network.Name}` has unknown source port `{sourceName}`"); - continue; - } - sourceExpressions.Add(AcousticSourceExpression(patch, port, frequency, parameters)); - } - if (sourceExpressions.Count == 0) - { - sourceExpressions.Add("0.0"); - warnings.Add($"{name}: acoustic network `{network.Name}` has no valid source ports"); - } + warnings.Add($"{name}: acoustic network `{network.Name}` has no valid graph terminals; graph audio is silent"); + return "0.0"; + } - var baseInput = $"({string.Join(" + ", sourceExpressions)})"; - var lengthMeters = Math.Max(0.001f, primaryPath.AreaFunction.LengthMeters); - var quarterWave = primaryPath.PropagationSpeedMetersPerSecond / (4 * lengthMeters); - var back = primaryPath.AreaFunction.AverageDiameter(0.1f, 0.35f); - var middle = primaryPath.AreaFunction.AverageDiameter(0.35f, 0.7f); - var front = primaryPath.AreaFunction.AverageDiameter(0.7f, 1f); - var reflectionEnergy = primaryPath.AreaFunction.ReflectionCoefficients.Count == 0 - ? 0.12f - : MathF.Min(1, primaryPath.AreaFunction.ReflectionCoefficients.Sum(item => MathF.Abs(item)) / primaryPath.AreaFunction.ReflectionCoefficients.Count); - var loss = F(Math.Clamp(primaryPath.Loss, 0, 1)); - var q = F(2.5f + reflectionEnergy * 8f + (1 - Math.Clamp(primaryPath.Loss, 0, 1)) * 18f); - source.AppendLine($"{name}_acoustic_source = {baseInput};"); - source.AppendLine($"{name}_acoustic_f1 = max(40.0, {F(quarterWave)} * (1.0 + {F(back - middle)} * 0.18));"); - source.AppendLine($"{name}_acoustic_f2 = max(80.0, {F(quarterWave * 3)} * (1.0 + {F(middle - front)} * 0.14));"); - source.AppendLine($"{name}_acoustic_f3 = max(120.0, {F(quarterWave * 5)} * (1.0 + {F(front - back)} * 0.10));"); - source.AppendLine($"{name}_acoustic_body = ({name}_acoustic_source * 0.12 + ({name}_acoustic_source : fi.resonbp({name}_acoustic_f1, {q}, 1.0)) * 0.9 + ({name}_acoustic_source : fi.resonbp({name}_acoustic_f2, {q}, 1.0)) * 0.65 + ({name}_acoustic_source : fi.resonbp({name}_acoustic_f3, {q}, 1.0)) * 0.35) * {loss};"); - - var branchExpressions = new List(); - foreach (var branchName in network.Branches) - { - if (!branches.TryGetValue(branchName, out var branch) || - !paths.TryGetValue(branch.ToPath, out var branchPath)) - { - warnings.Add($"{name}: acoustic network `{network.Name}` has unknown branch `{branchName}`"); - continue; - } - - var branchLength = Math.Max(0.001f, branchPath.AreaFunction.LengthMeters); - var branchQuarterWave = branchPath.PropagationSpeedMetersPerSecond / (4 * branchLength); - var branchIndex = AcousticBranchIndex(patch, branch); - var branchPathName = $"/acoustic/branches/{branchIndex}"; - var branchOpening = $"clip01({parameters.Expression(OwnerField(branchPathName, "opening"), branch.Opening)})"; - var branchCoupling = $"max(0.0, {parameters.Expression(OwnerField(branchPathName, "coupling"), branch.Coupling)})"; - var branchQ = F(2f + Math.Clamp(branch.Coupling, 0, 1) * 8f); - var branchKindGain = branch.Kind == AcousticBranchKind.Nasal ? "0.75" : branch.Kind == AcousticBranchKind.Bronchial ? "0.55" : "0.45"; - source.AppendLine($"{name}_branch_{SafeIdentifier(branch.Name)} = ({name}_acoustic_source : fi.resonbp({F(branchQuarterWave)}, {branchQ}, 1.0) : fi.lowpass(2, {F(branchQuarterWave * 8)})) * {branchOpening} * {branchCoupling} * {branchKindGain};"); - branchExpressions.Add($"{name}_branch_{SafeIdentifier(branch.Name)}"); - } - - var radiationExpressions = new List(); - foreach (var radiationName in network.RadiationPorts) - { - if (!radiation.TryGetValue(radiationName, out var port)) - { - warnings.Add($"{name}: acoustic network `{network.Name}` has unknown radiation port `{radiationName}`"); - continue; - } - - var radiationIndex = AcousticRadiationPortIndex(patch, port); - var radiationPath = $"/acoustic/radiation/{radiationIndex}"; - var opening = $"max(0.0, {parameters.Expression(OwnerField(radiationPath, "opening"), port.Opening)})"; - var reflection = $"min(1.0, abs({parameters.Expression(OwnerField(radiationPath, "reflection"), port.Reflection)}))"; - var portLoss = $"clip01({parameters.Expression(OwnerField(radiationPath, "loss"), port.Loss)})"; - var aperture = RadiationApertureExpression(patch, parameters, port); - var highpass = RadiationHighpassExpression(port.Kind, aperture, false); - var reflectionWeight = $"(0.55 + 0.45 * {reflection})"; - radiationExpressions.Add($"(({name}_acoustic_body : fi.highpass(1, {highpass})) * {opening} * {reflectionWeight} * {portLoss})"); - } - if (radiationExpressions.Count == 0) - { - radiationExpressions.Add($"{name}_acoustic_body"); - } - - var branchMix = branchExpressions.Count == 0 ? "0.0" : string.Join(" + ", branchExpressions); - source.AppendLine($"{name}_acoustic_branches = {branchMix};"); - source.AppendLine($"{name}_acoustic_radiated = ({string.Join(" + ", radiationExpressions)}) + {name}_acoustic_branches;"); - return $"{name}_acoustic_radiated"; + private static string MissingGraphTractExpression(StringBuilder source, List warnings, string name) + { + warnings.Add($"{name}: vocal tract has no acoustic graph network; graph audio is silent"); + source.AppendLine($"{name}_acoustic_graph_radiated = 0.0;"); + return $"{name}_acoustic_graph_radiated"; } private static string AcousticGraphExpression( @@ -537,7 +463,7 @@ public static class FaustEmitter } if (networkTerminals.Count < 2) { - warnings.Add($"{name}: acoustic graph `{network.Name}` needs at least two valid terminals; using response proxy"); + warnings.Add($"{name}: acoustic graph `{network.Name}` needs at least two valid terminals; graph audio is silent"); return ""; } @@ -615,7 +541,7 @@ public static class FaustEmitter if (segments.Count == 0) { - warnings.Add($"{name}: acoustic graph `{network.Name}` produced no path segments; using response proxy"); + warnings.Add($"{name}: acoustic graph `{network.Name}` produced no path segments; graph audio is silent"); return ""; } @@ -979,318 +905,6 @@ public static class FaustEmitter return $"clip01(1.0 - abs({F(port.Position)} - ({target})) / ({radius}))"; } - private static string TractExpression( - StringBuilder source, - VocalTract tract, - string ownerPath, - string name, - string frequency, - string gate, - ParameterMap parameters) - { - var tractPath = OwnerField(ownerPath, "tract"); - var sections = Math.Max(4, tract.Sections); - var hasNose = tract.NoseSections > 0; - var intensity = $"clip01({parameters.Expression(OwnerField(tractPath, "intensity"), tract.Intensity)})"; - var tenseness = $"clip01({parameters.Expression(OwnerField(tractPath, "tenseness"), tract.Tenseness)})"; - var motion = tract.Motion; - var diameterSlew = parameters.Expression(OwnerField(tractPath, "motion/diameter_slew"), motion?.DiameterSlewPerSecond ?? 18); - var shapeReturn = parameters.Expression(OwnerField(tractPath, "motion/shape_return"), motion?.ShapeReturnPerSecond ?? 8); - var constrictionSlew = parameters.Expression(OwnerField(tractPath, "motion/constriction_slew"), motion?.ConstrictionSlewPerSecond ?? 24); - var velumSlew = parameters.Expression(OwnerField(tractPath, "motion/velum_slew"), motion?.VelumSlewPerSecond ?? 16); - var obstructionThreshold = parameters.Expression(OwnerField(tractPath, "motion/obstruction_threshold"), motion?.ObstructionThreshold ?? 0.05f); - var tongueIndexPath = OwnerField(tractPath, "tongue_index"); - var tongueDiameterPath = OwnerField(tractPath, "tongue_diameter"); - var velumPath = OwnerField(tractPath, "velum"); - var constrictionIndexPath = OwnerField(tractPath, "constriction_index"); - var constrictionDiameterPath = OwnerField(tractPath, "constriction_diameter"); - var lipOpeningPath = OwnerField(tractPath, "lip_opening"); - var indexScale = F(tract.IndexScale); - var tongueIndexRaw = ScaleIndex(parameters.Expression(tongueIndexPath, tract.TongueIndex)); - var tongueDiameterRaw = parameters.Expression(tongueDiameterPath, tract.TongueDiameter); - var velumRaw = $"clip01(({parameters.Expression(velumPath, tract.Velum)} - 0.01) / 0.39)"; - var constrictionIndexRaw = ScaleIndex(parameters.Expression(constrictionIndexPath, tract.ConstrictionIndex)); - var constrictionDiameterRaw = parameters.Expression(constrictionDiameterPath, tract.ConstrictionDiameter); - var tongueIndexValue = SmoothControl(motion, parameters, tongueIndexPath, diameterSlew, tongueIndexRaw); - var tongueDiameterValue = SmoothControl(motion, parameters, tongueDiameterPath, diameterSlew, tongueDiameterRaw); - var velumValue = SmoothControl(motion, parameters, velumPath, velumSlew, velumRaw); - var constrictionIndexValue = SmoothControl(motion, parameters, constrictionIndexPath, constrictionSlew, constrictionIndexRaw); - var constrictionDiameterValue = SmoothControl(motion, parameters, constrictionDiameterPath, constrictionSlew, constrictionDiameterRaw); - var turbulence = $"clip01({parameters.Expression(OwnerField(tractPath, "turbulence"), tract.Turbulence)})"; - var lipOpening = parameters.Expression(lipOpeningPath, tract.LipOpening); - var glottalReflection = parameters.Expression(OwnerField(tractPath, "glottal_reflection"), tract.GlottalReflection); - var lipReflection = parameters.Expression(OwnerField(tractPath, "lip_reflection"), tract.LipReflection); - var areaFunction = tract.AreaFunction; - var glottis = tract.Glottis; - var injection = tract.Injection; - var shapeBack = F(areaFunction?.AverageDiameter(0.18f, 0.38f) ?? 1.35f); - var shapeMiddle = F(areaFunction?.AverageDiameter(0.38f, 0.68f) ?? 1.5f); - var shapeFront = F(areaFunction?.AverageDiameter(0.68f, 0.96f) ?? 1.5f); - var shapeMinimum = F(areaFunction?.MinimumDiameter ?? 0.6f); - var reflectionEnergy = F(areaFunction is null ? 0.12f : MathF.Min(1, areaFunction.ReflectionCoefficients.Sum(reflection => MathF.Abs(reflection)) / Math.Max(1, areaFunction.ReflectionCoefficients.Count))); - var aspiration = $"clip01({parameters.Expression(OwnerField(tractPath, "glottis/aspiration"), glottis?.Aspiration ?? 0.08f)})"; - var glottalSkew = $"clip01({parameters.Expression(OwnerField(tractPath, "glottis/skew"), glottis?.Skew ?? 0.42f)})"; - var injectionPositionPath = OwnerField(tractPath, "injection/position"); - var injectionDiameterPath = OwnerField(tractPath, "injection/diameter"); - var injectionPositionRaw = ScaleIndex(parameters.Expression(injectionPositionPath, injection?.Position ?? tract.ConstrictionIndex)); - var injectionDiameterRaw = parameters.Expression(injectionDiameterPath, injection?.Diameter ?? tract.ConstrictionDiameter); - var injectionPositionValue = SmoothControl(motion, parameters, injectionPositionPath, constrictionSlew, injectionPositionRaw); - var injectionDiameterValue = SmoothControl(motion, parameters, injectionDiameterPath, constrictionSlew, injectionDiameterRaw); - var injectionTurbulence = $"clip01({parameters.Expression(OwnerField(tractPath, "injection/turbulence"), injection?.Turbulence ?? tract.Turbulence)})"; - var injectionBurst = $"clip01({parameters.Expression(OwnerField(tractPath, "injection/burst"), injection?.Burst ?? 0)})"; - var injectionWidth = $"max(1.0, {ScaleIndex(parameters.Expression(OwnerField(tractPath, "injection/width"), injection?.Width ?? 1))})"; - - source.AppendLine($"{name}_tract_phase = os.phasor(1.0, {frequency});"); - source.AppendLine($"{name}_tract_tongue_index = {tongueIndexValue};"); - source.AppendLine($"{name}_tract_tongue_diameter = {tongueDiameterValue};"); - source.AppendLine($"{name}_tract_velum = {velumValue};"); - source.AppendLine($"{name}_tract_constriction_index = {constrictionIndexValue};"); - source.AppendLine($"{name}_tract_constriction_diameter = {constrictionDiameterValue};"); - source.AppendLine($"{name}_tract_injection_index = {injectionPositionValue};"); - source.AppendLine($"{name}_tract_injection_diameter = {injectionDiameterValue};"); - var tongueIndex = $"{name}_tract_tongue_index"; - var tongueDiameter = $"{name}_tract_tongue_diameter"; - var velum = $"{name}_tract_velum"; - var constrictionIndex = $"{name}_tract_constriction_index"; - var constrictionDiameter = $"{name}_tract_constriction_diameter"; - var injectionPosition = $"{name}_tract_injection_index"; - var injectionDiameter = $"{name}_tract_injection_diameter"; - source.AppendLine($"{name}_tract_tongue_pos = clip01({tongueIndex} / {F(sections)});"); - source.AppendLine($"{name}_tract_constriction_pos = clip01({constrictionIndex} / {F(sections)});"); - source.AppendLine($"{name}_tract_injection_pos = clip01({injectionPosition} / {F(sections)});"); - source.AppendLine($"{name}_tract_tongue_close = clip01((3.5 - {tongueDiameter}) / 3.5);"); - source.AppendLine($"{name}_tract_constriction_close = clip01((1.15 - {constrictionDiameter}) / 1.15);"); - source.AppendLine($"{name}_tract_injection_close = clip01((1.15 - {injectionDiameter}) / max(0.05, 1.15 * {injectionWidth}));"); - source.AppendLine($"{name}_tract_lip = clip01({lipOpening} / 2.5);"); - source.AppendLine($"{name}_tract_shape_back = {shapeBack};"); - source.AppendLine($"{name}_tract_shape_middle = {shapeMiddle};"); - source.AppendLine($"{name}_tract_shape_front = {shapeFront};"); - source.AppendLine($"{name}_tract_shape_min = {shapeMinimum};"); - source.AppendLine($"{name}_tract_reflection_energy = {reflectionEnergy};"); - source.AppendLine($"{name}_tract_q = 2.0 + {tenseness} * 10.0 + {name}_tract_constriction_close * 8.0 + {name}_tract_reflection_energy * 4.0;"); - source.AppendLine($"{name}_tract_f1 = max(90.0, 260.0 + {name}_tract_lip * 720.0 - {name}_tract_tongue_close * 260.0 + ({name}_tract_shape_back - 1.35) * 210.0 - (1.0 - {name}_tract_shape_min) * 120.0 + {velum} * 120.0);"); - source.AppendLine($"{name}_tract_f2 = max(180.0, 820.0 + {name}_tract_tongue_pos * 1850.0 - {name}_tract_tongue_close * 640.0 + ({name}_tract_shape_middle - 1.5) * 360.0 - (1.0 - {name}_tract_lip) * 260.0);"); - source.AppendLine($"{name}_tract_f3 = max(500.0, 1900.0 + {name}_tract_constriction_pos * 2600.0 + {name}_tract_tongue_close * 700.0 + ({name}_tract_shape_front - 1.5) * 520.0);"); - source.AppendLine($"{name}_tract_lf_open = select2({name}_tract_phase < (0.42 + {glottalSkew} * 0.36), -0.28 * sin(ma.PI * ({name}_tract_phase - (0.42 + {glottalSkew} * 0.36)) / max(0.001, 1.0 - (0.42 + {glottalSkew} * 0.36))), sin(ma.PI * {name}_tract_phase / max(0.001, 0.42 + {glottalSkew} * 0.36)));"); - source.AppendLine($"{name}_tract_lf = ({name}_tract_lf_open - (0.12 + {tenseness} * 0.62) * sin(4.0 * ma.PI * {name}_tract_phase)) * {intensity} * (0.45 + 0.75 * pow(max(0.0, {tenseness}), 0.35));"); - source.AppendLine($"{name}_tract_aspiration = no.noise * {intensity} * {aspiration} * (1.0 - sqrt(max(0.0, {tenseness}))) * (0.08 + 0.22 * {name}_tract_constriction_close);"); - source.AppendLine($"{name}_tract_frication = no.noise * max({turbulence} * {name}_tract_constriction_close, {injectionTurbulence} * {name}_tract_injection_close) * {intensity} * (0.25 + 0.75 * {name}_tract_injection_pos) * (0.2 + 0.8 * {tenseness});"); - source.AppendLine($"{name}_tract_prev_injection_close = {name}_tract_injection_close : mem;"); - source.AppendLine($"{name}_tract_obstructed = select2({injectionDiameter} < {obstructionThreshold}, 0.0, 1.0);"); - source.AppendLine($"{name}_tract_prev_obstructed = {name}_tract_obstructed : mem;"); - source.AppendLine($"{name}_tract_release_opening = max(0.0, {name}_tract_prev_injection_close - {name}_tract_injection_close) * {name}_tract_prev_obstructed;"); - source.AppendLine($"{name}_tract_release_memory = {name}_tract_release_opening : + ~ *(0.935);"); - source.AppendLine($"{name}_tract_burst = no.noise * {name}_tract_release_memory * {injectionBurst} * {intensity};"); - source.AppendLine($"{name}_tract_excitation = ({name}_tract_lf + {name}_tract_aspiration + {name}_tract_burst) * (0.55 + 0.45 * abs({glottalReflection}));"); - source.AppendLine($"{name}_tract_injection_pressure = {name}_tract_frication * (0.55 + 0.45 * abs({glottalReflection}));"); - source.AppendLine($"{name}_tract_raw = {name}_tract_excitation + {name}_tract_injection_pressure;"); - if (tract.Propagation == TractPropagationMode.Waveguide && areaFunction is not null) - { - return TractWaveguideExpression( - source, - tract, - areaFunction, - name, - glottalReflection, - lipReflection, - velum, - injectionWidth, - tongueIndex, - tongueDiameter, - constrictionIndex, - constrictionDiameter, - lipOpening, - shapeReturn, - motion is not null && ( - parameters.IsBound(tongueIndexPath) || - parameters.IsBound(tongueDiameterPath) || - parameters.IsBound(constrictionIndexPath) || - parameters.IsBound(constrictionDiameterPath) || - parameters.IsBound(lipOpeningPath))); - } - - source.AppendLine($"{name}_tract_oral = {name}_tract_raw * 0.18 + ({name}_tract_raw : fi.resonbp({name}_tract_f1, {name}_tract_q, 1.0)) * (0.75 + {name}_tract_lip * 0.65) + ({name}_tract_raw : fi.resonbp({name}_tract_f2, {name}_tract_q, 1.0)) * (0.85 + {name}_tract_tongue_close) + ({name}_tract_raw : fi.resonbp({name}_tract_f3, {name}_tract_q, 1.0)) * (0.35 + {name}_tract_constriction_close);"); - if (hasNose) - { - source.AppendLine($"{name}_tract_nose = ({name}_tract_raw : fi.resonbp(260.0 + {velum} * 560.0, 3.0 + {velum} * 9.0, 1.0) : fi.lowpass(2, 2400.0 + {velum} * 1200.0)) * {velum};"); - } - else - { - source.AppendLine($"{name}_tract_nose = 0.0;"); - } - source.AppendLine($"{name}_tract_radiated = ({name}_tract_oral * (0.65 + 0.35 * abs({lipReflection})) + {name}_tract_nose);"); - return $"{name}_tract_radiated"; - - string ScaleIndex(string expression) => - tract.IndexScale == 1 ? expression : $"(({expression}) * {indexScale})"; - } - - private static string SmoothControl(TractMotion? motion, ParameterMap parameters, string fieldPath, string rate, string expression) => - motion is not null && parameters.IsBound(fieldPath) ? $"slew({rate}, {expression})" : expression; - - private static string TractWaveguideExpression( - StringBuilder source, - VocalTract tract, - TractAreaFunction areaFunction, - string name, - string glottalReflection, - string lipReflection, - string velum, - string injectionWidth, - string tongueIndex, - string tongueDiameter, - string constrictionIndex, - string constrictionDiameter, - string lipOpening, - string shapeReturn, - bool smoothShape) - { - var sections = areaFunction.Sections; - var loss = F(Math.Clamp(tract.WaveguideLoss, 0, 1)); - var substeps = Math.Max(1, tract.Substeps); - source.AppendLine($"{name}_wg_loss = {loss};"); - source.AppendLine($"{name}_wg_substeps = {substeps};"); - source.AppendLine($"{name}_wg_substep_drive = 1.0 / {name}_wg_substeps;"); - source.AppendLine($"{name}_wg_substep_loss = pow({name}_wg_loss, {name}_wg_substeps);"); - source.AppendLine($"{name}_wg_injection_cell = {name}_tract_injection_pos * {F(sections)};"); - for (var i = 0; i < sections; i++) - { - var rest = F(areaFunction.Diameters[i]); - var tongueWidth = F(Math.Max(1, sections * 0.18)); - var constrictionWidth = F(Math.Max(1, sections * 0.09)); - if (smoothShape) - { - source.AppendLine($"{name}_wg_tongue_weight_{i} = exp(0.0 - pow(({F(i)} - {tongueIndex}) / {tongueWidth}, 2.0));"); - source.AppendLine($"{name}_wg_constriction_weight_{i} = exp(0.0 - pow(({F(i)} - {constrictionIndex}) / {constrictionWidth}, 2.0));"); - source.AppendLine(i == sections - 1 - ? $"{name}_wg_diameter_base_{i} = {lipOpening};" - : $"{name}_wg_diameter_base_{i} = {rest} + ({tongueDiameter} - {rest}) * {name}_wg_tongue_weight_{i};"); - source.AppendLine($"{name}_wg_diameter_target_{i} = max(0.0, min({name}_wg_diameter_base_{i}, {constrictionDiameter} + max(0.0, {name}_wg_diameter_base_{i} - {constrictionDiameter}) * (1.0 - {name}_wg_constriction_weight_{i})));"); - } - else - { - source.AppendLine($"{name}_wg_diameter_target_{i} = {F(StaticWaveguideDiameter(tract, areaFunction, i, sections))};"); - } - source.AppendLine(smoothShape - ? $"{name}_wg_diameter_{i} = slew({shapeReturn}, {name}_wg_diameter_target_{i});" - : $"{name}_wg_diameter_{i} = {name}_wg_diameter_target_{i};"); - source.AppendLine($"{name}_wg_area_{i} = max(0.000001, {name}_wg_diameter_{i} * {name}_wg_diameter_{i});"); - source.AppendLine($"{name}_wg_inject_{i} = {name}_tract_injection_pressure * {name}_wg_substep_drive * clip01(1.0 - abs({name}_wg_injection_cell - {F(i)}) / {injectionWidth});"); - } - for (var i = 1; i < sections; i++) - { - source.AppendLine($"{name}_wg_k_{i} = ({name}_wg_area_{i - 1} - {name}_wg_area_{i}) / ({name}_wg_area_{i - 1} + {name}_wg_area_{i});"); - } - - var nasal = tract.Nasal is { AreaFunction: { } } ? tract.Nasal : null; - var noseSections = nasal?.AreaFunction is { } nasalFunction ? nasalFunction.Sections : 0; - var nasalJunction = nasal is null ? -1 : Math.Clamp(nasal.JunctionIndex, 1, sections - 2); - var stateCount = sections * 2 + noseSections * 2; - var stateInputs = new List(stateCount); - stateInputs.AddRange(Enumerable.Range(0, sections).Select(i => $"r{i}")); - stateInputs.AddRange(Enumerable.Range(0, sections).Select(i => $"l{i}")); - stateInputs.AddRange(Enumerable.Range(0, noseSections).Select(i => $"nr{i}")); - stateInputs.AddRange(Enumerable.Range(0, noseSections).Select(i => $"nl{i}")); - var nextStates = new List(stateCount); - - source.AppendLine($"{name}_wg(x) = {name}_wg_loop ~ si.bus({stateCount}) : (si.block({stateCount}), _) with {{"); - source.AppendLine($" {name}_wg_loop({string.Join(", ", stateInputs)}) = {string.Join(", ", nextStatesPlaceholder(stateCount))}, {name}_wg_out with {{"); - source.AppendLine($" {name}_wg_jr0 = (x * {name}_wg_substep_drive + {name}_wg_inject_0 * 0.5 + l0 * {glottalReflection});"); - for (var i = 1; i < sections; i++) - { - if (i == nasalJunction) - { - continue; - } - - source.AppendLine($" {name}_wg_scatter_{i} = {name}_wg_k_{i} * (r{i - 1} + l{i});"); - source.AppendLine($" {name}_wg_jr{i} = r{i - 1} - {name}_wg_scatter_{i} + {name}_wg_inject_{i} * 0.5;"); - source.AppendLine($" {name}_wg_jl{i - 1} = l{i} + {name}_wg_scatter_{i} + {name}_wg_inject_{i - 1} * 0.5;"); - } - - source.AppendLine($" {name}_wg_jl{sections - 1} = r{sections - 1} * {lipReflection};"); - var noseOutput = "0.0"; - if (nasal?.AreaFunction is { } noseShape) - { - var junction = nasalJunction; - var noseReflections = noseShape.ReflectionCoefficients; - var noseLoss = F(Math.Clamp(nasal.Loss, 0, 1)); - var noseReflection = F(nasal.Reflection); - source.AppendLine($" {name}_nose_loss = {noseLoss};"); - for (var i = 0; i < Math.Min(noseReflections.Count, noseSections - 1); i++) - { - source.AppendLine($" {name}_nose_k_{i + 1} = {F(noseReflections[i])};"); - } - source.AppendLine($" {name}_nose_area = max(0.000001, (0.01 + {velum} * 0.39) * (0.01 + {velum} * 0.39));"); - source.AppendLine($" {name}_nose_sum = {name}_wg_area_{junction - 1} + {name}_wg_area_{junction} + {name}_nose_area;"); - source.AppendLine($" {name}_nose_reflect_left = (2.0 * {name}_wg_area_{junction - 1} - {name}_nose_sum) / {name}_nose_sum;"); - source.AppendLine($" {name}_nose_reflect_right = (2.0 * {name}_wg_area_{junction} - {name}_nose_sum) / {name}_nose_sum;"); - source.AppendLine($" {name}_nose_reflect_nose = (2.0 * {name}_nose_area - {name}_nose_sum) / {name}_nose_sum;"); - source.AppendLine($" {name}_wg_jl{junction - 1} = ({name}_nose_reflect_left * r{junction - 1}) + (1.0 + {name}_nose_reflect_left) * (l{junction} + nl0) + {name}_wg_inject_{junction - 1} * 0.5;"); - source.AppendLine($" {name}_wg_jr{junction} = ({name}_nose_reflect_right * l{junction}) + (1.0 + {name}_nose_reflect_right) * (r{junction - 1} + nl0) + {name}_wg_inject_{junction} * 0.5;"); - source.AppendLine($" {name}_nose_jr0 = ({name}_nose_reflect_nose * nl0) + (1.0 + {name}_nose_reflect_nose) * (l{junction} + r{junction - 1});"); - for (var i = 1; i < noseSections; i++) - { - source.AppendLine($" {name}_nose_scatter_{i} = {name}_nose_k_{i} * (nr{i - 1} + nl{i});"); - source.AppendLine($" {name}_nose_jr{i} = nr{i - 1} - {name}_nose_scatter_{i};"); - source.AppendLine($" {name}_nose_jl{i - 1} = nl{i} + {name}_nose_scatter_{i};"); - } - source.AppendLine($" {name}_nose_jl{noseSections - 1} = nr{noseSections - 1} * {noseReflection};"); - noseOutput = $"{name}_nose_next_r{noseSections - 1}"; - } - - for (var i = 0; i < sections; i++) - { - source.AppendLine($" {name}_next_r{i} = {name}_wg_jr{i} * {name}_wg_substep_loss;"); - source.AppendLine($" {name}_next_l{i} = {name}_wg_jl{i} * {name}_wg_substep_loss;"); - nextStates.Add($"{name}_next_r{i}"); - } - nextStates.AddRange(Enumerable.Range(0, sections).Select(i => $"{name}_next_l{i}")); - if (noseSections > 0) - { - for (var i = 0; i < noseSections; i++) - { - source.AppendLine($" {name}_nose_next_r{i} = {name}_nose_jr{i} * {name}_nose_loss;"); - source.AppendLine($" {name}_nose_next_l{i} = {name}_nose_jl{i} * {name}_nose_loss;"); - nextStates.Add($"{name}_nose_next_r{i}"); - } - nextStates.AddRange(Enumerable.Range(0, noseSections).Select(i => $"{name}_nose_next_l{i}")); - } - source.Replace(string.Join(", ", nextStatesPlaceholder(stateCount)), string.Join(", ", nextStates)); - source.AppendLine($" {name}_tract_oral_waveguide = {name}_next_r{sections - 1} + {name}_next_l{sections - 1} * 0.05;"); - source.AppendLine($" {name}_tract_nose_waveguide = {noseOutput};"); - source.AppendLine($" {name}_wg_out = {name}_tract_oral_waveguide * (0.65 + 0.35 * abs({lipReflection})) + {name}_tract_nose_waveguide;"); - source.AppendLine(" };"); - source.AppendLine("};"); - source.AppendLine($"{name}_tract_radiated_raw = {name}_wg({name}_tract_excitation);"); - source.AppendLine($"{name}_tract_radiated = {name}_tract_radiated_raw;"); - return $"{name}_tract_radiated"; - - static IEnumerable nextStatesPlaceholder(int count) => - Enumerable.Range(0, count).Select(i => $"__next_state_{i}__"); - } - - private static float StaticWaveguideDiameter(VocalTract tract, TractAreaFunction areaFunction, int index, int emittedSections) - { - var restIndex = Math.Min(index, areaFunction.Diameters.Count - 1); - var diameter = areaFunction.Diameters[restIndex]; - if (index == emittedSections - 1) - { - diameter = tract.LipOpening; - } - else - { - var tongueWidth = Math.Max(1, emittedSections * 0.18f); - var tongueWeight = MathF.Exp(0 - MathF.Pow((index - tract.TongueIndex) / tongueWidth, 2)); - diameter = diameter + (tract.TongueDiameter - diameter) * tongueWeight; - } - - var constrictionWidth = Math.Max(1, emittedSections * 0.09f); - var constrictionWeight = MathF.Exp(0 - MathF.Pow((index - tract.ConstrictionIndex) / constrictionWidth, 2)); - diameter = Math.Min(diameter, tract.ConstrictionDiameter + Math.Max(0, diameter - tract.ConstrictionDiameter) * (1 - constrictionWeight)); - return Math.Max(0, diameter); - } - private static void EmitOperatorGraph(StringBuilder source, Playback playback, OperatorGraph graph, string name, ParameterMap parameters, List warnings) { if (graph.Operators.Count == 0) diff --git a/src/AquaSynth.Core/Model.cs b/src/AquaSynth.Core/Model.cs index ecf7e33..7cbfec9 100644 --- a/src/AquaSynth.Core/Model.cs +++ b/src/AquaSynth.Core/Model.cs @@ -398,8 +398,6 @@ public sealed record TractInjection( public enum TractPropagationMode { - Resonator, - Waveguide, Graph } @@ -478,9 +476,8 @@ public sealed record VocalTract( TractInjection? Injection = null, NasalBranch? Nasal = null, TractMotion? Motion = null, - TractPropagationMode Propagation = TractPropagationMode.Resonator, - float WaveguideLoss = 0.999f, - int Substeps = 1, + TractPropagationMode Propagation = TractPropagationMode.Graph, + float PropagationLoss = 0.999f, float IndexScale = 1, AcousticPortNetwork? AcousticNetwork = null); diff --git a/src/AquaSynth.Core/PatchScript.cs b/src/AquaSynth.Core/PatchScript.cs index 575e5fe..28c642b 100644 --- a/src/AquaSynth.Core/PatchScript.cs +++ b/src/AquaSynth.Core/PatchScript.cs @@ -1212,11 +1212,17 @@ public static class PatchScript var injection = ParseTractInjectionReference(fields, ownerPath, line); var nasal = ParseNasalBranchReference(fields, ownerPath, line); var motion = ParseTractMotionReference(fields, ownerPath, line); - var propagation = ParseTractPropagationMode(GetAny(fields, ["propagation", "model"], "resonator"), line); + if (HasAny(fields, "waveguide_loss")) + { + throw new PatchScriptException(line, "`waveguide_loss` has been removed; use graph `loss`"); + } + if (HasAny(fields, "substeps", "steps")) + { + throw new PatchScriptException(line, "`substeps` has been removed; graph timing is owned by path length and wave_clock"); + } + var propagation = ParseTractPropagationMode(GetAny(fields, ["propagation", "model"], "graph"), line); var originalSections = areaFunction?.Sections ?? 44; - var defaultSections = propagation == TractPropagationMode.Waveguide && areaFunction is not null && !HasAny(fields, "sections", "cells") - ? areaFunction.AcousticUnitDelaySections(44100, 343, 4) - : originalSections; + var defaultSections = originalSections; var sections = GetBoundInt(fields, line, defaultSections, OwnerField(ownerPath, "tract/sections"), "sections", "cells"); if (sections < 4) { @@ -1226,9 +1232,7 @@ public static class PatchScript ? areaFunction.Resample(sections) : areaFunction; var indexScale = originalSections <= 0 ? 1 : sections / (float)originalSections; - var defaultNoseSections = propagation == TractPropagationMode.Waveguide && nasal?.AreaFunction is { } nasalArea && !HasAny(fields, "nose_sections", "nose_cells") - ? nasalArea.AcousticUnitDelaySections(44100, 343, 1) - : nasal?.AreaFunction?.Sections ?? 28; + var defaultNoseSections = nasal?.AreaFunction?.Sections ?? 28; var noseSections = GetBoundInt(fields, line, defaultNoseSections, OwnerField(ownerPath, "tract/nose_sections"), "nose_sections", "nose_cells"); if (noseSections < 0) { @@ -1259,8 +1263,7 @@ public static class PatchScript nasal, motion, propagation, - GetBoundFloat(fields, line, 0.999f, OwnerField(ownerPath, "tract/waveguide_loss"), "waveguide_loss", "loss"), - GetBoundInt(fields, line, 1, OwnerField(ownerPath, "tract/substeps"), "substeps", "steps"), + GetBoundFloat(fields, line, 0.999f, OwnerField(ownerPath, "tract/loss"), "loss", "propagation_loss"), indexScale); var acousticNetwork = EnsureTractAcousticNetwork(ownerPath, tract); @@ -1300,7 +1303,7 @@ public static class PatchScript primaryPathName, oralArea, 343, - tract.WaveguideLoss, + tract.PropagationLoss, new AcousticAreaControl( tract.TongueIndex, tract.TongueDiameter, @@ -1365,21 +1368,14 @@ public static class PatchScript if (tract.Injection is { } injection) { var injectionName = string.IsNullOrWhiteSpace(injection.Name) ? $"{prefix}_injection" : $"{prefix}_{injection.Name}"; - if (tract.Propagation == TractPropagationMode.Graph) + var sourceWidth = Math.Max(0.25f, injection.Width); + var sourceIndexScale = tract.IndexScale / Math.Max(1, tract.Sections); + for (var section = 1; section < tract.Sections; section++) { - var sourceWidth = Math.Max(0.25f, injection.Width); - var sourceIndexScale = tract.IndexScale / Math.Max(1, tract.Sections); - for (var section = 1; section < tract.Sections; section++) - { - AddTractInjectionSource( - $"{injectionName}_{section}", - (section + 0.5f) / Math.Max(1, tract.Sections), - new AcousticSourcePositionControl(tract.ConstrictionIndex, sourceWidth, sourceIndexScale)); - } - } - else - { - AddTractInjectionSource(injectionName, NormalizeTractIndex(injection.Position, tract.Sections), null); + AddTractInjectionSource( + $"{injectionName}_{section}", + (section + 0.5f) / Math.Max(1, tract.Sections), + new AcousticSourcePositionControl(tract.ConstrictionIndex, sourceWidth, sourceIndexScale)); } void AddTractInjectionSource(string name, float position, AcousticSourcePositionControl? positionControl) @@ -1498,11 +1494,7 @@ public static class PatchScript var clockName = $"{prefix}_clock"; AddWaveClockRecord(new WaveClockPolicy( clockName, - tract.Propagation == TractPropagationMode.Waveguide - ? WaveClockDelayStrategy.UnitGrid - : tract.Propagation == TractPropagationMode.Graph - ? WaveClockDelayStrategy.FractionalLinear - : WaveClockDelayStrategy.FractionalLinear)); + WaveClockDelayStrategy.FractionalLinear)); var network = new AcousticPortNetwork( $"{prefix}_network", @@ -2592,11 +2584,11 @@ public static class PatchScript _ => target.ToString().ToLowerInvariant() }; - private static TractPropagationMode ParseTractPropagationMode(string value, int line) => value.ToLowerInvariant() switch + private static TractPropagationMode ParseTractPropagationMode(string value, int line) => value.ToLowerInvariant() switch { - "resonator" or "proxy" or "formant" => TractPropagationMode.Resonator, - "waveguide" or "kl" or "kelly-lochbaum" or "kelly_lochbaum" or "tube" => TractPropagationMode.Waveguide, "graph" or "acoustic_graph" or "network" => TractPropagationMode.Graph, + "resonator" or "proxy" or "formant" or "waveguide" or "kl" or "kelly-lochbaum" or "kelly_lochbaum" or "tube" => + throw new PatchScriptException(line, $"legacy tract propagation mode `{value}` has been removed; use `propagation=graph`"), _ => throw new PatchScriptException(line, $"unknown tract propagation mode `{value}`") }; diff --git a/src/AquaSynth.Core/PinkTromboneParityFixtures.cs b/src/AquaSynth.Core/PinkTromboneParityFixtures.cs index 5c908dc..17c11a8 100644 --- a/src/AquaSynth.Core/PinkTromboneParityFixtures.cs +++ b/src/AquaSynth.Core/PinkTromboneParityFixtures.cs @@ -133,7 +133,7 @@ public static class PinkTromboneParityFixtures nasal_branch name=nose junction=17 velum=.01 reflection=-.85 loss=.999 diameters=0.01,0.35,0.5,0.65,0.8,0.95,1.1,1.25,1.4,1.55,1.7,1.8,1.9,1.9,1.85,1.75,1.65,1.55,1.45,1.35,1.25,1.15,1.05,0.95,0.85,0.75,0.65,0.55 tract_motion name=motion diameter_slew=18 shape_return=8 constriction_slew=24 velum_slew=16 obstruction_threshold=.05 - tract shape=human glottis=modal injection=inj nasal_branch=nose motion=motion propagation=graph waveguide_loss=.999 freq={{F(controls.Frequency)}} gain={{F(controls.Gain)}} intensity={{F(controls.Intensity)}} tenseness={{F(controls.Tenseness)}} sustain=.45 decay=.12 tongue_index={{F(controls.TongueIndex)}} tongue_diameter={{F(controls.TongueDiameter)}} constriction_index={{F(controls.ConstrictionIndex)}} constriction_diameter={{F(controls.ConstrictionDiameter)}} turbulence={{F(controls.Turbulence)}} velum={{F(controls.Velum)}} lip={{F(controls.LipOpening)}} burst={{F(controls.Burst)}} glottal_reflection={{F(controls.GlottalReflection)}} lip_reflection={{F(controls.LipReflection)}} + tract shape=human glottis=modal injection=inj nasal_branch=nose motion=motion propagation=graph loss=.999 freq={{F(controls.Frequency)}} gain={{F(controls.Gain)}} intensity={{F(controls.Intensity)}} tenseness={{F(controls.Tenseness)}} sustain=.45 decay=.12 tongue_index={{F(controls.TongueIndex)}} tongue_diameter={{F(controls.TongueDiameter)}} constriction_index={{F(controls.ConstrictionIndex)}} constriction_diameter={{F(controls.ConstrictionDiameter)}} turbulence={{F(controls.Turbulence)}} velum={{F(controls.Velum)}} lip={{F(controls.LipOpening)}} burst={{F(controls.Burst)}} glottal_reflection={{F(controls.GlottalReflection)}} lip_reflection={{F(controls.LipReflection)}} """; } diff --git a/src/AquaSynth.Core/PinkTromboneReference.cs b/src/AquaSynth.Core/PinkTromboneReference.cs index b7b595e..bd7e3b7 100644 --- a/src/AquaSynth.Core/PinkTromboneReference.cs +++ b/src/AquaSynth.Core/PinkTromboneReference.cs @@ -52,36 +52,36 @@ public static class PinkTromboneReference new("/pink/lip/reflection", "Lip reflection", -0.85f, -0.98f, 0.1f, 0.001f, "coefficient", "control", "Lip-end reflection proxy.") ]; - public static ReferenceRebuild CurrentAquaSynthProxy() => + public static ReferenceRebuild CurrentAquaSynthGraph() => new( - "pink-trombone/current-aquasynth-proxy", + "pink-trombone/current-aquasynth-graph", "pink-trombone", - "Current AquaSynth source-filter proxy", + "Current AquaSynth typed acoustic graph", ReferenceId, BuiltInScripts.PinkTromboneProxy, [ - new("tract_voice_authority", "voice.Tract", "Pink Trombone pressure now lowers through a tract treatment on an ordinary AquaSynth voice."), + new("acoustic_graph_authority", "AcousticPortNetwork", "Pink Trombone pressure now lowers through the typed acoustic graph on an ordinary AquaSynth voice."), new("tract_area_function", "tract_shape diameters", "AquaSynth can now author reusable section diameter/area functions for tract voices."), new("diameter_to_reflection_coefficients", "TractAreaFunction.ReflectionCoefficients", "AquaSynth derives adjacent-section reflection coefficients from squared diameters as a reusable primitive."), new("glottal_source_primitive", "glottis", "AquaSynth can author reusable glottal excitation controls for tract voices."), new("positioned_injection_primitive", "tract_injection", "AquaSynth can author reusable constriction-position noise/burst injection controls."), - new("main_tract_waveguide_cells", "waveguide propagation over tract_shape sections", "AquaSynth can emit an oral bidirectional tube from derived section reflection coefficients."), - new("reflection_coefficients_applied_to_waveguide", "generated scattering junctions", "Derived reflection coefficients feed generated right/left wave scattering equations."), + new("main_tract_waveguide_cells", "graph path sections", "AquaSynth can emit an oral bidirectional graph path from derived section geometry."), + new("reflection_coefficients_applied_to_waveguide", "graph scattering junctions", "Derived areas feed generated right/left wave scattering equations."), new("nose_waveguide_cells", "nasal_branch", "AquaSynth can author a nasal branch as its own diameter/area tube."), - new("nose_junction", "generated three-way junction", "Waveguide lowering can emit a velum-controlled oral/nasal junction from local areas."), - new("positioned_turbulence_applied_to_waveguide_cells", "position-weighted waveguide injection", "Frication pressure can be distributed into oral waveguide section updates by injection position and width."), + new("nose_junction", "generated graph connection", "Graph lowering can emit a velum-controlled oral/nasal junction from local areas."), + new("positioned_turbulence_applied_to_waveguide_cells", "position-weighted graph source bank", "Frication pressure can be distributed into oral graph source ports by injection position and width."), new("tract_shape_motion", "tract_motion slew semantics", "AquaSynth can author tract control slew and obstruction thresholds for moving diameter targets."), - new("diameter_authority", "dynamic waveguide section diameters", "Waveguide lowering derives live per-section diameter targets before recalculating section areas and reflection coefficients."), - new("closure_transients", "obstruction-history burst", "Waveguide lowering derives burst pressure from prior obstruction state and current opening."), - new("tract_sample_rate", "physical-length acoustic grid", "Waveguide lowering can choose a compiled scattering grid from tract length and map runtime index controls onto it; `substeps` remains legacy clock pressure rather than the preferred surface."), + new("diameter_authority", "dynamic graph section areas", "Graph lowering derives live per-terminal area targets before scattering."), + new("closure_transients", "graph source release pulse", "Graph source lowering derives burst pressure from prior obstruction state and current opening."), + new("tract_sample_rate", "physical-length acoustic grid", "Graph lowering derives segment timing from tract length and maps runtime index controls onto the emitted graph; `substeps` is no longer a DSL owner."), new("runtime_controls", "/pink/frequency,/pink/intensity,/pink/tenseness,/pink/tongue/index,/pink/tongue/diameter,/pink/velum,/pink/turbulence", "AquaSynth can expose stable runtime parameter paths."), - new("glottal_pitch_pressure_proxy", "tract LF-style source", "AquaSynth can drive pitch/loudness-like controls without recompiling."), - new("turbulence_proxy", "position-aware frication controls", "The tract voice has constriction index/diameter and turbulence controls."), - new("nasal_proxy", "velum-controlled nasal resonator", "The tract voice has a velum/nasal output lane.") + new("glottal_pitch_pressure", "bounded graph glottal source", "AquaSynth can drive pitch/loudness-like controls without recompiling."), + new("turbulence_source", "position-aware frication source ports", "The tract voice has constriction index/diameter and turbulence controls."), + new("nasal_branch", "velum-controlled nasal graph branch", "The tract voice has a velum-controlled nasal branch.") ], [ - new("exact_twice_rate_state_update", "two recursive tract state updates per audio sample", "AquaSynth now chooses a physical unit-delay grid for Faust lowering, but it does not yet implement true fractional-delay or twice-rate PT state updates."), - new("lf_glottal_exactness", "Pink Trombone LF-style coefficients", "The proxy uses an LF-like glottal source but does not yet match Pink Trombone coefficient updates exactly.") + new("contact_aware_closure_state", "graph-owned upstream/downstream pressure storage", "The graph still needs a contact primitive that participates in scattering and flow."), + new("lf_glottal_exactness", "Pink Trombone LF-style coefficients", "The bounded source does not yet match Pink Trombone coefficient updates exactly.") ], - "This is a deliberately non-passing rebuild: it keeps the current source-filter proxy parseable while naming the tract-DSP authority AquaSynth lacks."); + "This is a deliberately non-passing rebuild: it proves Pink Trombone pressure lowers through the typed acoustic graph while naming the remaining closure/source exactness debt."); } diff --git a/src/AquaSynth.Core/ReferenceRebuilds.cs b/src/AquaSynth.Core/ReferenceRebuilds.cs index e2856f1..be52f26 100644 --- a/src/AquaSynth.Core/ReferenceRebuilds.cs +++ b/src/AquaSynth.Core/ReferenceRebuilds.cs @@ -133,7 +133,7 @@ public static class ReferenceRebuildCatalog public static readonly IReadOnlyList PinkTromboneRebuilds = [ - PinkTromboneReference.CurrentAquaSynthProxy() + PinkTromboneReference.CurrentAquaSynthGraph() ]; public static IEnumerable All() diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 3a17b93..041acec 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -150,7 +150,7 @@ {"timestamp":"2026-05-26T18:05:00+01:00","topic":"physical-voice-typed-path-graph","claim":"Aqua acoustic topology now uses a path graph with typed terminals and connections. `source_port`, `radiation_port`, and `branch` remain authoring sugar that populate terminal/connection records, while `AcousticPortNetwork` carries explicit graph terminal and connection names. This resolves the topology naming blocker; the remaining blocker is compiling that graph into bidirectional fractional-delay waveguide Faust.","evidence":"Added `AcousticTerminal`, `AcousticConnection`, terminal/connection enums, parser commands `terminal` and `connect`, branch/source/radiation graph sugar, and focused parser tests `ParserSupportsReusableAcousticPortNetworkPrimitives` and `ParserSupportsTypedAcousticPathGraph`; focused test command passed 4 tests with disabled build servers."} {"timestamp":"2026-05-26T18:35:00+01:00","topic":"physical-voice-typed-graph-faust-lowering","claim":"Typed acoustic path graphs now compile to Faust bidirectional segment state when terminals are present. The lowering splits paths at terminals, creates right/left segment state, scatters connected terminals by area-weighted pressure continuity, injects source terminals, and sums radiation terminals. Remaining known limits are integer sample segment delays, fallback for co-located same-path terminals, and only first area-scattering law lowering.","evidence":"Added `AcousticGraphExpression` in `FaustExport`; focused tests `ParserSupportsReusableAcousticPortNetworkPrimitives`, `ParserSupportsTypedAcousticPathGraph`, `FaustCompilerValidatesAcousticPathGraphWhenInstalled`, `ParserSupportsPinkTromboneStyleTractVoice`, and `WaveguideTractDefaultsToAcousticUnitDelayGrid` passed; `dotnet build src/AquaSynth.Core/AquaSynth.Core.csproj --no-restore --disable-build-servers -p:UseSharedCompilation=false -p:BuildInParallel=false` passed."} {"timestamp":"2026-05-26T19:10:00+01:00","topic":"physical-voice-graph-wave-clock-and-node-aggregation","claim":"Acoustic graph lowering now honors `wave_clock` delay strategy and aggregates co-located terminals into shared graph nodes. Sources can inject at connected nodes, and graph delay lowers through unit-grid, half-sample, linear fractional, Lagrange, or Thiran/allpass Faust primitives from physical segment length and `ma.SR`.","evidence":"Updated `AcousticGraphExpression` with wave-clock delay selection, same-position terminal node aggregation, connected-node source injection, and basic connection-law expression routing; focused tests `ParserSupportsReusableAcousticPortNetworkPrimitives`, `ParserSupportsTypedAcousticPathGraph`, `FaustCompilerValidatesAcousticPathGraphWhenInstalled`, `ParserSupportsPinkTromboneStyleTractVoice`, and `WaveguideTractDefaultsToAcousticUnitDelayGrid` passed; core build passed."} -{"timestamp":"2026-05-26T19:30:00+01:00","topic":"physical-voice-tract-graph-propagation","claim":"PT-shaped `tract` authoring can now opt into typed acoustic graph audio with `propagation=graph`. Generated tract acoustic networks now include typed terminals/connections, normalized tract-index positions, and a Thiran wave-clock default for graph propagation; legacy `propagation=waveguide` remains available as the old baseline.","evidence":"Added `TractPropagationMode.Graph`, parser alias `propagation=graph`, graph-first Faust routing for tract voices in graph mode, generated tract terminal/connection records, and focused test `TractVoiceCanLowerThroughAcousticGraph`; focused tests and core build passed."} +{"timestamp":"2026-05-26T19:30:00+01:00","topic":"physical-voice-tract-graph-propagation","claim":"PT-shaped `tract` authoring moved into typed acoustic graph audio with `propagation=graph`. Generated tract acoustic networks include typed terminals/connections, normalized tract-index positions, and a graph wave-clock default. Legacy `propagation=waveguide` was later removed and must not be treated as a baseline.","evidence":"Added `TractPropagationMode.Graph`, parser alias `propagation=graph`, graph-first Faust routing for tract voices in graph mode, generated tract terminal/connection records, and focused test `TractVoiceCanLowerThroughAcousticGraph`; focused tests and core build passed. Superseded by 2026-05-28 legacy-vocal-renderer-cut."} {"timestamp":"2026-05-26T19:55:00+01:00","topic":"pink-trombone-graph-logmel-evidence","claim":"Pink Trombone parity reporting now renders both legacy waveguide and graph-propagation candidates. Graph output is Faust-valid and audible, but open/front vowel log-mel cosine remains below legacy; nasal graph is near legacy, sibilant score improves while cosine remains low, and closure-release graph cosine becomes positive. Static tongue/constriction/lip baking into graph path did not materially move the latest report, pointing next pressure at source/scattering/radiation/transient behavior.","evidence":"Updated `PinkTromboneParityFixture` with `GraphAquaScript`, parity artifacts now include `candidate-graph.*` and per-lane reports. Latest run under `artifacts/parity/pink-trombone-logmel/20260526T182050731`: open graph cosine 0.3736 vs legacy 0.6143, front 0.3889 vs 0.6349, nasal 0.5318 vs 0.5425, sibilant 0.2102 vs 0.3744, closure 0.1168 vs -0.0820."} {"timestamp":"2026-05-26T20:25:00+01:00","topic":"pink-trombone-graph-source-radiation-evidence","claim":"Graph source and radiation semantics are now the live parity levers. LF-style glottal flow with a small harmonic pressure blend, graph radiation high-pass leakage, and aperture-weighted high-passed `TurbulenceJet` sources raise graph open/front vowel cosine above the legacy waveguide lane and make closure-release positive. Nasal remains over-loud and sibilant cosine remains weak, so the next pressure is nasal branch/radiation gain or junction coupling plus frication/transient detail.","evidence":"Latest optional PT log-mel run under `artifacts/parity/pink-trombone-logmel`: graph open 0.6393 vs legacy 0.6143, graph front 0.6596 vs legacy 0.6349, graph nasal 0.4607 with RMS ratio 1.6914 vs legacy nasal 0.5425, graph sibilant 0.2320 vs legacy 0.3744, graph closure 0.1170 vs legacy -0.0820."} {"timestamp":"2026-05-26T20:55:00+01:00","topic":"physical-voice-side-branch-scattering-blocker","claim":"Nasal graph parity is blocked by the side-branch port law, not by a missing scalar gain. Terminal-specific admittance in connection pressure is structurally cleaner but does not move PT log-mel metrics. Per-port outgoing coupling and squared generated velum opening both suppress nasal leakage only by making oral fixtures nearly silent, showing that the current pressure-wave normalization lets a weak side branch become an accidental loudness path. The next architecture needs power/flow-consistent branch-port scattering that separates junction admittance from outgoing wave normalization.","evidence":"Focused optional PT log-mel runs after per-port outgoing coupling produced open/front graph RMS ratios near 0.0017 with nasal cosine 0.5338; squared generated velum opening produced open/front RMS ratios near 0.0038/0.0039 and nasal RMS 1.5729. Both were cut. The retained terminal-admittance pressure solve preserves the previous source/radiation metrics."} @@ -201,3 +201,4 @@ {"evidence":"Hoisted graph turbulence/release source lowering into named Faust locals per source/node: `_closure`, `_release`, `_reservoir`, `_pressure_drive`, `_release_pressure`, `_noise_gate`, `_release_gate`, `_sustained`, `_burst_noise`, and `_release_pulse`. Fixed the emission order so helper locals are written before the node-source assignment. Focused structural/Faust checks, accepted utterance smoke, and static PT graph smoke passed. Latest utterance artifact `artifacts/parity/pink-trombone-utterance-logmel/20260528T114618213`; latest static artifact `artifacts/parity/pink-trombone-logmel/20260528T114618202`. Metrics match the prior radiation pass.","claim":"Closure/release pressure is now inspectable at the graph-source layer instead of buried in one expression. This is not yet true contact-aware plosive modeling; the next real change is to replace the source-local reservoir/source-impedance law with a graph/contact-owned upstream-downstream pressure model.","timestamp":"2026-05-28T12:20:00+01:00","topic":"acoustic-graph-source-reservoir-naming"} {"evidence":"Changed graph source-local closure reservoir charging from `abs(incident_pressure) * closure` to `max(0, incident_pressure) * closure`, so alternating negative pressure no longer charges a plosive reservoir. Accepted utterance smoke and static PT graph smoke passed. Latest utterance artifact `artifacts/parity/pink-trombone-utterance-logmel/20260528T114903720`; latest static artifact `artifacts/parity/pink-trombone-logmel/20260528T114953503`. Metrics did not move from the reservoir-naming pass.","claim":"Plosive storage should charge from compression, not rectified vibration. The lack of metric movement says the current audible failure is not the reservoir sign alone; Aqua still needs a contact-aware upstream/downstream closure state and source impedance instead of only a source-local scalar reservoir.","timestamp":"2026-05-28T12:55:00+01:00","topic":"acoustic-graph-positive-pressure-reservoir"} {"evidence":"Changed graph turbulence/release reservoir drive to use directed upstream-minus-downstream pressure at ordinary two-port path nodes (`max(0, upstream_incoming - downstream_incoming)`), with positive local incident pressure as the fallback for boundaries or more complex nodes. Focused structural/Faust checks, accepted utterance smoke, and static PT graph smoke passed. Latest utterance artifact `artifacts/parity/pink-trombone-utterance-logmel/20260528T115452268`; latest static artifact `artifacts/parity/pink-trombone-logmel/20260528T115719882`. Metrics still did not move.","claim":"Source-local reservoir direction is no longer the main explanation for weak plosives. The graph needs a contact/closure primitive that participates in scattering and flow, rather than a separate source pulse injected after the node law.","timestamp":"2026-05-28T13:05:00+01:00","topic":"acoustic-graph-directed-reservoir-drive"} +{"evidence":"Removed legacy vocal audio authorities: `TractPropagationMode` now only accepts graph lowering, parser legacy values fail fast, the Faust `Voice.Tract` resonator/waveguide renderers were deleted, the acoustic response proxy fallback was removed, `WaveguideLoss` became graph `PropagationLoss`, `substeps` was rejected, and the Pink Trombone built-in plus graph tests now route through typed `AcousticPortNetwork` lowering. Verification: stale-symbol scan only finds historical evidence and explicit rejection tests; full DSL test suite passed 180 tests.","claim":"Vocal acoustics now have one live authority: the typed acoustic graph. `Voice.Tract`, PT-shaped commands, and built-ins are authoring sugar that populate graph records; they cannot secretly render old proxy/waveguide audio when the graph is missing or weak.","timestamp":"2026-05-28T13:40:00+01:00","topic":"legacy-vocal-renderer-cut"} diff --git a/state/map.yaml b/state/map.yaml index 37f2eba..1f77a63 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -48,7 +48,7 @@ modules: vocal_tract_learning: src/AquaSynth.Core/VocalTractLearning.cs tract_voice_model: src/AquaSynth.Core/Model.cs tract_shape_model: src/AquaSynth.Core/Model.cs - tract_waveguide_lowering: src/AquaSynth.Core/FaustExport.cs + acoustic_graph_lowering: src/AquaSynth.Core/FaustExport.cs pink_trombone_parity_fixtures: src/AquaSynth.Core/PinkTromboneParityFixtures.cs pink_trombone_utterance_fixtures: src/AquaSynth.Core/PinkTromboneUtteranceFixtures.cs pink_trombone_logmel_parity_tests: tests/AquaSynth.Dsl.Tests/PinkTromboneLogMelParityTests.cs diff --git a/state/spine.yaml b/state/spine.yaml index 7d5d65c..891a502 100644 --- a/state/spine.yaml +++ b/state/spine.yaml @@ -115,11 +115,11 @@ live_invariants: - Do not hide missing graph structure behind unrelated voice fields. - The speech lane is the active center: IPA parity, utterance embeddings, synth-driver automation, rendered loss, and compiled Faust control sweeps take priority over new DX7/Zyn digestion. - Every learned speech arrow must stay inspectable: utterance metadata -> embedding, embedding plus phonetic features -> automation, automation -> rendered audio, rendered audio -> loss/gradient. - - Pink Trombone parity is structural waveguide pressure, not permission to add more formant proxy knobs. AquaSynth now has a `tract` DSL command that lowers into `Voice.Tract` with PT-shaped runtime controls and a Faust tract-voice proxy; it is still an ordinary voice treatment, not a separate graph owner and not an exact 44-cell/28-cell bidirectional waveguide. + - Pink Trombone parity is structural acoustic-graph pressure, not permission to add more formant proxy knobs or revive the old waveguide lane. AquaSynth has a `tract` DSL command with PT-shaped runtime controls, but vocal acoustics now lower through the typed `AcousticPortNetwork` graph; `Voice.Tract` is authoring sugar, not a second audio authority. - Physical voice modeling should generalize around continuous acoustic morphologies, acoustic port networks, source ports, branch/radiation ports, and wave-clock policies. A larynx, syrinx, or alien voice should differ by topology and source-port configuration, not by special-case modules. Faust `physmodels.lib`/`delays.lib` provide useful primitives (`pm.chain`, `pm.l2s`, `pm.waveguideFd*`, `de.fdelay*`, Thiran/allpass and Lagrange delays), but AquaSynth should still generate tract/branch scattering where live area controls and inspectable training parameters matter. - The physical voice research packet now includes a practical implementation/researcher map (`research/physical-voice-modeling/PEOPLE.md`) and talk/transcript ledger (`research/physical-voice-modeling/talks/TALKS.md`). Birkholz/VocalTractLab pressures multi-level articulatory control and gestures; Story/TubeTalker pressures continuous parametric area functions and length/coupling; Smith pressures bidirectional delay-line scattering and fractional-delay waveguides; Fels/ArtiSynth pressures separation between biomechanics, acoustics, timeline controls, and diagnostics. These are reusable DSL semantics, not modules to clone. - - 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 same-path two-port area discontinuities, scatters arbitrary non-bypass connection groups through one passive N-port area law, 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. + - Physical voice implementation has moved 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` exist. Existing `tract_shape`, `glottis`, `tract_injection`, `nasal_branch`, and `tract` commands populate acoustic records as authoring aliases; the legacy `Voice.Tract` resonator/waveguide renderers are removed. + - `acoustic` / `acoustic_voice` render an `AcousticPortNetwork` only through the compiled bidirectional Faust segment graph. Graph lowering splits paths at terminal positions, aggregates co-located terminals into graph nodes, orders connection ports deterministically, scatters same-path two-port area discontinuities, scatters arbitrary non-bypass connection groups through one passive N-port area law, 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 routes through `propagation=graph`; legacy propagation values now fail fast instead of producing proxy audio. - 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 lacks fully shaped graph-native closure pressure storage. The kept physical fixes move nasal coupling from global connection damping into transformed side-port admittance and use one Kelly-Lochbaum/PT-style traveling-wave convention for ordinary two-port area discontinuities and three-port branch junctions. The previous pressure-continuity rewrite was wrong for the graph's wave variables and produced the phone-vibration failure. 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. Node source/incident-pressure debug probes expose source-layer failures; a raw release-reservoir boost was tested and cut after the KL fix made it overdrive papa. Latest utterance artifact `artifacts/parity/pink-trombone-utterance-logmel/20260527T223931573` has papa at cosine 0.8828/RMS 1.0186 while thrombosis still fails from silence/articulation. Next cut is source impedance/constriction filtering for release energy, not global gain or PT-shaped modules. - PT utterance metrics now include cross-utterance separability because log-mel parity alone hid the user's actual listening failure. Artifact `artifacts/parity/pink-trombone-utterance-logmel/20260527T225833392` shows `mama/papa` candidate collapse: reference log-mel similarity 0.3791 versus candidate 0.6069, with candidate envelope similarity 0.8885. Interior source terminals no longer decide topology or node area/reflection; they attach to existing graph nodes and inject energy, while non-source terminals own geometry. Keep this source/topology cut even if other broken layers get louder. diff --git a/tests/AquaSynth.Dsl.Tests/PatchScriptTests.cs b/tests/AquaSynth.Dsl.Tests/PatchScriptTests.cs index 3efb977..7752449 100644 --- a/tests/AquaSynth.Dsl.Tests/PatchScriptTests.cs +++ b/tests/AquaSynth.Dsl.Tests/PatchScriptTests.cs @@ -91,7 +91,7 @@ public sealed class PatchScriptTests tract_injection name=sibilant position=6 diameter=.45 turbulence=.8 burst=.3 width=.8 nasal_branch name=nose junction=3 velum=.2 diameters=.01,.6,1.2,1.4 tract_motion name=quick diameter_slew=20 constriction_slew=30 velum_slew=12 obstruction_threshold=.08 - tract shape=human glottis=modal injection=sibilant nasal_branch=nose motion=quick propagation=waveguide sections=8 nose_sections=4 waveguide_loss=.998 substeps=2 freq=140 tongue_index=4 tongue_diameter=1.4 velum=.2 + tract shape=human glottis=modal injection=sibilant nasal_branch=nose motion=quick propagation=graph sections=8 nose_sections=4 loss=.998 freq=140 tongue_index=4 tongue_diameter=1.4 velum=.2 """); var shape = Assert.Single(patch.TractShapes); @@ -124,40 +124,30 @@ public sealed class PatchScriptTests Assert.Equal(injection, voice.Tract.Injection); Assert.Equal(nasal, voice.Tract.Nasal); Assert.Equal(motion, voice.Tract.Motion); - Assert.Equal(TractPropagationMode.Waveguide, voice.Tract.Propagation); - Assert.Equal(.998f, voice.Tract.WaveguideLoss, 5); - Assert.Equal(2, voice.Tract.Substeps); + Assert.Equal(TractPropagationMode.Graph, voice.Tract.Propagation); + Assert.Equal(.998f, voice.Tract.PropagationLoss, 5); Assert.NotNull(voice.AcousticNetwork); Assert.NotNull(voice.Tract.AcousticNetwork); Assert.Contains(patch.AcousticPaths, path => path.Name == "voices_0_oral"); Assert.Contains(patch.AcousticSourcePorts, port => port.Name == "voices_0_modal" && port.Kind == AcousticSourceKind.Glottal); - Assert.Contains(patch.AcousticSourcePorts, port => port.Name == "voices_0_sibilant" && port.Kind == AcousticSourceKind.TurbulenceJet); + Assert.Contains(patch.AcousticSourcePorts, port => port.Name.StartsWith("voices_0_sibilant_", StringComparison.Ordinal) && port.Kind == AcousticSourceKind.TurbulenceJet); Assert.Contains(patch.AcousticBranches, branch => branch.Name == "voices_0_nose" && branch.Kind == AcousticBranchKind.Nasal); Assert.Contains(patch.AcousticRadiationPorts, port => port.Name == "voices_0_lip" && port.Kind == AcousticRadiationKind.Lip); - Assert.Contains(patch.WaveClocks, clock => clock.Name == "voices_0_clock" && clock.Strategy == WaveClockDelayStrategy.UnitGrid); + Assert.Contains(patch.WaveClocks, clock => clock.Name == "voices_0_clock" && clock.Strategy == WaveClockDelayStrategy.FractionalLinear); Assert.Contains(patch.ParameterBindings, binding => binding.FieldPath == "/glottis/0/tenseness"); var faust = FaustEmitter.Emit(patch, new FaustExportOptions("tract_voice")).Source; - Assert.Contains("tract_lf", faust); - Assert.Contains("tract_frication", faust); - Assert.Contains("tract_shape_middle", faust); - Assert.Contains("tract_reflection_energy", faust); - Assert.Contains("tract_lf_open", faust); - Assert.Contains("tract_injection_close", faust); - Assert.Contains("wg_injection_cell", faust); - Assert.Contains("wg_loop ~ si.bus", faust); - Assert.Contains("wg_inject_6", faust); - Assert.Contains("wg_diameter_target_3", faust); - Assert.Contains("wg_area_3", faust); - Assert.Contains("wg_substep_drive", faust); - Assert.Contains("wg_substep_loss", faust); - Assert.Contains("tract_release_memory", faust); - Assert.Contains("tract_obstructed", faust); - Assert.Contains("slew(", faust); - Assert.Contains("wg_scatter_1", faust); - Assert.Contains("nose_reflect_nose", faust); - Assert.Contains("tract_nose_waveguide", faust); - Assert.Contains("tract_oral_waveguide", faust); + Assert.Contains("acoustic_graph_radiated", faust); + Assert.Contains("graph_loop ~ si.bus", faust); + Assert.Contains("graph_source_voices_0_modal", faust); + Assert.Contains("graph_source_voices_0_sibilant_", faust); + Assert.Contains("graph_terminal_area_voices_0_area_", faust); + Assert.Contains("graph_connection_reflection_voices_0_nose_connection", faust); + Assert.Contains("de.fdelay", faust); + Assert.Contains("_reservoir_drive", faust); + Assert.Contains("_release_pulse", faust); + Assert.DoesNotContain("tract_lf", faust); + Assert.DoesNotContain("wg_", faust); } [Fact] @@ -169,8 +159,8 @@ public sealed class PatchScriptTests param path=/voice/mouth_opening default=1.2 min=0 max=2 step=.001 path name=trachea length_cm=12 diameters=.4,.7,1,1 path name=oral length_cm=17 diameters=.6,1.1,1.6,1.2,.8 - source_port name=left_labium path=trachea kind=labial position=.1 pressure=@/voice/left_pressure tension=.55 opening=.4 noise=.02 - source_port name=right_labium path=trachea kind=labial position=.1 pressure=.65 tension=.5 opening=.45 noise=.03 balance=.8 position_index=.12 position_width=.05 position_index_scale=1 + source_port name=left_labium path=trachea kind=labial position=0 pressure=@/voice/left_pressure tension=.55 opening=.4 noise=.02 + source_port name=right_labium path=trachea kind=labial position=0 pressure=.65 tension=.5 opening=.45 noise=.03 balance=.8 position_index=.12 position_width=.05 position_index_scale=1 branch name=throat from_path=trachea from_position=.9 to_path=oral kind=bronchial opening=@/voice/throat_opening coupling=.7 radiation_port name=mouth path=oral kind=lip position=1 opening=@/voice/mouth_opening reflection=-.82 wave_clock name=continuous strategy=thiran order=1 max_delay=4096 smoothing_ms=3 @@ -393,7 +383,7 @@ public sealed class PatchScriptTests var patch = PatchScript.Parse(""" tract_shape name=longform length_cm=24 diameters=.5,1,2,1,.5 nasal_branch name=side length_cm=9 diameters=.01,.4,.8,.4 - tract shape=longform nasal_branch=side propagation=waveguide + tract shape=longform nasal_branch=side propagation=graph """); var shape = Assert.Single(patch.TractShapes); @@ -410,7 +400,7 @@ public sealed class PatchScriptTests { var patch = PatchScript.Parse(""" tract_shape name=curve length_cm=17 diameters=.5,1,2,1,.5 - tract shape=curve sections=9 propagation=waveguide + tract shape=curve sections=9 propagation=graph """); var shape = Assert.Single(patch.TractShapes); @@ -424,32 +414,47 @@ public sealed class PatchScriptTests } [Fact] - public void WaveguideTractDefaultsToAcousticUnitDelayGrid() + public void GraphTractPreservesDeclaredMorphologyGrid() { var patch = PatchScript.Parse(""" tract_shape name=human length_cm=17 diameters=.6,.6,.8,1,1.2,1.4,1.5,1.5,1.5,1.5,1.4,1.2,1,.8,.7,.6,.6,.8,1,1.2,1.4,1.5,1.5,1.5,1.5,1.4,1.2,1,.8,.7,.6,.6,.8,1,1.2,1.4,1.5,1.5,1.5,1.5,1.4,1.2,1,.8 nasal_branch name=nose length_cm=12 junction=17 diameters=.01,.35,.5,.65,.8,.95,1.1,1.25,1.4,1.55,1.7,1.8,1.9,1.9,1.85,1.75,1.65,1.55,1.45,1.35,1.25,1.15,1.05,.95,.85,.75,.65,.55 tract_injection name=inj position=32 width=1 - tract shape=human nasal_branch=nose injection=inj propagation=waveguide tongue_index=12.9 constriction_index=32 + tract shape=human nasal_branch=nose injection=inj propagation=graph tongue_index=12.9 constriction_index=32 """); var tract = Assert.Single(patch.Voices).Tract; Assert.NotNull(tract?.AreaFunction); - Assert.Equal(22, tract.Sections); - Assert.Equal(15, tract.NoseSections); - Assert.Equal(22, tract.AreaFunction.Sections); - Assert.Equal(15, tract.Nasal?.AreaFunction?.Sections); - Assert.Equal(9, tract.Nasal?.JunctionIndex); - Assert.Equal(.5f, tract.IndexScale, 2); + Assert.Equal(44, tract.Sections); + Assert.Equal(28, tract.NoseSections); + Assert.Equal(44, tract.AreaFunction.Sections); + Assert.Equal(28, tract.Nasal?.AreaFunction?.Sections); + Assert.Equal(17, tract.Nasal?.JunctionIndex); + Assert.Equal(1, tract.IndexScale, 2); Assert.Equal(12.9f, tract.TongueIndex, 2); Assert.Equal(32, tract.ConstrictionIndex, 2); Assert.Equal(32, tract.Injection?.Position); Assert.Equal(1, tract.Injection?.Width); + Assert.Equal(WaveClockDelayStrategy.FractionalLinear, Assert.Single(patch.WaveClocks).Strategy); - var faust = FaustEmitter.Emit(patch, new FaustExportOptions("unit_delay_grid")).Source; - Assert.Contains("_tract_tongue_index = ((12.9) * 0.5);", faust); - Assert.Contains("_tract_injection_index = ((32) * 0.5);", faust); + var faust = FaustEmitter.Emit(patch, new FaustExportOptions("graph_declared_grid")).Source; + Assert.Contains("graph_loop ~ si.bus", faust); + Assert.Contains("de.fdelay", faust); + Assert.DoesNotContain("_wg_", faust); + } + + [Fact] + public void ParserRejectsRemovedTractWaveguideFields() + { + var propagation = Assert.Throws(() => PatchScript.Parse("tract propagation=waveguide")); + Assert.Contains("legacy tract propagation mode", propagation.Message); + + var loss = Assert.Throws(() => PatchScript.Parse("tract waveguide_loss=.999")); + Assert.Contains("waveguide_loss", loss.Message); + + var substeps = Assert.Throws(() => PatchScript.Parse("tract substeps=2")); + Assert.Contains("substeps", substeps.Message); } [Fact] @@ -663,12 +668,12 @@ public sealed class PatchScriptTests } [Fact] - public void PinkTromboneReferenceDeclaresMissingWaveguideAuthority() + public void PinkTromboneReferenceDeclaresGraphAuthority() { var reference = PinkTromboneReference.ToReferencePatch(); var rebuild = Assert.Single(ReferenceRebuildCatalog.PinkTromboneRebuilds); var patch = PatchScript.Parse(rebuild.Script); - var export = FaustEmitter.Emit(patch, new FaustExportOptions("pink_trombone_proxy")); + var export = FaustEmitter.Emit(patch, new FaustExportOptions("pink_trombone_graph")); Assert.Equal("pink-trombone", rebuild.Family); Assert.Contains(reference.Features, feature => feature.Name == "main_tract_waveguide_cells" && feature.Value == "44"); @@ -677,7 +682,7 @@ public sealed class PatchScriptTests Assert.Contains(reference.Features, feature => feature.Name == "reflection_formula"); Assert.Contains(reference.Parameters, parameter => parameter.Path == "/pink/tongue/index"); Assert.Contains(reference.Parameters, parameter => parameter.Path == "/pink/constriction/diameter"); - Assert.Contains(rebuild.MatchedFeatures, feature => feature.Name == "tract_voice_authority"); + Assert.Contains(rebuild.MatchedFeatures, feature => feature.Name == "acoustic_graph_authority"); Assert.Contains(rebuild.MatchedFeatures, feature => feature.Name == "tract_area_function"); Assert.Contains(rebuild.MatchedFeatures, feature => feature.Name == "diameter_to_reflection_coefficients"); Assert.Contains(rebuild.MatchedFeatures, feature => feature.Name == "glottal_source_primitive"); @@ -691,7 +696,7 @@ public sealed class PatchScriptTests Assert.Contains(rebuild.MatchedFeatures, feature => feature.Name == "diameter_authority"); Assert.Contains(rebuild.MatchedFeatures, feature => feature.Name == "closure_transients"); Assert.Contains(rebuild.MatchedFeatures, feature => feature.Name == "tract_sample_rate"); - Assert.Contains(rebuild.MissingFeatures, feature => feature.Name == "exact_twice_rate_state_update"); + Assert.Contains(rebuild.MissingFeatures, feature => feature.Name == "contact_aware_closure_state"); Assert.NotEmpty(patch.TractShapes); Assert.NotEmpty(patch.GlottalSources); Assert.NotEmpty(patch.TractInjections); diff --git a/tests/AquaSynth.Dsl.Tests/PinkTromboneLogMelParityTests.cs b/tests/AquaSynth.Dsl.Tests/PinkTromboneLogMelParityTests.cs index 1a773e0..0721a35 100644 --- a/tests/AquaSynth.Dsl.Tests/PinkTromboneLogMelParityTests.cs +++ b/tests/AquaSynth.Dsl.Tests/PinkTromboneLogMelParityTests.cs @@ -486,7 +486,7 @@ public sealed class PinkTromboneLogMelParityTests nasal_branch name=nose length_cm=12 junction=17 velum=@/pink/velum reflection=@/pink/lip/reflection loss=.999 diameters=0.01,0.35,0.5,0.65,0.8,0.95,1.1,1.25,1.4,1.55,1.7,1.8,1.9,1.9,1.85,1.75,1.65,1.55,1.45,1.35,1.25,1.15,1.05,0.95,0.85,0.75,0.65,0.55 tract_motion name=motion diameter_slew=18 shape_return=8 constriction_slew=24 velum_slew=16 obstruction_threshold=.05 - tract shape=human glottis=modal injection=inj nasal_branch=nose motion=motion propagation=graph waveguide_loss=.999 freq=@/pink/frequency gain=@/pink/gain intensity=@/pink/intensity tenseness=@/pink/tenseness attack=.03 sustain={{F(fixture.DurationSeconds)}} decay=.05 tongue_index=@/pink/tongue/index tongue_diameter=@/pink/tongue/diameter constriction_index=@/pink/constriction/index constriction_diameter=@/pink/constriction/diameter turbulence=@/pink/turbulence velum=@/pink/velum lip=@/pink/lip/opening burst=@/pink/burst glottal_reflection=@/pink/glottal/reflection lip_reflection=@/pink/lip/reflection + tract shape=human glottis=modal injection=inj nasal_branch=nose motion=motion propagation=graph loss=.999 freq=@/pink/frequency gain=@/pink/gain intensity=@/pink/intensity tenseness=@/pink/tenseness attack=.03 sustain={{F(fixture.DurationSeconds)}} decay=.05 tongue_index=@/pink/tongue/index tongue_diameter=@/pink/tongue/diameter constriction_index=@/pink/constriction/index constriction_diameter=@/pink/constriction/diameter turbulence=@/pink/turbulence velum=@/pink/velum lip=@/pink/lip/opening burst=@/pink/burst glottal_reflection=@/pink/glottal/reflection lip_reflection=@/pink/lip/reflection """; private static string UtteranceControlCsv(PinkTromboneUtteranceFixture fixture) diff --git a/tools/TractGraphRenderer/Program.cs b/tools/TractGraphRenderer/Program.cs index 16c947a..1aedf13 100644 --- a/tools/TractGraphRenderer/Program.cs +++ b/tools/TractGraphRenderer/Program.cs @@ -60,7 +60,7 @@ static string Script(RenderRequest controls) => nasal_branch name=nose junction=17 velum=.01 reflection=-.85 loss=.999 diameters=0.01,0.35,0.5,0.65,0.8,0.95,1.1,1.25,1.4,1.55,1.7,1.8,1.9,1.9,1.85,1.75,1.65,1.55,1.45,1.35,1.25,1.15,1.05,0.95,0.85,0.75,0.65,0.55 tract_motion name=motion diameter_slew=18 shape_return=8 constriction_slew=24 velum_slew=16 obstruction_threshold=.05 - tract shape=human glottis=modal injection=inj nasal_branch=nose motion=motion propagation=graph waveguide_loss=.999 freq={{F(controls.Frequency)}} gain={{F(controls.Gain)}} intensity={{F(controls.Intensity)}} tenseness={{F(controls.Tenseness)}} sustain={{F(Math.Max(0.05f, controls.DurationSeconds - 0.12f))}} decay=.12 tongue_index={{F(controls.TongueIndex)}} tongue_diameter={{F(controls.TongueDiameter)}} constriction_index={{F(controls.ConstrictionIndex)}} constriction_diameter={{F(controls.ConstrictionDiameter)}} turbulence={{F(controls.Turbulence)}} velum={{F(controls.Velum)}} lip={{F(controls.LipOpening)}} burst={{F(controls.Burst)}} glottal_reflection={{F(controls.GlottalReflection)}} lip_reflection={{F(controls.LipReflection)}} + tract shape=human glottis=modal injection=inj nasal_branch=nose motion=motion propagation=graph loss=.999 freq={{F(controls.Frequency)}} gain={{F(controls.Gain)}} intensity={{F(controls.Intensity)}} tenseness={{F(controls.Tenseness)}} sustain={{F(Math.Max(0.05f, controls.DurationSeconds - 0.12f))}} decay=.12 tongue_index={{F(controls.TongueIndex)}} tongue_diameter={{F(controls.TongueDiameter)}} constriction_index={{F(controls.ConstrictionIndex)}} constriction_diameter={{F(controls.ConstrictionDiameter)}} turbulence={{F(controls.Turbulence)}} velum={{F(controls.Velum)}} lip={{F(controls.LipOpening)}} burst={{F(controls.Burst)}} glottal_reflection={{F(controls.GlottalReflection)}} lip_reflection={{F(controls.LipReflection)}} """; static string F(float value) =>