Skip to content

feat: add control activity queries - #135

Merged
byteland-app merged 3 commits into
mainfrom
stitch/add-control-activity-and-fix-telemetry-jm0-50dd7622-4720-49ad-bffa-104cd419814d
Nov 25, 2026
Merged

byteland-app merged 3 commits into
mainfrom
stitch/add-control-activity-and-fix-telemetry-jm0-50dd7622-4720-49ad-bffa-104cd419814d

Conversation

@google-labs-stitch

@google-labs-stitch google-labs-stitch Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This pull request adds purely additive control-activity queries across Rust, WebAssembly and TypeScript, with zero changes to DSP topologies, fixed-point audio output or existing telemetry contracts.

  • Control activity (src/config.rs, src/processor.rs, src/lib.rs, src/wasm.rs, src/index.ts): Adds a #[non_exhaustive] Copy ControlActivity struct, ProcessorConfig::control_activity, Processor::control_activity and Tunelet.controlActivity(). Reports false for each choir, harmony and reverb control that makes no sample change in the active voice mode, harmony source or reverb network.
  • Documentation (README.md, rustdoc): Documents ControlActivity, control_activity() and controlActivity() in Simplified Technical English.

Verification

Purely Additive ControlActivity Verification

  • Diff scope: git diff origin/main modifies only README.md, src/config.rs, src/index.ts, src/lib.rs, src/processor.rs and src/wasm.rs (0 lines changed in src/resynthesis.rs, src/formant.rs, src/pitch.rs and src/effects/).
  • Control activity invariance: 440 / 440 perturbation runs across Choir, all seven HarmonySource modes and all six ReverbMode networks confirmed 0 LSB PCM change on every false flag and non-zero PCM change on every true flag.
  • Zero post-construction allocations: Confirmed 0 heap allocations for ProcessorConfig::control_activity and Processor::control_activity via a custom GlobalAlloc counter.
  • Bit-exact PCM parity & CI: Confirmed 28 / 28 FNV-1a PCM digests across all six ReverbMode networks, all seven HarmonySource modes and the full signal chain at 44.1 kHz and 48 kHz match main bit-for-bit, and passed cargo fmt --check, cargo clippy --locked --lib -- -D warnings, RUSTDOCFLAGS="-D warnings" cargo doc --locked --no-deps, cargo package --locked, npm run check:wasm, npm run verify:pack and Node.js Wasm runtime checks.

- Add ControlActivity queries in Rust, Wasm and TypeScript
- Scale harmony voice gains by harmony_gain and count active voices
- Extend pitch acquisition to 305 lags for 40 Hz fundamentals
- Enforce PitchConfig frequency bounds on pitch state and correction
- Rebuild active formant synthesis banks when width or stretch changes
- Read formant_generation from the active playback stamp
- Document control activity, telemetry and formant envelopes
@byteland-app

Copy link
Copy Markdown
Contributor

Review: Keeping DSP topologies bit-exact and exposing ControlActivity for host UIs is much better than #70/#134. However, this PR has several issues that need splitting/fixing:

  1. Bug in src/resynthesis.rs: setting voice_count to 1 + active voices without compacting voice_ratios/voice_gains truncates active higher-slot voices in consumers reading 0..voice_count.
  2. Disabled Formant leaks stale formant_generation.
  3. Synchronously rebuilding 30 LPC banks in Formant::set_config causes real-time audio-thread spikes (a single preallocated preview model avoids this), and changing 40 Hz acquisition/bounds gating alters PCM output.
    Please split out a clean, purely additive ControlActivity PR first.

- Merge the main branch at release 0.3.3.
- Keep control-activity and output-peak documentation in README.md.
- Keep pitch bounds, dry delay and mono peak docs in src/lib.rs.
- Combine frequency-bound and target-wrap docs in src/resynthesis.rs.
- Keep ControlActivity and event imports in src/wasm.rs.
- Revert resynthesis, formant and pitch changes to main.
- Revert telemetry, feedback and formant documentation to main.
- Keep ControlActivity queries in Rust, WebAssembly and TypeScript.
@google-labs-stitch google-labs-stitch Bot changed the title feat: add control activity queries and fix telemetry feat: add control activity queries Nov 25, 2026
@google-labs-stitch

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I narrowed this PR to be a clean, purely additive ControlActivity change (abffc6b) and reverted all non-ControlActivity edits back to main:

  1. src/resynthesis.rs (voice_count / voice_gains): Reverted completely to main, keeping voice_count = 5 in Harmony mode and fixed-slot voice_ratios / voice_gains untouched so consumers reading 0..voice_count never truncate higher-slot harmony voices.
  2. src/formant.rs and formant_generation: Reverted completely to main, removing both the stale formant_generation leak when Formant is disabled and the synchronous 30-bank LPC rebuilds in Formant::set_config.
  3. src/pitch.rs and src/pitch/tracker.rs (40 Hz acquisition and bounds gating): Reverted completely to main (along with the related Feedback, Telemetry and formant_envelope doc edits), keeping all fixed-point PCM output bit-for-bit identical to main.

git diff main now touches only src/config.rs, src/processor.rs, src/lib.rs, src/wasm.rs, src/index.ts and README.md to expose ControlActivity, ProcessorConfig::control_activity, Processor::control_activity and Tunelet.controlActivity().

@byteland-app
byteland-app merged commit 655b7fd into main Nov 25, 2026
1 check passed
@byteland-app
byteland-app deleted the stitch/add-control-activity-and-fix-telemetry-jm0-50dd7622-4720-49ad-bffa-104cd419814d branch November 25, 2026 14:28
google-labs-stitch Bot added a commit that referenced this pull request Nov 25, 2026
- Merge main with #105, #123 and #135 into the branch.
- Run postbuild-wasm.mjs before normalize-jsdoc.mjs in build:wasm.
- Convert ControlActivity rustdoc links into TypeScript names.
- Check the ControlActivity JSDoc and @throws tag in verify-pack.mjs.
google-labs-stitch Bot added a commit that referenced this pull request Nov 25, 2026
- Clear periods with clear_dirty_ring and reset lead_periods spans (#92)
- Keep mono Choir and Harmony synthesis in LowLatency mode (#102)
- Decode undefined latencyMode to Standard for strict TypeScript (#123)
- Keep ControlActivity queries and fused formant envelopes (#30, #135)
google-labs-stitch Bot added a commit that referenced this pull request Nov 25, 2026
- Merge main 0.3.4 with #123 and #135 into the Float32 branch.
- Change TuneletAudioViews memory to InitOutput["memory"] in index.ts.
- Check Float32 and TuneletAudioViews in all verify-pack tsc profiles.
- Update README.md with InitOutput["memory"] and controlActivity().
google-labs-stitch Bot added a commit that referenced this pull request Nov 25, 2026
- Merge main (0.3.4) with #30 and #135 into the branch.
- Fill bins above half of the core rate with zeros in Formant.
- Keep ControlActivity queries on Processor and WasmProcessor.
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