Tract: coarticulation fixes for the tract-weak-spots-1 listening verdict (#52)
Merged as head maintainer after Soul passes 2 and 3 (aqua-body:verdict:cut-tract-coarticulation-pr52.s2, ...fix2.s3). Unheard: every clip is a measurement, not a listening. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
71cf9caeb6
commit
ca6af1d678
19 changed files with 981 additions and 71 deletions
|
|
@ -68,7 +68,7 @@ public sealed class NasalCouplingTests
|
|||
}
|
||||
|
||||
private static float Spline(SynthPatch patch, string namePrefix, string surfacePath) =>
|
||||
patch.ControlSplines.Single(spline => spline.Name.StartsWith(namePrefix, StringComparison.Ordinal) && spline.SurfacePath == surfacePath).Points[0].Value;
|
||||
patch.ControlSplines.Single(spline => spline.Name.StartsWith(namePrefix, StringComparison.Ordinal) && spline.SurfacePath == surfacePath).Points[^1].Value; // a held place: the last point is the gesture's value whether or not a boundary ramp precedes it
|
||||
|
||||
// Distance of a vowel_set consonant constriction from the lip plane in cm, from the constriction_index spline: the surface is a section
|
||||
// index in [0, sections] and the area model reads position = index / (sections - 1).
|
||||
|
|
|
|||
84
tests/AquaSynth.Dsl.Tests/PhoneTransitionTests.cs
Normal file
84
tests/AquaSynth.Dsl.Tests/PhoneTransitionTests.cs
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
using AquaSynth.Dsl;
|
||||
using AquaSynth.Faust;
|
||||
|
||||
namespace AquaSynth.Dsl.Tests;
|
||||
|
||||
// What Meta heard in tract-weak-spots-1 (2026-11-13) while every formant matched: clicks at the phone boundaries of nibu, a /b/ burst the
|
||||
// length of a fricative, and a first 100 ms that climbed from silence. These pin the three causes at the control-spline and DSP-source
|
||||
// level (docs/listening/tract-weak-spots-1-analysis-20261113.md); the renders are measured by tools/formant-check/ear_metrics.py.
|
||||
public sealed class PhoneTransitionTests
|
||||
{
|
||||
private static SynthPatch Nibu() => PatchScript.Parse(IpaGestureExperiment.BuildWordScript(
|
||||
[
|
||||
(new IpaGestureExperimentTarget("w_n", "n", "", .095f), 1f),
|
||||
(new IpaGestureExperimentTarget("w_i", "i", "", .18f), 1f),
|
||||
(new IpaGestureExperimentTarget("w_b", "b", "", .095f), 1f),
|
||||
(new IpaGestureExperimentTarget("w_u", "u", "", .18f), 1f)
|
||||
], frequency: 140));
|
||||
|
||||
[Fact]
|
||||
public void NoSurfaceStepsAtAPhoneBoundary()
|
||||
{
|
||||
var timeline = new ControlSplineTimeline(Nibu().ControlSplines);
|
||||
var worst = (Surface: "", Boundary: 0f, Step: 0f);
|
||||
foreach (var boundary in new[] { .095f, .275f, .37f })
|
||||
{
|
||||
foreach (var surface in timeline.SurfacePaths)
|
||||
{
|
||||
var step = MathF.Abs(timeline.ValueAt(surface, boundary + .0005f) - timeline.ValueAt(surface, boundary - .0005f));
|
||||
if (step > worst.Step) worst = (surface, boundary, step);
|
||||
}
|
||||
}
|
||||
|
||||
// 0.5 ms either side of a boundary; a 30 ms ramp across the full 0..1 range moves 0.017 in that time, a step moves it by the
|
||||
// whole difference (the pre-fix nibu stepped /vocal/areas/0/area/constriction_diameter by 0.77 at the 95 ms boundary).
|
||||
Assert.True(worst.Step < .03f, $"{worst.Surface} steps {worst.Step:0.000} at {worst.Boundary} s");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThePhoneAfterABoundaryArrivesAtItsFirstValueWithinTheTransition()
|
||||
{
|
||||
var timeline = new ControlSplineTimeline(Nibu().ControlSplines);
|
||||
const string diameter = "/vocal/areas/0/area/constriction_diameter";
|
||||
var closedN = timeline.ValueAt(diameter, .05f);
|
||||
Assert.True(closedN < .1f, "the /n/ constriction is shut");
|
||||
Assert.True(timeline.ValueAt(diameter, .095f + .002f) < .5f, "still closing into the vowel two ms after the boundary");
|
||||
Assert.Equal(1f, timeline.ValueAt(diameter, .095f + .035f), 2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheFirstPhoneOfAWordStartsAtItsOwnValue()
|
||||
{
|
||||
var timeline = new ControlSplineTimeline(Nibu().ControlSplines);
|
||||
Assert.Equal(timeline.ValueAt("/vocal/areas/0/area/constriction_diameter", 0f), timeline.ValueAt("/vocal/areas/0/area/constriction_diameter", .02f), 3);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AStopOpensInTwelveMillisecondsNotAThirdOfItsGesture()
|
||||
{
|
||||
var timeline = new ControlSplineTimeline(Nibu().ControlSplines);
|
||||
const string contact = "/vocal/contacts/0/opening";
|
||||
const float start = .275f, duration = .095f;
|
||||
Assert.True(timeline.ValueAt(contact, start + duration - .013f) < .1f, "closed until 12 ms before the end");
|
||||
Assert.True(timeline.ValueAt(contact, start + duration) > .8f, "open at the end");
|
||||
var opening = 0f;
|
||||
for (var t = start + .03f; t <= start + duration; t += .0005f)
|
||||
{
|
||||
if (timeline.ValueAt(contact, t) > .3f) { opening = t; break; }
|
||||
}
|
||||
|
||||
Assert.True(start + duration - opening < .012f, $"the opening crosses 0.3 only {start + duration - opening:0.000} s before the end");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ControlSmoothersStartAtTheirInputNotAtZero()
|
||||
{
|
||||
var source = FaustEmitter.Emit(Nibu(), new FaustExportOptions("transition_probe")).Source;
|
||||
Assert.Contains("smoo_init(x) =", source);
|
||||
Assert.Contains("smoo_init;", source);
|
||||
// Every control surface and spline-point slider uses it; patch parameters keep si.smoo.
|
||||
var remaining = source.Split('\n').Where(line => line.Contains("hslider", StringComparison.Ordinal) && line.Contains(": si.smoo;", StringComparison.Ordinal)
|
||||
&& (line.Contains("\"/vocal/", StringComparison.Ordinal) || line.Contains("\"/splines/", StringComparison.Ordinal))).ToArray();
|
||||
Assert.Empty(remaining);
|
||||
}
|
||||
}
|
||||
|
|
@ -16,9 +16,10 @@ public sealed class PlaceTableTests(ITestOutputHelper output)
|
|||
|
||||
private static float ConstrictionIndex(string script, string name) =>
|
||||
PatchScript.Parse(script).ControlSplines
|
||||
.Single(s => s.Name.StartsWith($"{name}_constriction_index", StringComparison.Ordinal) && s.SurfacePath == "/vocal/areas/0/area/constriction_index").Points[0].Value;
|
||||
.Single(s => s.Name.StartsWith($"{name}_constriction_index", StringComparison.Ordinal) && s.SurfacePath == "/vocal/areas/0/area/constriction_index").Points[^1].Value; // the held place; a boundary ramp may precede it
|
||||
|
||||
// Pre-cut values on af0e44f: the vowel_set constriction_index spline value of /b/ and /n/ (and the hash of the whole script and of the
|
||||
// Re-pinned on the phone-transition cut (boundary ramps, 12 ms stop release, smoo_init, vocal attack): these ids moved on purpose; the invariant
|
||||
// that survives is that a word of labials writes no position surface (below), not these bytes. Faust ids re-pinned again on the PR 52 fix passes (smoo_init pole, pitch-ratio smoother, shut lips for stops, spline handles; the scripts are unchanged; the last move is the smoo_from step line only, which reverts to prev * pole + x * (1 - pole): the old ids come back when that line is put back). Pre-cut values on af0e44f: the vowel_set constriction_index spline value of /b/ and /n/ (and the hash of the whole script and of the
|
||||
// Faust source for /apa/ and /aba/, which this cut must not change by a byte; the ids are a SHA-256 prefix).
|
||||
private const float BIndex = 0.8333333f, NIndex = 0.7118056f;
|
||||
|
||||
|
|
@ -28,7 +29,7 @@ public sealed class PlaceTableTests(ITestOutputHelper output)
|
|||
var b = ConstrictionIndex(Word("b"), "w_1_c");
|
||||
var n = ConstrictionIndex(Word("n"), "w_1_c");
|
||||
output.WriteLine($"b {b:R} n {n:R}");
|
||||
foreach (var (ipa, scriptSha, faustSha) in new[] { ("p", "61A96E0AE8C68F52", "28022E56A77DB5B1"), ("b", "5D5A6B653DC5D37D", "2FB84E792B878BFE") })
|
||||
foreach (var (ipa, scriptSha, faustSha) in new[] { ("p", "0E86DB0F40C0F12A", "358106F493D1783D"), ("b", "A63403EBAAD016FB", "AE80CF31EF1DDC9C") })
|
||||
{
|
||||
var script = Word(ipa);
|
||||
var faust = FaustEmitter.Emit(PatchScript.Parse(script), new FaustExportOptions("pin", SampleRate: 48000)).Source;
|
||||
|
|
@ -47,8 +48,8 @@ public sealed class PlaceTableTests(ITestOutputHelper output)
|
|||
{
|
||||
foreach (var (ipa, scriptSha, faustSha) in new[]
|
||||
{
|
||||
("p", "61A96E0AE8C68F52", "28022E56A77DB5B1"), ("b", "5D5A6B653DC5D37D", "2FB84E792B878BFE"),
|
||||
("n", "BDF24A66659D7BD6", "ABEB5D03DC9637DB"), ("t", "9DFBCDB5131F9776", "30E144D54F7E026F"),
|
||||
("p", "0E86DB0F40C0F12A", "358106F493D1783D"), ("b", "A63403EBAAD016FB", "AE80CF31EF1DDC9C"),
|
||||
("n", "5C3FA24E40D9DE26", "B2B9C5E1015B60A9"), ("t", "45941CCFD93561B3", "0AACE6D26F648FB0"),
|
||||
})
|
||||
{
|
||||
var script = Word(ipa);
|
||||
|
|
@ -109,8 +110,9 @@ public sealed class PlaceTableTests(ITestOutputHelper output)
|
|||
var script = IpaGestureExperiment.BuildWordScript(
|
||||
[(Phone("0_b", "b", 0.095f), 1f), (Phone("1_a", "a", 0.18f), 1f), (new IpaGestureExperimentTarget("w_2_t", "t", "voiceless_alveolar_plosive", 0.095f), 1f), (Phone("3_a", "a", 0.18f), 1f), (Phone("4_p", "p", 0.095f), 1f)], 140);
|
||||
Assert.All(SitePoints(script, "w_0_b"), v => Assert.Equal(0f, v));
|
||||
Assert.All(SitePoints(script, "w_4_p"), v => Assert.Equal(0f, v));
|
||||
Assert.All(SitePoints(script, "w_2_t"), v => Assert.True(v > 0.8f));
|
||||
Assert.All(SitePoints(script, "w_4_p").Skip(1), v => Assert.Equal(0f, v));
|
||||
// after the 30 ms boundary ramp from the previous plosive's place (the first point is that place)
|
||||
Assert.All(SitePoints(script, "w_2_t").Skip(1), v => Assert.True(v > 0.8f));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -120,11 +122,13 @@ public sealed class PlaceTableTests(ITestOutputHelper output)
|
|||
.Single(s => s.Name.StartsWith("w_1_c_constriction_diameter", StringComparison.Ordinal)).Points.Select(p => p.Value).ToArray();
|
||||
var t = PatchScript.Parse(Word("t", "voiceless_alveolar_plosive")).ControlSplines
|
||||
.Single(s => s.Name.StartsWith("w_1_c_constriction_diameter", StringComparison.Ordinal)).Points;
|
||||
Assert.Equal(0f, t[0].Value);
|
||||
// lead-in (the vowel's open 1), arrival, closure hold, end: shut from the arrival to the hold, and the hold ends StopReleaseSeconds before the stop does
|
||||
Assert.Equal(1f, t[0].Value);
|
||||
Assert.Equal(0f, t[1].Value);
|
||||
Assert.Equal(0.65f, (t[1].TimeSeconds - 0.18f) / 0.095f, 3);
|
||||
Assert.Equal(0f, t[2].Value);
|
||||
Assert.Equal(1 - 0.012f / 0.095f, (t[2].TimeSeconds - 0.18f) / 0.095f, 3);
|
||||
var b = Diameter(Word("b"));
|
||||
Assert.True(b[0] > 0 && Math.Abs(b[0] - b[1]) < 1e-6f, "the lip-sealed stop keeps the 0.03 aperture spline (its source text is pinned)");
|
||||
Assert.True(b[1] > 0 && Math.Abs(b[1] - b[2]) < 1e-6f, "the lip-sealed stop keeps the 0.03 aperture spline (its source text is pinned)");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
183
tests/AquaSynth.Dsl.Tests/StopClosureAndControlRenderTests.cs
Normal file
183
tests/AquaSynth.Dsl.Tests/StopClosureAndControlRenderTests.cs
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
using AquaSynth.Dsl;
|
||||
using AquaSynth.Faust;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace AquaSynth.Dsl.Tests;
|
||||
|
||||
// Renders behind the tract-coarticulation findings of the PR 52 Soul pass: what the closing ramp into a stop sounds like, what the DSP
|
||||
// does with a stop's 12 ms opening, and what the control smoothers and the word attack do at the start of a render. Each reads the
|
||||
// rendered signal (or the DSP's own probe), not the emitted text.
|
||||
[Collection("NativeFaust")]
|
||||
public sealed class StopClosureAndControlRenderTests(ITestOutputHelper output)
|
||||
{
|
||||
private const int Rate = 48000;
|
||||
|
||||
private static AquaSynthCompiledPatch? Compile(string source, float seconds)
|
||||
{
|
||||
using var compiler = new AquaSynthPatchCompiler(new AquaSynthNativeOptions(SampleRate: Rate));
|
||||
if (!compiler.TryCompileSource(new AquaSynthCompileIdentity("stop_closure", "stop_closure", ""), source, seconds, out var patch, out var error))
|
||||
{
|
||||
Assert.Fail($"compile failed: {error}");
|
||||
}
|
||||
|
||||
return patch;
|
||||
}
|
||||
|
||||
private static string Word(string ipa) => IpaGestureExperiment.BuildWordScript(
|
||||
[(new IpaGestureExperimentTarget("w_0_a", "a", "", 0.18f), 1f), (new IpaGestureExperimentTarget("w_1_c", ipa, "", 0.095f), 1f), (new IpaGestureExperimentTarget("w_2_a", "a", "", 0.18f), 1f)], 140);
|
||||
|
||||
// Power above 4 kHz (100 Hz grid to 12 kHz) of a Hann-windowed stretch.
|
||||
private static double HighPower(float[] x, double from, double to)
|
||||
{
|
||||
var a = (int)(from * Rate);
|
||||
var n = (int)((to - from) * Rate);
|
||||
var seg = Enumerable.Range(0, n).Select(i => x[a + i] * (0.5 - 0.5 * Math.Cos(2 * Math.PI * i / (n - 1)))).ToArray();
|
||||
double sum = 0;
|
||||
for (var hz = 4000; hz < 12000; hz += 100)
|
||||
{
|
||||
double re = 0, im = 0;
|
||||
for (var i = 0; i < n; i++) { var w = 2 * Math.PI * hz * i / Rate; re += seg[i] * Math.Cos(w); im -= seg[i] * Math.Sin(w); }
|
||||
sum += re * re + im * im;
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
// The 30 ms boundary ramp into a stop moves the contact, constriction and lip surfaces through every aperture between open and shut. The
|
||||
// burst noise is 4 * opening * (1 - opening) times a gain, and the gain was held through the closure, so each of those passes was a 15-20 ms
|
||||
// hiss before the stop. The interval is the stop's start to its release, against the same length of the vowel before it, in the >4 kHz
|
||||
// band, with the glottal source silent and the burst gain kept: the voiced stops' own voicing runs through the ramp and its harmonics
|
||||
// fill that band (/d/ read -11.6 dB with the source on and -52.8 with it off; with the source on it swings between -13.5 and -9.3 dB
|
||||
// with f0 alone, 139.5 to 145 Hz, as the harmonics fall on and off the 100 Hz grid), so with the source on the measure cannot tell the
|
||||
// voicing from the hiss. Source off, the burst gain held through the closure read +5 dB (/p/) and +14 dB (/t/, /d/) on 3b62b9c; gated,
|
||||
// every stop reads -52 dB. -30 is the bound between the two. /g/ is not here: it is not in TryIpaDescriptor, so it would render the default approximant and could not fail.
|
||||
[FaustTheory]
|
||||
[InlineData("p")]
|
||||
[InlineData("b")]
|
||||
[InlineData("t")]
|
||||
[InlineData("d")]
|
||||
[InlineData("k")]
|
||||
public void ClosingIntoAStopMakesNoHighFrequencyNoise(string ipa)
|
||||
{
|
||||
var parsed = PatchScript.Parse(Word(ipa));
|
||||
var voiceless = parsed with
|
||||
{
|
||||
ControlSplines = parsed.ControlSplines.Select(s => s.Name.StartsWith("w_1_c_source_level", StringComparison.Ordinal)
|
||||
? s with { Points = s.Points.Select(q => q with { Value = 0, OutValue = 0, InValue = 0 }).ToArray() }
|
||||
: s).ToArray()
|
||||
};
|
||||
using var patch = Compile(FaustEmitter.Emit(voiceless, new FaustExportOptions("stop_closure", SampleRate: Rate)).Source, 0.5f);
|
||||
var x = patch!.Render(0.5f);
|
||||
const double from = 0.18;
|
||||
var release = PatchScript.StopReleaseStartSeconds(0.095f);
|
||||
var closing = HighPower(x, from, from + release);
|
||||
var vowel = HighPower(x, from - release, from);
|
||||
var db = 10 * Math.Log10(closing / vowel);
|
||||
output.WriteLine($"/{ipa}/ >4 kHz energy of the closing interval {db:F1} dB re the vowel's before it, source silent");
|
||||
Assert.True(db < -30, $"/{ipa}/ closes with {db:F1} dB re the vowel's own >4 kHz energy");
|
||||
}
|
||||
|
||||
// The Faust lowering of a Bezier segment ignores the handle times and runs the curve on the linear fraction of the segment; the C# timeline
|
||||
// solves the curve's time, so a handle longer than the segment folds it. The stop's 12 ms opening had 23.75 ms handles: the contact opening
|
||||
// read 0.05 to 0.87 between 6 and 7 ms in C# and 0.46 to 0.57 in the DSP. This reads the opening through the DSP's own contact reservoir probe
|
||||
// (stored pressure + (1 - opening) * resistance, both at their defaults once the other splines are dropped) and compares it with the timeline.
|
||||
[FaustFact]
|
||||
public void TheDspRendersTheStopOpeningAsTheTimelineEvaluatesIt()
|
||||
{
|
||||
var script = Word("p");
|
||||
var parsed = PatchScript.Parse(script);
|
||||
var contact = parsed.ControlSplines.Where(s => s.SurfacePath == "/vocal/contacts/0/opening").ToArray();
|
||||
var alone = parsed with { ControlSplines = contact };
|
||||
var timeline = new ControlSplineTimeline(contact);
|
||||
var source = FaustEmitter.Emit(alone, new FaustExportOptions("stop_opening", SampleRate: Rate, DebugProbeUi: true)).Source;
|
||||
using var patch = Compile(source, 0.5f);
|
||||
using var stream = patch!.CreateStreamingPatch();
|
||||
var reservoir = stream.ProbePaths.Single(p => p.EndsWith("/contact/contact/reservoir", StringComparison.Ordinal));
|
||||
var release = 0.18f + PatchScript.StopReleaseStartSeconds(0.095f);
|
||||
var outputs = new[] { new float[48] };
|
||||
var dsp = new List<(float Time, float Reservoir)>();
|
||||
for (var block = 0; block < 400; block++)
|
||||
{
|
||||
stream.ProcessBlock([], outputs, 48);
|
||||
var t = (block + 1) * 48f / Rate;
|
||||
if (t >= release - 0.004f && t <= release + 0.016f) dsp.Add((t, stream.ReadProbe(reservoir)));
|
||||
}
|
||||
|
||||
// reservoir is linear in the opening; scale it by its own end points
|
||||
var shut = dsp.First().Reservoir;
|
||||
var open = dsp.Last().Reservoir;
|
||||
var worst = 0f;
|
||||
foreach (var (time, value) in dsp)
|
||||
{
|
||||
var dspOpening = (value - shut) / (open - shut);
|
||||
var curve = timeline.ValueAt("/vocal/contacts/0/opening", time);
|
||||
var shutValue = timeline.ValueAt("/vocal/contacts/0/opening", dsp.First().Time);
|
||||
var openValue = timeline.ValueAt("/vocal/contacts/0/opening", dsp.Last().Time);
|
||||
var timelineOpening = (curve - shutValue) / (openValue - shutValue);
|
||||
worst = MathF.Max(worst, MathF.Abs(dspOpening - timelineOpening));
|
||||
}
|
||||
|
||||
output.WriteLine($"worst difference between the DSP's opening and the timeline's over the release: {worst:F3}");
|
||||
Assert.True(worst < 0.08f, $"the DSP's stop opening departs from the timeline by {worst:F3}");
|
||||
}
|
||||
|
||||
// The same fact without the DSP: every handle of an authored spline is a third of its segment, so the C# curve is the curve the lowering runs.
|
||||
[Fact]
|
||||
public void EveryAuthoredSplineHandleIsAThirdOfItsSegment()
|
||||
{
|
||||
var splines = PatchScript.Parse(Word("p")).ControlSplines.Where(s => s.Points.Count > 1).ToArray();
|
||||
Assert.NotEmpty(splines);
|
||||
foreach (var spline in splines)
|
||||
{
|
||||
for (var i = 0; i + 1 < spline.Points.Count; i++)
|
||||
{
|
||||
var third = (spline.Points[i + 1].TimeSeconds - spline.Points[i].TimeSeconds) / 3;
|
||||
Assert.Equal(third, spline.Points[i].OutTimeOffsetSeconds, 5);
|
||||
Assert.Equal(third, spline.Points[i + 1].InTimeOffsetSeconds, 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Replaces the emitted patch's process with one control through the emitted smoo_init, so the smoother under test is the one the exporter
|
||||
// writes. Starts at its input at sample 0, and moves at si.smoo's 22.7 ms time constant when the control moves (5 ms gave 0.89 here).
|
||||
[FaustFact]
|
||||
public void ASmootherStartsAtItsInputAndMovesAtSiSmoosPace()
|
||||
{
|
||||
var emitted = FaustEmitter.Emit(PatchScript.Parse(Word("p")), new FaustExportOptions("smoo", SampleRate: Rate)).Source;
|
||||
var lines = emitted.Split('\n').Select(l => l.StartsWith("process =", StringComparison.Ordinal) ? "process = hslider(\"/vocal/sources/0/pressure\", 0.7, 0, 1, 0.001) : smoo_init;" : l);
|
||||
using var patch = Compile(string.Join('\n', lines), 0.2f);
|
||||
using var stream = patch!.CreateStreamingPatch();
|
||||
var first = new[] { new float[480] };
|
||||
stream.ProcessBlock([], first, 480);
|
||||
output.WriteLine($"sample 0 {first[0][0]:F4}, after 10 ms {first[0][479]:F4}");
|
||||
Assert.Equal(0.7f, first[0][0], 4);
|
||||
Assert.Equal(0.7f, first[0][479], 4);
|
||||
var after = new[] { new float[240] };
|
||||
stream.ProcessBlock([], after, 240, new Dictionary<string, float> { ["/vocal/sources/0/pressure"] = 1f });
|
||||
// 5 ms into a step from 0.7 to 1 with a 22.7 ms time constant
|
||||
var expected = 0.7 + 0.3 * (1 - Math.Pow(1 - 44.1 / Rate, 0.005 * Rate));
|
||||
output.WriteLine($"5 ms after a step to 1: {after[0][239]:F4}, si.smoo would be {expected:F4}");
|
||||
Assert.InRange(after[0][239], expected - 0.01, expected + 0.01);
|
||||
}
|
||||
|
||||
// A word starts with a 12 ms attack, not a step: the control smoothers no longer fade it in, and a step onset would be a click.
|
||||
[FaustFact]
|
||||
public void AWordBeginsWithATwelveMillisecondAttack()
|
||||
{
|
||||
double FirstMillisecondsPeak(string script)
|
||||
{
|
||||
using var patch = Compile(FaustEmitter.Emit(PatchScript.Parse(script), new FaustExportOptions("attack", SampleRate: Rate)).Source, 0.4f);
|
||||
var x = patch!.Render(0.4f);
|
||||
var steady = x.Skip((int)(0.05 * Rate)).Take((int)(0.1 * Rate)).Max(Math.Abs);
|
||||
return x.Take((int)(0.002 * Rate)).Max(Math.Abs) / steady;
|
||||
}
|
||||
|
||||
var script = IpaGestureExperiment.BuildWordScript([(new IpaGestureExperimentTarget("w_0_a", "a", "", 0.3f), 1f)], 140);
|
||||
Assert.Contains("attack=.012", script);
|
||||
var attacked = FirstMillisecondsPeak(script);
|
||||
var stepped = FirstMillisecondsPeak(script.Replace("attack=.012 ", "", StringComparison.Ordinal));
|
||||
output.WriteLine($"peak of the first 2 ms re the steady peak: with the attack {attacked:F3}, without {stepped:F3}");
|
||||
Assert.True(attacked < 0.25, $"the first 2 ms reach {attacked:F2} of the steady peak");
|
||||
Assert.True(stepped > 2 * attacked, "without the attack the onset is a step");
|
||||
}
|
||||
}
|
||||
|
|
@ -24,6 +24,11 @@ public sealed class StressAndReleaseRenderTests(ITestOutputHelper output)
|
|||
using (patch) return patch!.Render(seconds);
|
||||
}
|
||||
|
||||
// The stop's release time and the start of its closure (every articulator at its shut value, after the boundary ramp into it), both from the
|
||||
// one owner in PatchScript rather than as fractions of the gesture; the consonant is [from, to).
|
||||
private static double ReleaseAt(double from, double to) => from + PatchScript.StopReleaseStartSeconds((float)(to - from));
|
||||
private static double ClosureFrom(double from) => from + PatchScript.PhoneTransitionSeconds;
|
||||
|
||||
private static double Rms(float[] x, double from, double to)
|
||||
{
|
||||
var a = (int)(from * Rate);
|
||||
|
|
@ -95,7 +100,8 @@ public sealed class StressAndReleaseRenderTests(ITestOutputHelper output)
|
|||
var withoutBurst = Render(script, 0.4f, p => p with { ControlSplines = p.ControlSplines.Where(s => !s.SurfacePath.EndsWith("/release_flow", StringComparison.Ordinal)).ToArray() });
|
||||
// Everything but the burst's noise is deterministic and shared, so the difference of the two renders is the burst alone.
|
||||
var burst = withBurst.Zip(withoutBurst, (x, y) => x - y).ToArray();
|
||||
const double releaseFrom = 0.095 * 0.65, vowelFrom = 0.095;
|
||||
const double vowelFrom = 0.095;
|
||||
var releaseFrom = ReleaseAt(0, vowelFrom);
|
||||
var vowelPeak = Peak(withBurst, vowelFrom + 0.06, vowelFrom + 0.18);
|
||||
var burstPeak = Peak(burst, releaseFrom, vowelFrom + 0.01);
|
||||
var burstBeforeRelease = Peak(burst, 0, releaseFrom - 0.005);
|
||||
|
|
@ -121,7 +127,7 @@ public sealed class StressAndReleaseRenderTests(ITestOutputHelper output)
|
|||
var withoutBurst = Render(script, 0.77f, p => p with { ControlSplines = p.ControlSplines.Where(s => !s.SurfacePath.EndsWith("/release_flow", StringComparison.Ordinal)).ToArray() });
|
||||
var burst = withBurst.Zip(withoutBurst, (x, y) => x - y).ToArray();
|
||||
const double bFrom = 0.275, bTo = 0.37;
|
||||
var atRelease = Peak(burst, bFrom + 0.095 * 0.6, bTo + 0.02);
|
||||
var atRelease = Peak(burst, ReleaseAt(bFrom, bTo) - 0.003, bTo + 0.02);
|
||||
var leading = Peak(burst, 0, bFrom);
|
||||
var trailing = Peak(burst, bTo + 0.12, 0.77);
|
||||
output.WriteLine($"burst peak {atRelease:F4} at the release, {leading:F4} before the plosive (n, a), {trailing:F4} after it (a, n, tail)");
|
||||
|
|
@ -130,17 +136,64 @@ public sealed class StressAndReleaseRenderTests(ITestOutputHelper output)
|
|||
Assert.True(trailing < atRelease / 10, "no burst noise in the vowel, the nasal and the tail after the plosive");
|
||||
}
|
||||
|
||||
// The burst gain's window, read off the spline itself: it opens one ramp (0.15 of the gesture) before the plosive and has closed one ramp after it.
|
||||
// The rendered test above survived three mutants of the window (ramp 0, ramp 1.0 of the gesture, end moved to 3 ramps), so the bound is pinned here.
|
||||
// The burst gain's window, read off the spline itself: it exists only from the stop's release start, one ramp (0.15 of the release window)
|
||||
// before it and one after the stop's end. A gain held through the closure made the closing ramp a hiss (ClosingIntoAStopMakesNoHighFrequencyNoise).
|
||||
[Fact]
|
||||
public void PlosiveBurstGainWindowIsOneRampEitherSide()
|
||||
public void PlosiveBurstGainWindowIsOneRampEitherSideOfTheRelease()
|
||||
{
|
||||
IpaGestureExperimentTarget Phone(string label, string ipa, float seconds) => new($"w_{label}", ipa, "", seconds);
|
||||
var script = IpaGestureExperiment.BuildWordScript(
|
||||
[(Phone("0_n", "n", 0.095f), 1f), (Phone("1_a", "a", 0.18f), 1f), (Phone("2_b", "b", 0.095f), 1f), (Phone("3_a", "a", 0.18f), 1f), (Phone("4_n", "n", 0.095f), 1f)], 140);
|
||||
var window = PatchScript.Parse(script).ControlSplines.Single(s => s.SurfacePath.EndsWith("/release_flow", StringComparison.Ordinal) && s.Points.Any(p => p.Value > 0));
|
||||
const double start = 0.275, duration = 0.095, ramp = 0.15 * duration;
|
||||
Assert.Equal((start - ramp, start + duration + ramp), (window.Points.Min(p => (double)p.TimeSeconds), window.Points.Max(p => (double)p.TimeSeconds)), new TupleTolerance(1e-4));
|
||||
const double start = 0.275, duration = 0.095;
|
||||
var release = start + PatchScript.StopReleaseStartSeconds((float)duration);
|
||||
var ramp = 0.15 * (start + duration - release);
|
||||
Assert.Equal((release - ramp, start + duration + ramp), (window.Points.Min(p => (double)p.TimeSeconds), window.Points.Max(p => (double)p.TimeSeconds)), new TupleTolerance(1e-4));
|
||||
}
|
||||
|
||||
// The contact opening, the tongue's constriction and the lips all leave their shut value at the instant the burst gain window opens: one
|
||||
// owner, StopReleaseStartSeconds. Read off the splines, so a stale constant in one of them (the contact opening 20 ms early while the
|
||||
// burst keeps the owner's time) fails here and not only through a closure level that happens to cross a bound.
|
||||
[Theory]
|
||||
[InlineData("b", "w_2_b")]
|
||||
[InlineData("t", "w_2_t")]
|
||||
[InlineData("k", "w_2_k")]
|
||||
public void AStopsArticulatorsOpenWhereItsBurstGainWindowOpens(string ipa, string name)
|
||||
{
|
||||
IpaGestureExperimentTarget Phone(string label, string symbol, float seconds) => new($"w_{label}", symbol, "", seconds);
|
||||
var script = IpaGestureExperiment.BuildWordScript(
|
||||
[(Phone("0_n", "n", 0.095f), 1f), (Phone("1_a", "a", 0.18f), 1f), (Phone($"2_{ipa}", ipa, 0.095f), 1f), (Phone("3_a", "a", 0.18f), 1f)], 140);
|
||||
var splines = PatchScript.Parse(script).ControlSplines;
|
||||
const double start = 0.275, duration = 0.095;
|
||||
var release = start + PatchScript.StopReleaseStartSeconds((float)duration);
|
||||
var gain = splines.Single(s => s.Name.StartsWith(name, StringComparison.Ordinal) && s.SurfacePath.EndsWith("/release_flow", StringComparison.Ordinal));
|
||||
var ramp = 0.15 * (start + duration - release);
|
||||
Assert.Equal(release - ramp, gain.Points.Min(p => (double)p.TimeSeconds), 1e-4);
|
||||
var paths = ipa == "b"
|
||||
? new[] { "/vocal/contacts/0/opening", "/vocal/areas/0/area/constriction_diameter", "/vocal/areas/0/area/lip_opening", "/vocal/radiation/0/aperture" }
|
||||
: ["/vocal/contacts/0/opening", "/vocal/areas/0/area/constriction_diameter"];
|
||||
foreach (var path in paths)
|
||||
{
|
||||
var spline = splines.Single(s => s.Name.StartsWith(name, StringComparison.Ordinal) && s.SurfacePath == path);
|
||||
Assert.Equal(release, spline.Points.Where(p => p.TimeSeconds < start + duration - 1e-6).Max(p => (double)p.TimeSeconds), 1e-4);
|
||||
}
|
||||
}
|
||||
|
||||
// The nasal keeps its murmur's small lip opening where a stop shuts the lips (0.04 cm against 0): the shut-lip term is the stop's only.
|
||||
// Extending it to nasals moves /m/'s first nasal formant by 30 Hz and its murmur level by 0.4 dB and no render test notices, so the
|
||||
// value is read off the splines.
|
||||
[Theory]
|
||||
[InlineData("m", 0.04f)]
|
||||
[InlineData("b", 0f)]
|
||||
public void OnlyAStopShutsTheLipsCompletely(string ipa, float shut)
|
||||
{
|
||||
var script = IpaGestureExperiment.BuildWordScript(
|
||||
[(new IpaGestureExperimentTarget("w_0_a", "a", "", 0.18f), 1f), (new IpaGestureExperimentTarget("w_1_c", ipa, "", 0.095f), 1f), (new IpaGestureExperimentTarget("w_2_a", "a", "", 0.18f), 1f)], 140);
|
||||
foreach (var path in new[] { "/vocal/areas/0/area/lip_opening", "/vocal/radiation/0/aperture" })
|
||||
{
|
||||
var spline = PatchScript.Parse(script).ControlSplines.Single(s => s.Name.StartsWith("w_1_c", StringComparison.Ordinal) && s.SurfacePath == path);
|
||||
Assert.Equal(shut, spline.Points.Min(p => p.Value), 1e-4);
|
||||
}
|
||||
}
|
||||
|
||||
// /ɑ C ɑ/ at the scaffold's own durations (vowel 0.18 s, consonant 0.095 s). Returns the render and the consonant's [start, end).
|
||||
|
|
@ -241,7 +294,8 @@ public sealed class StressAndReleaseRenderTests(ITestOutputHelper output)
|
|||
private static SynthPatch WithoutBurst(SynthPatch p) =>
|
||||
p with { ControlSplines = p.ControlSplines.Where(s => !s.SurfacePath.EndsWith("/release_flow", StringComparison.Ordinal)).ToArray() };
|
||||
|
||||
// The closure of a stop is the part before its contact opens (0.65 of the gesture), 0.2 of the gesture in from its start, without the burst.
|
||||
// The closure of a stop is the part after the boundary ramp into it and before its release, without the burst (the ramp is the tract still
|
||||
// shutting on the vowel's decaying voicing; its noise is measured by ClosingIntoAStopMakesNoHighFrequencyNoise).
|
||||
// A tongue closure at the nasal's 0.03 cm aperture leaked: /t/ read -14.3 dB re the flanking vowels against /p/ -22.1 (the lips seal /p/);
|
||||
// completely closed it reads -24.3.
|
||||
[Fact]
|
||||
|
|
@ -252,7 +306,7 @@ public sealed class StressAndReleaseRenderTests(ITestOutputHelper output)
|
|||
var (x, from, to) = VowelConsonantVowel(ipa, descriptor: descriptor, edit: WithoutBurst);
|
||||
if (x is null) return double.NaN;
|
||||
var vowels = Math.Sqrt((Math.Pow(Rms(x, from - 0.08, from - 0.01), 2) + Math.Pow(Rms(x, to + 0.03, to + 0.12), 2)) / 2);
|
||||
return 20 * Math.Log10(Rms(x, from + 0.2 * (to - from), from + 0.65 * (to - from)) / vowels);
|
||||
return 20 * Math.Log10(Rms(x, ClosureFrom(from), ReleaseAt(from, to)) / vowels);
|
||||
}
|
||||
|
||||
var p = Closure("p", "voiceless_bilabial_plosive");
|
||||
|
|
@ -269,7 +323,7 @@ public sealed class StressAndReleaseRenderTests(ITestOutputHelper output)
|
|||
var (nb, _, _) = VowelConsonantVowel("t", descriptor: "voiceless_alveolar_plosive", edit: WithoutBurst);
|
||||
if (x is null || nb is null) return;
|
||||
var burst = x.Zip(nb, (a, b) => a - b).ToArray();
|
||||
var peak = Peak(burst, from + 0.6 * (to - from), to + 0.01);
|
||||
var peak = Peak(burst, ReleaseAt(from, to) - 0.003, to + 0.01);
|
||||
var vowel = Peak(x, to + 0.06, to + 0.17);
|
||||
output.WriteLine($"/t/ burst peak {peak:F4}, vowel peak {vowel:F4}, ratio {peak / vowel:F2}");
|
||||
Assert.True(peak > 0.004, "audible");
|
||||
|
|
@ -288,7 +342,7 @@ public sealed class StressAndReleaseRenderTests(ITestOutputHelper output)
|
|||
if (withBurst is null || withoutBurst is null) return;
|
||||
var burst = withBurst.Zip(withoutBurst, (x, y) => x - y).ToArray();
|
||||
const double tFrom = 0.275, tTo = 0.37;
|
||||
var atRelease = Peak(burst, tFrom + 0.095 * 0.6, tTo + 0.02);
|
||||
var atRelease = Peak(burst, ReleaseAt(tFrom, tTo) - 0.003, tTo + 0.02);
|
||||
var leading = Peak(burst, 0, tFrom);
|
||||
var trailing = Peak(burst, tTo + 0.12, 0.77);
|
||||
output.WriteLine($"/t/ burst peak {atRelease:F4} at the release, {leading:F5} before the plosive, {trailing:F5} after it");
|
||||
|
|
@ -305,7 +359,7 @@ public sealed class StressAndReleaseRenderTests(ITestOutputHelper output)
|
|||
var (x, from, to) = VowelConsonantVowel("t");
|
||||
var (nb, _, _) = VowelConsonantVowel("t", edit: WithoutBurst);
|
||||
if (x is null || nb is null) return;
|
||||
var start = (int)((from + 0.65 * (to - from)) * Rate);
|
||||
var start = (int)(ReleaseAt(from, to) * Rate);
|
||||
const int n = 960;
|
||||
var seg = Enumerable.Range(0, n).Select(i => (x[start + i] - nb[start + i]) * (0.5 - 0.5 * Math.Cos(2 * Math.PI * i / (n - 1)))).ToArray();
|
||||
double Power(double hz)
|
||||
|
|
@ -324,39 +378,44 @@ public sealed class StressAndReleaseRenderTests(ITestOutputHelper output)
|
|||
}
|
||||
|
||||
// /k/ over the /t/ tests: its own place (the velar distance in the place table), closure sealed by the tongue, burst under half the vowel.
|
||||
// The spec asks /k/'s closure to be at or below /p/'s. It is not: with the voiceless source as /p/ and /t/ have it the closure reads
|
||||
// -14.9 dB re the vowels (/p/ -20.4, /t/ -24.9). The tract itself seals: with the glottal source's flow scale held at 0 over the gesture the
|
||||
// same closure reads -22.7 dB, under /p/; with the source on, the 150 Hz voicing is what reaches the output through a closure that leaves
|
||||
// only a short rear cavity (the glottal pressure that the tract wall radiates is higher the smaller that cavity is). Silencing voicing in
|
||||
// voiceless stops would change /p/ and /t/ (pinned byte for byte), so the criterion is reported as unmet (fork), not met by a /k/ special case.
|
||||
// The second assertion is a regression bound on the measured leak, not the criterion.
|
||||
// The spec asks /k/'s closure to be at or below /p/'s. With the voiceless source as /p/ and /t/ have it, it is not, and was not on main
|
||||
// either (-14.9 dB re the vowels, /p/ -20.4): the 150 Hz voicing reaches the output through a closure that leaves only a short rear cavity.
|
||||
// Silencing voicing in voiceless stops would change /p/ and /t/ (pinned byte for byte), so the criterion stays unmet (fork).
|
||||
// The measure is the source-on closure in its settled part (25 ms after the 30 ms closing ramp has finished, to 5 ms before the release),
|
||||
// because the source-off closure cannot see a leak: with the source off nothing drives the tract, and leaks of .02, .05 and .1 of the
|
||||
// diameter scale read -21.1, -21.2 and -21.2 dB over .21 to .263 s against -21.0 sealed, while the source-on closure reads 1.8, 1.8 and
|
||||
// 4.1 dB louder in the settled part. The closure
|
||||
// right after the ramp is no use either: the seal completes at the end of the ramp with the vowel's tail still in the rear cavity (the
|
||||
// source-off /k/ read -21.0 dB over .21 to .263 s with the ramp and -27.5 with the contact and the constriction stepped shut; main's
|
||||
// 30 ms-later window read -25.7), and that decays within the first 25 ms.
|
||||
// The test therefore proves its own measure first (a leak injected into the tongue's closed diameter must read 3 dB louder) and then bounds
|
||||
// the sealed closure (-16.5 measured; a .005, .03 or .035 leak reads -15.1, a .02 leak -14.7).
|
||||
[Fact]
|
||||
public void AVelarStopClosureSealsAndItsLeakIsTheGlottalSource()
|
||||
public void AVelarStopClosureSealsAndTheMeasureSeesALeak()
|
||||
{
|
||||
static SynthPatch WithoutSource(SynthPatch p) =>
|
||||
static SynthPatch Leaking(SynthPatch p) =>
|
||||
WithoutBurst(p) with
|
||||
{
|
||||
ControlSplines = WithoutBurst(p).ControlSplines
|
||||
.Select(s => s.Name.StartsWith("w_1_c_source_level", StringComparison.Ordinal)
|
||||
? s with { Points = s.Points.Select(q => q with { Value = 0, OutValue = 0, InValue = 0 }).ToArray() }
|
||||
.Select(s => s.Name == "w_1_c_constriction_diameter"
|
||||
? s with { Points = s.Points.Select(q => q.Value == s.Points.Min(v => v.Value) ? q with { Value = 0.1f, OutValue = 0, InValue = 0 } : q).ToArray() }
|
||||
: s).ToArray()
|
||||
};
|
||||
|
||||
double Closure(string ipa, string descriptor, Func<SynthPatch, SynthPatch> edit)
|
||||
double Closure(Func<SynthPatch, SynthPatch> edit)
|
||||
{
|
||||
var (x, from, to) = VowelConsonantVowel(ipa, descriptor: descriptor, edit: edit);
|
||||
var (x, from, to) = VowelConsonantVowel("k", descriptor: "voiceless_velar_plosive", edit: edit);
|
||||
if (x is null) return double.NaN;
|
||||
var vowels = Math.Sqrt((Math.Pow(Rms(x, from - 0.08, from - 0.01), 2) + Math.Pow(Rms(x, to + 0.03, to + 0.12), 2)) / 2);
|
||||
return 20 * Math.Log10(Rms(x, from + 0.2 * (to - from), from + 0.65 * (to - from)) / vowels);
|
||||
return 20 * Math.Log10(Rms(x, ClosureFrom(from) + 0.025, ReleaseAt(from, to) - 0.005) / vowels);
|
||||
}
|
||||
|
||||
var p = Closure("p", "voiceless_bilabial_plosive", WithoutBurst);
|
||||
var k = Closure("k", "voiceless_velar_plosive", WithoutBurst);
|
||||
var kSilent = Closure("k", "voiceless_velar_plosive", WithoutSource);
|
||||
output.WriteLine($"closure re vowels: /p/ {p:F1} dB, /k/ {k:F1} dB, /k/ with the glottal source off {kSilent:F1} dB");
|
||||
if (double.IsNaN(p)) return;
|
||||
Assert.True(kSilent <= p, $"the /k/ closure seals: without the glottal source it is {kSilent:F1} dB, at or under /p/ ({p:F1} dB)");
|
||||
Assert.True(k <= -12, $"the /k/ closure with the source is {k:F1} dB (regression bound; the criterion, at or under /p/ {p:F1} dB, is not met)");
|
||||
var sealedClosure = Closure(WithoutBurst);
|
||||
var leaking = Closure(Leaking);
|
||||
output.WriteLine($"/k/ closure re vowels, source on, settled part: sealed {sealedClosure:F1} dB, with a 0.1 leak {leaking:F1} dB");
|
||||
if (double.IsNaN(sealedClosure)) return;
|
||||
Assert.True(leaking >= sealedClosure + 3, $"the measure sees a leak: sealed {sealedClosure:F1} dB, leaking {leaking:F1} dB");
|
||||
Assert.True(sealedClosure <= -15.5, $"the /k/ closure seals: {sealedClosure:F1} dB re the vowels (measured -16.5; leaks of .005 to .1 read -15.1 to -12.4, the measure is not monotonic in the leak, so the bound sits under the weakest of them)");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -366,7 +425,7 @@ public sealed class StressAndReleaseRenderTests(ITestOutputHelper output)
|
|||
var (nb, _, _) = VowelConsonantVowel("k", descriptor: "voiceless_velar_plosive", edit: WithoutBurst);
|
||||
if (x is null || nb is null) return;
|
||||
var burst = x.Zip(nb, (a, b) => a - b).ToArray();
|
||||
var peak = Peak(burst, from + 0.6 * (to - from), to + 0.01);
|
||||
var peak = Peak(burst, ReleaseAt(from, to) - 0.003, to + 0.01);
|
||||
var vowel = Peak(x, to + 0.06, to + 0.17);
|
||||
output.WriteLine($"/k/ burst peak {peak:F4}, vowel peak {vowel:F4}, ratio {peak / vowel:F2}");
|
||||
Assert.True(peak > 0.004, "audible");
|
||||
|
|
@ -384,7 +443,7 @@ public sealed class StressAndReleaseRenderTests(ITestOutputHelper output)
|
|||
if (withBurst is null || withoutBurst is null) return;
|
||||
var burst = withBurst.Zip(withoutBurst, (x, y) => x - y).ToArray();
|
||||
const double kFrom = 0.275, kTo = 0.37;
|
||||
var atRelease = Peak(burst, kFrom + 0.095 * 0.6, kTo + 0.02);
|
||||
var atRelease = Peak(burst, ReleaseAt(kFrom, kTo) - 0.003, kTo + 0.02);
|
||||
var leading = Peak(burst, 0, kFrom);
|
||||
var trailing = Peak(burst, kTo + 0.12, 0.77);
|
||||
output.WriteLine($"/k/ burst peak {atRelease:F4} at the release, {leading:F5} before the plosive, {trailing:F5} after it");
|
||||
|
|
@ -402,7 +461,7 @@ public sealed class StressAndReleaseRenderTests(ITestOutputHelper output)
|
|||
var (x, from, to) = VowelConsonantVowel(ipa, descriptor: descriptor);
|
||||
var (nb, _, _) = VowelConsonantVowel(ipa, descriptor: descriptor, edit: WithoutBurst);
|
||||
if (x is null || nb is null) return (double.NaN, double.NaN);
|
||||
var start = (int)((from + 0.65 * (to - from)) * Rate);
|
||||
var start = (int)(ReleaseAt(from, to) * Rate);
|
||||
const int n = 960;
|
||||
var seg = Enumerable.Range(0, n).Select(i => (x[start + i] - nb[start + i]) * (0.5 - 0.5 * Math.Cos(2 * Math.PI * i / (n - 1)))).ToArray();
|
||||
double Power(double hz)
|
||||
|
|
@ -468,7 +527,7 @@ public sealed class StressAndReleaseRenderTests(ITestOutputHelper output)
|
|||
if (withBurst is null || withoutBurst is null) return;
|
||||
var burst = withBurst.Zip(withoutBurst, (x, y) => x - y).ToArray();
|
||||
const double dFrom = 0.275, dTo = 0.37;
|
||||
var atRelease = Peak(burst, dFrom + 0.095 * 0.6, dTo + 0.02);
|
||||
var atRelease = Peak(burst, ReleaseAt(dFrom, dTo) - 0.003, dTo + 0.02);
|
||||
var leading = Peak(burst, 0, dFrom);
|
||||
var trailing = Peak(burst, dTo + 0.12, 0.77);
|
||||
output.WriteLine($"/d/ burst peak {atRelease:F4} at the release, {leading:F5} before the plosive, {trailing:F5} after it");
|
||||
|
|
|
|||
|
|
@ -148,10 +148,10 @@ public sealed class WeksaPhonesTests
|
|||
Assert.Equal([WeksaWordPlan.ConsonantSeconds, WeksaWordPlan.VowelSeconds * WeksaWordPlan.CueFor(WeksaStress.Primary).Duration, WeksaWordPlan.ConsonantSeconds, WeksaWordPlan.ConsonantSeconds, WeksaWordPlan.VowelSeconds],
|
||||
plan.Phones.Select(p => p.Target.DurationSeconds));
|
||||
var patch = PatchScript.Parse(IpaGestureExperiment.BuildWordScript(plan.Phones.ToArray(), 140));
|
||||
var ih = patch.ControlSplines.Where(s => s.Name.StartsWith("x_1_ɪ_vowel_", StringComparison.Ordinal)).ToDictionary(s => s.SurfacePath, s => s.Points[0].Value);
|
||||
var ih = patch.ControlSplines.Where(s => s.Name.StartsWith("x_1_ɪ_vowel_", StringComparison.Ordinal)).ToDictionary(s => s.SurfacePath, s => s.Points[^1].Value);
|
||||
Assert.Equal(1f, ih["/vocal/areas/0/area/vowel_ih"]);
|
||||
Assert.Equal(0f, ih["/vocal/areas/0/area/vowel_i"]);
|
||||
var oo = patch.ControlSplines.Where(s => s.Name.StartsWith("x_4_ʊ_vowel_", StringComparison.Ordinal)).ToDictionary(s => s.SurfacePath, s => s.Points[0].Value);
|
||||
var oo = patch.ControlSplines.Where(s => s.Name.StartsWith("x_4_ʊ_vowel_", StringComparison.Ordinal)).ToDictionary(s => s.SurfacePath, s => s.Points[^1].Value);
|
||||
Assert.Equal(1f, oo["/vocal/areas/0/area/vowel_oo_short"]);
|
||||
Assert.Equal(0f, oo["/vocal/areas/0/area/vowel_u"]);
|
||||
}
|
||||
|
|
@ -190,7 +190,7 @@ public sealed class WeksaPhonesTests
|
|||
var none = patch(WeksaStress.None);
|
||||
var primary = patch(WeksaStress.Primary);
|
||||
float First(SynthPatch p, string prefix, string surface) =>
|
||||
p.ControlSplines.Single(sp => sp.Name.StartsWith(prefix, StringComparison.Ordinal) && sp.SurfacePath == surface).Points[0].Value;
|
||||
p.ControlSplines.Single(sp => sp.Name.StartsWith(prefix, StringComparison.Ordinal) && sp.SurfacePath == surface).Points[^1].Value;
|
||||
|
||||
// pitch_ratio surface range 0.5..2: normalized (1.06 - .5) / 1.5; unstressed holds 1 -> (1 - .5) / 1.5.
|
||||
Assert.Equal((1.06f - .5f) / 1.5f, First(primary, "w_1_i_source_pitch", "/vocal/sources/0/pitch_ratio"), 4);
|
||||
|
|
|
|||
Loading…
Reference in a new issue