Skip to content

feat(resynthesis): add low-latency mode without formant overlap - #85

Closed
google-labs-stitch[bot] wants to merge 1 commit into
mainfrom
stitch/add-low-latency-mode-jm1-12956110-38d8-4677-83ab-bef997900faa
Closed

google-labs-stitch[bot] wants to merge 1 commit into
mainfrom
stitch/add-low-latency-mode-jm1-12956110-38d8-4677-83ab-bef997900faa

Conversation

@google-labs-stitch

Copy link
Copy Markdown
Contributor

Summary

This change adds LatencyMode (Standard, LowLatency) to ResynthesisConfig across the Rust, WebAssembly and TypeScript APIs.

  • Export LatencyMode (Standard default, LowLatency) from src/resynthesis.rs and src/lib.rs, with "standard" | "lowLatency" TypeScript declarations.
  • Add pub latency_mode: LatencyMode to ResynthesisConfig (latencyMode in TypeScript).
  • Skip the 1,543-frame overlap buffer and LPC formants in Resynthesis::process_sample, Resynthesis::render_lead, Resynthesis::tail_frames and Resynthesis::formant_envelope when LatencyMode::LowLatency is active.
  • Keep input_period separate from periods so Choir voices keep resampled periods while Processor::feedback reports raw input pitch and returns voiced == false on silence.
  • Reset resynthesis and post-resynthesis audio histories without heap allocation when latency_mode changes via set_config or TimedEvent.
  • Return 50 frames in LatencyMode::LowLatency and 1,593 frames in LatencyMode::Standard from Processor::latency_frames, Feedback::latency_frames and Tunelet.latencyFrames.
  • Update rustdoc and README.md in ASD-STE100 Simplified Technical English.

Verification

Measured 220 Hz vocal onset latency at 48 kHz

  • Bit-identical Standard parity: Verified sample-exact i16 PCM output, feedback(), telemetry(), tail_frames() and formant_envelope() against v0.3.2 across Default, Choir, Harmony, Formant and effect configurations at 44.1 kHz and 48 kHz.
  • Measured LowLatency delay:
    • latency_frames(), feedback().latency_frames and Tunelet.latencyFrames return 50 at 44.1 kHz and 48 kHz.
    • Dry impulse (dry_mix == 1.0) outputs at 0 frames of delay; wet impulse (dry_mix == 0.0) outputs at 50 frames of delay.
    • A 220 Hz vocal waveform outputs wet audio at 50 frames (1.13 ms at 44.1 kHz and 1.04 ms at 48 kHz).
  • Choir feedback & Formant validation: Verified feedback() reports raw input pitch and voiced == false on silence when choir_voices > 1 and pitch_ratio != 1.0. Verified FormantConfig range validation, skipped 2 * sample_rate tail frames and Ok(false) with zeroed slices from formant_envelope() in LowLatency.
  • Zero-allocation real-time guard: Verified zero heap allocations after Processor::new across audio blocks, latency_mode transitions (set_config and TimedEvent), feedback, telemetry, reset and drain.
  • CI checks: cargo fmt --check, cargo clippy --locked --lib -- -D warnings, cargo build --locked --release, RUSTDOCFLAGS="-D warnings" cargo doc --locked --no-deps, cargo package --list --locked, RUSTDOCFLAGS="-D warnings" npm run check:wasm and npm run verify:pack passed with zero warnings.

Automated PR initiated by user @byteland-app via Stitch Loop.

- Export LatencyMode and add latency_mode to ResynthesisConfig.
- Skip the overlap buffer and LPC formants in LatencyMode::LowLatency.
- Keep input_period separate from the Choir lead periods.
- Reset the audio histories when latency_mode changes.
- Return 50 or 1,593 frames from the Rust and Wasm latency getters.
- Update the crate documentation and README.md.
@byteland-app

Copy link
Copy Markdown
Contributor

Closing as superseded by #114. #114 achieves the same 50-frame low-latency mode while preserving full causal 128-frame Formant processing and formant_envelope() support, and marks latency_mode as optional in Wasm for backward compatibility.

@byteland-app
byteland-app deleted the stitch/add-low-latency-mode-jm1-12956110-38d8-4677-83ab-bef997900faa branch November 25, 2026 08:02
@google-labs-stitch

Copy link
Copy Markdown
Contributor Author

Thank you. Pull request #85 stays closed because #114 replaces it. Pull request #114 keeps causal 128-frame formant control, formant_envelope() support and an optional latencyMode field in Wasm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant