Stress carries duration, amplitude and f0 (source pitch_ratio surface); plosive release burst from contact release_flow; vowels open the contact
Primary stress: duration 220/160, source flow x1.26 (+2 dB), f0 x1.06 (Sluijter & van Heuven 1996); secondary halfway (design value). The exporter's contact term adds white noise shaped by stored pressure and 4*o*(1-o) of the opening, gain from release_flow. Unheard. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7343b66709
commit
563a6a8e1f
8 changed files with 203 additions and 31 deletions
|
|
@ -714,6 +714,8 @@ public static partial class FaustEmitter
|
|||
var opening = parameters.Expression(OwnerField(owner, "opening"), port.Opening);
|
||||
var impedance = parameters.Expression(OwnerField(owner, "impedance"), port.Impedance);
|
||||
var flowScale = parameters.Expression(OwnerField(owner, "flow_scale"), port.FlowScale);
|
||||
// f0 is the voice frequency times the source's ratio (the stress cue), smoothed over 10 ms so a step in the ratio is a glide.
|
||||
var pitchRatio = $"({parameters.Expression(OwnerField(owner, "pitch_ratio"), port.PitchRatio)} : si.smooth(ba.tau2pole(0.01)))";
|
||||
var load = $"{voiceName}_primitive_source_{safe}_load_pressure";
|
||||
var voiced = $"{voiceName}_primitive_source_{safe}_voiced";
|
||||
var flow = $"{voiceName}_primitive_source_{safe}_flow";
|
||||
|
|
@ -721,7 +723,7 @@ 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}) : fi.lowpass(1, {cutoff})) * clip01({opening}) * clip01(0.25 + {tension});");
|
||||
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)};");
|
||||
keepAlive.Add(load);
|
||||
keepAlive.Add(voiced);
|
||||
|
|
@ -744,13 +746,19 @@ public static partial class FaustEmitter
|
|||
var opening = $"clip01({parameters.Expression(OwnerField(owner, "opening"), contact.Opening)})";
|
||||
var resistance = parameters.Expression(OwnerField(owner, "resistance"), contact.Resistance);
|
||||
var stored = parameters.Expression(OwnerField(owner, "stored_pressure"), contact.StoredPressure);
|
||||
var releaseGain = parameters.Expression(OwnerField(owner, "release_flow"), contact.ReleaseFlow);
|
||||
var released = $"{voiceName}_primitive_contact_{safe}_released_flow";
|
||||
var reservoir = $"{voiceName}_primitive_contact_{safe}_reservoir";
|
||||
var burst = $"{voiceName}_primitive_contact_{safe}_burst";
|
||||
source.AppendLine($" {reservoir} = {ProbeSignal(options, $"/debug/{voiceName}/contact/{contact.Name}/reservoir", $"(({stored}) + (1.0 - {opening}) * {resistance})", 0, 2)};");
|
||||
source.AppendLine($" {released} = {ProbeSignal(options, $"/debug/{voiceName}/contact/{contact.Name}/released_flow", $"({reservoir}) * {opening} * (1.0 - min(0.95, {resistance} * 0.5))", -2, 2)};");
|
||||
// Release burst: noise whose amplitude is the stored pressure through the opening area as it passes between shut and open
|
||||
// (4 * o * (1 - o) peaks at half open and vanishes at both ends), so a shut or fully open contact is silent.
|
||||
source.AppendLine($" {burst} = {ProbeSignal(options, $"/debug/{voiceName}/contact/{contact.Name}/burst", $"no.noise * ({releaseGain}) * ({stored}) * 4.0 * {opening} * (1.0 - {opening})", -2, 2)};");
|
||||
keepAlive.Add(reservoir);
|
||||
keepAlive.Add(burst);
|
||||
keepAlive.Add(released);
|
||||
return released;
|
||||
return $"({released} + {burst})";
|
||||
}
|
||||
|
||||
// Open fraction of a branch port: the ladder reads it as the velum area when the branch joins two paths of the network,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ public sealed record IpaGestureExperimentTarget(
|
|||
string Ipa,
|
||||
string Descriptor,
|
||||
float DurationSeconds = 0.18f,
|
||||
string Notes = "");
|
||||
string Notes = "",
|
||||
float PitchRatio = 1f);
|
||||
|
||||
public sealed record IpaGestureExperimentVariant(
|
||||
string Id,
|
||||
|
|
@ -225,7 +226,7 @@ public static class IpaGestureExperiment
|
|||
}
|
||||
|
||||
private static string GestureLine(IpaGestureExperimentTarget target, float start, float duration, float intensity) =>
|
||||
$"phoneme_gesture name={SafeDslName(target.Id)} ipa={target.Ipa} {(target.Descriptor.Length == 0 ? "" : $"descriptor={target.Descriptor.Replace(' ', '_')} ")}start={Format(start)} dur={Format(duration)} intensity={Format(intensity)}";
|
||||
$"phoneme_gesture name={SafeDslName(target.Id)} ipa={target.Ipa} {(target.Descriptor.Length == 0 ? "" : $"descriptor={target.Descriptor.Replace(' ', '_')} ")}start={Format(start)} dur={Format(duration)} intensity={Format(intensity)}{(target.PitchRatio == 1f ? "" : $" pitch_ratio={Format(target.PitchRatio)}")}";
|
||||
|
||||
// One cell per sample at 48 kHz: 17.52 cm * 48000 / 350 m/s = 24.03 cells, a ladder 17.5 cm long (the mean of Story's vocal tract lengths).
|
||||
private const int TractSpeedMetersPerSecond = 350;
|
||||
|
|
|
|||
|
|
@ -473,7 +473,8 @@ public sealed record SourcePort(
|
|||
float Noise = 0.08f,
|
||||
float Impedance = 0.35f,
|
||||
float FlowScale = 0.02f,
|
||||
float Tilt = 0.5f);
|
||||
float Tilt = 0.5f,
|
||||
float PitchRatio = 1f);
|
||||
|
||||
public sealed record ConstrictionContact(
|
||||
string Name,
|
||||
|
|
|
|||
|
|
@ -938,7 +938,8 @@ public static class PatchScript
|
|||
GetBoundFloat(fields, line, 0.08f, $"/vocal/sources/{_sourcePorts.Count}/noise", "noise", "aspiration"),
|
||||
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, 0.5f, $"/vocal/sources/{_sourcePorts.Count}/tilt", "tilt", "spectral_tilt"),
|
||||
GetBoundFloat(fields, line, 1f, $"/vocal/sources/{_sourcePorts.Count}/pitch_ratio", "pitch_ratio", "f0_ratio"));
|
||||
_sourcePorts.Add(port);
|
||||
_sourcePortsByName[name] = port;
|
||||
RegisterSourcePortSurfaces(_sourcePorts.Count - 1, port);
|
||||
|
|
@ -1385,6 +1386,7 @@ public static class PatchScript
|
|||
RegisterNormalizedPrimitiveSurface(OwnerField(owner, "impedance"), port.Name, "impedance", port.Impedance, 0.05f, 2);
|
||||
RegisterNormalizedPrimitiveSurface(OwnerField(owner, "flow_scale"), port.Name, "flow_scale", port.FlowScale, 0, 0.2f);
|
||||
RegisterNormalizedPrimitiveSurface(OwnerField(owner, "tilt"), port.Name, "tilt", port.Tilt);
|
||||
RegisterNormalizedPrimitiveSurface(OwnerField(owner, "pitch_ratio"), port.Name, "pitch_ratio", port.PitchRatio, 0.5f, 2f);
|
||||
}
|
||||
|
||||
private void RegisterAreaFunctionSurfaces(int index, AreaFunction area)
|
||||
|
|
@ -1502,7 +1504,7 @@ public static class PatchScript
|
|||
}
|
||||
}
|
||||
|
||||
private void EmitPhonemeGestureSplines(string name, string descriptor, float start, float duration, float intensity)
|
||||
private void EmitPhonemeGestureSplines(string name, string descriptor, float start, float duration, float intensity, float pitchRatio = 1f)
|
||||
{
|
||||
var tokens = DescriptorTokens(descriptor);
|
||||
var voiced = tokens.Contains("voiced") || tokens.Contains("vowel") || tokens.Contains("nasal") || tokens.Contains("approximant");
|
||||
|
|
@ -1517,6 +1519,10 @@ public static class PatchScript
|
|||
AddAuthoredSpline($"{name}_source_pressure", "/vocal/sources/0/pressure", start, duration, (0, 0.4f), (0.2f, pressure), (1, pressure * 0.85f));
|
||||
AddAuthoredSpline($"{name}_source_tension", "/vocal/sources/0/tension", start, duration, (0, voiced ? 0.55f : 0.18f), (1, voiced ? 0.62f : 0.20f));
|
||||
AddAuthoredSpline($"{name}_source_opening", "/vocal/sources/0/opening", start, duration, (0, voiced ? 0.45f : 0.25f), (1, voiced ? 0.48f : 0.28f));
|
||||
// Intensity is an amplitude factor on the source's flow scale (the level lever: pressure saturates in the tanh), and the f0 ratio
|
||||
// is held per gesture; both default to the source's own value.
|
||||
HoldFractionOfDefault($"{name}_source_level", "/vocal/sources/0/flow_scale", start, duration, intensity);
|
||||
HoldOnSurface($"{name}_source_pitch", "/vocal/sources/0/pitch_ratio", start, duration, pitchRatio);
|
||||
AddAuthoredSpline($"{name}_source_noise", "/vocal/sources/0/noise", start, duration, (0, tokens.Contains("fricative") ? 0.45f : 0.05f), (1, tokens.Contains("fricative") ? 0.55f : 0.05f));
|
||||
|
||||
if (tokens.Contains("vowel"))
|
||||
|
|
@ -1556,6 +1562,9 @@ 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));
|
||||
// The release burst is turbulence at the opening constriction: its gain is held for the plosive and the exporter shapes
|
||||
// it by the stored pressure and the opening (see PrimitiveContactExpression).
|
||||
HoldOnSurface($"{name}_release_flow", "/vocal/contacts/0/release_flow", start, duration, PlosiveBurstGain);
|
||||
AddAuthoredSpline($"{name}_velum", "/vocal/branches/0/opening", start, duration, (0, VelumClosed), (1, VelumClosed));
|
||||
}
|
||||
else if (tokens.Contains("fricative"))
|
||||
|
|
@ -1590,6 +1599,16 @@ public static class PatchScript
|
|||
// 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, VelumClosed), (1, VelumClosed));
|
||||
// The contact is fully open for a vowel; a contact left half open by the previous stop would keep making release noise.
|
||||
AddAuthoredSpline($"{name}_contact", "/vocal/contacts/0/opening", start, duration, (0, 1), (1, 1));
|
||||
}
|
||||
|
||||
// Holds a surface at its default value times a factor (clamped to the surface range).
|
||||
private void HoldFractionOfDefault(string name, string surfacePath, float start, float duration, float factor)
|
||||
{
|
||||
if (!_controlSurfacesByPath.TryGetValue(surfacePath, out var surface)) return;
|
||||
var normalized = Math.Clamp(surface.DefaultNormalized * factor, 0, 1);
|
||||
AddAuthoredSpline(name, surfacePath, start, duration, (0, normalized), (1, normalized));
|
||||
}
|
||||
|
||||
// Holds a surface at a value in its own unit (cm, section index); splines carry the surface's normalized range.
|
||||
|
|
@ -1634,6 +1653,10 @@ public static class PatchScript
|
|||
// leave a 0.008 cm^2 leak that shows in the oral formants.
|
||||
private const float VelumClosed = 0f;
|
||||
|
||||
// Gain of the plosive release burst (contact release_flow, surface range 0..2). A DESIGN VALUE set by measurement against the
|
||||
// following vowel; no published burst level was retrieved.
|
||||
private const float PlosiveBurstGain = 0.06f;
|
||||
|
||||
// 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
|
||||
|
|
@ -2655,13 +2678,14 @@ public static class PatchScript
|
|||
var start = GetFloat(fields, line, 0, "start", "time", "at");
|
||||
var duration = Math.Max(0.001f, GetFloat(fields, line, 0.12f, "dur", "duration", "length"));
|
||||
var intensity = Math.Clamp(GetFloat(fields, line, 1, "intensity", "gain", "strength"), 0, 2);
|
||||
var pitchRatio = Math.Clamp(GetFloat(fields, line, 1, "pitch_ratio", "f0_ratio"), 0.5f, 2f);
|
||||
var descriptor = GestureDescriptor(ipa, fields);
|
||||
var name = TryGetAny(fields, ["name", "n"], out var nameText)
|
||||
? nameText
|
||||
: $"ipa_{SafeName(ipa)}_{_phonemeGestures.Count}";
|
||||
|
||||
_phonemeGestures.Add(new PhonemeGesture(name, ipa, descriptor, start, duration, intensity));
|
||||
EmitPhonemeGestureSplines(name, descriptor, start, duration, intensity);
|
||||
EmitPhonemeGestureSplines(name, descriptor, start, duration, intensity, pitchRatio);
|
||||
}
|
||||
|
||||
private void AddControlCurve(IReadOnlyDictionary<string, string> fields, int line)
|
||||
|
|
|
|||
|
|
@ -80,6 +80,9 @@ public static class ProbeTimelineReport
|
|||
Add(samples, block, $"contact:{contact.Name}", "resistance", resistance);
|
||||
Add(samples, block, $"contact:{contact.Name}", "reservoir", reservoir);
|
||||
Add(samples, block, $"contact:{contact.Name}", "released_flow", reservoir * opening * (1 - Math.Min(0.95f, resistance * 0.5f)));
|
||||
var releaseGain = SurfaceValue(surfacesByField, splinesBySurface, $"{owner}/release_flow", contact.ReleaseFlow, timeSeconds);
|
||||
// The exporter's burst is white noise of this amplitude (noise itself is not mirrored).
|
||||
Add(samples, block, $"contact:{contact.Name}", "burst_amplitude", releaseGain * stored * 4 * opening * (1 - opening));
|
||||
}
|
||||
|
||||
foreach (var branchName in network.Branches)
|
||||
|
|
|
|||
|
|
@ -71,19 +71,28 @@ public static class WeksaPhonesReader
|
|||
/// <summary>
|
||||
/// A Weksa phones line as a word the tract can render. Every phone must be in the DSL's IPA table
|
||||
/// (<see cref="PatchScript.TryIpaDescriptor"/>); a phone outside it is listed in <see cref="Unsupported"/> and the plan
|
||||
/// carries no targets, so nothing is approximated. Duration is the vowel/consonant length AquaSynth owns; stress moves
|
||||
/// only the gesture intensity, the one thing the word script uses stress for.
|
||||
/// carries no targets, so nothing is approximated. Base durations are the vowel/consonant lengths AquaSynth owns; stress
|
||||
/// carries its three acoustic cues (<see cref="StressCue"/>): the marked phone is longer, louder and higher in f0.
|
||||
/// </summary>
|
||||
public sealed record WeksaWordPlan(IReadOnlyList<(IpaGestureExperimentTarget Target, float Intensity)> Phones, IReadOnlyList<WeksaPhone> Unsupported)
|
||||
{
|
||||
public const float VowelSeconds = 0.18f, ConsonantSeconds = 0.095f;
|
||||
public bool Renderable => Unsupported.Count == 0;
|
||||
|
||||
public static float StressIntensity(WeksaStress stress) => stress switch
|
||||
/// <summary>Duration factor, amplitude factor on the source flow and f0 ratio of a stressed phone against an unstressed one.</summary>
|
||||
public readonly record struct StressCue(float Duration, float Amplitude, float PitchRatio);
|
||||
|
||||
/// <summary>
|
||||
/// Primary stress: duration 220/160 = 1.375 (stressed against unstressed syllable in initial-stress pairs, Sluijter and van
|
||||
/// Heuven 1996), amplitude 2 dB = 1.26 (the 1-3 dB overall-intensity difference they report), f0 +6 percent (their unaccented
|
||||
/// f0 difference). Secondary stress is placed halfway, in dB and in percent: a DESIGN VALUE, no secondary-stress measurement was
|
||||
/// retrieved. Unheard.
|
||||
/// </summary>
|
||||
public static StressCue CueFor(WeksaStress stress) => stress switch
|
||||
{
|
||||
WeksaStress.Primary => 1.2f,
|
||||
WeksaStress.Secondary => 1.1f,
|
||||
_ => 1f
|
||||
WeksaStress.Primary => new(220f / 160f, 1.26f, 1.06f),
|
||||
WeksaStress.Secondary => new(1.19f, 1.12f, 1.03f),
|
||||
_ => new(1f, 1f, 1f)
|
||||
};
|
||||
|
||||
public static WeksaWordPlan From(WeksaPhones word, string label)
|
||||
|
|
@ -93,8 +102,9 @@ public sealed record WeksaWordPlan(IReadOnlyList<(IpaGestureExperimentTarget Tar
|
|||
var targets = word.Phones.Select((p, i) =>
|
||||
{
|
||||
PatchScript.TryIpaDescriptor(p.Ipa, out var descriptor);
|
||||
var seconds = descriptor.EndsWith("_vowel", StringComparison.Ordinal) ? VowelSeconds : ConsonantSeconds;
|
||||
return (new IpaGestureExperimentTarget($"{label}_{i}_{p.Ipa}", p.Ipa, "", seconds), StressIntensity(p.Stress));
|
||||
var cue = CueFor(p.Stress);
|
||||
var seconds = (descriptor.EndsWith("_vowel", StringComparison.Ordinal) ? VowelSeconds : ConsonantSeconds) * cue.Duration;
|
||||
return (new IpaGestureExperimentTarget($"{label}_{i}_{p.Ipa}", p.Ipa, "", seconds, PitchRatio: cue.PitchRatio), cue.Amplitude);
|
||||
}).ToArray();
|
||||
return new WeksaWordPlan(targets, []);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue