From ec73200093725f6a97f5100f30d0be47f67db2d1 Mon Sep 17 00:00:00 2001 From: Aqua Date: Sun, 8 Nov 2026 03:41:20 +0000 Subject: [PATCH] Callers of FaustEmitter that render at a known rate pass it: the ladder's cell length follows the sample rate The vocal ladder has one cell per sample, so exporting at the 48 kHz default and rendering at 44.1 kHz (daemon, IPA trial, song worker, graph renderer) shifted every formant down 8%. Speech-loss surface and AquaLower still take the default; the wasm compile path has no rate. Co-Authored-By: Claude Sonnet 5.5 --- src/AquaSynth.Faust/AquaSynthDaemonService.cs | 2 +- src/AquaSynth.Faust/IpaTrialOrchestrator.cs | 13 +++++++------ tools/IpaTrialWorker/Program.cs | 2 +- tools/TractGraphRenderer/Program.cs | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/AquaSynth.Faust/AquaSynthDaemonService.cs b/src/AquaSynth.Faust/AquaSynthDaemonService.cs index 0021895..16897f6 100644 --- a/src/AquaSynth.Faust/AquaSynthDaemonService.cs +++ b/src/AquaSynth.Faust/AquaSynthDaemonService.cs @@ -906,7 +906,7 @@ public sealed class AquaSynthDaemonService : IDisposable try { var faustName = AquaSynthNativeCompiler.SafeFaustName(identity.FaustName); - var source = FaustEmitter.EmitScript(identity.Script, new FaustExportOptions(faustName)).Source; + var source = FaustEmitter.EmitScript(identity.Script, new FaustExportOptions(faustName, SampleRate: options.SampleRate)).Source; return compiler.TryCompileSource(identity, source, durationSeconds, out patch, out error); } catch (Exception ex) diff --git a/src/AquaSynth.Faust/IpaTrialOrchestrator.cs b/src/AquaSynth.Faust/IpaTrialOrchestrator.cs index ef37d3d..5f6e2fe 100644 --- a/src/AquaSynth.Faust/IpaTrialOrchestrator.cs +++ b/src/AquaSynth.Faust/IpaTrialOrchestrator.cs @@ -156,12 +156,13 @@ public static class IpaTrialOrchestrator var candidateDir = Path.Combine(round.RoundDirectory, "audio", candidate.Id); Directory.CreateDirectory(candidateDir); var script = await File.ReadAllTextAsync(candidate.ScriptPath, cancellationToken).ConfigureAwait(false); - var source = FaustEmitter.EmitScript(script, new FaustExportOptions(candidate.Id)).Source; + var referenceFixture = PinkTromboneParityFixtures.ById(target.ReferenceFixtureId); + var reference = referenceRenderer.Render(referenceFixture.Controls, target.Target.DurationSeconds + .18f); + // The vocal ladder's cell length is tied to the rate the DSP runs at, which is the reference's rate. + var source = FaustEmitter.EmitScript(script, new FaustExportOptions(candidate.Id, SampleRate: reference.SampleRate)).Source; var dspPath = Path.Combine(candidateDir, "candidate.dsp"); await File.WriteAllTextAsync(dspPath, source, cancellationToken).ConfigureAwait(false); - var referenceFixture = PinkTromboneParityFixtures.ById(target.ReferenceFixtureId); - var reference = referenceRenderer.Render(referenceFixture.Controls, target.Target.DurationSeconds + .18f); var candidateRender = await FaustCompiler.RenderAsync( source, new FaustRenderOptions(reference.SampleRate, reference.Samples.Length / (float)reference.SampleRate), @@ -311,12 +312,12 @@ public static class IpaTrialOrchestrator var timelinePath = Path.Combine(timelineRoot, $"{safeCandidateId}.csv"); await File.WriteAllTextAsync(timelinePath, ProbeTimelineReport.ToCsv(timeline), cancellationToken).ConfigureAwait(false); - var source = FaustEmitter.EmitScript(script, new FaustExportOptions(safeCandidateId)).Source; + var referenceFixture = PinkTromboneParityFixtures.ById(mapped.target.ReferenceFixtureId); + var reference = referenceRenderer.Render(referenceFixture.Controls, mapped.target.Target.DurationSeconds + .18f); + var source = FaustEmitter.EmitScript(script, new FaustExportOptions(safeCandidateId, SampleRate: reference.SampleRate)).Source; var dspPath = Path.Combine(candidateDir, "candidate.dsp"); await File.WriteAllTextAsync(dspPath, source, cancellationToken).ConfigureAwait(false); - var referenceFixture = PinkTromboneParityFixtures.ById(mapped.target.ReferenceFixtureId); - var reference = referenceRenderer.Render(referenceFixture.Controls, mapped.target.Target.DurationSeconds + .18f); var candidateRender = await FaustCompiler.RenderAsync( source, new FaustRenderOptions(reference.SampleRate, reference.Samples.Length / (float)reference.SampleRate), diff --git a/tools/IpaTrialWorker/Program.cs b/tools/IpaTrialWorker/Program.cs index f7089d1..1e7cbbc 100644 --- a/tools/IpaTrialWorker/Program.cs +++ b/tools/IpaTrialWorker/Program.cs @@ -267,7 +267,7 @@ static async Task SongScoreAsync(Dictionary options) : ProbeTimelineReport.Build(patch, timelineNetwork.Name, 12); await File.WriteAllTextAsync(timelinePath, ProbeTimelineReport.ToCsv(timeline), Encoding.UTF8); timelineFacts = PrimitiveTimelineFactExtractor.Extract(timeline).ToArray(); - var source = FaustEmitter.EmitScript(script, new FaustExportOptions(safeCandidateId)).Source; + var source = FaustEmitter.EmitScript(script, new FaustExportOptions(safeCandidateId, SampleRate: challenge.SampleRate)).Source; await File.WriteAllTextAsync(dspPath, source, Encoding.UTF8); artifacts.Add(Artifact("candidate-dsp", dspPath)); diff --git a/tools/TractGraphRenderer/Program.cs b/tools/TractGraphRenderer/Program.cs index c872da3..4a492cf 100644 --- a/tools/TractGraphRenderer/Program.cs +++ b/tools/TractGraphRenderer/Program.cs @@ -21,7 +21,7 @@ if (FaustCompiler.FindFaust() is null) } var script = Script(request); -var export = FaustEmitter.EmitScript(script, new FaustExportOptions("aqua_tract_graph_audition")); +var export = FaustEmitter.EmitScript(script, new FaustExportOptions("aqua_tract_graph_audition", SampleRate: request.SampleRate)); var render = await FaustCompiler.RenderAsync( export.Source, new FaustRenderOptions(request.SampleRate, request.DurationSeconds));