the ultimate vocal synthesizer - sing, speak, beatbox, and more
Rust
Review round 2: accurate verification numbers; allocation test over every creature
Jameson Hodge44491c557eca
diff --git a/crates/chimera-wasm/tests/realtime.rs b/crates/chimera-wasm/tests/realtime.rsindex b5aeb43..a376971 100644--- a/crates/chimera-wasm/tests/realtime.rs+++ b/crates/chimera-wasm/tests/realtime.rs@@ -43,7 +43,6 @@ fn the_audio_thread_abi_does_not_allocate() {let h = engine_new(48000.0);// planned off the audio threadlet plan = plan_utterance(&tokenize_ipa("ˈhɛloʊ ˈwɝld ʃi sɛlz"), &PlanOptions { body: "male".into(), t0: 0.0, f0: Some(110.0), ..Default::default() });- let creature_req = br#"{"id":"elephant","params":{"pitch":20}}"#.to_vec();unsafe {let render = |blocks: usize| {for b in 0..blocks {@@ -85,23 +84,27 @@ fn the_audio_thread_abi_does_not_allocate() {render(50);assert_eq!(allocs() - before, 0, "the human voice's audio path allocated");- // a creature switch allocates; what follows must not- assert_eq!(engine_set_creature(h, creature_req.as_ptr(), creature_req.len()), 0);- let before = allocs();- for b in 0..600 {- engine_render(h, 128);- if b % 6 == 0 {- assert!(!engine_creature_telemetry(h).is_null());- }- match b {- 50 => engine_play_call(h, 0, f64::NAN, f64::NAN),- 200 => engine_creature_param(h, 0, 30.0),- 300 => engine_play_call(h, 1, 25.0, 0.8),- 400 => engine_stop_call(h),- _ => {}+ // a creature switch allocates; what follows must not (every creature)+ for def in chimera::creatures::CREATURES.iter() {+ let req = format!(r#"{{"id":"{}","params":{{}}}}"#, def.id).into_bytes();+ assert_eq!(engine_set_creature(h, req.as_ptr(), req.len()), 0);+ let before = allocs();+ for b in 0..400 {+ engine_render(h, 128);+ if b % 6 == 0 {+ assert!(!engine_creature_telemetry(h).is_null());+ }+ match b {+ 30 => engine_set_gate(h, 1.0),+ 50 => engine_play_call(h, 0, f64::NAN, f64::NAN),+ 150 => engine_creature_param(h, 0, def.params[0].default * 1.1),+ 200 => engine_play_call(h, def.calls.len() - 1, 1.2 * def.params[0].default, 0.8),+ 300 => engine_stop_call(h),+ _ => {}+ }}+ assert_eq!(allocs() - before, 0, "{}: the creature's audio path allocated", def.id);}- assert_eq!(allocs() - before, 0, "the creature's audio path allocated");engine_free(h);}}diff --git a/docs/rust-engine.md b/docs/rust-engine.mdindex 2eb106d..87d4174 100644--- a/docs/rust-engine.md+++ b/docs/rust-engine.md@@ -239,7 +239,8 @@ render call and so it isn't needed.- creatures: within 2e-10, including the chaotic and self-oscillating modes;- plans and beat sequences: bit-exact apart from 1-ulp `f0` values;- G2P, IPA and syllables: exact on about 3 200 cases;- - geometry and analysis: within 1e-12 relative.+ - geometry: within 8e-14 relative; analysis (transfer functions, formants, FFT, LPC): within+ 1e-10 relative (the UI's dB curve 9.7e-11, formants 1.1e-12).- **The bun tests** that were about the engine are now `cargo test`s with the same thresholds.The UI's live paths (Sing keys, worklet ordering, creature telemetry layout) run on the wasmbuild.