Nasal side branch: the 19-section Dang & Honda nasal tract, a velopharyngeal port area (opening * 0.8 cm^2) instead of a 0.4 cm diameter, vowel_set consonants placed in cm (/m/ at the lips, /n/ on the alveolar ridge cell), velum shut = opening 0
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b2d0363f2c
commit
671ff4ca01
6 changed files with 276 additions and 15 deletions
|
|
@ -13,8 +13,6 @@ public static partial class FaustEmitter
|
|||
private const float LadderGlottalReflection = 0.75f;
|
||||
// Speed of sound in cm/s used only to size the lip end correction from the lip radius (the ladder's own cell length uses the path's speed).
|
||||
private const float LipEndCorrectionSoundSpeedCentimeters = 35000f;
|
||||
// Full-open velum diameter in cm, as in Pink Trombone's velum target.
|
||||
private const float VelumOpenDiameterCentimeters = 0.4f;
|
||||
|
||||
private sealed record LadderPath(
|
||||
WaveguidePath Path,
|
||||
|
|
@ -70,8 +68,9 @@ public static partial class FaustEmitter
|
|||
continue;
|
||||
}
|
||||
|
||||
// The velopharyngeal port area, cm^2: opening * coupling * the design maximum (NasalTractAreas); it is the nasal ladder's first cell.
|
||||
var velum = $"{name}_primitive_branch_{SafeIdentifier(branch.Name)}_velum_area";
|
||||
source.AppendLine($" {velum} = max(0.000001, pow({admittances[branch.Name]} * {F(VelumOpenDiameterCentimeters)}, 2.0));");
|
||||
source.AppendLine($" {velum} = max(0.000001, {admittances[branch.Name]} * {F(NasalTractAreas.VelopharyngealPortMaximumAreaSquareCentimeters)});");
|
||||
var sum = $"({oral.A(cell)} + {oral.A(cell + 1)} + {velum})";
|
||||
var key = $"{name}_primitive_branch_{SafeIdentifier(branch.Name)}";
|
||||
source.AppendLine($" {key}_refl_left = (2.0 * {oral.A(cell)} - {sum}) / {sum};");
|
||||
|
|
|
|||
|
|
@ -232,13 +232,13 @@ public static class IpaGestureExperiment
|
|||
|
||||
private static string Scaffold(IReadOnlyList<string> gestureLines, float sustain, float frequency) => $$"""
|
||||
patch gain=.45
|
||||
morphology name=oral length_cm={{Format(StoryVowelAreas.MeanLengthCentimeters)}} diameters=.55,.75,1.05,1.45,1.25,.8 tongue_index=3 tongue_diameter=1.4 constriction_index=4 constriction_diameter=1 lip_opening=4
|
||||
morphology name=oral length_cm={{Format(StoryVowelAreas.MeanLengthCentimeters)}} diameters=.55,.75,1.05,1.45,1.25,.8 tongue_index=3 tongue_diameter=1.4 constriction_index=4 constriction_diameter=1 constriction_width=.03 lip_opening=4
|
||||
vowel_set area_function=oral source={{StoryVowelAreas.Source}}
|
||||
morphology name=nasal length_cm=12 diameters=.04,.28,.52,.72
|
||||
morphology name=nasal length_cm={{Format(NasalTractAreas.LengthCentimeters)}} areas={{NasalTractAreas.AreasList()}}
|
||||
waveguide_path name=oral_path morphology=oral speed={{TractSpeedMetersPerSecond}} strategy=thiran order=1 max_delay=4096 loss=.998
|
||||
waveguide_path name=nasal_path morphology=nasal speed={{TractSpeedMetersPerSecond}} strategy=thiran order=1 max_delay=4096 loss=.997
|
||||
source_port name=folds path=oral_path kind=glottal position=0 pressure=.66 tension=.54 opening=.42 noise=.04 impedance=.32 flow_scale=.12
|
||||
branch_port name=velopharynx from=oral_path from_position=.45 to=nasal_path opening=.01 coupling=1
|
||||
branch_port name=velopharynx from=oral_path from_position=.45 to=nasal_path opening=0 coupling=1
|
||||
constriction_contact name=contact path=oral_path position=.92 opening=1 resistance=.45 stored_pressure=.12
|
||||
radiation_load name=mouth path=oral_path kind=lip position=1 aperture=.8 reflection=-1 impedance=.28
|
||||
radiation_load name=nostril path=nasal_path kind=lip position=1 aperture=.8 reflection=-1 impedance=.28
|
||||
|
|
|
|||
33
src/AquaSynth.Core/NasalTractAreas.cs
Normal file
33
src/AquaSynth.Core/NasalTractAreas.cs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
namespace AquaSynth.Dsl;
|
||||
|
||||
/// <summary>
|
||||
/// The owner of the nasal tract area function and of the velopharyngeal port's maximum area. Data: Birkholz P, 2005, "3D-Artikulatorische
|
||||
/// Sprachsynthese", dissertation Universitaet Rostock, Table 2.3 (the nasal cavity of one subject, after Dang J, Honda K, 1994, "Morphological
|
||||
/// and acoustical analysis of the nasal and the paranasal cavities", JASA 96(4):2088-2100): 19 sections of 0.6 cm (11.4 cm), areas in cm^2,
|
||||
/// velopharyngeal end first, nostrils last. A test compares <see cref="Areas"/> to the cited values.
|
||||
/// Not modelled: the paranasal sinus Helmholtz resonators (zeros at 552-1682 Hz in the same source) and the piriform fossae. The table is a
|
||||
/// one-subject measurement and is unheard here: nothing in this file says how any nasal sounds.
|
||||
/// </summary>
|
||||
public static class NasalTractAreas
|
||||
{
|
||||
public const string Source = "birkholz2005-table2.3";
|
||||
public const float SectionLengthCentimeters = 0.6f;
|
||||
public const float LengthCentimeters = 11.4f;
|
||||
|
||||
public static IReadOnlyList<float> Areas { get; } =
|
||||
[
|
||||
1.63f, 2.07f, 2.72f, 3.59f, 4.24f, 3.26f, 3.04f, 3.04f, 2.72f, 2.5f,
|
||||
2.39f, 2.39f, 1.85f, 0.76f, 1.41f, 1.74f, 1.30f, 1.74f, 0.76f,
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Maximum cross-section area of the velopharyngeal port in cm^2: the ladder's port area is opening * coupling * this. A DESIGN VALUE:
|
||||
/// no source for the range of the port area was retrieved (Birkholz's velum port is a controllable area; its range is not in the
|
||||
/// material read). 0.8 cm^2 is a wide-open port, below the first nasal section (1.63 cm^2) so the port, not the table, is the narrowest
|
||||
/// first cell. Pink Trombone's earlier constant, a 0.4 cm diameter (0.16 cm^2 area at full opening and coupling), was likewise unsourced.
|
||||
/// </summary>
|
||||
public const float VelopharyngealPortMaximumAreaSquareCentimeters = 0.8f;
|
||||
|
||||
/// <summary>The scaffold's morphology line value for areas=, invariant-culture comma separated.</summary>
|
||||
public static string AreasList() => string.Join(",", Areas.Select(area => area.ToString("0.##", System.Globalization.CultureInfo.InvariantCulture)));
|
||||
}
|
||||
|
|
@ -1525,7 +1525,19 @@ public static class PatchScript
|
|||
return;
|
||||
}
|
||||
|
||||
AddAuthoredSpline($"{name}_constriction_index", "/vocal/areas/0/area/constriction_index", start, duration, (0, place), (1, place));
|
||||
if (_areaFunctions.Count > 0 && _areaFunctions[0].Vowels is not null && _areaFunctions[0].Deformation is { } control)
|
||||
{
|
||||
// Under vowel_set the constriction is placed by distance along the tract: the surface is a section index, so a normalized
|
||||
// place fraction would land at fraction * sections / (sections - 1) of the tract, past the lips for a labial.
|
||||
var sections = Math.Max(2, _areaFunctions[0].Shape.Sections);
|
||||
var position = ConsonantPositionFromGlottis(tokens, place, _areaFunctions[0].Shape.LengthCentimeters);
|
||||
HoldOnSurface($"{name}_constriction_index", "/vocal/areas/0/area/constriction_index", start, duration, position * (sections - 1) / control.IndexScale);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddAuthoredSpline($"{name}_constriction_index", "/vocal/areas/0/area/constriction_index", start, duration, (0, place), (1, place));
|
||||
}
|
||||
|
||||
AddAuthoredSpline($"{name}_constriction_diameter", "/vocal/areas/0/area/constriction_diameter", start, duration, (0, constriction), (0.5f, constriction), (1, Math.Min(0.65f, constriction + 0.2f)));
|
||||
|
||||
if (tokens.Contains("bilabial") || tokens.Contains("labiodental") || tokens.Contains("labial") || tokens.Contains("rounded"))
|
||||
|
|
@ -1544,13 +1556,13 @@ public static class PatchScript
|
|||
{
|
||||
AddAuthoredSpline($"{name}_contact", "/vocal/contacts/0/opening", start, duration, (0, 0.02f), (0.65f, 0.02f), (1, 0.9f));
|
||||
AddAuthoredSpline($"{name}_stored_pressure", "/vocal/contacts/0/stored_pressure", start, duration, (0, 0.4f), (0.65f, 0.75f), (1, 0.05f));
|
||||
AddAuthoredSpline($"{name}_velum", "/vocal/branches/0/opening", start, duration, (0, 0.01f), (1, 0.01f));
|
||||
AddAuthoredSpline($"{name}_velum", "/vocal/branches/0/opening", start, duration, (0, VelumClosed), (1, VelumClosed));
|
||||
}
|
||||
else if (tokens.Contains("fricative"))
|
||||
{
|
||||
AddAuthoredSpline($"{name}_contact", "/vocal/contacts/0/opening", start, duration, (0, 0.18f), (1, 0.22f));
|
||||
AddAuthoredSpline($"{name}_contact_resistance", "/vocal/contacts/0/resistance", start, duration, (0, 0.75f), (1, 0.85f));
|
||||
AddAuthoredSpline($"{name}_velum", "/vocal/branches/0/opening", start, duration, (0, 0.01f), (1, 0.01f));
|
||||
AddAuthoredSpline($"{name}_velum", "/vocal/branches/0/opening", start, duration, (0, VelumClosed), (1, VelumClosed));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1577,7 +1589,7 @@ public static class PatchScript
|
|||
// gain the consonant closures use (the lip cell cannot shut), so a vowel keeps it fully open; scaling it by the lip
|
||||
// area as well counted the rounding twice and left /u/ 30 dB under /i/.
|
||||
AddAuthoredSpline($"{name}_lip_radiation", "/vocal/radiation/0/aperture", start, duration, (0, 1), (1, 1));
|
||||
AddAuthoredSpline($"{name}_velum", "/vocal/branches/0/opening", start, duration, (0, 0.01f), (1, 0.01f));
|
||||
AddAuthoredSpline($"{name}_velum", "/vocal/branches/0/opening", start, duration, (0, VelumClosed), (1, VelumClosed));
|
||||
}
|
||||
|
||||
// Holds a surface at a value in its own unit (cm, section index); splines carry the surface's normalized range.
|
||||
|
|
@ -1618,6 +1630,25 @@ public static class PatchScript
|
|||
.Split(['_', ',', '+', ' '], StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
|
||||
.ToHashSet(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
// A shut velum is opening 0: the port area is linear in the opening (opening * coupling * NasalTractAreas maximum), so 0.01 would
|
||||
// leave a 0.008 cm^2 leak that shows in the oral formants.
|
||||
private const float VelumClosed = 0f;
|
||||
|
||||
// Distance from the lip plane to the alveolar ridge in cm. A DESIGN VALUE; no source for the distance was retrieved. 2.555 cm puts the
|
||||
// closure on the centre of ladder cell 20 of 24 of the scaffold tract (17.52 cm at 48 kHz and 350 m/s: (20.5 / 24) * 17.52 = 14.965 cm
|
||||
// from the glottis), the cell grid being what a narrow constriction (scaffold constriction_width .03, e-fold 0.63 cm) can close; it is
|
||||
// the ladder's counterpart of the tube check's closed end after section 37 of 44 (14.73 cm).
|
||||
private const float AlveolarRidgeCentimetersFromLips = 2.555f;
|
||||
|
||||
// Normalized position (0 glottis, 1 lips) of a consonant's constriction in the vowel_set path: labials at the lip plane, alveolars
|
||||
// AlveolarRidgeCentimetersFromLips behind it, every other place at its PlaceTarget fraction of the tract length.
|
||||
private static float ConsonantPositionFromGlottis(HashSet<string> tokens, float placeFraction, float lengthCentimeters)
|
||||
{
|
||||
if (tokens.Contains("bilabial") || tokens.Contains("labiodental") || tokens.Contains("labial")) return 1;
|
||||
if (tokens.Contains("alveolar")) return 1 - AlveolarRidgeCentimetersFromLips / lengthCentimeters;
|
||||
return placeFraction;
|
||||
}
|
||||
|
||||
private static float PlaceTarget(HashSet<string> tokens)
|
||||
{
|
||||
if (tokens.Contains("bilabial") || tokens.Contains("labiodental") || tokens.Contains("labial")) return 0.96f;
|
||||
|
|
|
|||
113
tests/AquaSynth.Dsl.Tests/NasalCouplingTests.cs
Normal file
113
tests/AquaSynth.Dsl.Tests/NasalCouplingTests.cs
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
using AquaSynth.Dsl;
|
||||
|
||||
namespace AquaSynth.Dsl.Tests;
|
||||
|
||||
// The nasal side branch: the cited nasal tract, the velopharyngeal port area, and where the scaffold's nasal and bilabial/alveolar gestures
|
||||
// close the mouth. The murmur itself is measured in VocalTractFormantTests (renders).
|
||||
public sealed class NasalCouplingTests
|
||||
{
|
||||
// Birkholz 2005 Table 2.3 after Dang & Honda 1994, copied here independently of NasalTractAreas: 19 sections of 0.6 cm, cm^2,
|
||||
// velopharyngeal end first.
|
||||
private static readonly float[] CitedAreas =
|
||||
[
|
||||
1.63f, 2.07f, 2.72f, 3.59f, 4.24f, 3.26f, 3.04f, 3.04f, 2.72f, 2.5f, 2.39f, 2.39f, 1.85f, 0.76f, 1.41f, 1.74f, 1.30f, 1.74f, 0.76f,
|
||||
];
|
||||
|
||||
[Fact]
|
||||
public void TheNasalTractTableIsTheCitedNineteenSections()
|
||||
{
|
||||
Assert.Equal(CitedAreas, NasalTractAreas.Areas.ToArray());
|
||||
Assert.Equal(11.4f, NasalTractAreas.LengthCentimeters, 4);
|
||||
Assert.Equal(NasalTractAreas.LengthCentimeters, CitedAreas.Length * NasalTractAreas.SectionLengthCentimeters, 3);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheScaffoldNasalMorphologyIsTheCitedTableAtItsLength()
|
||||
{
|
||||
var patch = PatchScript.Parse(IpaGestureExperiment.BuildWordScript([(new IpaGestureExperimentTarget("v_m", "m", "", .2f), 1f)]));
|
||||
var nasal = patch.AreaFunctions.Single(area => area.Name == "nasal").Shape;
|
||||
|
||||
Assert.Equal(11.4f, nasal.LengthCentimeters, 3);
|
||||
Assert.Equal(CitedAreas.Length, nasal.Diameters.Count);
|
||||
for (var i = 0; i < CitedAreas.Length; i++)
|
||||
{
|
||||
Assert.Equal(CitedAreas[i], nasal.Diameters[i] * nasal.Diameters[i], 2);
|
||||
}
|
||||
}
|
||||
|
||||
// The emitted velum area expression, evaluated with the admittance (opening * coupling) it reads set to a constant: the port area is
|
||||
// linear in the opening with the cited maximum, 0.8 cm^2.
|
||||
[Theory]
|
||||
[InlineData(1.0, 0.8)]
|
||||
[InlineData(0.7, 0.56)]
|
||||
[InlineData(0.25, 0.2)]
|
||||
public void TheVelopharyngealPortAreaIsTheOpeningTimesTheMaximumPortArea(double opening, double expectedAreaSquareCentimeters)
|
||||
{
|
||||
var source = FaustEmitter.Emit(
|
||||
PatchScript.Parse(IpaGestureExperiment.BuildWordScript([(new IpaGestureExperimentTarget("v_m", "m", "", .2f), 1f)])),
|
||||
new FaustExportOptions("velum", SampleRate: 48000)).Source;
|
||||
var area = Regex.Match(source, @"^\s*(\w+)_velum_area = (.+);$", RegexOptions.Multiline);
|
||||
Assert.True(area.Success);
|
||||
var admittance = Regex.Match(area.Groups[2].Value, @"\b(\w+_admittance)\b");
|
||||
Assert.True(admittance.Success, area.Groups[2].Value);
|
||||
var program = $"import(\"stdfaust.lib\");\n{admittance.Groups[1].Value} = {opening.ToString(CultureInfo.InvariantCulture)};\n" +
|
||||
$"area = {area.Groups[2].Value};\nprocess = area;\n";
|
||||
using var compiler = new AquaSynthPatchCompiler(new AquaSynthNativeOptions(SampleRate: 48000));
|
||||
if (!compiler.TryCompileSource(new AquaSynthCompileIdentity("velum", "velum", ""), program, .05f, out var compiled, out var error))
|
||||
{
|
||||
if (error?.Contains("not found", StringComparison.OrdinalIgnoreCase) == true) return;
|
||||
Assert.Fail($"velum program failed: {error}");
|
||||
}
|
||||
|
||||
using (compiled)
|
||||
{
|
||||
Assert.Equal(expectedAreaSquareCentimeters, compiled!.Render()[^1], 3);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
// 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).
|
||||
private static double CentimetresFromLips(string ipa)
|
||||
{
|
||||
var patch = PatchScript.Parse(IpaGestureExperiment.BuildWordScript([(new IpaGestureExperimentTarget("v_c", ipa, "", .2f), 1f)]));
|
||||
var oral = patch.AreaFunctions.Single(area => area.Name == "oral");
|
||||
var index = Spline(patch, "v_c_constriction_index", "/vocal/areas/0/area/constriction_index") * oral.Shape.Sections;
|
||||
return (1 - index / (oral.Shape.Sections - 1)) * oral.Shape.LengthCentimeters;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UnderVowelSetMClosesAtTheLipsAndNAtTheAlveolarRidgeInCentimetres()
|
||||
{
|
||||
Assert.InRange(CentimetresFromLips("m"), -.05, .05);
|
||||
Assert.InRange(CentimetresFromLips("n"), 2.4, 2.7);
|
||||
Assert.True(CentimetresFromLips("n") > CentimetresFromLips("m") + 2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WithoutVowelSetTheConstrictionStaysOnTheNormalizedPlaceFraction()
|
||||
{
|
||||
// The earlier surface semantics are kept for hand-written scripts: the place fraction is the normalized spline value itself.
|
||||
var patch = PatchScript.Parse("""
|
||||
morphology name=oral length_cm=17 diameters=.6,.8,1.2,1.6,1.3,.9 tongue_index=3 tongue_diameter=1.4 constriction_index=4 constriction_diameter=1 lip_opening=1.5
|
||||
morphology name=nasal length_cm=12 diameters=.05,.35,.6,.8
|
||||
waveguide_path name=oral_path morphology=oral loss=.998
|
||||
waveguide_path name=nasal_path morphology=nasal loss=.997
|
||||
source_port name=folds path=oral_path pressure=.7 tension=.55 opening=.45 noise=.05 impedance=.3
|
||||
branch_port name=velopharynx from=oral_path from_position=.45 to=nasal_path opening=0 coupling=1
|
||||
constriction_contact name=contact path=oral_path position=.92 opening=.5 resistance=.4 stored_pressure=.1
|
||||
radiation_load name=mouth path=oral_path aperture=.8 reflection=-.82 impedance=.28
|
||||
vocal_network name=voice paths=oral_path,nasal_path sources=folds contacts=contact branches=velopharynx radiation=mouth
|
||||
phoneme_gesture name=en ipa=n start=0 dur=.16 intensity=.8
|
||||
phoneme_gesture name=em ipa=m start=.2 dur=.16 intensity=.8
|
||||
vocal network=voice freq=150 gain=.2 sustain=.6
|
||||
""");
|
||||
|
||||
Assert.Equal(.78f, Spline(patch, "en_constriction_index", "/vocal/areas/0/area/constriction_index"));
|
||||
Assert.Equal(.96f, Spline(patch, "em_constriction_index", "/vocal/areas/0/area/constriction_index"));
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ public sealed class VocalTractFormantTests(ITestOutputHelper output)
|
|||
private const int Rate = 48000;
|
||||
private const float Pitch = 10f;
|
||||
|
||||
private static string Script(float tongueIndex, float tongueDiameter, float lipOpening, float velum = .01f) => $$"""
|
||||
private static string Script(float tongueIndex, float tongueDiameter, float lipOpening, float velum = 0f) => $$"""
|
||||
morphology name=oral length_cm=17 diameters=.55,.75,1.05,1.45,1.25,.8 tongue_index={{tongueIndex}} tongue_diameter={{tongueDiameter}} constriction_index=4 constriction_diameter=4 lip_opening={{lipOpening}}
|
||||
morphology name=nasal length_cm=12 diameters=.04,.28,.52,.72
|
||||
waveguide_path name=oral_path morphology=oral loss=.998
|
||||
|
|
@ -164,7 +164,7 @@ public sealed class VocalTractFormantTests(ITestOutputHelper output)
|
|||
[Fact]
|
||||
public void LadderStaysBoundedForASecondWithTheVelumOpen()
|
||||
{
|
||||
foreach (var (ti, td, lo, velum) in new[] { (3f, .15f, 2.2f, .01f), (1.5f, .5f, 2.2f, 1f), (2f, 1.2f, .6f, 1f) })
|
||||
foreach (var (ti, td, lo, velum) in new[] { (3f, .15f, 2.2f, 0f), (1.5f, .5f, 2.2f, 1f), (2f, 1.2f, .6f, 1f) })
|
||||
{
|
||||
var window = Render(Script(ti, td, lo, velum));
|
||||
if (window is null) return;
|
||||
|
|
@ -182,11 +182,13 @@ public sealed class VocalTractFormantTests(ITestOutputHelper output)
|
|||
[Fact]
|
||||
public void WithTheMouthClosedOnlyAnOpenVelumLetsSoundOutThroughTheNose()
|
||||
{
|
||||
// constriction_diameter .001 at tract index 4 shuts the oral ladder; the only way out is the junction into the nasal ladder.
|
||||
// constriction_diameter .001 at tract index 4 shuts the oral ladder; the only way out is the junction into the nasal ladder. A shut
|
||||
// velum is opening 0: the port area is linear in the opening, and a flow source into a nearly lossless closed tract leaves through even
|
||||
// a 0.008 cm^2 port (opening .01 measured rms 1.0e-2 against 2.1e-2 open).
|
||||
string Closed(float velum) => Script(1.5f, .5f, 2.2f, velum)
|
||||
.Replace("constriction_diameter=4", "constriction_diameter=.001", StringComparison.Ordinal)
|
||||
.Replace("diameters=.04,.28,.52,.72", "diameters=.9,1.3,1.5,1.2", StringComparison.Ordinal);
|
||||
var shut = Render(Closed(.01f));
|
||||
var shut = Render(Closed(0f));
|
||||
var open = Render(Closed(1f));
|
||||
if (shut is null || open is null) return;
|
||||
|
||||
|
|
@ -341,7 +343,7 @@ public sealed class VocalTractFormantTests(ITestOutputHelper output)
|
|||
waveguide_path name=oral_path morphology=oral speed=350 loss=.998
|
||||
waveguide_path name=nasal_path morphology=nasal speed=350 loss=.997
|
||||
source_port name=folds path=oral_path pressure=.7 tension=.55 opening=.5 noise=0 impedance=.3 flow_scale=.12 tilt=0
|
||||
branch_port name=velopharynx from=oral_path from_position=.45 to=nasal_path opening=.01 coupling=1
|
||||
branch_port name=velopharynx from=oral_path from_position=.45 to=nasal_path opening=0 coupling=1
|
||||
radiation_load name=mouth path=oral_path aperture=1 reflection=-1 impedance=.28
|
||||
radiation_load name=nostril path=nasal_path aperture=.8 reflection=-1 impedance=.28
|
||||
vocal_network name=voice paths=oral_path,nasal_path sources=folds branches=velopharynx radiation=mouth,nostril
|
||||
|
|
@ -469,4 +471,87 @@ public sealed class VocalTractFormantTests(ITestOutputHelper output)
|
|||
output.WriteLine($"ah lip cap 4 cm F1 {open[0]}; 0.4 cm F1 {capped[0]}");
|
||||
Assert.True(capped[0] < open[0] - 80, $"lip cap .4 cm F1 {capped[0]} vs open {open[0]}");
|
||||
}
|
||||
|
||||
// ---- Nasal coupling: the murmur of /m/ and /n/ against the nostril transfer of tools/formant-check/tube_formants.py --nasal ----
|
||||
|
||||
// The independent tube chain (Story 2008 geometric-mean oral shape, port after section 22 of 44, A_vp 0.56 cm^2 = the gesture's 0.7 opening,
|
||||
// the 19-section nasal table, rigid closed oral end after section 44 for /m/ and section 37 for /n/, 17.52 cm): N1 325 / 352 Hz, transfer
|
||||
// zeros (short circuit of the oral side branch) 882 / 1136 Hz; the quarter-wave c / 4L of the uniform branch would say 999 / 1465 Hz.
|
||||
private const double TubeM1 = 325, TubeN1 = 352, TubeMZero = 882, TubeNZero = 1136;
|
||||
|
||||
// Smoothed line spectrum in dB (flattened by the saw's 1/f) of a steady 10 Hz render, indexed by line number k (k * Pitch Hz).
|
||||
private static double[] SmoothedDb(float[] window)
|
||||
{
|
||||
var lines = Lines(window);
|
||||
var db = lines.Select(line => 20 * Math.Log10(Math.Max(1e-12, line))).ToArray();
|
||||
return db.Select((_, k) => k < 2 || k > db.Length - 3 ? db[k] : db.Skip(k - 2).Take(5).Average()).ToArray();
|
||||
}
|
||||
|
||||
// First dip above the first peak: the first local minimum of the smoothed spectrum, 200-2000 Hz, at least 3 dB under the lower of the
|
||||
// maxima on either side of it.
|
||||
private static double FirstDip(double[] db)
|
||||
{
|
||||
for (var k = (int)(200 / Pitch); k < (int)(2000 / Pitch); k++)
|
||||
{
|
||||
if (!(db[k] < db[k - 1] && db[k] <= db[k + 1])) continue;
|
||||
var left = db[k]; for (var j = k; j > 0 && db[j] >= left; j--) left = db[j];
|
||||
var right = db[k]; for (var j = k; j < db.Length - 1 && db[j] >= right; j++) right = db[j];
|
||||
if (Math.Min(left, right) - db[k] >= 3) return k * Pitch;
|
||||
}
|
||||
|
||||
return double.NaN;
|
||||
}
|
||||
|
||||
private (double N1, double Dip)? Murmur(string ipa)
|
||||
{
|
||||
var window = GestureWindow(ipa);
|
||||
if (window is null) return null;
|
||||
var n1 = Peaks(window)[0];
|
||||
var dip = FirstDip(SmoothedDb(window));
|
||||
output.WriteLine($"/{ipa}/ murmur: N1 {n1:F0} Hz, first dip {dip:F0} Hz");
|
||||
return (n1, dip);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheMurmurOfMAndNHasItsFirstPeakBelow400HzNearTheTubeChain()
|
||||
{
|
||||
var m = Murmur("m");
|
||||
var n = Murmur("n");
|
||||
if (m is null || n is null) return;
|
||||
|
||||
Assert.InRange(m.Value.N1, 250, 400);
|
||||
Assert.InRange(n.Value.N1, 250, 400);
|
||||
Assert.InRange(m.Value.N1, TubeM1 * .85, TubeM1 * 1.15);
|
||||
Assert.InRange(n.Value.N1, TubeN1 * .85, TubeN1 * 1.15);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheFirstZeroOfTheNasalMurmurSitsWhereTheOralSideBranchPutsItAndRisesWhenTheBranchIsShorter()
|
||||
{
|
||||
var m = Murmur("m");
|
||||
var n = Murmur("n");
|
||||
if (m is null || n is null) return;
|
||||
|
||||
Assert.InRange(m.Value.Dip, TubeMZero * .85, TubeMZero * 1.15);
|
||||
Assert.InRange(n.Value.Dip, TubeNZero * .85, TubeNZero * 1.15);
|
||||
// /n/ closes the mouth 2.6 cm from the lips, /m/ at the lips: a shorter branch beyond the port, a higher zero.
|
||||
Assert.True(n.Value.Dip >= 1.15 * m.Value.Dip, $"/n/ dip {n.Value.Dip} Hz against /m/ dip {m.Value.Dip} Hz");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AnOralClosureWithTheVelumShutLeavesTheMurmurSilentAndOpeningTheVelumLetsItOut()
|
||||
{
|
||||
var open = GestureWindow("m");
|
||||
if (open is null) return;
|
||||
|
||||
// The same /m/ with the velum spline held shut: the gesture's own velum control is the only door, so remove it.
|
||||
var shut = Render(IpaGestureExperiment.BuildWordScript([(new IpaGestureExperimentTarget("v_m", "m", "", 1.5f), 1f)], Pitch, 0.1f)
|
||||
.Replace("noise=.04", "noise=0 tilt=1", StringComparison.Ordinal)
|
||||
.Replace($"freq={Pitch}", $"freq={Pitch} min_freq=5", StringComparison.Ordinal),
|
||||
patch => patch with { ControlSplines = patch.ControlSplines.Where(spline => spline.SurfacePath != "/vocal/branches/0/opening").ToArray() });
|
||||
if (shut is null) return;
|
||||
|
||||
output.WriteLine($"/m/ velum open rms {Rms(open):E2}, velum shut rms {Rms(shut):E2}");
|
||||
Assert.True(Rms(open) > 10 * Rms(shut), $"open {Rms(open):E2} shut {Rms(shut):E2}");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue