Skip to content

feat(events)!: add scalar parameter control events - #61

Merged
byteland-app merged 6 commits into
mainfrom
stitch/feat/scalar-control-events-jm1-4a694372-e0a5-413d-abe3-3f7cd15c4124
Nov 26, 2026
Merged

byteland-app merged 6 commits into
mainfrom
stitch/feat/scalar-control-events-jm1-4a694372-e0a5-413d-abe3-3f7cd15c4124

Conversation

@google-labs-stitch

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

Copy link
Copy Markdown
Contributor

Summary

  • Add #[non_exhaustive] to ControlEvent and add the #[non_exhaustive] ParameterControl enum in src/events.rs, re-export it from src/lib.rs, and add ControlEvent::Parameter(ParameterControl) for 29 scalar parameters across PunchConfig, WarmConfig, ResynthesisConfig, CorrectionConfig (including Humanize and FlexTune), FormantConfig, HarmonyConfig, and ReverbConfig for the 0.4.0 breaking window.
  • Validate each ParameterControl variant in ParameterControl::validate, ControlEvent::validate, and sequential block preflight (ValidatedEvents::new + validate_in_sequence + ParameterControl::apply_to, coordinated with feat!: add partial configuration patches and patch events #122) through shared validate_* helpers before any state or output change, with the exact dotted field path and inclusive range of its stage structure.
  • Handle ControlEvent::Parameter in Processor::apply to update self.config, clear drain_remaining, and call only the setter for the changed field.
  • Add field-diff guards to stage setters in Punch, Warm, Reverb (including hall_diffuse in configure_diffusion for MediumHall and LargeHall), Formant, HarmonyState, and Resynthesis (including configure_correction_decay for retune_ms and humanize, configure_flex_tune, and dwell resets on humanize == 0.0 and pitch_ratio changes), while constructors initialize all coefficients unconditionally.
  • Replace the two Resynthesis::apply_config calls in Processor::drain_into with a temporary aspiration_muted flag on Formant.
  • Add cfg_attr(all(feature = "wasm", target_arch = "wasm32"), ...) serde and tsify attributes on ParameterControl, decode { type: "parameter", value: { type, value } } with cached keys in src/wasm.rs into the reusable TimedEvent buffer across both Int16Array and Float32 methods, normalize ParameterControl JSDoc links in scripts/normalize-jsdoc.mjs, check ParameterControl types and runtime events in scripts/verify-pack.mjs, and document all 29 variants and ranges in rustdoc, src/wasm.rs, and README.md.

Verification

  • Passed cargo build --locked --release, cargo fmt --check, cargo clippy --locked --lib -- -D warnings, RUSTDOCFLAGS="-D warnings" cargo doc --locked --no-deps, cargo package --locked, RUSTDOCFLAGS="-D warnings" npm run check:wasm, npm run verify:pack, npm run verify:pack -- --ignore-scripts, .githooks/pre-commit, .githooks/commit-msg, and MSRV 1.88 (cargo build --locked --lib + --target wasm32-unknown-unknown --features wasm) with zero warnings.
  • Verified bit-identical PCM and f32 output, Processor::config, Feedback, Telemetry, ControlActivity, formant_envelope, and drain* output against main (0850e25, 0x71ee66cde2fb0796) and across all 29 ParameterControl variants (including Humanize, FlexTune, MediumHall / LargeHall ReverbDiffusion, mono Formant, and MIDI HarmonySource switches) in native Rust and WebAssembly (Int16Array and Float32 copied + in-place methods) compared to equivalent stage ControlEvent updates.
  • Verified out-of-range and non-finite ParameterControl cases, multi-event validate_in_sequence sequences, and malformed JavaScript parameter event cases fail before any state, configuration, output buffer, or drain change.
  • Verified zero heap allocations after Processor::new across all process*, drain*, control_activity, and formant_envelope paths.
  • Benchmarked 480,000 frames at 48 kHz with 120,000 dry_mix events:
    • Native Rust event overhead dropped from +59.441 ms (+132.416 ms on a 16-voice stereo formant-stretch preset) on main to +8.480 ms (noise floor -0.720 ms on the rich preset) with ParameterControl::DryMix.
    • WebAssembly event overhead on the 16-voice stereo formant-stretch preset dropped from +1359.44 ms (guarded stage events) to +196.44 ms (-85.5%) with cached-key ParameterControl decoding.

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

- Add the ParameterControl enum and ControlEvent::Parameter.
- Validate scalar controls with their stage paths and ranges.
- Guard unchanged fields in the stage setters.
- Mute aspiration with a flag on Formant for each drain call.
- Add serde and tsify attributes for the Wasm package.
- Document the scalar parameter variants and their ranges.
- Merge the upstream main branch into the feature branch.
- Quantize the mono harmony gain in configure_harmony_gain.
- Merge the main branch into the feature branch.
- Keep configure_all in Formant::new without a second reset.
- Clear aspiration_muted before the dirty check in Formant::reset.
@byteland-app

Copy link
Copy Markdown
Contributor

Review: Strong implementation of lightweight ParameterControl scalar events, single-source validate_* helpers, stage diff-guards, and drain aspiration_muted. Please rebase onto current main and re-run CI to clear the stuck PENDING check. Target this for the 0.4.0 breaking window (and consider adding #[non_exhaustive] to ControlEvent) so #122 can share the same validate_* helpers and diff-guards.

- Merge main at 0.3.3 into the scalar parameter control branch.
- Add #[non_exhaustive] to ControlEvent for the 0.4.0 release.
- Keep the new Punch and Warm fixed-point paths in the narrow setters.
- Reset scale_initialized in Resynthesis::set_pitch_ratio.
- Decode ParameterControl events with cached keys in src/wasm.rs.
@google-labs-stitch

Copy link
Copy Markdown
Contributor Author

Addressed in c967cbd:

  • Synced with main (0.3.3) and triggered a fresh CI run: Merged origin/main (since fast-forward-only branch protection prevents force-pushing a rebase) to resolve the merge conflicts and clear the stuck PENDING check:
    • Updated Punch and Warm narrow setters and field-diff guards to use main's 6 ms hold_tree and Q28/Q30/Q24 envelope paths.
    • Updated Resynthesis::set_pitch_ratio to also reset scale_initialized = false on a pitch_ratio change so ParameterControl::PitchRatio matches main's fix(resynthesis): stop correction when a shifted period wraps #3 period-wrap fix in Resynthesis::apply_config.
    • Extended EventKeys and decode_control_event (decode_parameter_control) in src/wasm.rs so { type: "parameter", value: { type, value } } decodes all 27 ParameterControl variants directly into the reusable TimedEvent buffer without serde_wasm_bindgen stage-object conversion.
  • Targeted the 0.4.0 breaking window and marked ControlEvent #[non_exhaustive]: Kept the ! breaking header (feat(events)!: ... with "bump-minor-pre-major": true targeting 0.4.0) and added #[non_exhaustive] to ControlEvent alongside #[non_exhaustive] ParameterControl, so feat!: add partial configuration patches and patch events #122 can share #[non_exhaustive] ControlEvent, the single-source validate_* helpers, and the stage field-diff guards.

@byteland-app

Copy link
Copy Markdown
Contributor

Round 2 review: Approved for the 0.4.0 breaking window — ParameterControl, single-source validate_* helpers, ControlEvent #[non_exhaustive], and full stage diff-guards are solid (and subsume #24). Please rebase onto updated main (after #46, #86, and #135) and coordinate with #122 on validate_in_sequence.

- Merge main 0.3.4 into this branch.
- Update hall allpass diffusion in Reverb::configure_diffusion.
- Add validate_chromatic_intervals and validate_diatonic_intervals.
- Add ParameterControl::apply_to and validate_in_sequence.
- Pass the active ProcessorConfig into ValidatedEvents::new.
- Check ParameterControl types and events in verify-pack.mjs.
@google-labs-stitch

Copy link
Copy Markdown
Contributor Author

Addressed in 1121bcc:

@byteland-app

Copy link
Copy Markdown
Contributor

Round 3 review: Approved for 0.4.0 — 27-variant ParameterControl, shared validate_* helpers, ControlEvent #[non_exhaustive], and stage diff-guards are verified (and subsume #24). Please rebase onto updated main after #20, #45, #107, and #117 (adding humanize/flex_tune validation alignment and any new normalize-jsdoc.mjs mappings).

- Keep the Stamp helpers and the formant validators in src/formant.rs.
- Add Humanize and FlexTune variants to ParameterControl.
- Add humanize and flex_tune validators and setters to Resynthesis.
- Reset dwell progress in Resynthesis::set_pitch_ratio.
- Pass processor settings to decode_events in Wasm Float32 methods.
- Normalize parameter JSDoc links in scripts/normalize-jsdoc.mjs.
- Document and verify all 29 scalar controls across PCM and Float32.
@google-labs-stitch

Copy link
Copy Markdown
Contributor Author

Addressed in 656d53a:

google-labs-stitch Bot added a commit that referenced this pull request Nov 26, 2026
- Merge upstream main with #139, #131, #104 and #61.
- Guard vibrato_preserve updates in Resynthesis::apply_config.
- Drop the duplicate PeriodFilter::configure call after new.
- Taper the vibrato modulation ratio with the flex_tune pull.
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