Skip to content

the ultimate vocal synthesizer - sing, speak, beatbox, and more

Rust

Hill climb 16: a pre-placed closure behind a stop seals as the front one opens

Jameson Hodgea353b70d1cba
diff --git a/crates/chimera/src/phonetics/planner.rs b/crates/chimera/src/phonetics/planner.rs
index 67d1863..719d53b 100644
--- a/crates/chimera/src/phonetics/planner.rs
+++ b/crates/chimera/src/phonetics/planner.rs
@@ -263,6 +263,11 @@ pub fn plan_utterance(input: &[Segment], o: &PlanOptions) -> Plan {
let prev_seg = if i > 0 { Some(&segs[i - 1]) } else { None };
let mut add_oral = |tg: &ArticPatch, a: f64, b: f64, speed: f64, label: &str| oral_gestures_into(def, tg, a, b, speed, label, &mut gestures);
match def.manner {
+ // a stop that closes behind another stop's closure, its articulator already placed by
+ // the segment before that (the tip raised for /ɹ/ in "sharp tree"), reaches contact
+ // sooner than from a vowel: with the usual lead it sealed ~20 ms before the front
+ // closure opened, and the tongue then pumped the air shut between the two closures
+ Manner::Stop if pre_placed_behind_closure(&segs, i) => add_oral(&def.targets, t0 + PLACED_CLOSURE_DELAY, t1, 1.55, def.ipa),
Manner::Stop | Manner::Nasal => add_oral(&def.targets, t0, t1, 1.55, def.ipa),
Manner::Tap => add_oral(&def.targets, t0, t1, 2.8, def.ipa),
Manner::Trill => {
@@ -391,6 +396,46 @@ pub fn plan_utterance(input: &[Segment], o: &PlanOptions) -> Plan {
Plan { gestures, segments: planned, end }
}
+/// Front-to-back order of the oral places of articulation.
+fn place_rank(place: &str) -> Option<u8> {
+ Some(match place {
+ "bilabial" => 0,
+ "labiodental" => 1,
+ "dental" => 2,
+ "alveolar" => 3,
+ "postalveolar" => 4,
+ "retroflex" => 5,
+ "palatal" => 6,
+ "velar" => 7,
+ "uvular" => 8,
+ _ => return None,
+ })
+}
+
+/// How much later a pre-placed closure behind another stop's closure is aimed (s): the time its
+/// shorter travel saves, so it seals as the front closure opens.
+const PLACED_CLOSURE_DELAY: f64 = 0.025;
+
+/// Whether stop `i` closes behind the closure of the stop before it, with its own articulators
+/// already set by the consonant before that one (/t/ in /ɹpt/: the tip is up for the /ɹ/ and
+/// stays free during the lip closure; a rhotic vowel raises it too). After any other vowel ("apt",
+/// "napkin") the timing is unchanged.
+fn pre_placed_behind_closure(segs: &[Seg], i: usize) -> bool {
+ let (Some(def), Some(prev)) = (segs[i].def.as_ref(), i.checked_sub(1).and_then(|j| segs[j].def.as_ref())) else { return false };
+ if def.manner != Manner::Stop || prev.manner != Manner::Stop || !closes_in_front(prev.place, def.place) || i < 2 {
+ return false;
+ }
+ let before = &segs[i - 2];
+ let rhotic = before.vowel.as_ref().filter(|v| v.get(ArticKey::TtCurl).unwrap_or(0.0) > 0.05);
+ let Some(tg) = before.def.as_ref().map(|d| &d.targets).or(rhotic) else { return false };
+ def.dominant.iter().all(|k| tg.get(*k).is_some())
+}
+
+/// Whether a closure at `front` lies in front of one at `back`.
+fn closes_in_front(front: &str, back: &str) -> bool {
+ matches!((place_rank(front), place_rank(back)), (Some(f), Some(b)) if f < b)
+}
+
/// Ramps of a given pitch (a sung note's) on a segment `dur` long: 60 ms, but at most half the
/// segment. A ramp-in starts before the segment, so in a fast run a full 60 ms would pull the
/// previous vowel off its note for most of its length.
diff --git a/crates/chimera/tests/consonant_artifacts.rs b/crates/chimera/tests/consonant_artifacts.rs
index d1d00fe..c2deefe 100644
--- a/crates/chimera/tests/consonant_artifacts.rs
+++ b/crates/chimera/tests/consonant_artifacts.rs
@@ -72,7 +72,6 @@ fn fading_sounds_do_not_buzz_at_the_control_rate() {
}
#[test]
-#[ignore = "target for the pronunciation batch: run with --ignored to measure it"]
fn the_p_of_sharp_does_not_pop() {
// "sharp tree": the lips close for /p/, then the tongue seals for /t/ while still moving and
// squeezes the air shut in between to about 11x the lungs' pressure (88 cmH2O, male voice).