mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Test the production speed boundary directly
Signed-off-by: John Tennant <johnmatthewtennant@gmail.com>
This commit is contained in:
committed by
John Tennant
parent
8b87b09381
commit
e914b1c18a
@@ -4,7 +4,6 @@ use std::time::Instant;
|
||||
mod playback_speed_dsp;
|
||||
|
||||
const SAMPLE_RATE: u32 = 24_000;
|
||||
const SENTENCE_LEAD_IN_SAMPLES: usize = 480;
|
||||
const TONE_SECONDS: f64 = 10.0;
|
||||
|
||||
fn main() {
|
||||
@@ -16,7 +15,6 @@ fn main() {
|
||||
|
||||
let compensated_lookahead = playback_speed_dsp::compensated_output_latency_samples(SAMPLE_RATE);
|
||||
let compensated_lookahead_ms = compensated_lookahead as f64 * 1_000.0 / SAMPLE_RATE as f64;
|
||||
let fixed_lead_in_ms = SENTENCE_LEAD_IN_SAMPLES as f64 * 1_000.0 / SAMPLE_RATE as f64;
|
||||
|
||||
for speed in [0.75_f32, 1.25, 1.5] {
|
||||
let started = Instant::now();
|
||||
@@ -25,7 +23,7 @@ fn main() {
|
||||
let elapsed = started.elapsed();
|
||||
println!(
|
||||
"{speed:.2}x: processing={:.2}ms, {:.3}% realtime, output={} samples, compensated \
|
||||
lookahead={compensated_lookahead_ms:.1}ms, fixed playback lead-in={fixed_lead_in_ms:.1}ms",
|
||||
DSP lookahead={compensated_lookahead_ms:.1}ms",
|
||||
elapsed.as_secs_f64() * 1_000.0,
|
||||
elapsed.as_secs_f64() / TONE_SECONDS * 100.0,
|
||||
output.len(),
|
||||
|
||||
@@ -25,8 +25,6 @@ pub(crate) use playback_speed_dsp::process_complete_chunk;
|
||||
use playback_speed_dsp::{validate_speed, DEFAULT_PLAYBACK_SPEED};
|
||||
|
||||
const SETTINGS_FILE: &str = "tts-playback-settings.json";
|
||||
#[cfg(test)]
|
||||
use playback_speed_dsp::UNITY_EPSILON;
|
||||
|
||||
/// Lock-free shared control read by the TTS worker before each synthesis chunk.
|
||||
#[derive(Clone, Debug)]
|
||||
@@ -135,22 +133,6 @@ fn save_to_path(path: &Path, speed: f32) -> Result<(), String> {
|
||||
.map_err(|error| format!("commit {}: {error}", resolved.display()))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
enum ProcessorKind {
|
||||
Bypass,
|
||||
Signalsmith,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn processor_kind(speed: f32) -> ProcessorKind {
|
||||
if (speed - DEFAULT_PLAYBACK_SPEED).abs() <= UNITY_EPSILON {
|
||||
ProcessorKind::Bypass
|
||||
} else {
|
||||
ProcessorKind::Signalsmith
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -158,9 +140,10 @@ mod tests {
|
||||
const SAMPLE_RATE: u32 = 24_000;
|
||||
|
||||
#[test]
|
||||
fn selects_bypass_only_at_unity() {
|
||||
assert_eq!(processor_kind(1.0), ProcessorKind::Bypass);
|
||||
assert_eq!(processor_kind(1.25), ProcessorKind::Signalsmith);
|
||||
fn unity_processing_is_a_bit_exact_bypass() {
|
||||
let input = vec![0.0, 0.125, -0.5, 1.0];
|
||||
let output = process_complete_chunk(&input, 1.0, SAMPLE_RATE).expect("unity output");
|
||||
assert_eq!(output, input);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user