Skip to content

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

Rust

Hill climb 27: her glottal pulse follows the fold's length, not the body's scale (her vowels 2 dB too loud for her folds); lips open slowly from contact (a /p/ thump, 6-10 dB over the speakers' below 500 Hz)

Jameson Hodgea135bcdd71a4
diff --git a/crates/chimera/src/anatomy/human.rs b/crates/chimera/src/anatomy/human.rs
index 62b7d26..3457a92 100644
--- a/crates/chimera/src/anatomy/human.rs
+++ b/crates/chimera/src/anatomy/human.rs
@@ -271,11 +271,15 @@ pub struct HumanBody {
pub tongue_radius: f64,
/// max lip width (cm, before scale)
pub lip_width: f64,
+ /// length of the membranous vocal fold, the part that vibrates (1 = adult male). Two thirds of
+ /// his in a woman (1/1.6 in Titze 1989, 10 mm of 17 in Zhang 2021), which puts her peak flow at
+ /// 0.63 of his; 6 mm of 17 in a child of 8-10 (Zhang 2021, after Titze 1989).
+ pub fold_length: f64,
}
-pub const BODY_MALE: HumanBody = HumanBody { name: "Adult male", scale: 1.0, pharynx: 1.0, tongue_radius: 2.25, lip_width: 4.6 };
-pub const BODY_FEMALE: HumanBody = HumanBody { name: "Adult female", scale: 0.9, pharynx: 0.88, tongue_radius: 2.2, lip_width: 4.4 };
-pub const BODY_CHILD: HumanBody = HumanBody { name: "Child", scale: 0.74, pharynx: 0.8, tongue_radius: 2.15, lip_width: 4.0 };
+pub const BODY_MALE: HumanBody = HumanBody { name: "Adult male", scale: 1.0, pharynx: 1.0, tongue_radius: 2.25, lip_width: 4.6, fold_length: 1.0 };
+pub const BODY_FEMALE: HumanBody = HumanBody { name: "Adult female", scale: 0.9, pharynx: 0.88, tongue_radius: 2.2, lip_width: 4.4, fold_length: 0.67 };
+pub const BODY_CHILD: HumanBody = HumanBody { name: "Child", scale: 0.74, pharynx: 0.8, tongue_radius: 2.15, lip_width: 4.0, fold_length: 0.35 };
/// The three human bodies by their short names.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
@@ -377,6 +381,7 @@ impl BodyMix {
pharynx: self.blend(|b| b.body().pharynx),
tongue_radius: self.blend(|b| b.body().tongue_radius),
lip_width: self.blend(|b| b.body().lip_width),
+ fold_length: self.blend(|b| b.body().fold_length),
}
}
}
diff --git a/crates/chimera/src/voice/human_airway.rs b/crates/chimera/src/voice/human_airway.rs
index ad0e68c..6ef966e 100644
--- a/crates/chimera/src/voice/human_airway.rs
+++ b/crates/chimera/src/voice/human_airway.rs
@@ -69,6 +69,11 @@ pub struct HumanAirway {
pub seal_hi: f64,
/// below this area (cm²) the closing rate slows with √A, so the seal is reached smoothly
pub seal_ease: f64,
+ /// Lips part from a point, so their gap and width grow together and the area starts slowly
+ /// (cm²/s at contact, reaching maxAreaRate by twice sealLo). Opened at the full rate from the
+ /// first sample, the flow's slope stepped up, the release's counterpart of the seal's click: a
+ /// /p/ read 6-10 dB over the speakers' below 500 Hz, its first millisecond the loudest.
+ pub lip_open_rate: f64,
/// areas committed at the start of the current control step (slew-limit baseline)
base: Option<[Vec<f64>; 4]>,
base_dt: f64,
@@ -158,6 +163,7 @@ impl HumanAirway {
seal_lo: 0.03,
seal_hi: 0.4,
seal_ease: 0.03,
+ lip_open_rate: 15.0,
base: None,
base_dt: 0.0,
noise_list: Vec::with_capacity(8),
@@ -227,11 +233,14 @@ impl HumanAirway {
};
seal_r + (open_r - seal_r) * u * u * (3.0 - 2.0 * u)
};
- let clamp_arr = |cur: &mut [f64], old: &[f64], mins: &mut [f64], old_mins: &[f64]| {
+ let lip_r = self.lip_open_rate * k2;
+ // opening rate of section i at area A: the sections ahead of the teeth are the lips'
+ let open_rate = |i: usize, lips_from: usize, area: f64| -> f64 { if i < lips_from { open_r } else { lip_r + (open_r - lip_r) * smooth(lo, 2.0 * lo, area) } };
+ let clamp_arr = |cur: &mut [f64], old: &[f64], mins: &mut [f64], old_mins: &[f64], lips_from: usize| {
for i in 0..cur.len() {
let d = cur[i] - old[i];
if d > 0.0 {
- let lim = (open_r + gain * cur[i]) * dt;
+ let lim = (open_rate(i, lips_from, old[i]) + gain * cur[i]) * dt;
if d > lim {
cur[i] = old[i] + lim;
}
@@ -243,7 +252,7 @@ impl HumanAirway {
}
let dm = mins[i] - old_mins[i];
if dm > 0.0 {
- let lim_m = (open_r + gain * mins[i]) * dt;
+ let lim_m = (open_rate(i, lips_from, old_mins[i]) + gain * mins[i]) * dt;
if dm > lim_m {
mins[i] = old_mins[i] + lim_m;
}
@@ -261,8 +270,9 @@ impl HumanAirway {
}
}
};
- clamp_arr(&mut self.ph_areas, &base[0], &mut self.ph_min, &base[2]);
- clamp_arr(&mut self.or_areas, &base[1], &mut self.or_min, &base[3]);
+ clamp_arr(&mut self.ph_areas, &base[0], &mut self.ph_min, &base[2], usize::MAX);
+ let lips_from = (self.or_areas.len() as f64 * (1.0 - (f.lip_s - f.teeth_s) / or_len)) as usize;
+ clamp_arr(&mut self.or_areas, &base[1], &mut self.or_min, &base[3], lips_from);
}
self.ph_len = ph_len;
self.or_len = or_len;
diff --git a/crates/chimera/src/voice/human_voice.rs b/crates/chimera/src/voice/human_voice.rs
index 9092506..5750d2c 100644
--- a/crates/chimera/src/voice/human_voice.rs
+++ b/crates/chimera/src/voice/human_voice.rs
@@ -254,15 +254,16 @@ impl HumanVoice {
let x = v.artic.x;
v.airway.apply(&x, 0.0);
v.airway.net.snap_to_targets();
- // smaller bodies radiate more high-frequency (derivative) energy at their higher f0
- // (a ramp from the adult female's scale up to the adult male's, so blended bodies have no step)
+ // a level match: at their higher f0 smaller bodies radiate more for the same flow, since the
+ // output is the flow's derivative (a ramp from the adult female's scale up to the adult
+ // male's, so blended bodies have no step)
let sc = v.airway.body.scale;
v.output_gain *= if sc >= 1.0 {
1.0
} else if sc <= 0.9 {
- 0.55
+ 0.69
} else {
- 0.55 + 0.45 * (sc - 0.9) / 0.1
+ 0.69 + 0.31 * (sc - 0.9) / 0.1
};
v.apply_source();
v
@@ -309,7 +310,9 @@ impl HumanVoice {
let s = self.source;
let g = &mut self.glottis.params;
let k2 = self.airway.body.scale * self.airway.body.scale;
- g.amplitude = 0.17 * k2 * (if s.voiced { 1.0 } else { 0.0 });
+ // the pulse's peak area is the vibrating fold's length by how far its edge swings
+ let body = self.airway.body;
+ g.amplitude = 0.17 * body.fold_length * body.scale * (if s.voiced { 1.0 } else { 0.0 });
g.abduction = (if s.voiced { 0.1 * s.breathiness * s.breathiness } else { 0.2 + 0.1 * s.breathiness }) * k2;
self.base_abduction = g.abduction;
self.base_closure = 0.0;
diff --git a/crates/chimera/tests/body_mix.rs b/crates/chimera/tests/body_mix.rs
index 66e4573..36f1b62 100644
--- a/crates/chimera/tests/body_mix.rs
+++ b/crates/chimera/tests/body_mix.rs
@@ -42,6 +42,7 @@ fn deserializes_from_a_name_or_a_mix() {
fn blends_land_between_the_presets() {
let mid = BodyMix::new(0.5, 0.0);
assert!((mid.body().scale - 0.95).abs() < 1e-12);
+ assert!(between(mid.body().fold_length, BODY_MALE.fold_length, BODY_FEMALE.fold_length));
assert!(default_f0(mid) > 110.0 && default_f0(mid) < 205.0);
// calibrated targets: each key between the two presets'
for v in ["i", "a", "u"] {
diff --git a/crates/chimera/tests/body_source.rs b/crates/chimera/tests/body_source.rs
new file mode 100644
index 0000000..b1aad81
--- /dev/null
+++ b/crates/chimera/tests/body_source.rs
@@ -0,0 +1,45 @@
+//! The glottal pulse follows the fold's length (experiment 27). It went with the body's scale, so a
+//! woman at twice a man's f0 and 0.81 of his area had 1.45 times his maximum flow declination rate at
+//! the same lung pressure, where real women's is lower than men's, and her vowels stood too far above
+//! her consonants.
+use chimera::anatomy::human::{BODY_CHILD, BODY_FEMALE, BODY_MALE, HumanBody};
+use chimera::phonetics::planner::vowel_artic;
+use chimera::voice::human_voice::{HumanVoice, SourcePatch};
+
+const FS: f64 = 48000.0;
+
+/// Peak-to-peak flow (L/s) and the steepest fall of flow (L/s²) of a held /a/, medians over cycles.
+fn held(body: HumanBody, name: &str, f0: f64) -> (f64, f64) {
+ let mut v = HumanVoice::new(FS, body, 2);
+ v.set_source(&SourcePatch::f0(f0));
+ v.set_articulation(&vowel_artic("a", name.into()).unwrap(), None);
+ v.set_gate(1.0);
+ let port = v.airway.glottis_port;
+ let mut one = [0f32; 1];
+ let mut flow = Vec::new();
+ for i in 0..(0.8 * FS) as usize {
+ v.render(&mut one);
+ if i as f64 > 0.4 * FS {
+ flow.push(v.airway.net.u[port] / 1000.0);
+ }
+ }
+ let period = (FS / f0).round() as usize;
+ let median = |mut x: Vec<f64>| {
+ x.sort_by(f64::total_cmp);
+ x[x.len() / 2]
+ };
+ let ac = median(flow.chunks_exact(period).map(|c| c.iter().cloned().fold(f64::MIN, f64::max) - c.iter().cloned().fold(f64::MAX, f64::min)).collect());
+ let fall = median(flow.chunks_exact(period).map(|c| c.windows(2).map(|w| (w[0] - w[1]) * FS).fold(0.0, f64::max)).collect());
+ (ac, fall)
+}
+
+#[test]
+fn her_folds_pass_less_air_than_his() {
+ let (male_ac, male_fall) = held(BODY_MALE, "male", 112.0);
+ let (female_ac, female_fall) = held(BODY_FEMALE, "female", 205.0);
+ let (child_ac, _) = held(BODY_CHILD, "child", 260.0);
+ let (flow, fall) = (female_ac / male_ac, female_fall / male_fall);
+ assert!((0.55..0.72).contains(&flow), "her peak flow is {flow:.2} of his");
+ assert!(fall < 1.25, "her flow falls {fall:.2} times as fast as his");
+ assert!(child_ac < female_ac, "a child {child_ac:.3} L/s, a woman {female_ac:.3}");
+}
diff --git a/crates/chimera/tests/stop_spans.rs b/crates/chimera/tests/stop_spans.rs
index a71a785..cc21169 100644
--- a/crates/chimera/tests/stop_spans.rs
+++ b/crates/chimera/tests/stop_spans.rs
@@ -124,3 +124,25 @@ fn the_port_seals_later_before_a_voiced_stop() {
assert!(voiced - voiceless > 10.0, "{name}: /nd/ +{voiced} ms, /nt/ +{voiceless} ms");
}
}
+
+/// The loudest pair of blocks (about 5 ms) around a stop's release, dB re the vowel before it.
+fn release_burst(r: &Render) -> f64 {
+ let stop = r.plan.segments.iter().find(|s| s.kind == "stop").unwrap();
+ let vowel = r.plan.segments.iter().find(|s| s.kind == "vowel").unwrap();
+ let mean = |a: f64, b: f64| {
+ let v: Vec<f64> = r.blocks.iter().filter(|x| x.0 > a && x.0 <= b).map(|x| x.1).collect();
+ v.iter().sum::<f64>() / v.len() as f64
+ };
+ let at = r.blocks.iter().filter(|x| x.0 > stop.t1 - 0.01 && x.0 <= stop.t1 + 0.02);
+ let near: Vec<f64> = at.map(|x| x.1).collect();
+ let burst = near.windows(2).map(|w| 0.5 * (w[0] + w[1])).fold(0.0, f64::max);
+ 10.0 * (burst / mean(vowel.t0 + 0.03, vowel.t1 - 0.02)).log10()
+}
+
+/// Lips opened at the full area rate from the first sample stepped up the flow's slope: a thump the
+/// speakers' /p/ doesn't have (experiment 27). The male read -4.5 dB here; men's read -11.8 before a vowel.
+#[test]
+fn a_lip_release_starts_slowly() {
+ let b = release_burst(&render("ˈɑpɑ", "male"));
+ assert!(b < -5.0, "/p/ release {b:.1} dB re the vowel");
+}
diff --git a/src/wasm/types.ts b/src/wasm/types.ts
index 3e27fc8..9394763 100644
--- a/src/wasm/types.ts
+++ b/src/wasm/types.ts
@@ -63,6 +63,8 @@ export interface HumanBody {
tongueRadius: number;
/** max lip width (cm, before scale) */
lipWidth: number;
+ /** length of the membranous vocal fold, the part that vibrates (1 = adult male) */
+ foldLength: number;
}
export interface ArticSpec {