refactor(processor): simplify analyzer and normaliser implementation#60
Merged
flexiondotorg merged 8 commits intomainfrom Mar 16, 2026
Merged
refactor(processor): simplify analyzer and normaliser implementation#60flexiondotorg merged 8 commits intomainfrom
flexiondotorg merged 8 commits intomainfrom
Conversation
…nstants Remove duplicate constant definitions from adaptive.go and use the canonical constants from normalise.go. Both la2aHighCrestSafetyMargin and la2aHighCrestMinLimiterCeiling were duplicates of safetyMarginDB and minLimiterCeilingDB respectively, requiring manual synchronisation across two files. Consolidating to a single source eliminates the Shotgun Surgery smell and ensures any future adjustments need only happen once. Signed-off-by: Martin Wimpress <code@wimpress.io>
…Spec Replace set/call/restore pattern that mutated config.ResampleEnabled with direct filter construction. The function now builds the resample filter spec directly using fmt.Sprintf instead of calling buildResampleFilter(), which is gated on ResampleEnabled. Add TestBuildLoudnormFilterSpec_DoesNotMutateConfig to prevent regression of this Inappropriate Intimacy smell. Signed-off-by: Martin Wimpress <code@wimpress.io>
Remove exported MeasureOutputSilenceRegion and MeasureOutputSpeechRegion; rename to unexported measureOutputSilenceRegion and measureOutputSpeechRegion. These functions are only used in tests and should not be part of the public API. Update test call sites and test function names accordingly. Signed-off-by: Martin Wimpress <code@wimpress.io>
…alyzer - Rename shadowing `frameCount` to `spectralFrameCountF` in spectral averaging block - Remove unused `lastFrameTime` variable that silenced a compiler warning Signed-off-by: Martin Wimpress <code@wimpress.io>
…cellation Replace error message string comparison with idiomatic sentinel error pattern. This eliminates Primitive Obsession by introducing errCancelledByUser sentinel and using errors.Is for comparison instead of Error() string matching. - Add errors import - Define errCancelledByUser sentinel error - Update creation site to use sentinel value - Use errors.Is for idiomatic comparison Signed-off-by: Martin Wimpress <code@wimpress.io>
…trics Remove unreachable silence detection block from extractFrameMetadata (lines 832-880), silence metadata keys, and unused accumulators: - silenceRegions, pendingSilenceStart, hasPendingSilence fields - peakMax field and accumulation/reset sites in intervalAccumulator - six metaKeySilence* variable declarations All changes are pure deletions identified in Phase 1 dead code analysis. Signed-off-by: Martin Wimpress <code@wimpress.io>
… function - Move measureOutputSilenceRegion and measureOutputSpeechRegion to analyzer_output_test.go - Inline createLoudnormFilterGraph wrapper and delete function from normalise.go - Eliminate public functions with no external callers All changes are pure deletions and relocations; build and tests pass. Signed-off-by: Martin Wimpress <code@wimpress.io>
Contributor
There was a problem hiding this comment.
1 issue found across 9 files
Confidence score: 5/5
- This PR looks low risk to merge: the only reported issue is low severity (2/10) and appears documentation/comment accuracy related rather than behavioral.
- In
internal/processor/analyzer_output.go, the comment aboveMeasureOutputRegionsreferences test-only/removed function names, which could mislead future maintainers about the production measurement path. - Pay close attention to
internal/processor/analyzer_output.go- update theMeasureOutputRegionscomment so it reflects the current production flow.
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/processor/analyzer_output.go">
<violation number="1" location="internal/processor/analyzer_output.go:187">
P3: This comment now references test-only/removed function names instead of the production measurement path, so it will mislead readers of `MeasureOutputRegions`.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Reword to explain outcome (measured in separate passes) rather than function names, maintaining clarity for future maintainers. Signed-off-by: Martin Wimpress <code@wimpress.io>
Contributor
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Requires human review: This is a significant refactor of core audio processing logic, including changes to public APIs, constant consolidation, and removal of silence detection code across multiple files.
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
This pull request consolidates duplicated logic, removes unused code, and eliminates hidden mutations throughout the processor package. The changes reduce cognitive load and make the codebase easier to maintain.
Changes
Testing
Related Issues
N/A