Skip to content

feat(harmony): add per-voice harmony mix controls - #40

Closed
google-labs-stitch[bot] wants to merge 3 commits into
mainfrom
stitch/add-per-voice-harmony-mix-jm0-53bd2627-bd38-47e8-9b20-95beaaf0c130
Closed

google-labs-stitch[bot] wants to merge 3 commits into
mainfrom
stitch/add-per-voice-harmony-mix-jm0-53bd2627-bd38-47e8-9b20-95beaaf0c130

Conversation

@google-labs-stitch

Copy link
Copy Markdown
Contributor

Summary

This pull request adds per-voice mix controls for the four harmony voices and a lead voice gain control in Harmony mode, while keeping the single shared post-mix Formant synthesis stage and zero audio-path allocations:

  • ResynthesisConfig::lead_gain: Adds lead_gain: f32 in 0.0..=1.0 (default 1.0) with validation (resynthesis.lead_gain). Slot 0 scales its output by lead_gain and continues to advance its reader when lead_gain is 0.0, preserving formant stamp alignment.
  • HarmonyConfig per-voice mix controls:
    • voice_gains: [f32; HARMONY_VOICES] in 0.0..=1.0 (default [1.0, 1.0, 1.0, 1.0]), validated under resynthesis.harmony.voice_gains.
    • voice_pans: [f32; HARMONY_VOICES] in -1.0..=1.0 (default [-0.33333334, 0.33333334, -1.0, 1.0]), validated under resynthesis.harmony.voice_pans.
    • voice_mutes: [bool; HARMONY_VOICES] (default [false, false, false, false]).
  • Fixed-point mix coefficients & mono attenuation: Resynthesis::configure_coefficients precomputes Q14 lead_gain, mono harmony voice gains (harmony_mono), and constant-power stereo pan gains (harmony_pan). Resynthesis::process_sample applies harmony_gain, voice_gains, and voice_mutes in both mono and stereo modes, eliminating default mono overload while keeping stereo output bit-identical to baseline when using default settings.
  • WebAssembly & TypeScript compatibility: Exposes optional camelCase fields (leadGain, voiceGains, voicePans, voiceMutes) with serde defaults so existing JavaScript callers remain compatible.
  • Documentation: Documents how Resynthesis::voices and Telemetry::voice_gains report controller envelopes independently of mix controls, and updates src/wasm.rs and README.md.

Verification

  • cargo build --locked --release
  • cargo fmt --check
  • cargo clippy --locked --lib -- -D warnings
  • cargo clippy --locked --target wasm32-unknown-unknown --features wasm --lib -- -D warnings
  • RUSTDOCFLAGS="-D warnings" cargo doc --locked --no-deps
  • npm run build (wasm-pack + tsc)
  • Verified bit-identical stereo Harmony (with and without formants) and Choir PCM output against unmodified main baseline, 0 clipped frames on a -6 dBFS 4-voice mono Harmony render (harmony_gain = 0.5), lead-only mono output when harmony_gain = 0.0 matching voice_mutes = [true; 4], formant envelope alignment when lead_gain = 0.0, and Node.js Wasm backward compatibility and TimedEvent automation.

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

- Add lead_gain to ResynthesisConfig and validate its range.
- Add voice_gains, voice_pans and voice_mutes to HarmonyConfig.
- Validate voice_gains and voice_pans in HarmonyConfig::validate.
- Precompute Q14 lead, mono harmony and stereo pan gains.
- Apply harmony mix gains in mono and stereo resynthesis.
- Accept absent optional harmony mix fields in JavaScript.
- Document the harmony mix fields and telemetry gains.
…harmony-mix-jm0-53bd2627-bd38-47e8-9b20-95beaaf0c130

# Conflicts:
#	README.md
#	src/resynthesis.rs
…harmony-mix-jm0-53bd2627-bd38-47e8-9b20-95beaaf0c130
@byteland-app

Copy link
Copy Markdown
Contributor

Closing as superseded by #133. #133 includes per-voice harmony mix controls along with independent per-voice formant banks, silent-voice IIR bypass, and parameter deduplication.

@byteland-app
byteland-app deleted the stitch/add-per-voice-harmony-mix-jm0-53bd2627-bd38-47e8-9b20-95beaaf0c130 branch November 25, 2026 08:06
@google-labs-stitch

Copy link
Copy Markdown
Contributor Author

Thank you. Pull request #40 stays closed because #133 replaces it. We made no more changes on this branch.

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