voice-source-1: glottal pulse and noise-colour listening kit (unheard) #53
14 changed files with 453 additions and 17 deletions
|
|
@ -758,14 +758,21 @@ public static partial class FaustEmitter
|
|||
// Harmonic glottal source: a band-limited saw through a one-pole lowpass. Tilt 0 is the brightest source and 1 the
|
||||
// steepest rolloff; the cutoff sweeps five octaves, 6400 Hz down to 200 Hz, and sits below Nyquist.
|
||||
var cutoff = $"min(0.45 * ma.SR, 200.0 * pow(2.0, (1.0 - clip01({parameters.Expression(OwnerField(owner, "tilt"), port.Tilt)})) * 5.0))";
|
||||
source.AppendLine($" {voiced} = (os.sawtooth(({frequency}) * {pitchRatio}) : fi.lowpass(1, {cutoff})) * clip01({opening}) * clip01(0.25 + {tension});");
|
||||
source.AppendLine($" {flow} = {ProbeSignal(options, $"/debug/{voiceName}/source/{port.Name}/flow", $"({flowScale}) * (({voiced}) * ma.tanh((({pressure}) * (0.5 + {tension})) / max(0.05, {impedance})) + 0.08 * no.noise * {parameters.Expression(OwnerField(owner, "noise"), port.Noise)})", -2, 2)};");
|
||||
var wave = port.Pulse == GlottalPulse.Rosenberg ? RosenbergPulse($"(({frequency}) * {pitchRatio})") : $"os.sawtooth(({frequency}) * {pitchRatio})";
|
||||
source.AppendLine($" {voiced} = ({wave} : fi.lowpass(1, {cutoff})) * clip01({opening}) * clip01(0.25 + {tension});");
|
||||
source.AppendLine($" {flow} = {ProbeSignal(options, $"/debug/{voiceName}/source/{port.Name}/flow", $"({flowScale}) * (({voiced}) * ma.tanh((({pressure}) * (0.5 + {tension})) / max(0.05, {impedance})) + 0.08 * {(port.NoiseHighPassHz > 0 ? $"(no.noise : fi.highpass(2, {port.NoiseHighPassHz.ToString("0.###", CultureInfo.InvariantCulture)}))" : "no.noise")} * {parameters.Expression(OwnerField(owner, "noise"), port.Noise)})", -2, 2)};");
|
||||
keepAlive.Add(load);
|
||||
keepAlive.Add(voiced);
|
||||
keepAlive.Add(flow);
|
||||
return flow;
|
||||
}
|
||||
|
||||
// Rosenberg C flow pulse of one period (phase p of 0..1): opening 0.5 (1 - cos(pi p / 0.4)) for p < 0.4, return cos(pi/2 (p - 0.4) / 0.16)
|
||||
// for the next 0.16, closed after. Its mean is 0.4 / 2 + 0.16 * 2 / pi = 0.301859 and its rms about that mean is 0.372667; it is made zero-mean
|
||||
// and scaled by 0.57735 / 0.372667 = 1.549 to the rms of os.sawtooth (1 / sqrt 3), so a swap of the pulse leaves the SOURCE level where it was (the rendered level moves: the pulse has no strong upper harmonics for the tract to pass).
|
||||
public static string RosenbergPulse(string frequency) =>
|
||||
$"(((os.lf_sawpos({frequency}) : (\\(p).(select2(p < 0.4, select2(p < 0.56, 0.0, cos(ma.PI * 0.5 * (p - 0.4) / 0.16)), 0.5 * (1.0 - cos(ma.PI * p / 0.4)))))) - 0.301859) * 1.549)";
|
||||
|
||||
private static (string Released, string Burst) PrimitiveContactExpression(
|
||||
StringBuilder source,
|
||||
SynthPatch patch,
|
||||
|
|
|
|||
|
|
@ -474,7 +474,17 @@ public sealed record SourcePort(
|
|||
float Impedance = 0.35f,
|
||||
float FlowScale = 0.02f,
|
||||
float Tilt = 0.5f,
|
||||
float PitchRatio = 1f);
|
||||
float PitchRatio = 1f,
|
||||
GlottalPulse Pulse = GlottalPulse.Saw,
|
||||
float NoiseHighPassHz = 0f);
|
||||
|
||||
// The glottal flow waveform of a primitive source port. Saw is the band-limited saw the tilt lowpass shapes; Rosenberg is the
|
||||
// Rosenberg C pulse (open phase 0.4 of the period, return phase 0.16), zero-mean and scaled to the saw's rms at the source. The rendered level still differs: the tract passes less of the pulse (-2.5 dB output rms on /ɑmi/, measured -2.54).
|
||||
public enum GlottalPulse
|
||||
{
|
||||
Saw,
|
||||
Rosenberg
|
||||
}
|
||||
|
||||
public sealed record ConstrictionContact(
|
||||
string Name,
|
||||
|
|
|
|||
|
|
@ -968,7 +968,9 @@ public static class PatchScript
|
|||
GetBoundFloat(fields, line, 0.35f, $"/vocal/sources/{_sourcePorts.Count}/impedance", "impedance", "load", "source_impedance"),
|
||||
GetBoundFloat(fields, line, 0.02f, $"/vocal/sources/{_sourcePorts.Count}/flow_scale", "flow_scale", "scale"),
|
||||
GetBoundFloat(fields, line, 0.5f, $"/vocal/sources/{_sourcePorts.Count}/tilt", "tilt", "spectral_tilt"),
|
||||
GetBoundFloat(fields, line, 1f, $"/vocal/sources/{_sourcePorts.Count}/pitch_ratio", "pitch_ratio", "f0_ratio"));
|
||||
GetBoundFloat(fields, line, 1f, $"/vocal/sources/{_sourcePorts.Count}/pitch_ratio", "pitch_ratio", "f0_ratio"),
|
||||
ParseGlottalPulse(GetAny(fields, ["pulse", "glottal_pulse"], "saw"), line),
|
||||
Math.Clamp(GetFloat(fields, line, 0f, "noise_highpass", "noise_hp"), 0f, 8000f));
|
||||
_sourcePorts.Add(port);
|
||||
_sourcePortsByName[name] = port;
|
||||
RegisterSourcePortSurfaces(_sourcePorts.Count - 1, port);
|
||||
|
|
@ -4443,6 +4445,13 @@ public static class PatchScript
|
|||
_ => throw new PatchScriptException(line, $"unknown tract propagation mode `{value}`")
|
||||
};
|
||||
|
||||
private static GlottalPulse ParseGlottalPulse(string value, int line) => value.ToLowerInvariant() switch
|
||||
{
|
||||
"saw" or "sawtooth" => GlottalPulse.Saw,
|
||||
"rosenberg" => GlottalPulse.Rosenberg,
|
||||
_ => throw new PatchScriptException(line, $"unknown glottal pulse `{value}` (saw, rosenberg)")
|
||||
};
|
||||
|
||||
private static AcousticSourceKind ParseAcousticSourceKind(string value, int line) => value.ToLowerInvariant() switch
|
||||
{
|
||||
"glottal" or "glottis" or "larynx" => AcousticSourceKind.Glottal,
|
||||
|
|
|
|||
|
|
@ -12,19 +12,19 @@ public sealed class GlottalSourceSpectrumTests(ITestOutputHelper output)
|
|||
private const int Rate = 48000;
|
||||
private const float Pitch = 137f;
|
||||
|
||||
private static string Script(float tilt, float pitch) => $$"""
|
||||
private static string Script(float tilt, float pitch, string extra = "") => $$"""
|
||||
morphology name=oral length_cm=17 diameters=.6,.8,1.2,1.5,.9
|
||||
waveguide_path name=oral_path morphology=oral loss=.998
|
||||
source_port name=folds path=oral_path pressure=.7 tension=.55 opening=.45 noise=0 impedance=.3 tilt={{tilt}}
|
||||
source_port name=folds path=oral_path pressure=.7 tension=.55 opening=.45 noise=0 impedance=.3 tilt={{tilt}} {{extra}}
|
||||
radiation_load name=mouth path=oral_path aperture=.8 reflection=-.82 impedance=.28
|
||||
vocal_network name=voice paths=oral_path sources=folds radiation=mouth
|
||||
vocal network=voice freq={{pitch}} gain=.2 sustain=1.5
|
||||
""";
|
||||
|
||||
// One second of steady output, so every harmonic of Pitch and every other integer-Hz frequency sits on its own DFT bin.
|
||||
private float[]? Render(float tilt, float pitch = Pitch, int skip = 4800)
|
||||
private float[]? Render(float tilt, float pitch = Pitch, int skip = 4800, string extra = "")
|
||||
{
|
||||
var source = FaustEmitter.Emit(PatchScript.Parse(Script(tilt, pitch)), new FaustExportOptions("glottal_spectrum")).Source;
|
||||
var source = FaustEmitter.Emit(PatchScript.Parse(Script(tilt, pitch, extra)), new FaustExportOptions("glottal_spectrum")).Source;
|
||||
using var compiler = new AquaSynthPatchCompiler(new AquaSynthNativeOptions(SampleRate: Rate));
|
||||
if (!compiler.TryCompileSource(new AquaSynthCompileIdentity("glottal_spectrum", "glottal_spectrum", ""), source, 1.4f, out var patch, out var error))
|
||||
{
|
||||
|
|
@ -122,4 +122,133 @@ public sealed class GlottalSourceSpectrumTests(ITestOutputHelper output)
|
|||
var defaulted = PatchScript.Parse(Script(.8f, Pitch).Replace("tilt=0.8", "", StringComparison.Ordinal));
|
||||
Assert.Equal(.5f, Assert.Single(defaulted.SourcePorts).Tilt, 5);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PulseAndNoiseHighPassAreAuthoredSourceFieldsDefaultingToSawAndWhite()
|
||||
{
|
||||
var port = Assert.Single(PatchScript.Parse(Script(.5f, Pitch, "pulse=rosenberg noise_hp=2000")).SourcePorts);
|
||||
Assert.Equal(GlottalPulse.Rosenberg, port.Pulse);
|
||||
Assert.Equal(2000f, port.NoiseHighPassHz);
|
||||
var defaulted = Assert.Single(PatchScript.Parse(Script(.5f, Pitch)).SourcePorts);
|
||||
Assert.Equal(GlottalPulse.Saw, defaulted.Pulse);
|
||||
Assert.Equal(0f, defaulted.NoiseHighPassHz);
|
||||
Assert.Throws<PatchScriptException>(() => PatchScript.Parse(Script(.5f, Pitch, "pulse=triangle")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OnlyTheRosenbergPulseEmitsThePhasorAndOnlyAHighPassedSourceEmitsTheNoiseFilter()
|
||||
{
|
||||
string Emit(string extra) => FaustEmitter.Emit(PatchScript.Parse(Script(.5f, Pitch, extra)), new FaustExportOptions("pulse_emit")).Source;
|
||||
Assert.DoesNotContain("lf_sawpos", Emit(""), StringComparison.Ordinal);
|
||||
Assert.Contains("lf_sawpos", Emit("pulse=rosenberg"), StringComparison.Ordinal);
|
||||
Assert.DoesNotContain("fi.highpass(2, 2000", Emit(""), StringComparison.Ordinal);
|
||||
Assert.Contains("fi.highpass(2, 2000", Emit("noise_hp=2000"), StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RosenbergPulseIsPeriodicAtThePitchAndRendersWithinSixDbOfTheSaw()
|
||||
{
|
||||
var saw = Render(.5f);
|
||||
var pulse = Render(.5f, extra: "pulse=rosenberg");
|
||||
if (saw is null || pulse is null) return;
|
||||
|
||||
double Rms(float[] w) => Math.Sqrt(w.Sum(v => (double)v * v) / w.Length);
|
||||
var difference = Db(Rms(pulse) / Rms(saw));
|
||||
output.WriteLine($"rosenberg rms {Rms(pulse):E3} saw rms {Rms(saw):E3} ({difference:F2} dB)");
|
||||
// The source rms is matched, the rendered level is not: the tract passes the saw's strong upper harmonics and the pulse has none (-3.2 dB here, -2.5 dB on /ɑmi/, measured -2.54).
|
||||
Assert.InRange(difference, -6, 0);
|
||||
var fundamental = Magnitude(pulse, Pitch);
|
||||
var between = Magnitude(pulse, Pitch * 1.5);
|
||||
Assert.True(Db(between / fundamental) < -30, $"energy between harmonics {Db(between / fundamental):F1} dB re the fundamental");
|
||||
}
|
||||
|
||||
// One expression compiled alone as a one-output DSP. The pulse is run at 100 Hz, which divides the rate (480 samples a period), so every sample
|
||||
// sits at a known phase; the patch path scales a bare signal by a constant, so levels are read against os.sawtooth through the same path.
|
||||
// Expected values are Rosenberg C written out here, independent of the emitted formula's spelling.
|
||||
private float[]? RenderBare(string expression, double seconds)
|
||||
{
|
||||
var dsp = $"import(\"stdfaust.lib\");\nprocess = {expression};\n";
|
||||
using var compiler = new AquaSynthPatchCompiler(new AquaSynthNativeOptions(SampleRate: Rate));
|
||||
if (!compiler.TryCompileSource(new AquaSynthCompileIdentity("pulse_bare", "pulse_bare", ""), dsp, (float)seconds + .1f, out var patch, out var error))
|
||||
{
|
||||
if (error?.Contains("Faust toolchain not found", StringComparison.OrdinalIgnoreCase) == true ||
|
||||
error?.Contains("Faust DLL not found", StringComparison.OrdinalIgnoreCase) == true)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Assert.Fail($"bare pulse compile failed: {error}");
|
||||
}
|
||||
|
||||
using (patch) return patch!.Render((float)seconds);
|
||||
}
|
||||
|
||||
private static double RosenbergC(double p) =>
|
||||
p < 0.4 ? 0.5 * (1 - Math.Cos(Math.PI * p / 0.4)) : p < 0.56 ? Math.Cos(Math.PI * 0.5 * (p - 0.4) / 0.16) : 0;
|
||||
|
||||
[Fact]
|
||||
public void RosenbergPulseIsTheDocumentedRosenbergCZeroMeanAtTheSawsRms()
|
||||
{
|
||||
const int period = 480;
|
||||
var pulse = RenderBare(FaustEmitter.RosenbergPulse("100.0"), 0.5);
|
||||
var saw = RenderBare("os.sawtooth(100.0)", 0.5);
|
||||
if (pulse is null || saw is null) return;
|
||||
var cycle = pulse.Skip(period).Take(period).ToArray();
|
||||
double Rms(IEnumerable<float> w) => Math.Sqrt(w.Sum(v => (double)v * v) / w.Count());
|
||||
// Calibrate the path's scale on the saw (rms 1/sqrt3 at the source): read every pulse sample back at source level.
|
||||
var scale = Rms(saw.Skip(period).Take(period)) / (1 / Math.Sqrt(3));
|
||||
cycle = cycle.Select(v => (float)(v / scale)).ToArray();
|
||||
|
||||
// Rosenberg C has mean 0.301859 and rms 0.372667 about it; the emitted pulse is that, zero-mean, scaled to the saw's rms.
|
||||
Assert.InRange(cycle.Average(), -0.003, 0.003);
|
||||
var rms = Rms(cycle);
|
||||
output.WriteLine($"pulse rms {rms:F5} (saw 1/sqrt3 = {1 / Math.Sqrt(3):F5}), path scale {scale:F4}, peak {cycle.Max():F4}, floor {cycle.Min():F4}");
|
||||
Assert.InRange(Db(rms / (1 / Math.Sqrt(3))), -0.05, 0.05);
|
||||
|
||||
// Shape at every phase point. The phasor's alignment to the sample grid is not part of the contract, so find the shift that fits,
|
||||
// then hold every point to the closed form: opening cosine, return cosine, closed plateau. A linear opening, another scale or no return phase all miss.
|
||||
double Expected(int n, int shift) => (RosenbergC(((n + shift) % period) / (double)period) - 0.301859) * 1.549;
|
||||
var shift = Enumerable.Range(0, period).MinBy(k => Enumerable.Range(0, period).Sum(n => Math.Pow(cycle[n] - Expected(n, k), 2)));
|
||||
var worst = Enumerable.Range(0, period).Max(n => Math.Abs(cycle[n] - Expected(n, shift)));
|
||||
output.WriteLine($"best shift {shift} samples, worst deviation from Rosenberg C {worst:E2}");
|
||||
Assert.True(worst < 0.01, $"worst deviation from Rosenberg C {worst:E2} at shift {shift}");
|
||||
// The regions by value: the opening peaks at p = 0.4 at (1 - mean) * 1.549, the closed floor is -mean * 1.549 and holds for 0.44 of the period (plus the tail of the return cosine inside the tolerance).
|
||||
Assert.InRange(cycle.Max(), (1 - 0.301859) * 1.549 - 0.01, (1 - 0.301859) * 1.549 + 0.01);
|
||||
Assert.InRange(cycle.Min(), -0.301859 * 1.549 - 0.01, -0.301859 * 1.549 + 0.01);
|
||||
Assert.InRange(cycle.Count(v => Math.Abs(v - (-0.301859 * 1.549)) < 0.01), (int)(0.44 * period) - 15, (int)(0.44 * period) + 15);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NoiseHighPassCornerIsTheAuthoredHertz()
|
||||
{
|
||||
// The source's noise alone (pressure 0 silences the voiced part), white and through fi.highpass(2, fc): band energy against the white render tells the corner.
|
||||
// A 2 kHz corner leaves almost nothing under 700 Hz, passes 3-3.8 kHz whole and takes a few dB off 1.6-2.4 kHz; a 1 kHz corner passes the middle band; a 4 kHz corner cuts it.
|
||||
double Band(float[] w, double lo, double hi)
|
||||
{
|
||||
double sum = 0;
|
||||
for (var hz = lo; hz < hi; hz += 25) sum += Math.Pow(Magnitude(w, hz), 2);
|
||||
return sum;
|
||||
}
|
||||
|
||||
double[] Shape(string extra)
|
||||
{
|
||||
var window = Render(.5f, extra: "pressure=0 noise=2 " + extra);
|
||||
return window is null ? [] : [Band(window, 100, 700), Band(window, 1600, 2400), Band(window, 3000, 3800)];
|
||||
}
|
||||
|
||||
var white = Shape("");
|
||||
var at2k = Shape("noise_hp=2000 pulse=saw");
|
||||
if (white.Length == 0 || at2k.Length == 0) return;
|
||||
var at1k = Shape("noise_hp=1000");
|
||||
var at4k = Shape("noise_hp=4000");
|
||||
output.WriteLine($"band energies (100-700, 1600-2400, 3000-3800 Hz) white {string.Join(" ", white.Select(b => b.ToString("E2")))}");
|
||||
foreach (var (name, shape) in new[] { ("1k", at1k), ("2k", at2k), ("4k", at4k) }) output.WriteLine($"hp {name}: " + string.Join(" ", shape.Select(b => b.ToString("E2"))));
|
||||
double Rel(double[] shape, int band) => Db(Math.Sqrt(shape[band] / white[band]));
|
||||
Assert.True(Rel(at2k, 0) < -18, $"2 kHz corner leaves {Rel(at2k, 0):F1} dB at 100-700 Hz");
|
||||
Assert.InRange(Rel(at2k, 1), -6, -1.5);
|
||||
Assert.True(Rel(at2k, 2) > -1.5, $"2 kHz corner leaves {Rel(at2k, 2):F1} dB at 3-3.8 kHz");
|
||||
// A 1 kHz corner passes the 1.6-2.4 kHz band nearly whole; a 4 kHz corner cuts it hard.
|
||||
Assert.True(Rel(at1k, 1) > -2, $"1 kHz corner: {Rel(at1k, 1):F1} dB at 1.6-2.4 kHz");
|
||||
Assert.True(Rel(at4k, 1) < -9, $"4 kHz corner: {Rel(at4k, 1):F1} dB at 1.6-2.4 kHz");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,12 +8,17 @@ using AquaSynth.Faust;
|
|||
// Offline probe: one word, segmented by Weksa (the phones line of `weksa lower --phones`), as a run of IPA gestures on the
|
||||
// IpaGestureExperiment scaffold, rendered through the native libfaust path to a mono 16-bit WAV plus script.aqua, source.dsp
|
||||
// and manifest.json. It measures peak, rms and NaN; it cannot say how the word sounds.
|
||||
// usage: WordRender <outDir> <label> <freq-hz> <phones.json> [--no-burst]
|
||||
// usage: WordRender <outDir> <label> <freq-hz> <phones.json> [--no-burst] [--source "key=value ..."]
|
||||
// --source sets or replaces fields on the scaffold's `source_port` line (pulse=rosenberg, noise_hp=2000, tilt=.3): one source parameter changed, the phrase untouched.
|
||||
// noise=X also flattens the gesture noise splines to X: the gestures hold /vocal/sources/0/noise at 0.05 through a vowel and the spline wins over the slider's base value, so the field alone changes nothing. Meant for voiced-only phrases (a fricative's rise is flattened too).
|
||||
// --no-burst drops the plosive release_flow splines (the same edit the burst test makes), so a render pair isolates the burst.
|
||||
// exit: 0 rendered, 1 compile or non-finite output, 2 usage, 3 phones file refused, 4 phones the tract cannot make (listed, nothing rendered)
|
||||
// exit: 0 rendered, 1 compile or non-finite output, 2 usage or a refused --source (unknown or repeated key, no value, non-number, negative, noise_hp outside 0-8000, a script the parser rejects), 3 phones file refused, 4 phones the tract cannot make (listed, nothing rendered)
|
||||
const int Rate = 48000, Frames = 512;
|
||||
var noBurst = args.Length == 5 && args[4] == "--no-burst";
|
||||
if (args.Length != 4 && !noBurst) { Console.Error.WriteLine("usage: WordRender <outDir> <label> <freq-hz> <phones.json> [--no-burst]"); return 2; }
|
||||
var noBurst = args.Skip(4).Contains("--no-burst");
|
||||
var sourceAt = Array.IndexOf(args, "--source");
|
||||
var sourceFields = sourceAt >= 0 && sourceAt + 1 < args.Length ? args[sourceAt + 1] : "";
|
||||
var extra = args.Length - 4 - (noBurst ? 1 : 0) - (sourceAt >= 0 ? 2 : 0);
|
||||
if (args.Length < 4 || extra != 0 || (sourceAt >= 0 && (sourceAt < 4 || sourceAt + 1 >= args.Length))) { Console.Error.WriteLine("usage: WordRender <outDir> <label> <freq-hz> <phones.json> [--no-burst] [--source \"key=value ...\"]"); return 2; }
|
||||
var outDir = Path.GetFullPath(args[0]);
|
||||
var label = args[1];
|
||||
var freq = float.Parse(args[2], System.Globalization.CultureInfo.InvariantCulture);
|
||||
|
|
@ -36,6 +41,33 @@ var phones = plan.Phones.ToArray();
|
|||
Directory.CreateDirectory(outDir);
|
||||
|
||||
var script = IpaGestureExperiment.BuildWordScript(phones, freq);
|
||||
float? noiseLevel = null;
|
||||
// The fields a source_port accepts here, exactly as PatchScript spells them (case-sensitive): PatchScript ignores a key it does not know, so a typo would render the scaffold and record a change.
|
||||
string[] sourceKeys = ["pressure", "tension", "opening", "noise", "impedance", "flow_scale", "tilt", "pitch_ratio", "pulse", "noise_hp"];
|
||||
var seenKeys = new HashSet<string>(StringComparer.Ordinal);
|
||||
foreach (var field in sourceFields.Split(' ', StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
string? refusal = null;
|
||||
var eq = field.IndexOf('=');
|
||||
var key = eq > 0 ? field[..eq] : field;
|
||||
var value = eq > 0 ? field[(eq + 1)..] : "";
|
||||
float number = 0;
|
||||
if (eq <= 0 || value.Length == 0) refusal = "expected key=value";
|
||||
else if (!sourceKeys.Contains(key, StringComparer.Ordinal)) refusal = $"unknown key `{key}` (keys: {string.Join(", ", sourceKeys)})";
|
||||
else if (!seenKeys.Add(key)) refusal = $"key `{key}` given twice";
|
||||
else if (key != "pulse" && !(float.TryParse(value, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out number) && float.IsFinite(number))) refusal = $"`{key}` needs a number, got `{value}`";
|
||||
else if (key == "noise_hp" && number is < 0 or > 8000) refusal = "`noise_hp` is a corner in Hz, 0 to 8000";
|
||||
else if (key != "pulse" && number < 0) refusal = $"`{key}` is negative";
|
||||
if (refusal is not null) { Console.Error.WriteLine($"REFUSED --source field `{field}`: {refusal}"); return 2; }
|
||||
if (key == "noise") noiseLevel = number;
|
||||
var lines = script.Split('\n');
|
||||
var at = Array.FindIndex(lines, l => l.TrimStart().StartsWith("source_port name=folds ", StringComparison.Ordinal));
|
||||
if (at < 0) { Console.Error.WriteLine($"REFUSED --source field `{field}`: the scaffold has no source_port name=folds line"); return 2; }
|
||||
var tokens = lines[at].TrimEnd().Split(' ').Where(t => !t.StartsWith(key + "=", StringComparison.Ordinal)).Append(field);
|
||||
lines[at] = lines[at][..(lines[at].Length - lines[at].TrimStart().Length)] + string.Join(' ', tokens.Where(t => t.Length > 0));
|
||||
script = string.Join('\n', lines);
|
||||
}
|
||||
|
||||
File.WriteAllText(Path.Combine(outDir, "script.aqua"), script + "\n");
|
||||
var seconds = phones.Sum(p => p.Item1.DurationSeconds) + 0.12f;
|
||||
var home = AquaSynthFaustToolchain.Find();
|
||||
|
|
@ -43,7 +75,11 @@ Console.WriteLine($"faust home: {home ?? "(not found)"}");
|
|||
using var compiler = new AquaSynthPatchCompiler(new AquaSynthNativeOptions(SampleRate: Rate));
|
||||
// The exporter emits one merged spline per surface (the ControlSplineTimeline curve), so the DSP carries the word's motion
|
||||
// itself and no slider is driven from outside.
|
||||
var parsed = PatchScript.Parse(script);
|
||||
SynthPatch parsed;
|
||||
try { parsed = PatchScript.Parse(script); }
|
||||
catch (PatchScriptException ex) { Console.Error.WriteLine($"REFUSED --source \"{sourceFields}\": {ex.Message}"); return 2; }
|
||||
if (noiseLevel is { } nz)
|
||||
parsed = parsed with { ControlSplines = parsed.ControlSplines.Select(sp => sp.SurfacePath != "/vocal/sources/0/noise" ? sp : sp with { Points = sp.Points.Select(pt => pt with { Value = nz, OutValue = nz, InValue = nz }).ToArray() }).ToArray() };
|
||||
if (noBurst) parsed = parsed with { ControlSplines = parsed.ControlSplines.Where(s => !s.SurfacePath.EndsWith("/release_flow", StringComparison.Ordinal)).ToArray() };
|
||||
var source = FaustEmitter.Emit(parsed, new FaustExportOptions(label, SampleRate: Rate)).Source;
|
||||
File.WriteAllText(Path.Combine(outDir, "source.dsp"), source);
|
||||
|
|
@ -87,7 +123,7 @@ using (var w = new BinaryWriter(File.Create(wav)))
|
|||
var rms = Math.Sqrt(sum / pcm.Length);
|
||||
File.WriteAllText(Path.Combine(outDir, "manifest.json"), JsonSerializer.Serialize(new
|
||||
{
|
||||
label, freq, noBurst, weksa = new { word.Language, word.Source, Phones = word.Phones.Select(p => new { p.Ipa, Stress = p.Stress.ToString() }) }, seconds, sampleRate = Rate, frames = pcm.Length, peak, rms, nonFinite = nan,
|
||||
label, freq, noBurst, sourceFields, weksa = new { word.Language, word.Source, Phones = word.Phones.Select(p => new { p.Ipa, Stress = p.Stress.ToString() }) }, seconds, sampleRate = Rate, frames = pcm.Length, peak, rms, nonFinite = nan,
|
||||
wavSha256 = Convert.ToHexString(SHA256.HashData(File.ReadAllBytes(wav))).ToLowerInvariant(),
|
||||
scriptSha256 = Convert.ToHexString(SHA256.HashData(File.ReadAllBytes(Path.Combine(outDir, "script.aqua")))).ToLowerInvariant(),
|
||||
os = RuntimeInformation.OSDescription, faustHome = home
|
||||
|
|
|
|||
18
tools/WordRender/source-refusals.sh
Executable file
18
tools/WordRender/source-refusals.sh
Executable file
|
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
# Negative check for WordRender --source: every malformed field must exit 2 with a REFUSED line naming it, never crash (134) or render.
|
||||
# source-refusals.sh <WordRender.dll> <phones.json> e.g. tools/aqua-listen/kits/voice-source/phones/ami.json
|
||||
set -u
|
||||
DLL=$1; PHONES=$2; OUT=$(mktemp -d); bad=0
|
||||
check() { # <expected substring> <source string>
|
||||
msg=$(dotnet "$DLL" "$OUT/o" refuse 140 "$PHONES" --source "$2" 2>&1 >/dev/null); code=$?
|
||||
if [ $code -eq 2 ] && [[ "$msg" == *REFUSED*"$1"* ]]; then echo "ok [$2] -> 2 $msg"; else echo "FAIL [$2] -> exit $code: $msg"; bad=1; fi
|
||||
}
|
||||
check pulze "pulze=rosenberg"
|
||||
check Noise "Noise=.33"
|
||||
check noise "noise"
|
||||
check noise=abc "noise=abc"
|
||||
check noise_hp=-5 "noise_hp=-5"
|
||||
check noise_hp=9000 "noise_hp=9000"
|
||||
check noise "noise=.1 noise=.2"
|
||||
check pulse=triangle "pulse=triangle"
|
||||
rm -rf "$OUT"; exit $bad
|
||||
1
tools/aqua-listen/.gitignore
vendored
Normal file
1
tools/aqua-listen/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
__pycache__/
|
||||
|
|
@ -39,7 +39,7 @@ node smoke.mjs dist/listen.html # optional
|
|||
```
|
||||
|
||||
- `id`, `file` (wav, mp3, ogg or flac, relative to `--clips`), `title`, `feel` (intended feel; shown to the listener), `group`: required. `pair`: optional, must name another clip whose `pair` names this one. Anything wrong stops the build with the full list of problems.
|
||||
- Title, id and group are hidden from the listener and appear only in the export. The intended feel is shown, since "did it land" needs it.
|
||||
- Title, id and group are not shown beside a clip, but they are in the page's bytes and in the export, which a listener can press at any time: they are not hidden. Keep a title a short neutral label; nothing a listener should not read goes in a title. The intended feel is shown, since "did it land" needs it.
|
||||
- Order is shuffled from a random seed kept with the listener's answers (it is in the export). A pair is shuffled as one unit, with A/B position shuffled inside it.
|
||||
- Audio is embedded as-is (base64), so the page is about 1.4x the clip bytes. The build warns over 100 MB.
|
||||
- Autosave key is the kit id plus the sorted clip ids (`aqua-listen.v2:<kit id>:<ids>`), not the content hash: a rebuilt page (edited note, re-rendered clip) keeps the listener's answers, and a kit with a different clip-id set starts fresh while the old entry stays in the browser. Saved state is the shuffle seed, answers by clip id and pair choices by `idA|idB`; a pair's A/B/same value is positional (A is the first of the pair in the seed's order), so it holds only while the manifest's clip order is unchanged. When the new key is empty, the page adopts the fullest earlier `aqua-listen:<kit id>:<hash>` save whose answers name only this kit's clips; a save already under the new key is never overwritten. The save also records `pairSig`, the manifest's clip ids in manifest order: on load, a save whose `pairSig` is missing or different keeps its seed and answers and drops its pair picks, so reordering or re-pairing clips never reassigns a pick (an adopted hash-keyed save has no signature and cannot be checked, so its pairs are kept and stamped with the current one). A save missing `pairs`, or with `answers` that is not an object, is normalised to empty rather than crashing the page. "Erase this kit's saved answers" removes the new key and any adoptable hash-keyed save of this kit.
|
||||
|
|
@ -57,8 +57,8 @@ The blank verdict files this was meant to match were not found under `/opt/commo
|
|||
|
||||
### Kits in the repo
|
||||
|
||||
`kits/tract-weak-spots` and `kits/tract-stops` hold a `kit.json`, the `phones/*.json` that WordRender reads, and a `render.sh` that renders the clips (`render.sh <repo-root> <out-root>`; needs CULTLIB_ROOT and AQUASYNTH_FAUST_HOME, see the script header). Build a page from the rendered clips:
|
||||
`node tools/aqua-listen/build.mjs --manifest tools/aqua-listen/kits/tract-stops/kit.json --clips <out-root>/clips --out <out-root>/dist`. The titles in those kit.json files carry measured figures, a prediction and a falsifier; the page hides them from the listener.
|
||||
`kits/voice-source` is the voice-source kit: one phrase, five pairs, each pair changing one source parameter (`pulse=`, `noise=`, `noise_hp=` on the scaffold's `source_port`, set through `WordRender --source`); `predictions.md` was committed before any clip was rendered, `hnr.py` names the noise settings in dB, `clips.py` makes the clip files. `kits/tract-weak-spots` and `kits/tract-stops` hold a `kit.json`, the `phones/*.json` that WordRender reads, and a `render.sh` that renders the clips (`render.sh <repo-root> <out-root>`; needs CULTLIB_ROOT and AQUASYNTH_FAUST_HOME, see the script header). Build a page from the rendered clips:
|
||||
`node tools/aqua-listen/build.mjs --manifest tools/aqua-listen/kits/tract-stops/kit.json --clips <out-root>/clips --out <out-root>/dist`. The titles in `kits/tract-weak-spots` and `kits/tract-stops` still carry measured figures, a prediction and a falsifier, and the page does not hide them (they are in its bytes and in the export), so those pages are not blind to them. The `kits/voice-source` titles are neutral condition labels; its figures, predictions and falsifiers are in `predictions.md`.
|
||||
|
||||
### Pictures and burst notes (for a reader who cannot listen)
|
||||
|
||||
|
|
|
|||
28
tools/aqua-listen/kits/voice-source/clips.py
Normal file
28
tools/aqua-listen/kits/voice-source/clips.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Turns the six voice-source renders into the kit's clip files and measures them.
|
||||
clips.py <out-root> reads out/<label>/<label>.wav, writes clips/*.wav and measures.txt
|
||||
ros_matched is ros multiplied by (saw rms / ros rms) over the whole clip; every other clip is a byte copy of a render, and a clip used in two pairs is
|
||||
written once per pair under its own file name, so each pair is a unit the page can shuffle. Needs numpy."""
|
||||
import sys, wave, shutil, pathlib
|
||||
import numpy as np
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).parent))
|
||||
from hnr import read, hnr
|
||||
|
||||
out = pathlib.Path(sys.argv[1]); clips = out / "clips"; clips.mkdir(exist_ok=True)
|
||||
w = lambda n: out / "out" / n / f"{n}.wav"
|
||||
x = {n: read(str(w(n)))[0] for n in ["ref", "ros", "w20", "h20", "h25", "h15"]}
|
||||
rms = lambda a: float(np.sqrt(np.mean(a * a)))
|
||||
gain = rms(x["ref"]) / rms(x["ros"])
|
||||
with wave.open(str(w("ros"))) as src, wave.open(str(clips / "ros_matched.wav"), "wb") as dst:
|
||||
dst.setparams(src.getparams())
|
||||
dst.writeframes((np.clip(x["ros"] * gain, -1, 1) * 32767).astype("<i2").tobytes())
|
||||
files = {"saw_a.wav": "ref", "ros.wav": "ros", "saw_b.wav": "ref", "clean.wav": "ref", "w20.wav": "w20", "w20_b.wav": "w20", "h20.wav": "h20", "h25.wav": "h25", "h15.wav": "h15"}
|
||||
for f, n in files.items():
|
||||
shutil.copyfile(w(n), clips / f)
|
||||
lines = [f"{'clip':14s} {'HNR dB':>7s} {'rms':>8s} {'peak':>7s}"]
|
||||
for name in sorted(p.name for p in clips.glob("*.wav")):
|
||||
a, _ = read(str(clips / name))
|
||||
lines.append(f"{name:14s} {hnr(a, 48000)[0]:7.1f} {rms(a):8.4f} {np.abs(a).max():7.3f}")
|
||||
lines.append(f"ros_matched gain {gain:.3f} ({20 * np.log10(gain):.2f} dB)")
|
||||
(out / "measures.txt").write_text("\n".join(lines) + "\n")
|
||||
print("\n".join(lines))
|
||||
43
tools/aqua-listen/kits/voice-source/hnr.py
Normal file
43
tools/aqua-listen/kits/voice-source/hnr.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Harmonics-to-noise ratio of a clip, Boersma (1993) autocorrelation method, so a noise setting can be named in dB instead of in engine units.
|
||||
hnr.py CLIP.wav [f0-hz] prints median HNR over the voiced frames, and the frame count
|
||||
Frames of 40 ms at a 10 ms hop; a frame counts when its rms is above a tenth of the loudest frame's. r = the window-corrected normalised
|
||||
autocorrelation peak within +-25 % of f0 (default 140); HNR = 10 log10(r / (1 - r)). Reads 16-bit mono wav; needs numpy only.
|
||||
It is a measurement of the periodic share of the rendered output, not of the source alone: the tract shapes both.
|
||||
"""
|
||||
import sys, wave
|
||||
import numpy as np
|
||||
|
||||
|
||||
def read(path):
|
||||
with wave.open(path) as w:
|
||||
assert w.getsampwidth() == 2 and w.getnchannels() == 1
|
||||
return np.frombuffer(w.readframes(w.getnframes()), dtype="<i2").astype(float) / 32768, w.getframerate()
|
||||
|
||||
|
||||
def hnr(x, fs, f0=140.0, win=0.04, hop=0.01):
|
||||
n, h = int(win * fs), int(hop * fs)
|
||||
w = np.hanning(n)
|
||||
nfft = 1 << (2 * n - 1).bit_length()
|
||||
wac = np.fft.irfft(np.abs(np.fft.rfft(w, nfft)) ** 2)[:n]
|
||||
wac /= wac[0]
|
||||
lo, hi = int(fs / (f0 * 1.25)), int(fs / (f0 * 0.75))
|
||||
frames = [x[i:i + n] for i in range(0, len(x) - n, h)]
|
||||
rms = np.array([np.sqrt(np.mean(f * f)) for f in frames])
|
||||
out = []
|
||||
for f, e in zip(frames, rms):
|
||||
if e < 0.1 * rms.max():
|
||||
continue
|
||||
f = (f - f.mean()) * w
|
||||
if not f.any():
|
||||
continue
|
||||
ac = np.fft.irfft(np.abs(np.fft.rfft(f, nfft)) ** 2)[:n]
|
||||
r = float(np.clip((ac[lo:hi] / ac[0] / wac[lo:hi]).max(), 1e-6, 1 - 1e-6))
|
||||
out.append(10 * np.log10(r / (1 - r)))
|
||||
return float(np.median(out)), len(out)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
x, fs = read(sys.argv[1])
|
||||
v, k = hnr(x, fs, float(sys.argv[2]) if len(sys.argv) > 2 else 140.0)
|
||||
print(f"{v:.1f} dB over {k} frames")
|
||||
89
tools/aqua-listen/kits/voice-source/kit.json
Normal file
89
tools/aqua-listen/kits/voice-source/kit.json
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
{
|
||||
"kit": {
|
||||
"id": "voice-source-1",
|
||||
"title": "Synthetic voice: one source change at a time",
|
||||
"note": "The same short phrase, five pairs. In each pair only one thing about the voice's sound source differs. Tell us what you hear in the voice itself: buzz, edge, kazoo, breath, hiss. There are no wrong answers; 'no difference' is a real answer."
|
||||
},
|
||||
"clips": [
|
||||
{
|
||||
"id": "pulse-saw",
|
||||
"file": "saw_a.wav",
|
||||
"group": "pulse",
|
||||
"pair": "pulse-rosenberg",
|
||||
"title": "saw pulse, scaffold noise",
|
||||
"feel": "the short made-up phrase 'ah-mee' in a synthetic voice; listen to the voice itself (buzz, edge, breath), not the words"
|
||||
},
|
||||
{
|
||||
"id": "pulse-rosenberg",
|
||||
"file": "ros.wav",
|
||||
"group": "pulse",
|
||||
"pair": "pulse-saw",
|
||||
"title": "Rosenberg pulse, scaffold noise",
|
||||
"feel": "the short made-up phrase 'ah-mee' in a synthetic voice; listen to the voice itself (buzz, edge, breath), not the words"
|
||||
},
|
||||
{
|
||||
"id": "pulsematch-saw",
|
||||
"file": "saw_b.wav",
|
||||
"group": "pulsematch",
|
||||
"pair": "pulsematch-rosenberg",
|
||||
"title": "saw pulse, scaffold noise",
|
||||
"feel": "the short made-up phrase 'ah-mee' in a synthetic voice; listen to the voice itself (buzz, edge, breath), not the words"
|
||||
},
|
||||
{
|
||||
"id": "pulsematch-rosenberg",
|
||||
"file": "ros_matched.wav",
|
||||
"group": "pulsematch",
|
||||
"pair": "pulsematch-saw",
|
||||
"title": "Rosenberg pulse, level matched to the saw",
|
||||
"feel": "the short made-up phrase 'ah-mee' in a synthetic voice; listen to the voice itself (buzz, edge, breath), not the words"
|
||||
},
|
||||
{
|
||||
"id": "noise-clean",
|
||||
"file": "clean.wav",
|
||||
"group": "noise",
|
||||
"pair": "noise-hnr20",
|
||||
"title": "scaffold noise",
|
||||
"feel": "the short made-up phrase 'ah-mee' in a synthetic voice; listen to the voice itself (buzz, edge, breath), not the words"
|
||||
},
|
||||
{
|
||||
"id": "noise-hnr20",
|
||||
"file": "w20.wav",
|
||||
"group": "noise",
|
||||
"pair": "noise-clean",
|
||||
"title": "white noise, level .33",
|
||||
"feel": "the short made-up phrase 'ah-mee' in a synthetic voice; listen to the voice itself (buzz, edge, breath), not the words"
|
||||
},
|
||||
{
|
||||
"id": "colour-white20",
|
||||
"file": "w20_b.wav",
|
||||
"group": "colour",
|
||||
"pair": "colour-hp20",
|
||||
"title": "white noise, level .33",
|
||||
"feel": "the short made-up phrase 'ah-mee' in a synthetic voice; listen to the voice itself (buzz, edge, breath), not the words"
|
||||
},
|
||||
{
|
||||
"id": "colour-hp20",
|
||||
"file": "h20.wav",
|
||||
"group": "colour",
|
||||
"pair": "colour-white20",
|
||||
"title": "noise high-passed at 2 kHz, level .33",
|
||||
"feel": "the short made-up phrase 'ah-mee' in a synthetic voice; listen to the voice itself (buzz, edge, breath), not the words"
|
||||
},
|
||||
{
|
||||
"id": "aspiration-hp25",
|
||||
"file": "h25.wav",
|
||||
"group": "aspiration",
|
||||
"pair": "aspiration-hp15",
|
||||
"title": "noise high-passed at 2 kHz, level .165",
|
||||
"feel": "the short made-up phrase 'ah-mee' in a synthetic voice; listen to the voice itself (buzz, edge, breath), not the words"
|
||||
},
|
||||
{
|
||||
"id": "aspiration-hp15",
|
||||
"file": "h15.wav",
|
||||
"group": "aspiration",
|
||||
"pair": "aspiration-hp25",
|
||||
"title": "noise high-passed at 2 kHz, level .6",
|
||||
"feel": "the short made-up phrase 'ah-mee' in a synthetic voice; listen to the voice itself (buzz, edge, breath), not the words"
|
||||
}
|
||||
]
|
||||
}
|
||||
1
tools/aqua-listen/kits/voice-source/phones/ami.json
Normal file
1
tools/aqua-listen/kits/voice-source/phones/ami.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"language": "en-US", "source": "ɑmi", "phones": [{"ipa": "ɑ", "stress": "none"}, {"ipa": "m", "stress": "none"}, {"ipa": "i", "stress": "none"}]}
|
||||
45
tools/aqua-listen/kits/voice-source/predictions.md
Normal file
45
tools/aqua-listen/kits/voice-source/predictions.md
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# voice-source-1: predictions, written before any clip was rendered
|
||||
|
||||
Phrase: /ɑmi/ (WordRender, 140 Hz, 48 kHz). Meta's verdict on tract-weak-spots-1 heard "a kazoo with a two pack a day smoking habit", "reedy ... pink trombone", "a basketball buzzer" for /m/ and /n/; the voice source (a band-limited saw through a one-pole lowpass, plus 0.08 x noise x white) is the shared suspect. Each pair below changes ONE source parameter, everything else is the scaffold's.
|
||||
|
||||
Source-side numbers (computed from the two source formulas alone, harmonics of 140 Hz after the same tilt lowpass at 1131 Hz; the tract is not in them): Rosenberg minus saw, per harmonic: H1 +1.2 dB, H2 +0.3, H3 -6.3, H5 -10.5, H8 -17.2, H10 -17.8, H15 -22.0, H20 -24.5, H28 -27.4. Source rms differs +0.4 dB.
|
||||
|
||||
| pair | A | B | what changes | prediction | falsified if |
|
||||
|---|---|---|---|---|---|
|
||||
| pulse | saw | rosenberg | `pulse=` | B is darker and rounder: less buzz, less edge, F2 of /i/ weaker (the harmonics near 2 kHz are ~22 dB lower). Loudness the same (rms within 0.5 dB). | no difference heard; or B heard as buzzier/brighter; or B heard as the same "kazoo" quality. |
|
||||
| noise level | saw, noise at scaffold (effective level .05: the gesture splines hold noise at .05 and win over the slider's base value) | saw, white noise raised to HNR 20 dB | `noise=` | B has audible breath/hiss under the voice; a listener who called A a "kazoo" or "buzzer" hears B as less pure-tone, but still a machine. | B is not noisier; or the noise is heard as a separate hiss stream not fused with the voice; or A and B are both still a kazoo to the same degree (then purity of the periodicity is not what makes it a kazoo). |
|
||||
| noise colour | white noise, HNR 20 dB | noise high-passed at 2 kHz, HNR 20 dB | `noise_hp=` (noise level re-set to keep HNR 20) | B reads as hiss/"s"-like air, more separable from the voice than A; A reads as roughness/breathy voice. | no difference; or B heard as less hissy than A. |
|
||||
| aspiration level | high-passed noise, HNR 25 dB | high-passed noise, HNR 15 dB | `noise=` | B is clearly hissy; A is at most faintly airy and may be called "no difference" from a clean voice. | A is already clearly hissy, or B is not hissier than A. |
|
||||
|
||||
Measured HNR (hnr.py, Boersma autocorrelation, median over voiced frames) is reported next to each clip after rendering; a target missed by more than 2 dB is stated as missed, and the noise value is not retuned to the answer.
|
||||
|
||||
What this kit cannot say: LF (the Liljencrants-Fant model) is not tested; the pulse is Rosenberg C with fixed open phase 0.4 and return 0.16. One listener, one phrase, one f0, one device.
|
||||
|
||||
## Added after the calibration renders, before the kit renders
|
||||
|
||||
Sixteen calibration renders of the same phrase were made in two rounds of eight (14:32 and 14:43 on 2026-11-13; nobody listened to them). The figures below are from the second round plus the Rosenberg render of the first; the first round's other five renders were made and their results are not reported here. They gave: noise 0 -> HNR 30.8 dB (the method's ceiling on this phrase), white noise .1/.16/.25 -> 27.7/25.2/22.2, noise high-passed at 2 kHz .2/.4/.7/1.0 -> 24.5/18.4/13.6/10.6, and Rosenberg at the scaffold's noise -> 29.1 dB. They also showed the Rosenberg render is 2.5 dB lower in output rms (measured -2.54 dB on the final render) and 6.8 dB lower in peak than the saw, although the SOURCE rms is matched: the tract passes the saw's strong upper harmonics and the pulse has none. The first prediction row's "loudness the same" is therefore already known to be false at the output; it stays in the table as written.
|
||||
|
||||
A fifth pair is added so loudness cannot carry the answer: the Rosenberg render scaled up by its measured rms deficit against the saw (a gain on the clip, applied by the kit's render script), against the same saw render. Prediction: the same darker, rounder B as the pulse pair, and B is no longer the quieter one. FALSIFIED if B at matched rms is no longer heard as darker/rounder (then loudness, not shape, carried the first pair), or if it is heard as louder or brighter.
|
||||
|
||||
Targets chosen from the calibration fit: white .33 -> HNR 20 dB; high-passed .33 -> 20 dB, .165 -> 25 dB, .6 -> 15 dB.
|
||||
|
||||
## Measured on main ca6af1d
|
||||
|
||||
Figures for the ten kit clips, taken on main `ca6af1d` (PR #52) with `hnr.py` and `clips.py` (`measures.txt`). Removed from the clip titles, which the listener can see through the export.
|
||||
|
||||
| clip id | file | HNR dB | output rms | peak | note |
|
||||
|---|---|---|---|---|---|
|
||||
| pulse-saw | saw_a.wav | 30.3 | 0.0537 | 0.227 | scaffold: band-limited saw through the tilt lowpass |
|
||||
| pulse-rosenberg | ros.wav | 29.5 | 0.0401 (-2.5 dB re saw) | 0.102 (-6.9 dB) | rms deficit is a fact at the output; the prediction row's "loudness the same" is already falsified there |
|
||||
| pulsematch-saw | saw_b.wav | 30.3 | 0.0537 | 0.227 | byte copy of pulse-saw's render |
|
||||
| pulsematch-rosenberg | ros_matched.wav | 29.5 | 0.0537 (matched to the saw) | 0.137 | ros times 1.341 (+2.55 dB) |
|
||||
| noise-clean | clean.wav | 30.3 | 0.0537 | 0.227 | the scaffold's noise floor, 0.05; noise 0 measured 30.8 before the tract fix, the method's ceiling here |
|
||||
| noise-hnr20 | w20.wav | 19.9 | 0.0539 | 0.242 | white noise raised to level 0.33 |
|
||||
| colour-white20 | w20_b.wav | 19.9 | 0.0539 | 0.242 | byte copy of noise-hnr20's render |
|
||||
| colour-hp20 | h20.wav | 19.9 | 0.0540 | 0.238 | noise high-passed at 2 kHz (2nd order), level 0.33 |
|
||||
| aspiration-hp25 | h25.wav | 25.8 | 0.0538 | 0.231 | high-passed noise, level 0.165 |
|
||||
| aspiration-hp15 | h15.wav | 14.9 | 0.0546 | 0.250 | high-passed noise, level 0.6 |
|
||||
|
||||
Band energy re total, 0-0.5 / 0.5-1.5 / 1.5-3 / 3-6 kHz, from the render before the tract fix of PR #52: saw -2.3 / -4.0 / -24.0 / -24.9 dB, Rosenberg -0.3 / -12.4 / -43.7 / -40.3 dB. These were not re-taken with the original method. A whole-file Hann periodogram on the new render gives saw -2.2 / -4.0 / -24.0 / -25.0 and Rosenberg -0.3 / -12.5 / -43.2 / -40.2, within 0.5 dB; a different FFT estimate of the new render differs by under 1 dB, and an independent check found the figures depend on the estimator (Welch differs by up to 1.6 dB, a raw periodogram by up to 3.1 dB). Read them as estimates to about 1 to 3 dB. The HNR figure is the Boersma autocorrelation method of `hnr.py` on the rendered output; Praat's autocorrelation HNR is within 0.5 dB for the noisy clips, and the clean clip sits at this method's ceiling.
|
||||
|
||||
Record corrections after the Soul pass (2026-11-14): the noise pair's table cell said the scaffold's noise was .04, the effective level is .05 (the cell was edited; the pair, the prediction and the falsifier are unchanged); the calibration addendum's count of renders was eight and is sixteen.
|
||||
20
tools/aqua-listen/kits/voice-source/render.sh
Executable file
20
tools/aqua-listen/kits/voice-source/render.sh
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
# Renders the voice-source-1 kit: the phrase /ɑmi/ (WordRender, 140 Hz, 48 kHz mono 16-bit), six renders that differ from the scaffold in ONE source field each:
|
||||
# ref (noise=.05, the scaffold's own effective level: byte-identical to a render with no --source) ros (pulse=rosenberg) w20 (noise=.33, white, HNR ~20) h20 (noise_hp=2000 noise=.33) h25 (noise_hp=2000 noise=.165) h15 (noise_hp=2000 noise=.6)
|
||||
# then ros_matched: ros scaled by the measured output-rms ratio saw/rosenberg, so a pair can be heard without the level difference.
|
||||
# render.sh <repo-root> <out-root> [jobs]
|
||||
# Needs CULTLIB_ROOT at the admitted CultLib revision and AQUASYNTH_FAUST_HOME. Under load each render is minutes (a Faust compile).
|
||||
# <out-root>/out/<label>/<label>.wav <out-root>/clips/*.wav the files kit.json names <out-root>/measures.txt HNR, rms, peak per clip
|
||||
# Build the page: node tools/aqua-listen/build.mjs --manifest tools/aqua-listen/kits/voice-source/kit.json --clips <out-root>/clips --out <out-root>/dist
|
||||
set -eu
|
||||
REPO=$(cd "$1" && pwd); OUT=$2; JOBS=${3:-6}; HERE=$REPO/tools/aqua-listen/kits/voice-source
|
||||
PY=${PYTHON:-python3}
|
||||
dotnet build "$REPO/tools/WordRender" -c Release -v q -o "$OUT/wr" | grep -E "rror\(s\)"
|
||||
mkdir -p "$OUT/out" "$OUT/clips"
|
||||
job() { n=$1; shift; dotnet "$OUT/wr/WordRender.dll" "$OUT/out/$n" "$n" 140 "$HERE/phones/ami.json" --source "$*" > "$OUT/out/$n.log" 2>&1 && echo "$n ok" || echo "$n FAILED (see $OUT/out/$n.log)"; }
|
||||
export -f job; export OUT HERE
|
||||
{
|
||||
echo "ref noise=.05"; echo "ros pulse=rosenberg"; echo "w20 noise=.33"
|
||||
echo "h20 noise_hp=2000 noise=.33"; echo "h25 noise_hp=2000 noise=.165"; echo "h15 noise_hp=2000 noise=.6"
|
||||
} | xargs -P "$JOBS" -L1 bash -c 'job "$@"' _
|
||||
$PY -I "$HERE/clips.py" "$OUT"
|
||||
Loading…
Reference in a new issue