Skip to content

P0: sample-accurate FX bypass de-click, zero added latency and cross-thread reconciliation - #107

Merged
masarray merged 1 commit into
mainfrom
fix/p0-fx-bypass-sample-declick-20261028
Oct 27, 2026
Merged

masarray merged 1 commit into
mainfrom
fix/p0-fx-bypass-sample-declick-20261028

Conversation

@masarray

Copy link
Copy Markdown
Owner

Root cause

Current setBypass publishes a bare atomic boolean and the audio callback jumps between VST3 processBlock and untouched dry samples at a buffer edge; this can cause an audible discontinuity regardless of callback CPU budget. Distinct from Issue #15 zero-plugin WASAPI crackles, still open.

Engine fix

  • Per-physical-slot FxBypassEnvelope, exclusively RT-owned; UI thread only publishes desired bypassFlags.
  • 8 ms linear wet/dry crossfade for zero-latency FX. Stereo dry snapshot copied into one preallocated buffer only during an actual transition; no RT allocation/locks/device restart/extra buffer latency.
  • For VST reporting positive latency, avoid mixing time-misaligned dry/wet: 8 ms down → switch at exact zero → 8 ms up. This is an intentional brief level dip, not a second processing graph or falsely "seamless" tail preservation.
  • Stable bypass skips VST processBlock, stable active path has no dry snapshot overhead. Preset staged graphs and device reopen reset envelope to the appropriate flag, not stale sample state. Latency telemetry updated on message thread.
  • C++ pure helper tests for first sample, transitions, reversals, no wet/dry sum for latency cases. Windows MSVC Release + CTest and current JS contract are gates.

Parallel thread reconciliation

Hardware FAT still needed

Toggle real plugin several times in sustained audio; test both zero-latency and latency-bearing effects; assess rapid toggles and simultaneous FX. This PR addresses discontinuities due to host bypass only. A passing CI cannot prove total elimination of audible clicks or fix capture discontinuities.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T22:15:52.722917Z c437a88 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c437a8851a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/LiveAudioEngine.h
Comment on lines +686 to 688
staged->bypassEnvelope[i].prepare (staged->slots[i].bypass, rate,
staged->slots[i].latency);
staged->slots[i].latency = staged->slots[i].processor->getLatencySamples();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Read restored plugin latency before preparing its bypass envelope

When recalling a preset containing a latency-bearing VST3, every staged Slot still has its default latency = 0 when passed to prepare(). The actual latency is read immediately afterward, but the envelope retains zero internally. Subsequent bypass toggles therefore use the zero-latency wet/dry crossfade instead of switching at silence, mixing time-misaligned signals and introducing comb filtering or cancellation during the transition. Since live recall does not restart the device, this persists until a later device restart. Populate the slot latency before preparing its envelope.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Live reconciliation update: While PR #107 was being prepared, meter PR #106 merged to main SHA 20222c6 and Windows/Chromium were PASS for its PR head. PR #107 has been rebuilt from this newer main, so it preserves meter ballistics. The handoff document in this branch records the original PR-open snapshot; the current authoritative status is #106 MERGED, #102 OPEN with conflicts, #101 OPEN, #107 pending Windows/Chromium gates. Cross-thread integration notes have also been posted directly to #102 and #101. Always read live main SHA before another merge.

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