the ultimate vocal synthesizer - sing, speak, beatbox, and more
Rust
Hill climb 31: her folds stay apart 13 points longer, by a body parameter (her flow fell faster than his, H1-H2 below his); lips start at 7 cm^2/s (it lifts her /p/ thump past its limit)
Jameson Hodgeb4244719d65b
diff --git a/crates/chimera/src/anatomy/human.rs b/crates/chimera/src/anatomy/human.rsindex 3457a92..2463268 100644--- a/crates/chimera/src/anatomy/human.rs+++ b/crates/chimera/src/anatomy/human.rs@@ -275,11 +275,16 @@ pub struct HumanBody {/// 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,+ /// how much more of the cycle the folds spend apart than an adult man's (0.13 = 13 points of+ /// open quotient): thinner folds meet for less of it. About 13 points in a woman's flow at normal+ /// loudness (Holmberg et al. 1988, second-hand), about 12 from her 3.5 dB more H1*-H2* (Classen+ /// et al. 1996, by Klatt & Klatt 1990, second-hand). A child's is taken to be a woman's, unsourced.+ pub open_phase: f64,}-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 };+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, open_phase: 0.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, open_phase: 0.13 };+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, open_phase: 0.13 };/// The three human bodies by their short names.#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]@@ -382,6 +387,7 @@ impl BodyMix {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),+ open_phase: self.blend(|b| b.body().open_phase),}}}diff --git a/crates/chimera/src/voice/human_airway.rs b/crates/chimera/src/voice/human_airway.rsindex 6ef966e..9ddcd59 100644--- a/crates/chimera/src/voice/human_airway.rs+++ b/crates/chimera/src/voice/human_airway.rs@@ -163,7 +163,7 @@ impl HumanAirway {seal_lo: 0.03,seal_hi: 0.4,seal_ease: 0.03,- lip_open_rate: 15.0,+ lip_open_rate: 7.0,base: None,base_dt: 0.0,noise_list: Vec::with_capacity(8),diff --git a/crates/chimera/src/voice/human_voice.rs b/crates/chimera/src/voice/human_voice.rsindex 5750d2c..834e826 100644--- a/crates/chimera/src/voice/human_voice.rs+++ b/crates/chimera/src/voice/human_voice.rs@@ -261,9 +261,9 @@ impl HumanVoice {v.output_gain *= if sc >= 1.0 {1.0} else if sc <= 0.9 {- 0.69+ 0.875} else {- 0.69 + 0.31 * (sc - 0.9) / 0.1+ 0.875 + 0.125 * (sc - 0.9) / 0.1};v.apply_source();v@@ -320,7 +320,7 @@ impl HumanVoice {// the arytenoids through the closed phase (Södersten & Lindestad 1990). It leaks a little// air and damps the tract, which lifts H1 and the band below 500 Hz.g.chink = (0.008 + 0.03 * s.breathiness) * k2;- g.open_quotient = 0.78 - 0.36 * s.tension;+ g.open_quotient = 0.78 - 0.36 * s.tension + body.open_phase;// The folds close along their length and depth over a return phase, not all at once, so// a sung or spoken voice closes softly (0.22 at tension 0.55): an abrupt closure put// 3-8 dB too much energy above 2 kHz. Pressing harder than that brings the abrupt closurediff --git a/crates/chimera/tests/body_mix.rs b/crates/chimera/tests/body_mix.rsindex 36f1b62..1871fe4 100644--- a/crates/chimera/tests/body_mix.rs+++ b/crates/chimera/tests/body_mix.rs@@ -43,6 +43,7 @@ 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!(between(mid.body().open_phase, BODY_MALE.open_phase, BODY_FEMALE.open_phase));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.rsindex b1aad81..5d49d03 100644--- a/crates/chimera/tests/body_source.rs+++ b/crates/chimera/tests/body_source.rs@@ -1,26 +1,46 @@//! 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.+//! her consonants. Her folds also stay apart for more of the cycle (experiment 31): at the same pulse+//! length as his, her flow still fell 1.10 times as fast and her H1-H2 sat below his, where real+//! women's fall is slower and their H1-H2 higher.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) {+/// A harmonic's power in the output: the largest over ±3 % of its frequency, for the drift.+fn harmonic(x: &[f64], f: f64) -> f64 {+ let at = |f: f64| {+ let n = x.len() as f64;+ let (mut re, mut im) = (0.0, 0.0);+ for (i, s) in x.iter().enumerate() {+ let w = 0.5 - 0.5 * (std::f64::consts::TAU * i as f64 / n).cos();+ let a = std::f64::consts::TAU * f * i as f64 / FS;+ re += w * s * a.cos();+ im += w * s * a.sin();+ }+ re * re + im * im+ };+ (0..21).map(|i| at(f * (0.97 + 0.003 * i as f64))).fold(0.0, f64::max)+}++/// Peak-to-peak flow (L/s) and the steepest fall of flow (L/s²) of a held /a/, medians over cycles,+/// and its H1-H2 (dB).+fn held(body: HumanBody, name: &str, f0: f64) -> (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();+ let (mut flow, mut out) = (Vec::new(), 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);+ out.push(one[0] as f64);}}let period = (FS / f0).round() as usize;@@ -30,16 +50,24 @@ fn held(body: HumanBody, name: &str, f0: f64) -> (f64, f64) {};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)+ (ac, fall, 10.0 * (harmonic(&out, f0) / harmonic(&out, 2.0 * f0)).log10())}#[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 (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}");}++#[test]+fn her_folds_stay_apart_for_more_of_the_cycle() {+ let (_, male_fall, male_h) = held(BODY_MALE, "male", 112.0);+ let (_, female_fall, female_h) = held(BODY_FEMALE, "female", 205.0);+ assert!(female_fall < male_fall, "her flow falls at {female_fall:.0} L/s², his at {male_fall:.0}");+ assert!(female_h > male_h, "her H1-H2 {female_h:.2} dB, his {male_h:.2}");+}diff --git a/src/wasm/types.ts b/src/wasm/types.tsindex 9394763..ffc758d 100644--- a/src/wasm/types.ts+++ b/src/wasm/types.ts@@ -65,6 +65,8 @@ export interface HumanBody {lipWidth: number;/** length of the membranous vocal fold, the part that vibrates (1 = adult male) */foldLength: number;+ /** how much more of the cycle the folds spend apart than an adult man's (0.13 = 13 points of open quotient) */+ openPhase: number;}export interface ArticSpec {