Skip to content

Fix #623: Adaptive noise gate with dynamic noise floor estimation#821

Open
Shan7Usmani wants to merge 2 commits into
shouri123:mainfrom
Shan7Usmani:feat/adaptive-noise-gate-623
Open

Fix #623: Adaptive noise gate with dynamic noise floor estimation#821
Shan7Usmani wants to merge 2 commits into
shouri123:mainfrom
Shan7Usmani:feat/adaptive-noise-gate-623

Conversation

@Shan7Usmani

Copy link
Copy Markdown

Description

Implements an adaptive noise gate that dynamically estimates the background noise floor from incoming audio and adjusts the gating threshold in real time. Low-amplitude ambient noise (fans, keystrokes, background chatter) is physically attenuated before it reaches the MediaRecorder, reducing Whisper STT API costs.

Fixes #623

Type of Change

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings

Implementation

AdaptiveNoiseGate class (src/audioProcessing.ts)

  • Tracks a running noise floor estimate from incoming RMS samples
  • Computes adaptive threshold = noiseFloor × multiplier (clamped to [0.003, 0.05])
  • Noise floor adapts upward during silence, decays slowly during speech
  • Hold counter prevents gate chatter during inter-word pauses

Integration

  • Replaces fixed rmsThreshold in the VAD loop with the adaptive threshold
  • Adds a GainNode to the audio graph (offscreenAudioGraph.ts) that physically gates the signal before reaching the MediaRecorder
  • Smooth gain ramps via setTargetAtTime (10ms time constant) to avoid audible clicks
  • Analyser and playback always receive the raw ungated signal (VAD/waveform unaffected)

Tests

  • 14 unit tests for AdaptiveNoiseGate (threshold, hold counter, noise floor adaptation, clamping, reset, non-finite RMS)
  • 2 offscreen graph tests updated for new gain node topology

@Shan7Usmani Shan7Usmani requested a review from shouri123 as a code owner June 20, 2026 09:09
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@Shan7Usmani, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 59 minutes and 52 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cd952b7d-9f67-474e-b9e7-aff150e808b7

📥 Commits

Reviewing files that changed from the base of the PR and between 35c28d6 and 687f399.

📒 Files selected for processing (6)
  • src/audioProcessing.test.ts
  • src/audioProcessing.ts
  • src/config.ts
  • src/offscreen.ts
  • src/offscreenAudioGraph.ts
  • tests/offscreenAudioGraph.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Thank You for Contributing to Late-Meet

Please ensure that:

  • the issue was assigned to you before opening this PR
  • the PR references the related issue
  • your changes follow repository contribution guidelines
  • the project builds successfully before submission

Unassigned, duplicate, or low-quality PRs may be closed.

Thank you for contributing 💙

@github-actions github-actions Bot added gssoc Official GSSoC contribution issue gssoc:approved GSSoC: PR approved and scored bug Something isn't working size/L type:design Type: Design / UI / UX (Optional bonus) type:feature Type: New Feature labels Jun 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👋 Thank you @Shan7Usmani for your contribution to Late-Meet!

✅ Verified: You are assigned to the linked issue #623.

Please review any automated suggestions or code review comments that may appear below! We will review your PR as soon as possible!


Please consider starring the repository ⭐ to show your support!

@github-actions github-actions Bot added type:code Type: Code change type:style Type: CSS/Styling change type:config Type: Configuration change type:test Type: Test files security-review Requires security review before merge and removed bug Something isn't working type:feature Type: New Feature type:design Type: Design / UI / UX (Optional bonus) size/L labels Jun 20, 2026
…imation

- Add AdaptiveNoiseGate class to src/audioProcessing.ts:
  - Estimates background noise floor from incoming RMS samples
  - Computes adaptive threshold = noiseFloor × multiplier (clamped)
  - Hold counter prevents gate chatter during inter-word pauses
  - Noise floor adapts upward during silence, decays slowly during speech

- Integrate into offscreen.ts VAD loop:
  - Replace fixed rmsThreshold with adaptive threshold from noise gate
  - Control a GainNode that physically attenuates silent passages before
    they reach the MediaRecorder, reducing STT API costs
  - Smooth gain ramps via setTargetAtTime (10ms time constant) to avoid clicks
  - Tick hold counter on every VAD cycle (even throttled ticks)

- Modify offscreenAudioGraph.ts:
  - Add noiseGateGain (GainNode) to OffscreenAudioGraph interface
  - Route sources through gain node → recorder destination (gated path)
  - Analyser and playback always receive raw ungated signal

- Add noise gate constants to config.ts

- Add 14 unit tests for AdaptiveNoiseGate in audioProcessing.test.ts
- Update 2 offscreen graph tests for new gain node topology
- Fix noise floor decay toward zero during speech (long-meeting bug)
  → noise floor is now untouched during speech, stays at last silence estimate
- Fix reset() ignoring constructor options → stores initialThreshold and restores it
- Remove unused frameCount field
- Rename process() → analyze() for clarity
- Remove gain ramp guard with arbitrary 0.01 tolerance (setTargetAtTime is idempotent)
- Update/add tests to verify fix behavior
@Shan7Usmani Shan7Usmani force-pushed the feat/adaptive-noise-gate-623 branch from 9a74105 to 687f399 Compare June 24, 2026 14:33
@github-actions github-actions Bot removed type:style Type: CSS/Styling change type:config Type: Configuration change security-review Requires security review before merge labels Jun 24, 2026
@sonarqubecloud

Copy link
Copy Markdown

@Shan7Usmani

Shan7Usmani commented Jun 24, 2026

Copy link
Copy Markdown
Author

@shouri123 this PR (#821 - adaptive noise gate) is rebased on latest main with all checks passing. Could you please review it as it has been there for days? Thanks!

@Shan7Usmani

Copy link
Copy Markdown
Author

@shouri123 please review the pr , i have 4 pr waiting to be merged from this project

@github-actions

Copy link
Copy Markdown
Contributor

This PR has been marked as stale due to inactivity.

@github-actions github-actions Bot added the stale label Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC: PR approved and scored gssoc Official GSSoC contribution issue stale type:code Type: Code change type:test Type: Test files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Implement adaptive Web Audio API noise gate for offscreen audio capture

1 participant