feat(processor): implement adaptive crest factor compression for quiet recordings#56
Merged
flexiondotorg merged 6 commits intomainfrom Mar 15, 2026
Merged
feat(processor): implement adaptive crest factor compression for quiet recordings#56flexiondotorg merged 6 commits intomainfrom
flexiondotorg merged 6 commits intomainfrom
Conversation
- Add high-crest override constants (maxDeficit, safetyMargin, minLimiterCeiling) - Add la2aOverrides struct to carry override floor values for sub-tuners - Add lerp() helper for linear interpolation (0.0-1.0) - Add diagnostic fields to FilterChainConfig: LA2AHighCrestActive, LA2AHighCrestDeficit, LA2AHighCrestSeverity, LA2AHighCrestProjectedTP Signed-off-by: Martin Wimpress <code@wimpress.io>
…r calculation Implement `applyHighCrestOverrides()` to predict when Pass 4 limiter ceiling will clamp and compute override floors that increase LA-2A compressor aggression. Changes: - Add deficit-based detection mirroring calculateLimiterCeiling() logic - Calculate severity from 0 to 1 based on deficit magnitude (0–8 dB range) - Return interpolated override floors for threshold, ratio, release, and knee - Populate diagnostic fields (deficit, severity, projectedTP) for all recordings - Add comprehensive unit tests with seven scenarios covering boundary cases Signed-off-by: Martin Wimpress <code@wimpress.io>
- Integrate applyHighCrestOverrides into tuneLA2ACompressor execution
flow
- Pass override parameters to all four sub-tuners (Release, Ratio,
Threshold, Knee)
- Add enforcement logic in each sub-tuner to respect override floors
while preserving clamps
- Add TestTuneLA2ACompressorHighCrest integration tests with four
acceptance cases
- high-crest overrides push ratio and threshold
- no deficit leaves sub-tuners unmodified
- Hot-input invariant: hot peaks and high-crest deficit cannot
co-occur
- Maximum severity: aggressive but bounded parameters at severity 1.0
Signed-off-by: Martin Wimpress <code@wimpress.io>
…ncation - Extend formatLA2ACompressorFilter() with active/inactive high-crest override diagnostic blocks, including deficit, severity, projected TP, and ceiling info - Fix LUFS value truncation in output filename generation by removing math.Round() (e.g., -26.8 LUFS now produces LUFS-26, not LUFS-27) - Update AGENTS.md documentation to clarify truncation behaviour Signed-off-by: Martin Wimpress <code@wimpress.io>
…ing fixes - Extend README.md filter comparison and example output with high-crest override diagnostics (active state, ceiling deficit, severity, projected TP) - Enhance FilterCompressor-Teletronix LA-2A.md with comprehensive high-crest override design documentation including detection algorithm, override floor tables, enforcement rules, and integration with existing tuning subsystems - Add high-crest override fields to FilterChainConfig documentation table - Clarify threshold range and release/knee interaction notes for override mode Signed-off-by: Martin Wimpress <code@wimpress.io>
Contributor
There was a problem hiding this comment.
4 issues found across 8 files
Confidence score: 4/5
- Overall risk looks low because the issues are confined to diagnostics, tests, and documentation rather than core processing logic.
- Most significant functional concern is in
internal/logging/report.go, where hardcodedNormTargetLUFScould make high-crest diagnostics diverge from configured loudnorm settings. - Test and docs mismatches reduce confidence in validation and guidance but are not likely to affect runtime behavior directly (
internal/processor/adaptive_test.go,README.md,docs/FilterCompressor-Teletronix LA-2A.md). - Pay close attention to
internal/logging/report.go,internal/processor/adaptive_test.go,README.md,docs/FilterCompressor-Teletronix LA-2A.md- diagnostics accuracy, test coverage, and documentation consistency.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="internal/logging/report.go">
<violation number="1" location="internal/logging/report.go:856">
P2: Use `cfg.LoudnormTargetI` instead of hardcoding `NormTargetLUFS` in the high-crest diagnostics, otherwise the reported gain and projected TP drift from the actual loudnorm settings.</violation>
</file>
<file name="README.md">
<violation number="1" location="README.md:171">
P2: These added diagnostics don't match the surrounding example values, so the README now documents an impossible high-crest result for this sample.</violation>
</file>
<file name="internal/processor/adaptive_test.go">
<violation number="1" location="internal/processor/adaptive_test.go:2478">
P2: This test re-runs the same code path twice, so it cannot prove inactive recordings still match the pre-override tuner behaviour.</violation>
</file>
<file name="docs/FilterCompressor-Teletronix LA-2A.md">
<violation number="1" location="docs/FilterCompressor-Teletronix LA-2A.md:70">
P3: This adds 350 ms / 6.0 high-crest values, but the config table below still says `LA2ARelease` tops out at 300 ms and `LA2AKnee` at 5.0.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
- Remove impossible high-crest example values from README.md (deficit 2.6 dB, projected TP 18.2 dBTP values were unrealistic) - Correct LA2ARelease range from 150–300 ms to 150–350 ms - Correct LA2AKnee range from 3.5–5.0 to 3.5–6.0 Signed-off-by: Martin Wimpress <code@wimpress.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implement Strategy 2: Adaptive Crest Factor Compression - LUFS High-Crest Override. Detects very quiet recordings with high peak-to-average energy ratios and applies specialised LA-2A compression parameters to prevent distortion and improve clarity.
Changes
HighCrestDetected,HighCrestAttackMs,HighCrestReleaseMs) to LA-2A tuning reportsapplyHighCrestOverrides()detection logic: identifies recordings where LUFS < -10 dB and crest factor > 8, triggering adaptive parameter adjustmenttuneLA2ACompressor()and sub-tuners (fixed, gentle, moderate, aggressive) with phase-specific parameter scalingmath.Round()call, preserving precision for very quiet recordingsTesting