Skip to content

Conversation

@flexiondotorg
Copy link
Contributor

@flexiondotorg flexiondotorg commented Jan 18, 2026

Summary

This PR enhances the adaptive filter tuning system to use more accurate measurements for filter parameter selection:

  • NoiseRemove adaptive thresholding: Replace fixed compand parameters with values derived from measured noise floor during silence analysis. Threshold scales to noise_floor + 5dB (clamped to [-70dB, -40dB]) and expansion scales from 4-12dB based on noise severity across 4 tiers.

  • Speech-specific spectral metrics: Filters that process speech content now prefer metrics from SpeechProfile (speech-only regions) over full-file measurements. This provides more accurate tuning for tuneDeesserFull, tuneLA2ARatio, tuneLA2ARelease, and tuneDC1Declick.

  • Fallback handling: Both improvements gracefully fall back to previous behavior when noise profile or speech metrics are unavailable.

Problem Solved

Previous adaptive tuning used full-file spectral measurements diluted by silence periods and fixed noise reduction parameters regardless of actual recording characteristics. This caused:

  • Clean recordings received no adaptive benefit
  • Noisy recordings could have speech unnecessarily affected
  • Filter parameters were not optimally tuned to actual content

Changes

  • internal/processor/adaptive.go: Core adaptive logic with preferSpeechMetric() helper and updated tuneNoiseRemove()
  • internal/processor/adaptive_test.go: 12 new test cases for metric preference and expansion scaling
  • internal/processor/filters.go: Updated default NoiseRemove config values
  • internal/logging/report.go: Enhanced rationale logging for adaptive decisions

Testing

  • just test passes with all new and existing tests
  • Tests cover edge cases: zero values, negative values, unavailable metrics, and all expansion tiers

Summary by cubic

Improves adaptive filter tuning with speech-aware metrics and noise-aware compand thresholds for more transparent, consistent processing. Speech filters now use measurements from speech regions, and noise reduction adjusts to the actual noise floor.

  • New Features
    • NoiseRemove compand: threshold = noise floor + 5 dB (clamped to [-70, -40]); expansion scales 4–12 dB by noise severity; falls back to -55 dB/6 dB without a noise profile.
    • Prefer SpeechProfile metrics for speech filters: de-esser (centroid, rolloff), LA‑2A ratio (kurtosis), LA‑2A release (flux), DC‑1 declick (centroid).
    • Logging shows measurement sources and adaptive rationale for decisions.
    • Defaults updated: de-esser enabled; compand defaults set to -55 dB threshold and 6 dB expansion.

Written for commit 7183b89. Summary will update on new commits.

…ured noise floor

Previously, tuneNoiseRemove() used fixed values (-55dB threshold, 6dB
expansion)
regardless of actual noise characteristics. This meant clean recordings
received
no adaptive benefit while noisy recordings could have speech
unnecessarily affected.
Now the compand filter adapts to measured noise from silence regions:
- Threshold: noise floor + 5dB (clamped to [-70, -40])
- Expansion: scales with noise severity (4-12dB across 4 tiers)
Default values updated to -55dB/6dB as fallback when no noise profile
available.
Enhanced logging shows measured noise floor and adaptive derivation
rationale.
Add TestScaleExpansion with 8 test cases covering all expansion tiers.

Signed-off-by: Martin Wimpress <[email protected]>

feat(processor): prefer speech-specific spectral metrics for adaptive
filter tuning

Previously, adaptive filter tuning used full-file spectral measurements
which are diluted by silence periods. The SpeechProfile struct contains
speech-specific versions of spectral metrics that provide more accurate
input for tuning filters that process speech content.
Now these filters prefer speech-specific measurements when available:
- tuneDeesserFull: centroid and rolloff for sibilance detection
- tuneLA2ARatio: kurtosis for harmonic structure decisions
- tuneLA2ARelease: flux for timing decisions
- tuneDC1Declick: centroid for window sizing
Falls back to full-file measurements when SpeechProfile is nil or has
zero values.
Added preferSpeechMetric helper with 4 test cases covering available,
zero, negative, and both-zero scenarios.

Signed-off-by: Martin Wimpress <[email protected]>
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 4 files

@flexiondotorg flexiondotorg merged commit 832dfbc into main Jan 18, 2026
5 checks passed
@flexiondotorg flexiondotorg deleted the adaptive branch January 18, 2026 00:14
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.

2 participants